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/jit-test/tests/debug/Object-seal-01.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/jit-test/tests/debug/Object-seal-01.js')
-rw-r--r-- | js/src/jit-test/tests/debug/Object-seal-01.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/debug/Object-seal-01.js b/js/src/jit-test/tests/debug/Object-seal-01.js new file mode 100644 index 000000000..760060208 --- /dev/null +++ b/js/src/jit-test/tests/debug/Object-seal-01.js @@ -0,0 +1,63 @@ +// Basic tests for obj.{seal,freeze,preventExtensions,isSealed,isFrozen,isExtensible}. + +var g = newGlobal(); +var dbg = new Debugger; +var gw = dbg.addDebuggee(g); + +g.eval("function compareObjects() {\n" + + " assertEq(Object.isExtensible(x), Object.isExtensible(y));\n" + + " var xnames = Object.getOwnPropertyNames(x).sort();\n" + + " var ynames = Object.getOwnPropertyNames(y).sort();\n" + + " assertEq(xnames.length, ynames.length);\n" + + " for (var i = 0; i < xnames.length; i++) {\n" + + " assertEq(xnames[i], ynames[i]);\n" + + " var name = xnames[i];\n" + + " var xd = Object.getOwnPropertyDescriptor(x, name);\n" + + " var yd = Object.getOwnPropertyDescriptor(y, name);\n" + + " assertEq(xd.configurable, yd.configurable, code + '.' + name + ' .configurable');\n" + + " assertEq(xd.enumerable, yd.enumerable, code + '.' + name + ' .enumerable');\n" + + " assertEq(xd.writable, yd.writable, code + '.' + name + ' .writable');\n" + + " }\n" + + "}\n"); + +function test(code) { + g.code = code; + g.eval("x = (" + code + ");"); + g.eval("y = (" + code + ");"); + var xw = gw.getOwnPropertyDescriptor("x").value; + + function check() { + // The Debugger.Object seal/freeze/preventExtensions methods + // had the same effect as the corresponding ES5 Object methods. + g.compareObjects(); + + // The Debugger.Object introspection methods agree with the ES5 Object methods. + assertEq(xw.isExtensible(), g.Object.isExtensible(g.x), code + ' isExtensible'); + assertEq(xw.isSealed(), g.Object.isSealed(g.x), code + ' isSealed'); + assertEq(xw.isFrozen(), g.Object.isFrozen(g.x), code + ' isFrozen'); + } + + check(); + + xw.preventExtensions(); + assertEq(g.Object.isExtensible(g.x), false, code + ' preventExtensions'); + g.Object.preventExtensions(g.y); + check(); + + xw.seal(); + assertEq(g.Object.isSealed(g.x), true, code + ' seal'); + g.Object.seal(g.y); + check(); + + xw.freeze(); + assertEq(g.Object.isFrozen(g.x), true, code + ' freeze'); + g.Object.freeze(g.y); + check(); +} + +test("{}"); +test("{a: [1], get b() { return -1; }}"); +test("Object.create(null, {x: {value: 3}, y: {get: Math.min}})"); +test("[]"); +test("[,,,,,]"); +test("[0, 1, 2]"); |