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/js1_8_5/extensions/proxy-proto-setter.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/js1_8_5/extensions/proxy-proto-setter.js')
-rw-r--r-- | js/src/tests/js1_8_5/extensions/proxy-proto-setter.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/js/src/tests/js1_8_5/extensions/proxy-proto-setter.js b/js/src/tests/js1_8_5/extensions/proxy-proto-setter.js new file mode 100644 index 000000000..37e620cd1 --- /dev/null +++ b/js/src/tests/js1_8_5/extensions/proxy-proto-setter.js @@ -0,0 +1,50 @@ +// |reftest| skip-if(!xulRuntime.shell) +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ +// Contributor: Blake Kaplan + +function expect(actual, arg) { + reportCompare(expect.expected, actual, arg); +} + +var window = { set x(y) { expect(this, y) }, y: 4 }; +expect.expected = window; +window.x = "setting through a setter directly"; +window.y = 5; +reportCompare(5, window.y, "setting properties works"); +var easy = { easy: 'yes', __proto__: window } +expect.expected = easy; +easy.x = "setting through a setter all-native on prototype"; +easy.y = 6; +reportCompare(5, window.y, "window.y remains as it was"); +reportCompare(6, easy.y, "shadowing works properly"); + +var sandbox = evalcx(''); +sandbox.window = window; +sandbox.print = print; +sandbox.expect = expect; +var hard = evalcx('Object.create(window)', sandbox); +expect.expected = hard; +hard.x = "a setter through proxy -> native"; +hard.y = 6; +reportCompare(5, window.y, "window.y remains as it was through a proxy"); +reportCompare(6, hard.y, "shadowing works on proxies"); + +hard.__proto__ = { 'passed': true } +reportCompare(true, hard.passed, "can set proxy.__proto__ through a native"); + +var inverse = evalcx('({ set x(y) { expect(this, y); }, y: 4 })', sandbox); +expect.expected = inverse; +inverse.x = "setting through a proxy directly"; +inverse.y = 5; +reportCompare(5, inverse.y, "setting properties works on proxies"); + +var inversehard = Object.create(inverse); +expect.expected = inversehard; +inversehard.x = "setting through a setter with a proxy on the proto chain"; +inversehard.y = 6; +reportCompare(5, inverse.y, "inverse.y remains as it was"); +reportCompare(6, inversehard.y, "shadowing works native -> proxy"); + +inversehard.__proto__ = { 'passed': true } +reportCompare(true, inversehard.passed, "can set native.__proto__ through a proxy"); |