Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (260669 => 260670)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2020-04-24 21:11:01 UTC (rev 260669)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2020-04-24 21:41:32 UTC (rev 260670)
@@ -1,3 +1,15 @@
+2020-04-24 Alexey Shvayka <[email protected]>
+
+ Re-sync wpt/WebIDL/ecmascript-binding and wpt/custom-elements/htmlconstructor from upstream
+ https://bugs.webkit.org/show_bug.cgi?id=210984
+
+ Reviewed by Darin Adler.
+
+ web-platform-tests revision: 39e9c51041a1
+
+ * web-platform-tests/WebIDL/ecmascript-binding/*: Updated.
+ * web-platform-tests/custom-elements/htmlconstructor/*: Updated.
+
2020-04-24 Antoine Quint <[email protected]>
Update the css/css-animations WPT tests
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-interface.any-expected.txt (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-interface.any-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-interface.any-expected.txt 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1,10 @@
+
+FAIL @@toStringTag exists on the prototype with the appropriate descriptor assert_own_property: expected property symbol "Symbol(Symbol.toStringTag)" missing
+PASS @@toStringTag must not exist on the instance
+FAIL Object.prototype.toString applied to the prototype assert_equals: expected "[object Blob]" but got "[object BlobPrototype]"
+PASS Object.prototype.toString applied to an instance
+FAIL Object.prototype.toString applied after modifying the prototype's @@toStringTag assert_own_property: Precondition for this test: @@toStringTag on the prototype expected property symbol "Symbol(Symbol.toStringTag)" missing
+PASS Object.prototype.toString applied to the instance after modifying the instance's @@toStringTag
+FAIL Object.prototype.toString applied to a null-prototype instance assert_equals: expected "[object Object]" but got "[object Blob]"
+FAIL Object.prototype.toString applied after deleting @@toStringTag assert_equals: prototype expected "[object Object]" but got "[object BlobPrototype]"
+
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-interface.any.html (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-interface.any.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-interface.any.html 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-interface.any.js (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-interface.any.js (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-interface.any.js 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1,62 @@
+"use strict";
+
+test(() => {
+ assert_own_property(Blob.prototype, Symbol.toStringTag);
+
+ const propDesc = Object.getOwnPropertyDescriptor(Blob.prototype, Symbol.toStringTag);
+ assert_equals(propDesc.value, "Blob", "value");
+ assert_equals(propDesc.configurable, true, "configurable");
+ assert_equals(propDesc.enumerable, false, "enumerable");
+ assert_equals(propDesc.writable, false, "writable");
+}, "@@toStringTag exists on the prototype with the appropriate descriptor");
+
+test(() => {
+ assert_not_own_property(new Blob(), Symbol.toStringTag);
+}, "@@toStringTag must not exist on the instance");
+
+test(() => {
+ assert_equals(Object.prototype.toString.call(Blob.prototype), "[object Blob]");
+}, "Object.prototype.toString applied to the prototype");
+
+test(() => {
+ assert_equals(Object.prototype.toString.call(new Blob()), "[object Blob]");
+}, "Object.prototype.toString applied to an instance");
+
+test(t => {
+ assert_own_property(Blob.prototype, Symbol.toStringTag, "Precondition for this test: @@toStringTag on the prototype");
+
+ t.add_cleanup(() => {
+ Object.defineProperty(Blob.prototype, Symbol.toStringTag, { value: "Blob" });
+ });
+
+ Object.defineProperty(Blob.prototype, Symbol.toStringTag, { value: "NotABlob" });
+ assert_equals(Object.prototype.toString.call(Blob.prototype), "[object NotABlob]", "prototype");
+ assert_equals(Object.prototype.toString.call(new Blob()), "[object NotABlob]", "instance");
+}, "Object.prototype.toString applied after modifying the prototype's @@toStringTag");
+
+test(t => {
+ const instance = new Blob();
+ assert_not_own_property(instance, Symbol.toStringTag, "Precondition for this test: no @@toStringTag on the instance");
+
+ Object.defineProperty(instance, Symbol.toStringTag, { value: "NotABlob" });
+ assert_equals(Object.prototype.toString.call(instance), "[object NotABlob]");
+}, "Object.prototype.toString applied to the instance after modifying the instance's @@toStringTag");
+
+// Chrome had a bug (https://bugs.chromium.org/p/chromium/issues/detail?id=793406) where if there
+// was no @@toStringTag in the prototype, it would fall back to a magic class string. This tests
+// that the bug is fixed.
+
+test(() => {
+ const instance = new Blob();
+ Object.setPrototypeOf(instance, null);
+
+ assert_equals(Object.prototype.toString.call(instance), "[object Object]");
+}, "Object.prototype.toString applied to a null-prototype instance");
+
+// This test must be last.
+test(() => {
+ delete Blob.prototype[Symbol.toStringTag];
+
+ assert_equals(Object.prototype.toString.call(Blob.prototype), "[object Object]", "prototype");
+ assert_equals(Object.prototype.toString.call(new Blob()), "[object Object]", "instance");
+}, "Object.prototype.toString applied after deleting @@toStringTag");
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-interface.any.worker-expected.txt (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-interface.any.worker-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-interface.any.worker-expected.txt 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1,10 @@
+
+FAIL @@toStringTag exists on the prototype with the appropriate descriptor assert_own_property: expected property symbol "Symbol(Symbol.toStringTag)" missing
+PASS @@toStringTag must not exist on the instance
+FAIL Object.prototype.toString applied to the prototype assert_equals: expected "[object Blob]" but got "[object BlobPrototype]"
+PASS Object.prototype.toString applied to an instance
+FAIL Object.prototype.toString applied after modifying the prototype's @@toStringTag assert_own_property: Precondition for this test: @@toStringTag on the prototype expected property symbol "Symbol(Symbol.toStringTag)" missing
+PASS Object.prototype.toString applied to the instance after modifying the instance's @@toStringTag
+FAIL Object.prototype.toString applied to a null-prototype instance assert_equals: expected "[object Object]" but got "[object Blob]"
+FAIL Object.prototype.toString applied after deleting @@toStringTag assert_equals: prototype expected "[object Object]" but got "[object BlobPrototype]"
+
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-interface.any.worker.html (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-interface.any.worker.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-interface.any.worker.html 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-iterator-prototype-object.any-expected.txt (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-iterator-prototype-object.any-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-iterator-prototype-object.any-expected.txt 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1,7 @@
+
+PASS @@toStringTag exists with the appropriate descriptor
+PASS Object.prototype.toString
+PASS Object.prototype.toString applied after modifying @@toStringTag
+FAIL Object.prototype.toString applied after nulling the prototype assert_equals: expected "[object Object]" but got "[object URLSearchParams Iterator]"
+FAIL Object.prototype.toString applied after deleting @@toStringTag assert_equals: prototype expected "[object Object]" but got "[object URLSearchParams Iterator]"
+
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-iterator-prototype-object.any.html (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-iterator-prototype-object.any.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-iterator-prototype-object.any.html 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-iterator-prototype-object.any.js (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-iterator-prototype-object.any.js (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-iterator-prototype-object.any.js 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1,50 @@
+"use strict";
+
+const iteratorProto = Object.getPrototypeOf((new URLSearchParams()).entries());
+
+test(() => {
+ assert_own_property(iteratorProto, Symbol.toStringTag);
+
+ const propDesc = Object.getOwnPropertyDescriptor(iteratorProto, Symbol.toStringTag);
+ assert_equals(propDesc.value, "URLSearchParams Iterator", "value");
+ assert_equals(propDesc.configurable, true, "configurable");
+ assert_equals(propDesc.enumerable, false, "enumerable");
+ assert_equals(propDesc.writable, false, "writable");
+}, "@@toStringTag exists with the appropriate descriptor");
+
+test(() => {
+ assert_equals(Object.prototype.toString.call(iteratorProto), "[object URLSearchParams Iterator]");
+}, "Object.prototype.toString");
+
+test(t => {
+ assert_own_property(iteratorProto, Symbol.toStringTag, "Precondition for this test: @@toStringTag exists");
+
+ t.add_cleanup(() => {
+ Object.defineProperty(iteratorProto, Symbol.toStringTag, { value: "URLSearchParams Iterator" });
+ });
+
+ Object.defineProperty(iteratorProto, Symbol.toStringTag, { value: "Not URLSearchParams Iterator" });
+ assert_equals(Object.prototype.toString.call(iteratorProto), "[object Not URLSearchParams Iterator]");
+}, "Object.prototype.toString applied after modifying @@toStringTag");
+
+// Chrome had a bug (https://bugs.chromium.org/p/chromium/issues/detail?id=793406) where if there
+// was no @@toStringTag, it would fall back to a magic class string. This tests that the bug is
+// fixed.
+
+test(t => {
+ const proto = Object.getPrototypeOf(iteratorProto);
+ t.add_cleanup(() => {
+ Object.setPrototypeOf(iteratorProto, proto);
+ });
+
+ Object.setPrototypeOf(iteratorProto, null);
+
+ assert_equals(Object.prototype.toString.call(iteratorProto), "[object Object]");
+}, "Object.prototype.toString applied after nulling the prototype");
+
+// This test must be last.
+test(() => {
+ delete iteratorProto[Symbol.toStringTag];
+
+ assert_equals(Object.prototype.toString.call(iteratorProto), "[object Object]", "prototype");
+}, "Object.prototype.toString applied after deleting @@toStringTag");
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-iterator-prototype-object.any.worker-expected.txt (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-iterator-prototype-object.any.worker-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-iterator-prototype-object.any.worker-expected.txt 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1,7 @@
+
+PASS @@toStringTag exists with the appropriate descriptor
+PASS Object.prototype.toString
+PASS Object.prototype.toString applied after modifying @@toStringTag
+FAIL Object.prototype.toString applied after nulling the prototype assert_equals: expected "[object Object]" but got "[object URLSearchParams Iterator]"
+FAIL Object.prototype.toString applied after deleting @@toStringTag assert_equals: prototype expected "[object Object]" but got "[object URLSearchParams Iterator]"
+
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-iterator-prototype-object.any.worker.html (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-iterator-prototype-object.any.worker.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-iterator-prototype-object.any.worker.html 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-named-properties-object.window-expected.txt (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-named-properties-object.window-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-named-properties-object.window-expected.txt 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1,6 @@
+
+FAIL @@toStringTag exists with the appropriate descriptor assert_own_property: expected property symbol "Symbol(Symbol.toStringTag)" missing
+PASS Object.prototype.toString
+FAIL Object.prototype.toString applied after modifying @@toStringTag assert_own_property: Precondition for this test: @@toStringTag exists expected property symbol "Symbol(Symbol.toStringTag)" missing
+FAIL Object.prototype.toString applied after deleting @@toStringTag assert_equals: prototype expected "[object EventTarget]" but got "[object WindowProperties]"
+
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-named-properties-object.window.html (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-named-properties-object.window.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-named-properties-object.window.html 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-named-properties-object.window.js (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-named-properties-object.window.js (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-named-properties-object.window.js 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1,42 @@
+"use strict";
+
+const namedPropertiesObject = Object.getPrototypeOf(Window.prototype);
+
+test(() => {
+ assert_own_property(namedPropertiesObject, Symbol.toStringTag);
+
+ const propDesc = Object.getOwnPropertyDescriptor(namedPropertiesObject, Symbol.toStringTag);
+ assert_equals(propDesc.value, "WindowProperties", "value");
+ assert_equals(propDesc.configurable, true, "configurable");
+ assert_equals(propDesc.enumerable, false, "enumerable");
+ assert_equals(propDesc.writable, false, "writable");
+}, "@@toStringTag exists with the appropriate descriptor");
+
+test(() => {
+ assert_equals(Object.prototype.toString.call(namedPropertiesObject), "[object WindowProperties]");
+}, "Object.prototype.toString");
+
+test(t => {
+ assert_own_property(namedPropertiesObject, Symbol.toStringTag, "Precondition for this test: @@toStringTag exists");
+
+ t.add_cleanup(() => {
+ Object.defineProperty(namedPropertiesObject, Symbol.toStringTag, { value: "WindowProperties" });
+ });
+
+ Object.defineProperty(namedPropertiesObject, Symbol.toStringTag, { value: "NotWindowProperties" });
+ assert_equals(Object.prototype.toString.call(namedPropertiesObject), "[object NotWindowProperties]");
+}, "Object.prototype.toString applied after modifying @@toStringTag");
+
+// Chrome had a bug (https://bugs.chromium.org/p/chromium/issues/detail?id=793406) where if there
+// was no @@toStringTag, it would fall back to a magic class string. This tests that the bug is
+// fixed.
+
+// Note: we cannot null out the prototype of the named properties object per
+// https://heycam.github.io/webidl/#named-properties-object-setprototypeof so we don't have a test that does that.
+
+// This test must be last.
+test(() => {
+ delete namedPropertiesObject[Symbol.toStringTag];
+
+ assert_equals(Object.prototype.toString.call(namedPropertiesObject), "[object EventTarget]", "prototype");
+}, "Object.prototype.toString applied after deleting @@toStringTag");
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/DOMException-custom-bindings.any.js (260669 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/DOMException-custom-bindings.any.js 2020-04-24 21:11:01 UTC (rev 260669)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/DOMException-custom-bindings.any.js 2020-04-24 21:41:32 UTC (rev 260670)
@@ -1,7 +1,7 @@
"use strict";
test(() => {
- assert_throws(new TypeError(), () => DOMException());
+ assert_throws_js(TypeError, () => DOMException());
}, "Cannot construct without new");
test(() => {
@@ -26,7 +26,7 @@
test(() => {
const getter = Object.getOwnPropertyDescriptor(DOMException.prototype, "message").get;
- assert_throws(new TypeError(), () => getter.apply({}));
+ assert_throws_js(TypeError, () => getter.apply({}));
}, "message getter performs brand checks (i.e. is not [LenientThis]");
test(() => {
@@ -43,7 +43,7 @@
test(() => {
const getter = Object.getOwnPropertyDescriptor(DOMException.prototype, "name").get;
- assert_throws(new TypeError(), () => getter.apply({}));
+ assert_throws_js(TypeError, () => getter.apply({}));
}, "name getter performs brand checks (i.e. is not [LenientThis]");
test(() => {
@@ -60,7 +60,7 @@
test(() => {
const getter = Object.getOwnPropertyDescriptor(DOMException.prototype, "code").get;
- assert_throws(new TypeError(), () => getter.apply({}));
+ assert_throws_js(TypeError, () => getter.apply({}));
}, "code getter performs brand checks (i.e. is not [LenientThis]");
test(() => {
@@ -98,7 +98,7 @@
}, "toString() behavior from Error.prototype applies as expected");
test(() => {
- assert_throws(new TypeError(), () => DOMException.prototype.toString());
+ assert_throws_js(TypeError, () => DOMException.prototype.toString());
}, "DOMException.prototype.toString() applied to DOMException.prototype throws because of name/message brand checks");
test(() => {
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/exceptions.html (260669 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/exceptions.html 2020-04-24 21:11:01 UTC (rev 260669)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/es-exceptions/exceptions.html 2020-04-24 21:41:32 UTC (rev 260670)
@@ -9,8 +9,8 @@
/**
* This file just picks one case where browsers are supposed to throw an
* exception, and tests the heck out of whether it meets the spec. In the
- * future, all these checks should be in assert_throws(), but we don't want
- * every browser failing every assert_throws() check until they fix every
+ * future, all these checks should be in assert_throws_dom(), but we don't want
+ * every browser failing every assert_throws_dom() check until they fix every
* single bug in their exception-throwing.
*
* We don't go out of our way to test everything that's already tested by
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/global-immutable-prototype.any.js (260669 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/global-immutable-prototype.any.js 2020-04-24 21:11:01 UTC (rev 260669)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/global-immutable-prototype.any.js 2020-04-24 21:41:32 UTC (rev 260670)
@@ -10,7 +10,7 @@
test(() => {
for (const object of objects) {
- assert_throws(new TypeError(), () => {
+ assert_throws_js(TypeError, () => {
Object.setPrototypeOf(object, {});
});
}
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/interface-prototype-object-expected.txt (260669 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/interface-prototype-object-expected.txt 2020-04-24 21:11:01 UTC (rev 260669)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/interface-prototype-object-expected.txt 2020-04-24 21:41:32 UTC (rev 260670)
@@ -1,4 +1,3 @@
-FAIL The class string of an interface prototype object is the concatenation of the interface's identifier and the string 'Prototype'. assert_true: An interface prototype object should have toStringTag property. expected true got false
PASS [Unscopable] extended attribute makes @@unscopables object on the prototype object, whose prototype is null.
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/interface-prototype-object.html (260669 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/interface-prototype-object.html 2020-04-24 21:11:01 UTC (rev 260669)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/interface-prototype-object.html 2020-04-24 21:41:32 UTC (rev 260670)
@@ -5,19 +5,7 @@
<script src=""
<script src=""
<script>
-// A specification issue was raised for this behavior.
-// https://www.w3.org/Bugs/Public/show_bug.cgi?id=28244
test(function() {
- // Checks toString() behavior.
- assert_class_string(Document.prototype, "DocumentPrototype");
-
- assert_true(Document.prototype.hasOwnProperty(Symbol.toStringTag),
- "An interface prototype object should have toStringTag property.");
- assert_equals(Document.prototype[Symbol.toStringTag], "DocumentPrototype");
-}, "The class string of an interface prototype object is the concatenation of " +
- "the interface's identifier and the string 'Prototype'.");
-
-test(function() {
// https://heycam.github.io/webidl/#create-an-interface-prototype-object
assert_own_property(Element.prototype, Symbol.unscopables, "Element.prototype has @@unscopables.");
let unscopables = Element.prototype[Symbol.unscopables];
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/iterator-prototype-object-expected.txt (260669 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/iterator-prototype-object-expected.txt 2020-04-24 21:11:01 UTC (rev 260669)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/iterator-prototype-object-expected.txt 2020-04-24 21:41:32 UTC (rev 260670)
@@ -2,7 +2,5 @@
PASS Has %IteratorPrototype% as prototype
PASS next() exists and is writable, enumerable, and configurable
PASS next() throws TypeError when called on ineligible receiver
-PASS Object.prototype.toString returns correct value
-PASS @@toStringTag has correct value
PASS Is specific to an interface
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/iterator-prototype-object.html (260669 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/iterator-prototype-object.html 2020-04-24 21:11:01 UTC (rev 260669)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/iterator-prototype-object.html 2020-04-24 21:41:32 UTC (rev 260670)
@@ -23,32 +23,23 @@
const usp = new URLSearchParams();
const iteratorProto = Object.getPrototypeOf(usp.entries());
- assert_throws(new TypeError(), () => {
+ assert_throws_js(TypeError, () => {
iteratorProto.next();
});
- assert_throws(new TypeError(), () => {
+ assert_throws_js(TypeError, () => {
iteratorProto.next.call(undefined);
});
- assert_throws(new TypeError(), () => {
+ assert_throws_js(TypeError, () => {
iteratorProto.next.call(42);
});
- assert_throws(new TypeError(), () => {
+ assert_throws_js(TypeError, () => {
iteratorProto.next.call(new Headers().entries());
});
}, "next() throws TypeError when called on ineligible receiver");
-test(() => {
- const iteratorProto = Object.getPrototypeOf(new URLSearchParams().entries());
- assert_equals(Object.prototype.toString.call(iteratorProto), "[object URLSearchParams Iterator]");
-}, "Object.prototype.toString returns correct value");
+// class string behavior tested in a dedicated file
test(() => {
- const iteratorProto = Object.getPrototypeOf(new URLSearchParams().entries());
- assert_equals(Object.getOwnPropertyDescriptor(iteratorProto, Symbol.toStringTag).value, "URLSearchParams Iterator");
- // Property attributes have not yet been fully spec'd.
-}, "@@toStringTag has correct value");
-
-test(() => {
const iteratorProto1 = Object.getPrototypeOf(new URLSearchParams().entries());
const iteratorProto2 = Object.getPrototypeOf(new Headers().entries());
assert_not_equals(iteratorProto1, iteratorProto2);
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-callback-interface-object.html (260669 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-callback-interface-object.html 2020-04-24 21:11:01 UTC (rev 260669)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-callback-interface-object.html 2020-04-24 21:41:32 UTC (rev 260670)
@@ -23,8 +23,8 @@
}, "Must have the correct property descriptor");
test(() => {
- assert_throws(new TypeError(), () => NodeFilter(), "call");
- assert_throws(new TypeError(), () => new NodeFilter(), "construct");
+ assert_throws_js(TypeError, () => NodeFilter(), "call");
+ assert_throws_js(TypeError, () => new NodeFilter(), "construct");
}, "Must throw a TypeError when called or constructed")
test(() => {
@@ -59,10 +59,10 @@
// OrdinaryHasInstance throws a TypeError if the right-hand-side doesn't have a .prototype object,
// which is the case for callback interfaces.
- assert_throws(new TypeError(), () => {
+ assert_throws_js(TypeError, () => {
(function () { }) instanceof NodeFilter;
});
- assert_throws(new TypeError(), () => {
+ assert_throws_js(TypeError, () => {
({ }) instanceof NodeFilter;
});
}, "instanceof must throw but only when we don't bail out early");
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/DefineOwnProperty-expected.txt (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/DefineOwnProperty-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/DefineOwnProperty-expected.txt 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1,6 @@
+
+FAIL Test [[DefineOwnProperty]] with no indexed property setter support. assert_throws_js: function "() =>
+ Object.defineProperty(domTokenList, "0", {value: true, writable: true})" did not throw
+FAIL Test [[DefineOwnProperty]] with indexed property setter support. assert_throws_js: function "() =>
+ Object.defineProperty(select, "0", {get: () => {}})" did not throw
+
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/DefineOwnProperty.html (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/DefineOwnProperty.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/DefineOwnProperty.html 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1,89 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Legacy platform objects [[DefineOwnProperty]] method</title>
+<link rel="help" href=""
+<script src=""
+<script src=""
+<script src=""
+<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>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/GetOwnProperty-expected.txt (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/GetOwnProperty-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/GetOwnProperty-expected.txt 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1,5 @@
+
+PASS [[GetOwnProperty]] with getters and no setters
+PASS [[GetOwnProperty]] with named property getters and setters
+PASS [[GetOwnProperty]] with indexed property getters and setters
+
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/GetOwnProperty.html (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/GetOwnProperty.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/GetOwnProperty.html 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1,84 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Legacy platform objects [[GetOwnProperty]] method</title>
+<link rel="help" href=""
+<script src=""
+<script src=""
+<script src=""
+<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>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/OwnPropertyKeys-expected.txt (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/OwnPropertyKeys-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/OwnPropertyKeys-expected.txt 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1,7 @@
+
+PASS must enumerate property indices in ascending numerical order
+PASS must enumerate property names in list order
+PASS must first enumerate property indices in ascending numerical order, then named properties in list order
+PASS must enumerate own properties after indexed and named properties even when they're added first
+PASS must enumerate symbols after strings, regardless of which ones got added first
+
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/OwnPropertyKeys.html (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/OwnPropertyKeys.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/OwnPropertyKeys.html 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Legacy platform objects [[OwnPropertyKeys]] method</title>
+<link rel="help" href=""
+<script src=""
+<script src=""
+<script>
+ function custom_assert_array_equals(actual, expected, msg) {
+ function replacer(k, v) {
+ if (typeof v === "symbol") {
+ return v.toString();
+ }
+ return v;
+ }
+ assert_array_equals(actual, expected, " actual " + JSON.stringify(actual, replacer) + " expected " + JSON.stringify(expected, replacer));
+ }
+
+ test(function() {
+ var element = document.createElement("div");
+ element.appendChild(document.createElement("div"));
+ element.appendChild(document.createElement("div"));
+ element.appendChild(document.createElement("div"));
+ custom_assert_array_equals(Reflect.ownKeys(element.childNodes), ["0", "1", "2"]);
+ }, "must enumerate property indices in ascending numerical order");
+
+ test(function() {
+ var element = document.createElement("div");
+ element.setAttribute("data-foo", "foo content");
+ element.setAttribute("data-bar", "bar content");
+ element.setAttribute("data-baz", "baz content");
+ custom_assert_array_equals(Reflect.ownKeys(element.dataset), ["foo", "bar", "baz"]);
+ }, "must enumerate property names in list order");
+
+
+ test(function() {
+ var element = document.createElement("div");
+ element.setAttribute("id", "foo");
+ element.setAttribute("class", "bar");
+ custom_assert_array_equals(Reflect.ownKeys(element.attributes), ["0", "1", "id", "class"]);
+ }, "must first enumerate property indices in ascending numerical order, then named properties in list order");
+
+
+ test(function() {
+ var element = document.createElement("div");
+ element.attributes.foo = "some value";
+ element.attributes.bar = "and another";
+ element.setAttribute("id", "foo");
+ element.setAttribute("class", "bar");
+ custom_assert_array_equals(Reflect.ownKeys(element.attributes), ["0", "1", "id", "class", "foo", "bar"]);
+ }, "must enumerate own properties after indexed and named properties even when they're added first");
+
+ test(function() {
+ var symb1 = Symbol();
+ var symb2 = Symbol();
+ var element = document.createElement("div");
+ element.attributes.foo = "some value";
+ element.attributes[symb1] = "symb1";
+ element.attributes[symb2] = "symb2";
+ element.attributes.bar = "and another";
+ element.setAttribute("id", "foo");
+ element.setAttribute("class", "bar");
+ custom_assert_array_equals(Reflect.ownKeys(element.attributes),
+ ["0", "1", "id", "class", "foo", "bar", symb1, symb2]);
+ }, "must enumerate symbols after strings, regardless of which ones got added first");
+</script>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/Set-expected.txt (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/Set-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/Set-expected.txt 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1,12 @@
+
+FAIL must not set the property value when assigning to a numeric property on an object which implements an indexed property getter but not a setter when not in strict mode assert_equals: expected (undefined) undefined but got (string) "foo"
+FAIL must throw when assigning to a numeric property on an object which implements a indexed property getter but not a setter in strict mode assert_throws_js: function "function () { element.childNodes["5"] = "foo"; }" did not throw
+PASS must allow assigning to a named property on an object which implements a named property getter but not a setter when not in strict mode
+PASS must allow assigning to a named property on an object which implements a named property getter but not a setter in strict mode
+PASS must allow assigning to a symbol property on an object which implements an indexed property getter but not a setter when not in strict mode
+PASS must allow assigning to a symbol property on an object which implements an indexed property getter but not a setter in strict mode
+PASS must allow assigning to a symbol property on an object which implements indexed and named property getters but no setters when not in strict mode
+PASS must allow assigning to a symbol property on an object which implements indexed and named property getters but no setters in strict mode
+PASS must allow assigning to a symbol property on an object which implements indexed and named property getters and setters when not in strict mode
+PASS must allow assigning to a symbol property on an object which implements indexed and named property getters and setters in strict mode
+
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/Set.html (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/Set.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/Set.html 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1,79 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Legacy platform objects [[Set]] method</title>
+<link rel="help" href=""
+<script src=""
+<script src=""
+<script>
+ test(function() {
+ var element = document.createElement("div");
+ element.appendChild(document.createElement("div"));
+ element.childNodes["5"] = "foo";
+ assert_equals(element.childNodes["5"], undefined);
+ }, "must not set the property value when assigning to a numeric property on an object which implements an indexed property getter but not a setter when not in strict mode");
+
+ test(function() {
+ "use strict";
+ var element = document.createElement("div");
+ element.appendChild(document.createElement("div"));
+ assert_throws_js(TypeError, function() { element.childNodes["5"] = "foo"; });
+ }, "must throw when assigning to a numeric property on an object which implements a indexed property getter but not a setter in strict mode");
+
+ test(function() {
+ var element = document.createElement("div");
+ element.attributes.foo = "foo";
+ assert_equals(element.attributes.foo, "foo");
+ }, "must allow assigning to a named property on an object which implements a named property getter but not a setter when not in strict mode");
+
+ test(function() {
+ "use strict";
+ var element = document.createElement("div");
+ element.attributes.foo = "foo";
+ assert_equals(element.attributes.foo, "foo");
+ }, "must allow assigning to a named property on an object which implements a named property getter but not a setter in strict mode");
+
+ var symbol = Symbol();
+
+ test(function() {
+ var element = document.createElement("div");
+ element.appendChild(document.createElement("div"));
+ element.childNodes[symbol] = "foo";
+ assert_equals(element.childNodes[symbol], "foo");
+ }, "must allow assigning to a symbol property on an object which implements an indexed property getter but not a setter when not in strict mode");
+
+ test(function() {
+ "use strict";
+ var element = document.createElement("div");
+ element.appendChild(document.createElement("div"));
+ element.childNodes[symbol] = "foo";
+ assert_equals(element.childNodes[symbol], "foo");
+ }, "must allow assigning to a symbol property on an object which implements an indexed property getter but not a setter in strict mode");
+
+ test(function() {
+ var element = document.createElement("div");
+ element.attributes[symbol] = "foo";
+ assert_equals(element.attributes[symbol], "foo");
+ }, "must allow assigning to a symbol property on an object which implements indexed and named property getters but no setters when not in strict mode");
+
+ test(function() {
+ "use strict";
+ var element = document.createElement("div");
+ element.attributes[symbol] = "foo";
+ assert_equals(element.attributes[symbol], "foo");
+ }, "must allow assigning to a symbol property on an object which implements indexed and named property getters but no setters in strict mode");
+
+ test(function() {
+ sessionStorage.clear();
+ this.add_cleanup(function() { sessionStorage.clear(); });
+ sessionStorage[symbol] = "foo";
+ assert_equals(sessionStorage[symbol], "foo");
+ }, "must allow assigning to a symbol property on an object which implements indexed and named property getters and setters when not in strict mode");
+
+ test(function() {
+ "use strict";
+ sessionStorage.clear();
+ this.add_cleanup(function() { sessionStorage.clear(); });
+ sessionStorage[symbol] = "foo";
+ assert_equals(sessionStorage[symbol], "foo");
+ }, "must allow assigning to a symbol property on an object which implements indexed and named property getters and setters in strict mode");
+</script>
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/helper.js (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/helper.js (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/helper.js 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1,22 @@
+function assert_prop_desc_equals(object, property_key, expected) {
+ let actual = Object.getOwnPropertyDescriptor(object, property_key);
+ if (expected === undefined) {
+ assert_equals(
+ actual, undefined,
+ "(assert_prop_desc_equals: no property descriptor expected)");
+ return;
+ }
+ for (p in actual) {
+ assert_true(
+ expected.hasOwnProperty(p),
+ "(assert_prop_desc_equals: property '" + p + "' is not expected)");
+ assert_equals(
+ actual[p], expected[p],
+ "(assert_prop_desc_equals: property '" + p + "')");
+ }
+ for (p in expected) {
+ assert_true(
+ actual.hasOwnProperty(p),
+ "(assert_prop_desc_equals: expected property '" + p + "' missing)");
+ }
+}
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/w3c-import.log (0 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/w3c-import.log (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/w3c-import.log 2020-04-24 21:41:32 UTC (rev 260670)
@@ -0,0 +1,21 @@
+The tests in this directory were imported from the W3C repository.
+Do NOT modify these tests directly in WebKit.
+Instead, create a pull request on the WPT github:
+ https://github.com/web-platform-tests/wpt
+
+Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport
+
+Do NOT modify or remove this file.
+
+------------------------------------------------------------------------
+Properties requiring vendor prefixes:
+None
+Property values requiring vendor prefixes:
+None
+------------------------------------------------------------------------
+List of files:
+/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/DefineOwnProperty.html
+/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/GetOwnProperty.html
+/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/OwnPropertyKeys.html
+/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/Set.html
+/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object/helper.js
Deleted: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object.html (260669 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object.html 2020-04-24 21:11:01 UTC (rev 260669)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object.html 2020-04-24 21:41:32 UTC (rev 260670)
@@ -1,191 +0,0 @@
-<!DOCTYPE html>
-<meta charset="utf-8">
-<title>Legacy platform objects</title>
-<link rel="help" href=""
-<script src=""
-<script src=""
-<script>
-function assert_prop_desc_equals(object, property_key, expected) {
- let actual = Object.getOwnPropertyDescriptor(object, property_key);
- if (expected === undefined) {
- assert_equals(
- actual, undefined,
- "(assert_prop_desc_equals: no property descriptor expected)");
- return;
- }
- for (p in actual) {
- assert_true(
- expected.hasOwnProperty(p),
- "(assert_prop_desc_equals: property '" + p + "' is not expected)");
- assert_equals(
- actual[p], expected[p],
- "(assert_prop_desc_equals: property '" + p + "')");
- }
- for (p in expected) {
- assert_true(
- actual.hasOwnProperty(p),
- "(assert_prop_desc_equals: expected property '" + p + "' missing)");
- }
-}
-
-// https://heycam.github.io/webidl/#legacy-platform-object-getownproperty
-// https://heycam.github.io/webidl/#LegacyPlatformObjectGetOwnProperty
-
-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");
-
-// https://heycam.github.io/webidl/#legacy-platform-object-defineownproperty
-// 3.9.3. [[DefineOwnProperty]]
-
-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(new TypeError(), () =>
- Object.defineProperty(domTokenList, "0", {value: true, writable: true}));
- assert_throws(new TypeError(), () =>
- Object.defineProperty(domTokenList, "1", {value: true, writable: true}));
- assert_throws(new TypeError(), () =>
- Object.defineProperty(domTokenList, "0", {get: () => {}}));
- assert_throws(new TypeError(), () =>
- Object.defineProperty(domTokenList, "0", {set: () => {}}));
- assert_throws(new TypeError(), () =>
- Object.defineProperty(domTokenList, "1", {get: () => {}}));
- assert_throws(new 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(new TypeError(), () => {
- "use strict";
- domTokenList[0] = "bar";
- });
- assert_throws(new 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(new TypeError(), () =>
- Object.defineProperty(select, "0", {get: () => {}}));
- assert_throws(new 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(new TypeError(), () =>
- Object.defineProperty(select, "0", {get: () => {}}));
- assert_throws(new 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>
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/put-forwards-expected.txt (260669 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/put-forwards-expected.txt 2020-04-24 21:11:01 UTC (rev 260669)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/put-forwards-expected.txt 2020-04-24 21:41:32 UTC (rev 260670)
@@ -5,4 +5,9 @@
PASS Exception propagation from getter of [PutForwards] attribute
PASS Exception propagation from setter of [PutForwards] target attribute
PASS TypeError when getter of [PutForwards] attribute returns non-object
+PASS Does not throw when setter of [PutForwards] attribute returns false
+PASS Setting a.relList to noreferrer is reflected in rel
+PASS Setting area.relList to noreferrer is reflected in rel
+FAIL Setting form.relList to noreferrer is reflected in rel assert_true: The attribute is a DOMTokenList expected true got false
+PASS Setting link.relList to stylesheet is reflected in rel
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/put-forwards.html (260669 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/put-forwards.html 2020-04-24 21:11:01 UTC (rev 260669)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/put-forwards.html 2020-04-24 21:41:32 UTC (rev 260670)
@@ -77,7 +77,7 @@
set: descriptor.set
});
- assert_throws(new SyntaxError(), () => {
+ assert_throws_js(SyntaxError, () => {
element.style = "color: green";
});
}, "Exception propagation from getter of [PutForwards] attribute");
@@ -94,7 +94,7 @@
}
});
- assert_throws(new SyntaxError(), () => {
+ assert_throws_js(SyntaxError, () => {
element.style = "color: green";
});
}, "Exception propagation from setter of [PutForwards] target attribute");
@@ -110,8 +110,39 @@
set: descriptor.set
});
- assert_throws(new TypeError(), () => {
+ assert_throws_js(TypeError, () => {
element.style = "color: green";
});
}, "TypeError when getter of [PutForwards] attribute returns non-object");
+
+
+test(() => {
+ var element = document.createElement("div");
+
+ var element_style = element.style;
+ Object.defineProperty(element.style, "cssText", {
+ value: null,
+ writable: false,
+ });
+
+ element.style = "color: green";
+ assert_equals(element.style, element_style);
+ assert_equals(element.style.cssText, null);
+}, "Does not throw when setter of [PutForwards] attribute returns false");
+
+function test_token_list(elementName, attribute, target, value) {
+ test(() => {
+ var element=document.createElement(elementName);
+ assert_true(element[attribute] instanceof DOMTokenList,"The attribute is a DOMTokenList");
+ element[attribute]=value;
+ assert_equals(element.getAttribute(target),value,"Setting the attribute is reflected in the target");
+ element[attribute]="";
+ assert_equals(element.getAttribute(target),"","Clearing the attribute is reflected in the target");
+ },"Setting "+elementName+"."+attribute+" to "+value+" is reflected in "+target)
+}
+
+test_token_list("a","relList","rel","noreferrer");
+test_token_list("area","relList","rel","noreferrer");
+test_token_list("form","relList","rel","noreferrer");
+test_token_list("link","relList","rel","stylesheet");
</script>
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/sequence-conversion.html (260669 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/sequence-conversion.html 2020-04-24 21:11:01 UTC (rev 260669)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/sequence-conversion.html 2020-04-24 21:41:32 UTC (rev 260670)
@@ -151,7 +151,7 @@
test(t => {
// Should fail rather than falling back to record
- assert_throws(new TypeError(), function() { new URLSearchParams(["key", "value"]); });
+ assert_throws_js(TypeError, function() { new URLSearchParams(["key", "value"]); });
}, "A string array in sequence<sequence> or record");
</script>
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/w3c-import.log (260669 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/w3c-import.log 2020-04-24 21:11:01 UTC (rev 260669)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/w3c-import.log 2020-04-24 21:41:32 UTC (rev 260670)
@@ -14,6 +14,9 @@
None
------------------------------------------------------------------------
List of files:
+/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-interface.any.js
+/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-iterator-prototype-object.any.js
+/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/class-string-named-properties-object.window.js
/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/constructors.html
/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/default-iterator-object.html
/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/global-immutable-prototype.any.js
@@ -23,7 +26,6 @@
/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/iterator-invalidation-foreach.html
/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/iterator-prototype-object.html
/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-callback-interface-object.html
-/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/legacy-platform-object.html
/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/no-regexp-special-casing.any.js
/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/put-forwards.html
/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/sequence-conversion.html
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/htmlconstructor/newtarget-expected.txt (260669 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/htmlconstructor/newtarget-expected.txt 2020-04-24 21:11:01 UTC (rev 260669)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/htmlconstructor/newtarget-expected.txt 2020-04-24 21:41:32 UTC (rev 260670)
@@ -2,13 +2,21 @@
PASS Use NewTarget's prototype, not the one stored at definition time
PASS Rethrow any exceptions thrown while getting the prototype
PASS If prototype is not object (null), derives the fallback from NewTarget's realm (autonomous custom elements)
+FAIL If prototype is not object (null), derives the fallback from NewTarget's GetFunctionRealm (autonomous custom elements) assert_equals: Must use the HTMLElement from the realm of NewTarget expected object "[object HTMLElementPrototype]" but got object "[object HTMLElementPrototype]"
PASS If prototype is not object (undefined), derives the fallback from NewTarget's realm (autonomous custom elements)
+FAIL If prototype is not object (undefined), derives the fallback from NewTarget's GetFunctionRealm (autonomous custom elements) assert_equals: Must use the HTMLElement from the realm of NewTarget expected object "[object HTMLElementPrototype]" but got object "[object HTMLElementPrototype]"
PASS If prototype is not object (5), derives the fallback from NewTarget's realm (autonomous custom elements)
+FAIL If prototype is not object (5), derives the fallback from NewTarget's GetFunctionRealm (autonomous custom elements) assert_equals: Must use the HTMLElement from the realm of NewTarget expected object "[object HTMLElementPrototype]" but got object "[object HTMLElementPrototype]"
PASS If prototype is not object (string), derives the fallback from NewTarget's realm (autonomous custom elements)
+FAIL If prototype is not object (string), derives the fallback from NewTarget's GetFunctionRealm (autonomous custom elements) assert_equals: Must use the HTMLElement from the realm of NewTarget expected object "[object HTMLElementPrototype]" but got object "[object HTMLElementPrototype]"
FAIL If prototype is not object (null), derives the fallback from NewTarget's realm (customized built-in elements) promise_test: Unhandled rejection with value: object "TypeError: Reflect.construct requires the first argument be a constructor"
+FAIL If prototype is not object (null), derives the fallback from NewTarget's GetFunctionRealm (customized built-in elements) promise_test: Unhandled rejection with value: object "TypeError: Reflect.construct requires the first argument be a constructor"
FAIL If prototype is not object (undefined), derives the fallback from NewTarget's realm (customized built-in elements) promise_test: Unhandled rejection with value: object "TypeError: Reflect.construct requires the first argument be a constructor"
+FAIL If prototype is not object (undefined), derives the fallback from NewTarget's GetFunctionRealm (customized built-in elements) promise_test: Unhandled rejection with value: object "TypeError: Reflect.construct requires the first argument be a constructor"
FAIL If prototype is not object (5), derives the fallback from NewTarget's realm (customized built-in elements) promise_test: Unhandled rejection with value: object "TypeError: Reflect.construct requires the first argument be a constructor"
+FAIL If prototype is not object (5), derives the fallback from NewTarget's GetFunctionRealm (customized built-in elements) promise_test: Unhandled rejection with value: object "TypeError: Reflect.construct requires the first argument be a constructor"
FAIL If prototype is not object (string), derives the fallback from NewTarget's realm (customized built-in elements) promise_test: Unhandled rejection with value: object "TypeError: Reflect.construct requires the first argument be a constructor"
+FAIL If prototype is not object (string), derives the fallback from NewTarget's GetFunctionRealm (customized built-in elements) promise_test: Unhandled rejection with value: object "TypeError: Reflect.construct requires the first argument be a constructor"
PASS HTMLParagraphElement constructor must not get .prototype until it finishes its extends sanity checks, calling proxy constructor directly
PASS HTMLParagraphElement constructor must not get .prototype until it finishes its extends sanity checks, calling via Reflect
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/htmlconstructor/newtarget.html (260669 => 260670)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/htmlconstructor/newtarget.html 2020-04-24 21:11:01 UTC (rev 260669)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/htmlconstructor/newtarget.html 2020-04-24 21:41:32 UTC (rev 260670)
@@ -40,9 +40,10 @@
// We have to not throw during define(), but throw during super()
let throws = false;
+ let err = { name: "prototype throws" };
function TestElement() {
throws = true;
- assert_throws({ name: "prototype throws" }, () => {
+ assert_throws_exactly(err, () => {
Reflect.construct(w.HTMLElement, [], new.target);
});
}
@@ -50,7 +51,7 @@
const ElementWithDynamicPrototype = new Proxy(TestElement, {
get: function (target, name) {
if (throws && name == "prototype")
- throw { name: "prototype throws" };
+ throw err;
return target[name];
}
});
@@ -91,6 +92,38 @@
returnNotAnObject = true;
new ElementWithDynamicPrototype();
}, "If prototype is not object (" + notAnObject + "), derives the fallback from NewTarget's realm (autonomous custom elements)");
+
+ test_with_window(w => {
+ // We have to return an object during define(), but not during super()
+ let returnNotAnObject = false;
+
+ function TestElement() {
+ const o = Reflect.construct(w.HTMLElement, [], new.target);
+
+ assert_equals(Object.getPrototypeOf(new.target), window.Function.prototype);
+ assert_equals(Object.getPrototypeOf(o), window.HTMLElement.prototype,
+ "Must use the HTMLElement from the realm of NewTarget");
+ assert_not_equals(Object.getPrototypeOf(o), w.HTMLElement.prototype,
+ "Must not use the HTMLElement from the realm of the active function object (w.HTMLElement)");
+
+ return o;
+ }
+
+ // Create the proxy in the subframe, which should not affect what our
+ // prototype ends up as.
+ const ElementWithDynamicPrototype = new w.Proxy(TestElement, {
+ get: function (target, name) {
+ if (name == "prototype")
+ return returnNotAnObject ? notAnObject : {};
+ return target[name];
+ }
+ });
+
+ w.customElements.define("test-element", ElementWithDynamicPrototype);
+
+ returnNotAnObject = true;
+ new ElementWithDynamicPrototype();
+ }, "If prototype is not object (" + notAnObject + "), derives the fallback from NewTarget's GetFunctionRealm (autonomous custom elements)");
});
[null, undefined, 5, "string"].forEach(function (notAnObject) {
@@ -122,6 +155,37 @@
returnNotAnObject = true;
new ElementWithDynamicPrototype();
}, "If prototype is not object (" + notAnObject + "), derives the fallback from NewTarget's realm (customized built-in elements)");
+
+ test_with_window(w => {
+ // We have to return an object during define(), but not during super()
+ let returnNotAnObject = false;
+
+ function TestElement() {
+ const o = Reflect.construct(w.HTMLParagraphElement, [], new.target);
+
+ assert_equals(Object.getPrototypeOf(o), window.HTMLParagraphElement.prototype,
+ "Must use the HTMLParagraphElement from the realm of NewTarget");
+ assert_not_equals(Object.getPrototypeOf(o), w.HTMLParagraphElement.prototype,
+ "Must not use the HTMLParagraphElement from the realm of the active function object (w.HTMLParagraphElement)");
+
+ return o;
+ }
+
+ // Create the proxy in the subframe, which should not affect what our
+ // prototype ends up as.
+ const ElementWithDynamicPrototype = new w.Proxy(TestElement, {
+ get: function (target, name) {
+ if (name == "prototype")
+ return returnNotAnObject ? notAnObject : {};
+ return target[name];
+ }
+ });
+
+ w.customElements.define("test-element", ElementWithDynamicPrototype, { extends: "p" });
+
+ returnNotAnObject = true;
+ new ElementWithDynamicPrototype();
+ }, "If prototype is not object (" + notAnObject + "), derives the fallback from NewTarget's GetFunctionRealm (customized built-in elements)");
});
test_with_window(w => {
@@ -139,9 +203,9 @@
// define() gets the prototype of the constructor it's passed, so
// reset the counter.
getCount = 0;
- assert_throws({'name': 'TypeError'},
- function () { new countingProxy() },
- "Should not be able to construct an HTMLParagraphElement not named 'p'");
+ assert_throws_js(TypeError,
+ function () { new countingProxy() },
+ "Should not be able to construct an HTMLParagraphElement not named 'p'");
assert_equals(getCount, 0, "Should never have gotten .prototype");
}, 'HTMLParagraphElement constructor must not get .prototype until it finishes its extends sanity checks, calling proxy constructor directly');
@@ -160,9 +224,9 @@
// define() gets the prototype of the constructor it's passed, so
// reset the counter.
getCount = 0;
- assert_throws({'name': 'TypeError'},
- function () { Reflect.construct(HTMLParagraphElement, [], countingProxy) },
- "Should not be able to construct an HTMLParagraphElement not named 'p'");
+ assert_throws_js(TypeError,
+ function () { Reflect.construct(HTMLParagraphElement, [], countingProxy) },
+ "Should not be able to construct an HTMLParagraphElement not named 'p'");
assert_equals(getCount, 0, "Should never have gotten .prototype");
}, 'HTMLParagraphElement constructor must not get .prototype until it finishes its extends sanity checks, calling via Reflect');
</script>