From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- testing/web-platform/tests/webidl/META.yml | 4 + testing/web-platform/tests/webidl/README.md | 1 + .../web-platform/tests/webidl/current-realm.html | 168 ++++++++++++ .../webidl/ecmascript-binding/allow-resizable.html | 31 +++ ...tributes-accessors-unique-function-objects.html | 35 +++ .../builtin-function-properties.any.js | 23 ++ .../class-string-interface.any.js | 62 +++++ .../class-string-iterator-prototype-object.any.js | 58 +++++ .../class-string-named-properties-object.window.js | 23 ++ .../webidl/ecmascript-binding/constructors.html | 132 ++++++++++ .../default-iterator-object.html | 27 ++ .../default-toJSON-cross-realm.html | 26 ++ .../es-exceptions/DOMException-constants.any.js | 51 ++++ .../DOMException-constructor-and-prototype.any.js | 32 +++ .../DOMException-constructor-behavior.any.js | 140 ++++++++++ .../DOMException-custom-bindings.any.js | 120 +++++++++ .../es-exceptions/exceptions.html | 78 ++++++ .../global-immutable-prototype.any.js | 25 ++ ...bal-object-implicit-this-value-cross-realm.html | 97 +++++++ .../global-object-implicit-this-value.any.js | 85 ++++++ .../webidl/ecmascript-binding/has-instance.html | 26 ++ .../interface-object-set-receiver.html | 37 +++ .../ecmascript-binding/interface-object.html | 28 ++ ...terface-prototype-constructor-set-receiver.html | 36 +++ .../interface-prototype-object.html | 15 ++ .../invalid-this-value-cross-realm.html | 45 ++++ .../iterator-invalidation-foreach.html | 40 +++ .../iterator-prototype-object.html | 47 ++++ .../legacy-callback-interface-object.html | 69 +++++ .../legacy-factor-function-subclass.window.js | 13 + .../legacy-platform-object/DefineOwnProperty.html | 89 +++++++ .../legacy-platform-object/GetOwnProperty.html | 84 ++++++ .../legacy-platform-object/OwnPropertyKeys.html | 65 +++++ .../legacy-platform-object/Set.html | 79 ++++++ .../legacy-platform-object/helper.js | 22 ++ .../no-regexp-special-casing.any.js | 47 ++++ ...observable-array-no-leak-of-internals.window.js | 18 ++ .../observable-array-ownkeys.window.js | 34 +++ .../webidl/ecmascript-binding/put-forwards.html | 148 +++++++++++ .../ecmascript-binding/sequence-conversion.html | 157 ++++++++++++ .../support/constructors-support.html | 8 + .../ecmascript-binding/support/create-realm.js | 12 + .../ecmascript-binding/support/dummy-iframe.html | 7 + .../window-named-properties-object.html | 284 +++++++++++++++++++++ .../tests/webidl/idlharness-shadowrealm.window.js | 2 + .../web-platform/tests/webidl/idlharness.any.js | 16 ++ 46 files changed, 2646 insertions(+) create mode 100644 testing/web-platform/tests/webidl/META.yml create mode 100644 testing/web-platform/tests/webidl/README.md create mode 100644 testing/web-platform/tests/webidl/current-realm.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/allow-resizable.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/attributes-accessors-unique-function-objects.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/builtin-function-properties.any.js create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/class-string-interface.any.js create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/class-string-iterator-prototype-object.any.js create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/class-string-named-properties-object.window.js create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/constructors.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/default-iterator-object.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/default-toJSON-cross-realm.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/es-exceptions/DOMException-constants.any.js create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/es-exceptions/DOMException-constructor-and-prototype.any.js create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/es-exceptions/DOMException-constructor-behavior.any.js create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/es-exceptions/DOMException-custom-bindings.any.js create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/es-exceptions/exceptions.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/global-immutable-prototype.any.js create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/global-object-implicit-this-value-cross-realm.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/global-object-implicit-this-value.any.js create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/has-instance.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/interface-object-set-receiver.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/interface-object.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/interface-prototype-constructor-set-receiver.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/interface-prototype-object.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/invalid-this-value-cross-realm.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/iterator-invalidation-foreach.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/iterator-prototype-object.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/legacy-callback-interface-object.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/legacy-factor-function-subclass.window.js create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/legacy-platform-object/DefineOwnProperty.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/legacy-platform-object/GetOwnProperty.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/legacy-platform-object/OwnPropertyKeys.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/legacy-platform-object/Set.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/legacy-platform-object/helper.js create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/no-regexp-special-casing.any.js create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/observable-array-no-leak-of-internals.window.js create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/observable-array-ownkeys.window.js create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/put-forwards.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/sequence-conversion.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/support/constructors-support.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/support/create-realm.js create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/support/dummy-iframe.html create mode 100644 testing/web-platform/tests/webidl/ecmascript-binding/window-named-properties-object.html create mode 100644 testing/web-platform/tests/webidl/idlharness-shadowrealm.window.js create mode 100644 testing/web-platform/tests/webidl/idlharness.any.js (limited to 'testing/web-platform/tests/webidl') diff --git a/testing/web-platform/tests/webidl/META.yml b/testing/web-platform/tests/webidl/META.yml new file mode 100644 index 0000000000..686acbbc60 --- /dev/null +++ b/testing/web-platform/tests/webidl/META.yml @@ -0,0 +1,4 @@ +spec: https://webidl.spec.whatwg.org/ +suggested_reviewers: + - domenic + - yuki3 diff --git a/testing/web-platform/tests/webidl/README.md b/testing/web-platform/tests/webidl/README.md new file mode 100644 index 0000000000..136a764998 --- /dev/null +++ b/testing/web-platform/tests/webidl/README.md @@ -0,0 +1 @@ +Tests for the [Web IDL Standard](https://webidl.spec.whatwg.org/). diff --git a/testing/web-platform/tests/webidl/current-realm.html b/testing/web-platform/tests/webidl/current-realm.html new file mode 100644 index 0000000000..29e07d1f79 --- /dev/null +++ b/testing/web-platform/tests/webidl/current-realm.html @@ -0,0 +1,168 @@ + + + +Current Realm + + +
+ + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/allow-resizable.html b/testing/web-platform/tests/webidl/ecmascript-binding/allow-resizable.html new file mode 100644 index 0000000000..54daa57bce --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/allow-resizable.html @@ -0,0 +1,31 @@ + + + + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/attributes-accessors-unique-function-objects.html b/testing/web-platform/tests/webidl/ecmascript-binding/attributes-accessors-unique-function-objects.html new file mode 100644 index 0000000000..167f55bcef --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/attributes-accessors-unique-function-objects.html @@ -0,0 +1,35 @@ + + +All attributes accessors are unique function objects + + + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/builtin-function-properties.any.js b/testing/web-platform/tests/webidl/ecmascript-binding/builtin-function-properties.any.js new file mode 100644 index 0000000000..885bb441ea --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/builtin-function-properties.any.js @@ -0,0 +1,23 @@ +"use strict"; + +test(() => { + const ownPropKeys = Reflect.ownKeys(Blob).slice(0, 3); + assert_array_equals(ownPropKeys, ["length", "name", "prototype"]); +}, 'Constructor property enumeration order of "length", "name", and "prototype"'); + +test(() => { + assert_own_property(Blob.prototype, "slice"); + + const ownPropKeys = Reflect.ownKeys(Blob.prototype.slice).slice(0, 2); + assert_array_equals(ownPropKeys, ["length", "name"]); +}, 'Method property enumeration order of "length" and "name"'); + +test(() => { + assert_own_property(Blob.prototype, "size"); + + const desc = Reflect.getOwnPropertyDescriptor(Blob.prototype, "size"); + assert_equals(typeof desc.get, "function"); + + const ownPropKeys = Reflect.ownKeys(desc.get).slice(0, 2); + assert_array_equals(ownPropKeys, ["length", "name"]); +}, 'Getter property enumeration order of "length" and "name"'); diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/class-string-interface.any.js b/testing/web-platform/tests/webidl/ecmascript-binding/class-string-interface.any.js new file mode 100644 index 0000000000..ee792d5368 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/class-string-interface.any.js @@ -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"); diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/class-string-iterator-prototype-object.any.js b/testing/web-platform/tests/webidl/ecmascript-binding/class-string-iterator-prototype-object.any.js new file mode 100644 index 0000000000..f878eb7b35 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/class-string-iterator-prototype-object.any.js @@ -0,0 +1,58 @@ +"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(() => { + const iterator = (new URLSearchParams()).keys(); + assert_equals(Object.prototype.toString.call(iterator), "[object URLSearchParams Iterator]"); + + Object.setPrototypeOf(iterator, null); + assert_equals(Object.prototype.toString.call(iterator), "[object Object]"); +}, "Object.prototype.toString applied to a null-prototype instance"); + +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 URLSearchParams Iterator]"); +}, "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"); diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/class-string-named-properties-object.window.js b/testing/web-platform/tests/webidl/ecmascript-binding/class-string-named-properties-object.window.js new file mode 100644 index 0000000000..a427a2f814 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/class-string-named-properties-object.window.js @@ -0,0 +1,23 @@ +"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"); + +// 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. Tests for this are present in +// the sibling class-string*.any.js tests. However, the named properties object always fails calls +// to [[DefineOwnProperty]] or [[SetPrototypeOf]] per the Web IDL spec, so there is no way to +// trigger the buggy behavior for it. diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/constructors.html b/testing/web-platform/tests/webidl/ecmascript-binding/constructors.html new file mode 100644 index 0000000000..61993a6200 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/constructors.html @@ -0,0 +1,132 @@ + + +Realm for constructed objects + + +
+ diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/default-iterator-object.html b/testing/web-platform/tests/webidl/ecmascript-binding/default-iterator-object.html new file mode 100644 index 0000000000..c7e9188521 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/default-iterator-object.html @@ -0,0 +1,27 @@ + + +Default iterator objects + + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/default-toJSON-cross-realm.html b/testing/web-platform/tests/webidl/ecmascript-binding/default-toJSON-cross-realm.html new file mode 100644 index 0000000000..79c3097f33 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/default-toJSON-cross-realm.html @@ -0,0 +1,26 @@ + + +Cross-realm [Default] toJSON() creates result object in its realm + + + + + + + + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/es-exceptions/DOMException-constants.any.js b/testing/web-platform/tests/webidl/ecmascript-binding/es-exceptions/DOMException-constants.any.js new file mode 100644 index 0000000000..bb846a494e --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/es-exceptions/DOMException-constants.any.js @@ -0,0 +1,51 @@ +'use strict'; + +test(function() { + // https://www.w3.org/Bugs/Public/show_bug.cgi?id=27732 + var constants = [ + "INDEX_SIZE_ERR", + "DOMSTRING_SIZE_ERR", + "HIERARCHY_REQUEST_ERR", + "WRONG_DOCUMENT_ERR", + "INVALID_CHARACTER_ERR", + "NO_DATA_ALLOWED_ERR", + "NO_MODIFICATION_ALLOWED_ERR", + "NOT_FOUND_ERR", + "NOT_SUPPORTED_ERR", + "INUSE_ATTRIBUTE_ERR", + "INVALID_STATE_ERR", + "SYNTAX_ERR", + "INVALID_MODIFICATION_ERR", + "NAMESPACE_ERR", + "INVALID_ACCESS_ERR", + "VALIDATION_ERR", + "TYPE_MISMATCH_ERR", + "SECURITY_ERR", + "NETWORK_ERR", + "ABORT_ERR", + "URL_MISMATCH_ERR", + "QUOTA_EXCEEDED_ERR", + "TIMEOUT_ERR", + "INVALID_NODE_TYPE_ERR", + "DATA_CLONE_ERR" + ] + var objects = [ + [DOMException, "DOMException constructor object"], + [DOMException.prototype, "DOMException prototype object"] + ] + constants.forEach(function(name, i) { + objects.forEach(function(o) { + var object = o[0], description = o[1]; + test(function() { + assert_equals(object[name], i + 1, name) + assert_own_property(object, name) + var pd = Object.getOwnPropertyDescriptor(object, name) + assert_false("get" in pd, "get") + assert_false("set" in pd, "set") + assert_false(pd.writable, "writable") + assert_true(pd.enumerable, "enumerable") + assert_false(pd.configurable, "configurable") + }, "Constant " + name + " on " + description) + }) + }) +}) diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/es-exceptions/DOMException-constructor-and-prototype.any.js b/testing/web-platform/tests/webidl/ecmascript-binding/es-exceptions/DOMException-constructor-and-prototype.any.js new file mode 100644 index 0000000000..a015470cad --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/es-exceptions/DOMException-constructor-and-prototype.any.js @@ -0,0 +1,32 @@ +test(function() { + assert_own_property(self, "DOMException", "property of global"); + + var desc = Object.getOwnPropertyDescriptor(self, "DOMException"); + assert_false("get" in desc, "get"); + assert_false("set" in desc, "set"); + assert_true(desc.writable, "writable"); + assert_false(desc.enumerable, "enumerable"); + assert_true(desc.configurable, "configurable"); +}, "existence and property descriptor of DOMException"); + +test(function() { + assert_own_property(self.DOMException, "prototype", "prototype property"); + + var desc = Object.getOwnPropertyDescriptor(self.DOMException, "prototype"); + assert_false("get" in desc, "get"); + assert_false("set" in desc, "set"); + assert_false(desc.writable, "writable"); + assert_false(desc.enumerable, "enumerable"); + assert_false(desc.configurable, "configurable"); +}, "existence and property descriptor of DOMException.prototype"); + +test(function() { + assert_own_property(self.DOMException.prototype, "constructor", "property of prototype"); + var desc = Object.getOwnPropertyDescriptor(self.DOMException.prototype, "constructor"); + assert_false("get" in desc, "get"); + assert_false("set" in desc, "set"); + assert_true(desc.writable, "writable"); + assert_false(desc.enumerable, "enumerable"); + assert_true(desc.configurable, "configurable"); + assert_equals(self.DOMException.prototype.constructor, self.DOMException, "equality with actual constructor"); +}, "existence and property descriptor of DOMException.prototype.constructor"); diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/es-exceptions/DOMException-constructor-behavior.any.js b/testing/web-platform/tests/webidl/ecmascript-binding/es-exceptions/DOMException-constructor-behavior.any.js new file mode 100644 index 0000000000..e9917af228 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/es-exceptions/DOMException-constructor-behavior.any.js @@ -0,0 +1,140 @@ +'use strict'; + +test(function() { + var ex = new DOMException(); + assert_equals(ex.name, "Error", + "Not passing a name should end up with 'Error' as the name"); + assert_equals(ex.message, "", + "Not passing a message should end up with empty string as the message"); +}, 'new DOMException()'); + +test(function() { + var ex = new DOMException(); + assert_false(ex.hasOwnProperty("name"), + "The name property should be inherited"); + assert_false(ex.hasOwnProperty("message"), + "The message property should be inherited"); +}, 'new DOMException(): inherited-ness'); + +test(function() { + var ex = new DOMException(null); + assert_equals(ex.name, "Error", + "Not passing a name should end up with 'Error' as the name"); + assert_equals(ex.message, "null", + "Passing null as message should end up with stringified 'null' as the message"); +}, 'new DOMException(null)'); + +test(function() { + var ex = new DOMException(undefined); + assert_equals(ex.name, "Error", + "Not passing a name should end up with 'Error' as the name"); + assert_equals(ex.message, "", + "Not passing a message should end up with empty string as the message"); +}, 'new DOMException(undefined)'); + +test(function() { + var ex = new DOMException(undefined); + assert_false(ex.hasOwnProperty("name"), + "The name property should be inherited"); + assert_false(ex.hasOwnProperty("message"), + "The message property should be inherited"); +}, 'new DOMException(undefined): inherited-ness'); + +test(function() { + var ex = new DOMException("foo"); + assert_equals(ex.name, "Error", + "Not passing a name should still end up with 'Error' as the name"); + assert_equals(ex.message, "foo", "Should be using passed-in message"); +}, 'new DOMException("foo")'); + +test(function() { + var ex = new DOMException("foo"); + assert_false(ex.hasOwnProperty("name"), + "The name property should be inherited"); + assert_false(ex.hasOwnProperty("message"), + "The message property should be inherited"); +}, 'new DOMException("foo"): inherited-ness'); + +test(function() { + var ex = new DOMException("bar", undefined); + assert_equals(ex.name, "Error", + "Passing undefined for name should end up with 'Error' as the name"); + assert_equals(ex.message, "bar", "Should still be using passed-in message"); +}, 'new DOMException("bar", undefined)'); + +test(function() { + var ex = new DOMException("bar", "NotSupportedError"); + assert_equals(ex.name, "NotSupportedError", "Should be using the passed-in name"); + assert_equals(ex.message, "bar", "Should still be using passed-in message"); + assert_equals(ex.code, DOMException.NOT_SUPPORTED_ERR, + "Should have the right exception code"); +}, 'new DOMException("bar", "NotSupportedError")'); + +test(function() { + var ex = new DOMException("bar", "NotSupportedError"); + assert_false(ex.hasOwnProperty("name"), + "The name property should be inherited"); + assert_false(ex.hasOwnProperty("message"), + "The message property should be inherited"); +}, 'new DOMException("bar", "NotSupportedError"): inherited-ness'); + +test(function() { + var ex = new DOMException("bar", "foo"); + assert_equals(ex.name, "foo", "Should be using the passed-in name"); + assert_equals(ex.message, "bar", "Should still be using passed-in message"); + assert_equals(ex.code, 0, + "Should have 0 for code for a name not in the exception names table"); +}, 'new DOMException("bar", "foo")'); + +[ + {name: "IndexSizeError", code: 1}, + {name: "HierarchyRequestError", code: 3}, + {name: "WrongDocumentError", code: 4}, + {name: "InvalidCharacterError", code: 5}, + {name: "NoModificationAllowedError", code: 7}, + {name: "NotFoundError", code: 8}, + {name: "NotSupportedError", code: 9}, + {name: "InUseAttributeError", code: 10}, + {name: "InvalidStateError", code: 11}, + {name: "SyntaxError", code: 12}, + {name: "InvalidModificationError", code: 13}, + {name: "NamespaceError", code: 14}, + {name: "InvalidAccessError", code: 15}, + {name: "TypeMismatchError", code: 17}, + {name: "SecurityError", code: 18}, + {name: "NetworkError", code: 19}, + {name: "AbortError", code: 20}, + {name: "URLMismatchError", code: 21}, + {name: "QuotaExceededError", code: 22}, + {name: "TimeoutError", code: 23}, + {name: "InvalidNodeTypeError", code: 24}, + {name: "DataCloneError", code: 25}, + + // These were removed from the error names table. + // See https://github.com/heycam/webidl/pull/946. + {name: "DOMStringSizeError", code: 0}, + {name: "NoDataAllowedError", code: 0}, + {name: "ValidationError", code: 0}, + + // The error names which don't have legacy code values. + {name: "EncodingError", code: 0}, + {name: "NotReadableError", code: 0}, + {name: "UnknownError", code: 0}, + {name: "ConstraintError", code: 0}, + {name: "DataError", code: 0}, + {name: "TransactionInactiveError", code: 0}, + {name: "ReadOnlyError", code: 0}, + {name: "VersionError", code: 0}, + {name: "OperationError", code: 0}, + {name: "NotAllowedError", code: 0} +].forEach(function(test_case) { + test(function() { + var ex = new DOMException("msg", test_case.name); + assert_equals(ex.name, test_case.name, + "Should be using the passed-in name"); + assert_equals(ex.message, "msg", + "Should be using the passed-in message"); + assert_equals(ex.code, test_case.code, + "Should have matching legacy code from error names table"); + },'new DOMexception("msg", "' + test_case.name + '")'); +}); diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/es-exceptions/DOMException-custom-bindings.any.js b/testing/web-platform/tests/webidl/ecmascript-binding/es-exceptions/DOMException-custom-bindings.any.js new file mode 100644 index 0000000000..cd4e5b6341 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/es-exceptions/DOMException-custom-bindings.any.js @@ -0,0 +1,120 @@ +"use strict"; + +test(() => { + assert_throws_js(TypeError, () => DOMException()); +}, "Cannot construct without new"); + +test(() => { + assert_equals(Object.getPrototypeOf(DOMException.prototype), Error.prototype); +}, "inherits from Error: prototype-side"); + +test(() => { + assert_equals(Object.getPrototypeOf(DOMException), Function.prototype); +}, "does not inherit from Error: class-side"); + +test(() => { + const e = new DOMException("message", "name"); + assert_false(e.hasOwnProperty("message"), "property is not own"); + + const propDesc = Object.getOwnPropertyDescriptor(DOMException.prototype, "message"); + assert_equals(typeof propDesc.get, "function", "property descriptor is a getter"); + assert_equals(propDesc.set, undefined, "property descriptor is not a setter"); + assert_true(propDesc.enumerable, "property descriptor enumerable"); + assert_true(propDesc.configurable, "property descriptor configurable"); +}, "message property descriptor"); + +test(() => { + const getter = Object.getOwnPropertyDescriptor(DOMException.prototype, "message").get; + + assert_throws_js(TypeError, () => getter.apply({})); +}, "message getter performs brand checks (i.e. is not [LegacyLenientThis])"); + +test(() => { + const e = new DOMException("message", "name"); + assert_false(e.hasOwnProperty("name"), "property is not own"); + + const propDesc = Object.getOwnPropertyDescriptor(DOMException.prototype, "name"); + assert_equals(typeof propDesc.get, "function", "property descriptor is a getter"); + assert_equals(propDesc.set, undefined, "property descriptor is not a setter"); + assert_true(propDesc.enumerable, "property descriptor enumerable"); + assert_true(propDesc.configurable, "property descriptor configurable"); +}, "name property descriptor"); + +test(() => { + const getter = Object.getOwnPropertyDescriptor(DOMException.prototype, "name").get; + + assert_throws_js(TypeError, () => getter.apply({})); +}, "name getter performs brand checks (i.e. is not [LegacyLenientThis])"); + +test(() => { + const e = new DOMException("message", "name"); + assert_false(e.hasOwnProperty("code"), "property is not own"); + + const propDesc = Object.getOwnPropertyDescriptor(DOMException.prototype, "code"); + assert_equals(typeof propDesc.get, "function", "property descriptor is a getter"); + assert_equals(propDesc.set, undefined, "property descriptor is not a setter"); + assert_true(propDesc.enumerable, "property descriptor enumerable"); + assert_true(propDesc.configurable, "property descriptor configurable"); +}, "code property descriptor"); + +test(() => { + const getter = Object.getOwnPropertyDescriptor(DOMException.prototype, "code").get; + + assert_throws_js(TypeError, () => getter.apply({})); +}, "code getter performs brand checks (i.e. is not [LegacyLenientThis])"); + +test(() => { + const e = new DOMException("message", "InvalidCharacterError"); + assert_equals(e.code, 5, "Initially the code is set to 5"); + + Object.defineProperty(e, "name", { + value: "WrongDocumentError" + }); + + assert_equals(e.code, 5, "The code is still set to 5"); +}, "code property is not affected by shadowing the name property"); + +test(() => { + const e = new DOMException("message", "name"); + assert_equals(Object.prototype.toString.call(e), "[object DOMException]"); +}, "Object.prototype.toString behavior is like other interfaces"); + +test(() => { + const e = new DOMException("message", "name"); + assert_false(e.hasOwnProperty("toString"), "toString must not exist on the instance"); + assert_false(DOMException.prototype.hasOwnProperty("toString"), "toString must not exist on DOMException.prototype"); + assert_equals(typeof e.toString, "function", "toString must still exist (via Error.prototype)"); +}, "Inherits its toString() from Error.prototype"); + +test(() => { + const e = new DOMException("message", "name"); + assert_equals(e.toString(), "name: message", + "The default Error.prototype.toString() behavior must work on supplied name and message"); + + Object.defineProperty(e, "name", { value: "new name" }); + Object.defineProperty(e, "message", { value: "new message" }); + assert_equals(e.toString(), "new name: new message", + "The default Error.prototype.toString() behavior must work on shadowed names and messages"); +}, "toString() behavior from Error.prototype applies as expected"); + +test(() => { + assert_throws_js(TypeError, () => DOMException.prototype.toString()); +}, "DOMException.prototype.toString() applied to DOMException.prototype throws because of name/message brand checks"); + +test(() => { + let stackOnNormalErrors; + try { + throw new Error("normal error"); + } catch (e) { + stackOnNormalErrors = e.stack; + } + + let stackOnDOMException; + try { + throw new DOMException("message", "name"); + } catch (e) { + stackOnDOMException = e.stack; + } + + assert_equals(typeof stackOnDOMException, typeof stackOnNormalErrors, "The typeof values must match"); +}, "If the implementation has a stack property on normal errors, it also does on DOMExceptions"); diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/es-exceptions/exceptions.html b/testing/web-platform/tests/webidl/ecmascript-binding/es-exceptions/exceptions.html new file mode 100644 index 0000000000..d26c662669 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/es-exceptions/exceptions.html @@ -0,0 +1,78 @@ + + +DOMException-throwing tests + +
+ + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/global-immutable-prototype.any.js b/testing/web-platform/tests/webidl/ecmascript-binding/global-immutable-prototype.any.js new file mode 100644 index 0000000000..6291c3ae93 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/global-immutable-prototype.any.js @@ -0,0 +1,25 @@ +// META: global=window,worker +// META: title=Immutability of the global prototype chain + +const objects = []; +setup(() => { + for (let object = self; object; object = Object.getPrototypeOf(object)) { + objects.push(object); + } +}); + +test(() => { + for (const object of objects) { + assert_throws_js(TypeError, () => { + Object.setPrototypeOf(object, {}); + }); + } +}, "Setting to a different prototype"); + +test(() => { + for (const object of objects) { + const expected = Object.getPrototypeOf(object); + Object.setPrototypeOf(object, expected); + assert_equals(Object.getPrototypeOf(object), expected); + } +}, "Setting to the same prototype"); diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/global-object-implicit-this-value-cross-realm.html b/testing/web-platform/tests/webidl/ecmascript-binding/global-object-implicit-this-value-cross-realm.html new file mode 100644 index 0000000000..b9939b801c --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/global-object-implicit-this-value-cross-realm.html @@ -0,0 +1,97 @@ + + +Cross-realm getter / setter / operation doesn't use lexical global object if |this| value is incompatible object / null / undefined + + + + + + + + + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/global-object-implicit-this-value.any.js b/testing/web-platform/tests/webidl/ecmascript-binding/global-object-implicit-this-value.any.js new file mode 100644 index 0000000000..4c159c6751 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/global-object-implicit-this-value.any.js @@ -0,0 +1,85 @@ +// META: global=window,worker + +// https://webidl.spec.whatwg.org/#dfn-attribute-getter (step 1.1.2.1) +// https://webidl.spec.whatwg.org/#dfn-attribute-setter (step 4.5.1) +// https://webidl.spec.whatwg.org/#dfn-create-operation-function (step 2.1.2.1) + +const notGlobalObject = Object.create(Object.getPrototypeOf(globalThis)); + +test(() => { + assert_throws_js(TypeError, () => { Object.create(globalThis).self; }); + assert_throws_js(TypeError, () => { getGlobalPropertyDescriptor("location").get.call(notGlobalObject); }); + assert_throws_js(TypeError, () => { Reflect.get(globalThis, "navigator", notGlobalObject); }); + assert_throws_js(TypeError, () => { new Proxy(globalThis, {}).onerror; }); +}, "Global object's getter throws when called on incompatible object"); + +test(() => { + assert_throws_js(TypeError, () => { Object.create(globalThis).origin = origin; }); + assert_throws_js(TypeError, () => { getGlobalPropertyDescriptor("onerror").set.call(notGlobalObject, onerror); }); + assert_throws_js(TypeError, () => { Reflect.set(globalThis, "onoffline", onoffline, notGlobalObject); }); + assert_throws_js(TypeError, () => { new Proxy(globalThis, {}).ononline = ononline; }); +}, "Global object's setter throws when called on incompatible object"); + +test(() => { + assert_throws_js(TypeError, () => { Object.create(globalThis).setInterval(() => {}, 100); }); + assert_throws_js(TypeError, () => { clearTimeout.call(notGlobalObject, () => {}); }); + assert_throws_js(TypeError, () => { Reflect.apply(btoa, notGlobalObject, [""]); }); + assert_throws_js(TypeError, () => { new Proxy(globalThis, {}).removeEventListener("foo", () => {}); }); +}, "Global object's operation throws when called on incompatible object"); + +if (typeof document !== "undefined") { + test(() => { + assert_throws_js(TypeError, () => { Object.getOwnPropertyDescriptor(window, "document").get.call(document.all); }); + }, "Global object's getter throws when called on incompatible object (document.all)"); + + test(() => { + assert_throws_js(TypeError, () => { Object.getOwnPropertyDescriptor(window, "name").set.call(document.all); }); + }, "Global object's setter throws when called on incompatible object (document.all)"); + + test(() => { + assert_throws_js(TypeError, () => { focus.call(document.all); }); + }, "Global object's operation throws when called on incompatible object (document.all)"); +} + +// An engine might have different code path for calling a function from outer scope to implement step 1.b.iii of https://tc39.es/ecma262/#sec-evaluatecall +const locationGetter = getGlobalPropertyDescriptor("location").get; +test(() => { + assert_equals(getGlobalPropertyDescriptor("self").get.call(null), self); + assert_equals((() => locationGetter())(), location); + assert_equals(Reflect.get(globalThis, "origin", null), origin); + assert_equals(Reflect.get(globalThis, "onoffline", undefined), onoffline); +}, "Global object's getter works when called on null / undefined"); + +test(() => { + const fn = () => {}; + + // origin is [Replaceable] + getGlobalPropertyDescriptor("origin").set.call(null, "foo"); + assert_equals(origin, "foo"); + getGlobalPropertyDescriptor("onerror").set.call(undefined, fn); + assert_equals(onerror, fn); + assert_true(Reflect.set(globalThis, "onoffline", fn, null)); + assert_equals(onoffline, fn); + + const ononlineSetter = getGlobalPropertyDescriptor("ononline").set; + (() => { ononlineSetter(fn); })(); + assert_equals(ononline, fn); +}, "Global object's setter works when called on null / undefined"); + +// An engine might have different code path for calling a function from outer scope to implement step 1.b.iii of https://tc39.es/ecma262/#sec-evaluatecall +const __addEventListener = addEventListener; +test(() => { + assert_equals(atob.call(null, ""), ""); + assert_equals(typeof (0, setInterval)(() => {}, 100), "number"); + + (() => { __addEventListener("foo", event => { event.preventDefault(); }); })(); + const __dispatchEvent = dispatchEvent; + (() => { assert_false(__dispatchEvent(new Event("foo", { cancelable: true }))); })(); +}, "Global object's operation works when called on null / undefined"); + +function getGlobalPropertyDescriptor(key) { + for (let obj = globalThis; obj; obj = Object.getPrototypeOf(obj)) { + const desc = Object.getOwnPropertyDescriptor(obj, key); + if (desc) return desc; + } +} diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/has-instance.html b/testing/web-platform/tests/webidl/ecmascript-binding/has-instance.html new file mode 100644 index 0000000000..caf0be4729 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/has-instance.html @@ -0,0 +1,26 @@ + + +instanceof behavior + + + + + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/interface-object-set-receiver.html b/testing/web-platform/tests/webidl/ecmascript-binding/interface-object-set-receiver.html new file mode 100644 index 0000000000..ca75a96bba --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/interface-object-set-receiver.html @@ -0,0 +1,37 @@ + + +window.Interface is defined on [[Set]] receiver + + + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/interface-object.html b/testing/web-platform/tests/webidl/ecmascript-binding/interface-object.html new file mode 100644 index 0000000000..132c61ddae --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/interface-object.html @@ -0,0 +1,28 @@ + + +Interface objects + + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/interface-prototype-constructor-set-receiver.html b/testing/web-platform/tests/webidl/ecmascript-binding/interface-prototype-constructor-set-receiver.html new file mode 100644 index 0000000000..64a2da8eb2 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/interface-prototype-constructor-set-receiver.html @@ -0,0 +1,36 @@ + + +Interface.prototype.constructor is defined on [[Set]] receiver + + + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/interface-prototype-object.html b/testing/web-platform/tests/webidl/ecmascript-binding/interface-prototype-object.html new file mode 100644 index 0000000000..299bcf926d --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/interface-prototype-object.html @@ -0,0 +1,15 @@ + + +Interface prototype objects + + + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/invalid-this-value-cross-realm.html b/testing/web-platform/tests/webidl/ecmascript-binding/invalid-this-value-cross-realm.html new file mode 100644 index 0000000000..0535115ac6 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/invalid-this-value-cross-realm.html @@ -0,0 +1,45 @@ + + +Cross-realm getter / setter / operation doesn't use lexical global object to throw an error for incompatible |this| value + + + + + + + + + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/iterator-invalidation-foreach.html b/testing/web-platform/tests/webidl/ecmascript-binding/iterator-invalidation-foreach.html new file mode 100644 index 0000000000..9d2e3b9cb2 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/iterator-invalidation-foreach.html @@ -0,0 +1,40 @@ + + +Behavior of iterators when modified within foreach + + + + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/iterator-prototype-object.html b/testing/web-platform/tests/webidl/ecmascript-binding/iterator-prototype-object.html new file mode 100644 index 0000000000..7859c1e46a --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/iterator-prototype-object.html @@ -0,0 +1,47 @@ + + +Iterator prototype objects + + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/legacy-callback-interface-object.html b/testing/web-platform/tests/webidl/ecmascript-binding/legacy-callback-interface-object.html new file mode 100644 index 0000000000..627d29507f --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/legacy-callback-interface-object.html @@ -0,0 +1,69 @@ + + +Legacy callback interface objects + + + + + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/legacy-factor-function-subclass.window.js b/testing/web-platform/tests/webidl/ecmascript-binding/legacy-factor-function-subclass.window.js new file mode 100644 index 0000000000..1fd64f41bb --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/legacy-factor-function-subclass.window.js @@ -0,0 +1,13 @@ +"use strict"; + +test(() => { + class CustomImage extends Image {} + var instance = new CustomImage(); + + assert_equals( + Object.getPrototypeOf(instance), CustomImage.prototype, + "Object.getPrototypeOf(instance) === CustomImage.prototype"); + + assert_true(instance instanceof CustomImage, "instance instanceof CustomImage"); + assert_true(instance instanceof HTMLImageElement, "instance instanceof HTMLImageElement"); +}, "[LegacyFactoryFunction] can be subclassed and correctly handles NewTarget"); diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/legacy-platform-object/DefineOwnProperty.html b/testing/web-platform/tests/webidl/ecmascript-binding/legacy-platform-object/DefineOwnProperty.html new file mode 100644 index 0000000000..ad32f6f89f --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/legacy-platform-object/DefineOwnProperty.html @@ -0,0 +1,89 @@ + + +Legacy platform objects [[DefineOwnProperty]] method + + + + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/legacy-platform-object/GetOwnProperty.html b/testing/web-platform/tests/webidl/ecmascript-binding/legacy-platform-object/GetOwnProperty.html new file mode 100644 index 0000000000..be3bcc61f0 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/legacy-platform-object/GetOwnProperty.html @@ -0,0 +1,84 @@ + + +Legacy platform objects [[GetOwnProperty]] method + + + + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/legacy-platform-object/OwnPropertyKeys.html b/testing/web-platform/tests/webidl/ecmascript-binding/legacy-platform-object/OwnPropertyKeys.html new file mode 100644 index 0000000000..d33980517b --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/legacy-platform-object/OwnPropertyKeys.html @@ -0,0 +1,65 @@ + + +Legacy platform objects [[OwnPropertyKeys]] method + + + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/legacy-platform-object/Set.html b/testing/web-platform/tests/webidl/ecmascript-binding/legacy-platform-object/Set.html new file mode 100644 index 0000000000..3134c81859 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/legacy-platform-object/Set.html @@ -0,0 +1,79 @@ + + +Legacy platform objects [[Set]] method + + + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/legacy-platform-object/helper.js b/testing/web-platform/tests/webidl/ecmascript-binding/legacy-platform-object/helper.js new file mode 100644 index 0000000000..01c1d00694 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/legacy-platform-object/helper.js @@ -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)"); + } +} diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/no-regexp-special-casing.any.js b/testing/web-platform/tests/webidl/ecmascript-binding/no-regexp-special-casing.any.js new file mode 100644 index 0000000000..4446dbf69c --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/no-regexp-special-casing.any.js @@ -0,0 +1,47 @@ +"use strict"; +// RegExps used to be special-cased in Web IDL, but that was removed in +// https://github.com/heycam/webidl/commit/bbb2bde. These tests check that implementations no longer +// do any such special-casing. + +test(() => { + const regExp = new RegExp(); + regExp.message = "some message"; + + const errorEvent = new ErrorEvent("type", regExp); + + assert_equals(errorEvent.message, "some message"); +}, "Conversion to a dictionary works"); + +test(() => { + const messageChannel = new MessageChannel(); + const regExp = new RegExp(); + regExp[Symbol.iterator] = function* () { + yield messageChannel.port1; + }; + + const messageEvent = new MessageEvent("type", { ports: regExp }); + + assert_array_equals(messageEvent.ports, [messageChannel.port1]); +}, "Conversion to a sequence works"); + +promise_test(async () => { + const regExp = new RegExp(); + + const response = new Response(regExp); + + assert_equals(await response.text(), "/(?:)/"); +}, "Can convert a RegExp to a USVString"); + +test(() => { + let functionCalled = false; + + const regExp = new RegExp(); + regExp.handleEvent = () => { + functionCalled = true; + }; + + self.addEventListener("testevent", regExp); + self.dispatchEvent(new Event("testevent")); + + assert_true(functionCalled); +}, "Can be used as an object implementing a callback interface"); diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/observable-array-no-leak-of-internals.window.js b/testing/web-platform/tests/webidl/ecmascript-binding/observable-array-no-leak-of-internals.window.js new file mode 100644 index 0000000000..f93464005d --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/observable-array-no-leak-of-internals.window.js @@ -0,0 +1,18 @@ +"use strict"; + +test(() => { + const observableArray = document.adoptedStyleSheets; + + let leaked_target = null; + let leaked_handler = null; + + let target_leaker = (target) => { leaked_target = target; return null; }; + Object.defineProperty(Object.prototype, "getPrototypeOf", {get: function() { + leaked_handler = this; + return target_leaker; + }}) + Object.getPrototypeOf(observableArray); + + assert_equals(leaked_target, null, "The proxy target leaked."); + assert_equals(leaked_handler, null, "The proxy handler leaked."); +}, "ObservableArray's internals won't leak"); diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/observable-array-ownkeys.window.js b/testing/web-platform/tests/webidl/ecmascript-binding/observable-array-ownkeys.window.js new file mode 100644 index 0000000000..29b537c475 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/observable-array-ownkeys.window.js @@ -0,0 +1,34 @@ +"use strict"; + +test(() => { + const observableArray = document.adoptedStyleSheets; + assert_array_equals( + Object.getOwnPropertyNames(observableArray), + ["length"], + "Initially only \"length\"."); + + observableArray["zzz"] = true; + observableArray["aaa"] = true; + assert_array_equals( + Object.getOwnPropertyNames(observableArray), + ["length", "zzz", "aaa"], + "Own properties whose key is a string have been added."); + + observableArray[0] = new CSSStyleSheet(); + observableArray[1] = new CSSStyleSheet(); + assert_array_equals( + Object.getOwnPropertyNames(observableArray), + ["0", "1", "length", "zzz", "aaa"], + "Own properties whose key is an array index have been added."); + + observableArray[Symbol.toStringTag] = "string_tag"; + observableArray[Symbol.toPrimitive] = "primitive"; + assert_array_equals( + Object.getOwnPropertyNames(observableArray), + ["0", "1", "length", "zzz", "aaa"], + "Own properties whose key is a symbol have been added (non-symbol)."); + assert_array_equals( + Object.getOwnPropertySymbols(observableArray), + [Symbol.toStringTag, Symbol.toPrimitive], + "Own properties whose key is a symbol have been added (symbol)."); +}, "ObservableArray's ownKeys trap"); diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/put-forwards.html b/testing/web-platform/tests/webidl/ecmascript-binding/put-forwards.html new file mode 100644 index 0000000000..7d99d65aa2 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/put-forwards.html @@ -0,0 +1,148 @@ + + +[PutForwards] behavior + + + + + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/sequence-conversion.html b/testing/web-platform/tests/webidl/ecmascript-binding/sequence-conversion.html new file mode 100644 index 0000000000..40764e9f57 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/sequence-conversion.html @@ -0,0 +1,157 @@ + + +Sequence conversion + + + + + + + + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/support/constructors-support.html b/testing/web-platform/tests/webidl/ecmascript-binding/support/constructors-support.html new file mode 100644 index 0000000000..3b2616170b --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/support/constructors-support.html @@ -0,0 +1,8 @@ + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/support/create-realm.js b/testing/web-platform/tests/webidl/ecmascript-binding/support/create-realm.js new file mode 100644 index 0000000000..45ded884fc --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/support/create-realm.js @@ -0,0 +1,12 @@ +"use strict"; + +function createRealm(t) { + return new Promise(resolve => { + const iframe = document.createElement("iframe"); + t.add_cleanup(() => { iframe.remove(); }); + iframe.onload = () => { resolve(iframe.contentWindow); }; + iframe.name = "dummy"; + iframe.src = "support/dummy-iframe.html"; + document.body.append(iframe); + }); +} diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/support/dummy-iframe.html b/testing/web-platform/tests/webidl/ecmascript-binding/support/dummy-iframe.html new file mode 100644 index 0000000000..3f773ae6f8 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/support/dummy-iframe.html @@ -0,0 +1,7 @@ + + +foo + + diff --git a/testing/web-platform/tests/webidl/ecmascript-binding/window-named-properties-object.html b/testing/web-platform/tests/webidl/ecmascript-binding/window-named-properties-object.html new file mode 100644 index 0000000000..cc49768906 --- /dev/null +++ b/testing/web-platform/tests/webidl/ecmascript-binding/window-named-properties-object.html @@ -0,0 +1,284 @@ + + +Internal methods of Window's named properties object + + + + + + diff --git a/testing/web-platform/tests/webidl/idlharness-shadowrealm.window.js b/testing/web-platform/tests/webidl/idlharness-shadowrealm.window.js new file mode 100644 index 0000000000..ab1ca9a019 --- /dev/null +++ b/testing/web-platform/tests/webidl/idlharness-shadowrealm.window.js @@ -0,0 +1,2 @@ +// META: script=/resources/idlharness-shadowrealm.js +idl_test_shadowrealm(["webidl"], []); diff --git a/testing/web-platform/tests/webidl/idlharness.any.js b/testing/web-platform/tests/webidl/idlharness.any.js new file mode 100644 index 0000000000..3c662ba8e6 --- /dev/null +++ b/testing/web-platform/tests/webidl/idlharness.any.js @@ -0,0 +1,16 @@ +// META: script=/resources/WebIDLParser.js +// META: script=/resources/idlharness.js + +"use strict"; + +idl_test( + ['webidl'], + [], + idl_array => { + idl_array.add_objects({ + DOMException: ['new DOMException()', + 'new DOMException("my message")', + 'new DOMException("my message", "myName")'] + }); + } +); -- cgit v1.2.3