Skip to content

Commit

Permalink
Merge branch 'master' into parse-error-in-shared-worker
Browse files Browse the repository at this point in the history
  • Loading branch information
Eriko Kurimoto committed Mar 19, 2020
2 parents c37c05b + 51ef1d6 commit f0ed797
Show file tree
Hide file tree
Showing 12,112 changed files with 167,365 additions and 328,565 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
191 changes: 0 additions & 191 deletions WebIDL/ecmascript-binding/legacy-platform-object.html

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Legacy platform objects [[DefineOwnProperty]] method</title>
<link rel="help" href="https://heycam.github.io/webidl/#legacy-platform-object-defineownproperty">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./helper.js"></script>
<script>

test(function() {
let span = document.createElement("span");
span.className = "foo";
// DOMTokenList supports an indexed property getter but not a setter.
let domTokenList = span.classList;
// Confirm the test settings.
assert_equals(domTokenList.length, 1);
assert_prop_desc_equals(domTokenList, "0",
{value: "foo", writable: false, enumerable: true,
configurable: true});
assert_prop_desc_equals(domTokenList, "1", undefined);
// Actual test
assert_throws_js(TypeError, () =>
Object.defineProperty(domTokenList, "0", {value: true, writable: true}));
assert_throws_js(TypeError, () =>
Object.defineProperty(domTokenList, "1", {value: true, writable: true}));
assert_throws_js(TypeError, () =>
Object.defineProperty(domTokenList, "0", {get: () => {}}));
assert_throws_js(TypeError, () =>
Object.defineProperty(domTokenList, "0", {set: () => {}}));
assert_throws_js(TypeError, () =>
Object.defineProperty(domTokenList, "1", {get: () => {}}));
assert_throws_js(TypeError, () =>
Object.defineProperty(domTokenList, "1", {set: () => {}}));
assert_equals(domTokenList[0], "foo");
assert_equals(domTokenList[1], undefined);
domTokenList[0] = "bar";
domTokenList[1] = "bar";
assert_equals(domTokenList[0], "foo");
assert_equals(domTokenList[1], undefined);
assert_throws_js(TypeError, () => {
"use strict";
domTokenList[0] = "bar";
});
assert_throws_js(TypeError, () => {
"use strict";
domTokenList[1] = "bar";
});
// Nothing must change after all.
assert_equals(domTokenList.length, 1);
assert_prop_desc_equals(domTokenList, "0",
{value: "foo", writable: false, enumerable: true,
configurable: true});
assert_prop_desc_equals(domTokenList, "1", undefined);
}, "Test [[DefineOwnProperty]] with no indexed property setter support.");

test(function() {
// HTMLSelectElement supports an indexed property setter.
let select = document.createElement("select");
let option0 = document.createElement("option");
let option1 = document.createElement("option");
// Confirm the test settings.
assert_equals(select.length, 0);
assert_prop_desc_equals(select, "0", undefined);
// Try to define an accessor property with non supported property index.
assert_throws_js(TypeError, () =>
Object.defineProperty(select, "0", {get: () => {}}));
assert_throws_js(TypeError, () =>
Object.defineProperty(select, "0", {set: () => {}}));
assert_prop_desc_equals(select, "0", undefined);
// writable, enumerable, configurable will be ignored.
Object.defineProperty(select, "0", {value: option0, writable: false,
enumerable: false, configurable: false});
assert_prop_desc_equals(select, "0",
{value: option0, writable: true, enumerable: true,
configurable: true});
select[1] = option1;
assert_prop_desc_equals(select, "1",
{value: option1, writable: true, enumerable: true,
configurable: true});
// Try to define an accessor property with a supported property index.
assert_throws_js(TypeError, () =>
Object.defineProperty(select, "0", {get: () => {}}));
assert_throws_js(TypeError, () =>
Object.defineProperty(select, "0", {set: () => {}}));
assert_prop_desc_equals(select, "0",
{value: option0, writable: true, enumerable: true,
configurable: true});
}, "Test [[DefineOwnProperty]] with indexed property setter support.");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Legacy platform objects [[GetOwnProperty]] method</title>
<link rel="help" href="https://heycam.github.io/webidl/#legacy-platform-object-getownproperty">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./helper.js"></script>
<script>

test(function() {
// DOMTokenList has an indexed property getter, no indexed property setter
// and no named property handlers.
let div = document.createElement("div");
div.classList.add("baz", "quux");
const domTokenList = div.classList;
assert_prop_desc_equals(
domTokenList, "1",
{value: "quux", writable: false, enumerable: true, configurable: true},
"[[GetOwnProperty]] for indexed properties returns the right descriptor");
assert_prop_desc_equals(
domTokenList, "42", undefined,
"[[GetOwnProperty]] with invalid index returns undefined");
assert_array_equals(Object.keys(domTokenList), ["0", "1"]);
assert_array_equals(Object.values(domTokenList), ["baz", "quux"]);

// getElementsByTagName() returns an HTMLCollection.
// HTMLCollection has indexed and named property getters, no setters. Its IDL
// interface declaration has [LegacyUnenumerableNamedProperties] so its named
// properties are not enumerable.
let span1 = document.createElement("span");
span1.id = "foo";
let span2 = document.createElement("span");
span2.id = "bar";
document.head.appendChild(span1);
document.head.appendChild(span2);
const elementList = document.getElementsByTagName("span");
assert_prop_desc_equals(
elementList, "foo",
{value: span1, writable: false, enumerable: false, configurable: true},
"[[GetOwnProperty]] for named properties returns the right descriptor");
assert_prop_desc_equals(
elementList, "1",
{value: span2, writable: false, enumerable: true, configurable: true},
"[[GetOwnProperty]] for indexed properties returns the right descriptor");
assert_prop_desc_equals(
elementList, "unknown", undefined,
"[[GetOwnProperty]] with invalid property name returns undefined");
assert_array_equals(Object.keys(elementList), ["0", "1"]);
assert_array_equals(Object.values(elementList), [span1, span2]);
}, "[[GetOwnProperty]] with getters and no setters");

test(function() {
// DOMStringMap supports named property getters and setters, but not indexed
// properties.
let span = document.createElement("span");
span.dataset.foo = "bar";
assert_prop_desc_equals(
span.dataset, "foo",
{value: "bar", writable: true, enumerable: true, configurable: true},
"[[GetOwnProperty]] for named properties returns the right descriptor");
assert_prop_desc_equals(
span.dataset, "unknown", undefined,
"[[GetOwnProperty]] with invalid property name returns undefined");
assert_array_equals(Object.keys(span.dataset), ["foo"]);
assert_array_equals(Object.values(span.dataset), ["bar"]);
}, "[[GetOwnProperty]] with named property getters and setters");

test(function() {
// HTMLSelectElement has indexed property getters and setters, but no support
// for named properties.
let selectElement = document.createElement("select");
assert_prop_desc_equals(
selectElement, "0", undefined,
"[[GetOwnProperty]] with invalid property index returns undefined");
let optionElement = document.createElement("option");
selectElement.appendChild(optionElement);
assert_prop_desc_equals(
selectElement, "0",
{value: optionElement, writable: true, enumerable: true, configurable: true},
"[[GetOwnProperty]] for indexed properties returns the right descriptor");
assert_array_equals(Object.keys(selectElement), ["0"]);
assert_array_equals(Object.values(selectElement), [optionElement]);
}, "[[GetOwnProperty]] with indexed property getters and setters");
</script>
Loading

0 comments on commit f0ed797

Please sign in to comment.