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/proxy/testDirectProxySetReceiverLookup.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/proxy/testDirectProxySetReceiverLookup.js')
-rw-r--r-- | js/src/jit-test/tests/proxy/testDirectProxySetReceiverLookup.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/proxy/testDirectProxySetReceiverLookup.js b/js/src/jit-test/tests/proxy/testDirectProxySetReceiverLookup.js new file mode 100644 index 000000000..e626d805a --- /dev/null +++ b/js/src/jit-test/tests/proxy/testDirectProxySetReceiverLookup.js @@ -0,0 +1,57 @@ +// Assigning to a proxy with no set handler causes the proxy's +// getOwnPropertyDescriptor handler to be called just before defineProperty +// in some cases. (ES6 draft rev 28, 2014 Oct 14, 9.1.9 step 5.c.) + +var attrs = ["configurable", "enumerable", "writable", "value", "get", "set"]; + +function test(target, id, existingDesc, expectedDesc) { + var log = ""; + var p = new Proxy(target, { + getOwnPropertyDescriptor(t, idarg) { + assertEq(idarg, id); + log += "g"; + return existingDesc; + }, + defineProperty(t, idarg, desc) { + assertEq(idarg, id); + for (var attr of attrs) { + var args = uneval([target, id, existingDesc]).slice(1, -1); + assertEq(attr in desc, attr in expectedDesc, + `test(${args}), checking existence of desc.${attr}`); + assertEq(desc[attr], expectedDesc[attr], + `test(${args}), checking value of desc.${attr}`); + } + log += "d"; + return true; + } + }); + p[id] = "pizza"; + assertEq(log, "gd"); +} + +var fullDesc = { + configurable: true, + enumerable: true, + writable: true, + value: "pizza" +}; +var valueOnlyDesc = { + value: "pizza" +}; +var sealedDesc = { + configurable: false, + enumerable: true, + writable: true, + value: "pizza" +}; + +test({}, "x", undefined, fullDesc); +test({}, "x", fullDesc, valueOnlyDesc); +test({x: 1}, "x", undefined, fullDesc); +test({x: 1}, "x", fullDesc, valueOnlyDesc); +test(Object.seal({x: 1}), "x", sealedDesc, valueOnlyDesc); +test(Object.create({x: 1}), "x", undefined, fullDesc); +test([0, 1, 2], "2", undefined, fullDesc); +test([0, 1, 2], "2", fullDesc, valueOnlyDesc); +test([0, 1, 2], "3", undefined, fullDesc); +test([0, 1, 2], "3", fullDesc, valueOnlyDesc); |