forked from web-platform-tests/wpt
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add WebAssembly[Symbol.toStringTag] test
- Loading branch information
1 parent
c44373f
commit 92920b6
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); |