From 09696f40a888a26d48fd24e9b38ef00c06448b80 Mon Sep 17 00:00:00 2001 From: Alexey Shvayka Date: Thu, 23 Jul 2020 15:17:14 +0300 Subject: [PATCH 1/3] Add WebAssembly[Symbol.toStringTag] test --- .../namespace-object-class-string.any.js | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 wasm/jsapi/namespace-object-class-string.any.js diff --git a/wasm/jsapi/namespace-object-class-string.any.js b/wasm/jsapi/namespace-object-class-string.any.js new file mode 100644 index 00000000000000..2f63aca2c55e5b --- /dev/null +++ b/wasm/jsapi/namespace-object-class-string.any.js @@ -0,0 +1,40 @@ +"use strict"; +// https://heycam.github.io/webidl/#es-namespaces +// https://webassembly.github.io/spec/js-api/#namespacedef-webassembly + +test(() => { + assert_own_property(WebAssembly, Symbol.toStringTag); + + const propDesc = Object.getOwnPropertyDescriptor(WebAssembly, Symbol.toStringTag); + assert_equals(propDesc.value, "WebAssembly", "value"); + assert_equals(propDesc.writable, false, "writable"); + assert_equals(propDesc.enumerable, false, "enumerable"); + assert_equals(propDesc.configurable, true, "configurable"); +}, "@@toStringTag exists on the namespace object with the appropriate descriptor"); + +test(() => { + assert_equals(WebAssembly.toString(), "[object WebAssembly]"); + assert_equals(Object.prototype.toString.call(WebAssembly), "[object WebAssembly]"); +}, "Object.prototype.toString applied to the namespace object"); + +test(t => { + assert_own_property(WebAssembly, Symbol.toStringTag, "Precondition: @@toStringTag on the namespace object"); + t.add_cleanup(() => { + Object.defineProperty(WebAssembly, Symbol.toStringTag, { value: "WebAssembly" }); + }); + + Object.defineProperty(WebAssembly, Symbol.toStringTag, { value: "Test" }); + assert_equals(WebAssembly.toString(), "[object Test]"); + assert_equals(Object.prototype.toString.call(WebAssembly), "[object Test]"); +}, "Object.prototype.toString applied after modifying the namespace object's @@toStringTag"); + +test(t => { + assert_own_property(WebAssembly, Symbol.toStringTag, "Precondition: @@toStringTag on the namespace object"); + t.add_cleanup(() => { + Object.defineProperty(WebAssembly, Symbol.toStringTag, { value: "WebAssembly" }); + }); + + assert_true(delete WebAssembly[Symbol.toStringTag]); + assert_equals(WebAssembly.toString(), "[object Object]"); + assert_equals(Object.prototype.toString.call(WebAssembly), "[object Object]"); +}, "Object.prototype.toString applied after deleting @@toStringTag"); From 27f7a4ec2f8ad2f98bc1f8e594f9aae58ce84da1 Mon Sep 17 00:00:00 2001 From: Alexey Shvayka Date: Thu, 23 Jul 2020 15:17:21 +0300 Subject: [PATCH 2/3] Add CSS[Symbol.toStringTag] test --- .../CSS-namespace-object-class-string.html | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 css/cssom/CSS-namespace-object-class-string.html diff --git a/css/cssom/CSS-namespace-object-class-string.html b/css/cssom/CSS-namespace-object-class-string.html new file mode 100644 index 00000000000000..96c427f6cf2dfc --- /dev/null +++ b/css/cssom/CSS-namespace-object-class-string.html @@ -0,0 +1,47 @@ + + +CSSOM - Symbol.toStringTag value of CSS namespace object + + + + + From 791d49531ec765cd3946d2bb82558f2f1d0f7049 Mon Sep 17 00:00:00 2001 From: Alexey Shvayka Date: Thu, 23 Jul 2020 15:17:30 +0300 Subject: [PATCH 3/3] Add console[Symbol.toStringTag] test --- ...nsole-namespace-object-class-string.any.js | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 console/console-namespace-object-class-string.any.js diff --git a/console/console-namespace-object-class-string.any.js b/console/console-namespace-object-class-string.any.js new file mode 100644 index 00000000000000..7b27e72d819251 --- /dev/null +++ b/console/console-namespace-object-class-string.any.js @@ -0,0 +1,40 @@ +"use strict"; +// https://heycam.github.io/webidl/#es-namespaces +// https://console.spec.whatwg.org/#console-namespace + +test(() => { + assert_own_property(console, Symbol.toStringTag); + + const propDesc = Object.getOwnPropertyDescriptor(console, Symbol.toStringTag); + assert_equals(propDesc.value, "console", "value"); + assert_equals(propDesc.writable, false, "writable"); + assert_equals(propDesc.enumerable, false, "enumerable"); + assert_equals(propDesc.configurable, true, "configurable"); +}, "@@toStringTag exists on the namespace object with the appropriate descriptor"); + +test(() => { + assert_equals(console.toString(), "[object console]"); + assert_equals(Object.prototype.toString.call(console), "[object console]"); +}, "Object.prototype.toString applied to the namespace object"); + +test(t => { + assert_own_property(console, Symbol.toStringTag, "Precondition: @@toStringTag on the namespace object"); + t.add_cleanup(() => { + Object.defineProperty(console, Symbol.toStringTag, { value: "console" }); + }); + + Object.defineProperty(console, Symbol.toStringTag, { value: "Test" }); + assert_equals(console.toString(), "[object Test]"); + assert_equals(Object.prototype.toString.call(console), "[object Test]"); +}, "Object.prototype.toString applied after modifying the namespace object's @@toStringTag"); + +test(t => { + assert_own_property(console, Symbol.toStringTag, "Precondition: @@toStringTag on the namespace object"); + t.add_cleanup(() => { + Object.defineProperty(console, Symbol.toStringTag, { value: "console" }); + }); + + assert_true(delete console[Symbol.toStringTag]); + assert_equals(console.toString(), "[object Object]"); + assert_equals(Object.prototype.toString.call(console), "[object Object]"); +}, "Object.prototype.toString applied after deleting @@toStringTag");