diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/tests/ecma_6/Symbol/realms.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/ecma_6/Symbol/realms.js')
-rw-r--r-- | js/src/tests/ecma_6/Symbol/realms.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/js/src/tests/ecma_6/Symbol/realms.js b/js/src/tests/ecma_6/Symbol/realms.js new file mode 100644 index 000000000..98a1284ee --- /dev/null +++ b/js/src/tests/ecma_6/Symbol/realms.js @@ -0,0 +1,36 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ */ + +// Symbols can be shared across realms. + +if (typeof Reflect !== "undefined" && typeof Reflect.Realm === "function") { + throw new Error("Congratulations on implementing Reflect.Realm! " + + "Please update this test to use it."); +} +if (typeof newGlobal === "function") { + var g = newGlobal(); + var gj = g.eval("jones = Symbol('jones')"); + assertEq(typeof gj, "symbol"); + assertEq(g.jones, g.jones); + assertEq(gj, g.jones); + assertEq(gj !== Symbol("jones"), true); + + // A symbol can be round-tripped to another realm and back; + // the result is the original symbol. + var smith = Symbol("smith"); + g.smith = smith; // put smith into the realm + assertEq(g.smith, smith); // pull it back out + + // Spot-check that non-generic methods can be applied to symbols and Symbol + // objects from other realms. + assertEq(Symbol.prototype.toString.call(gj), "Symbol(jones)"); + assertEq(Symbol.prototype.toString.call(g.eval("Object(Symbol('brown'))")), + "Symbol(brown)"); + + // Symbol.for functions share a symbol registry across all realms. + assertEq(g.Symbol.for("ponies"), Symbol.for("ponies")); + assertEq(g.eval("Symbol.for('rainbows')"), Symbol.for("rainbows")); +} + +if (typeof reportCompare === "function") + reportCompare(0, 0); |