js/src/tests/js1_8_5/extensions/proxy-proto-setter.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 // |reftest| skip-if(!xulRuntime.shell)
michael@0 2 // Any copyright is dedicated to the Public Domain.
michael@0 3 // http://creativecommons.org/licenses/publicdomain/
michael@0 4 // Contributor: Blake Kaplan
michael@0 5
michael@0 6 function expect(actual, arg) {
michael@0 7 reportCompare(expect.expected, actual, arg);
michael@0 8 }
michael@0 9
michael@0 10 var window = { set x(y) { expect(this, y) }, y: 4 };
michael@0 11 expect.expected = window;
michael@0 12 window.x = "setting through a setter directly";
michael@0 13 window.y = 5;
michael@0 14 reportCompare(5, window.y, "setting properties works");
michael@0 15 var easy = { easy: 'yes', __proto__: window }
michael@0 16 expect.expected = easy;
michael@0 17 easy.x = "setting through a setter all-native on prototype";
michael@0 18 easy.y = 6;
michael@0 19 reportCompare(5, window.y, "window.y remains as it was");
michael@0 20 reportCompare(6, easy.y, "shadowing works properly");
michael@0 21
michael@0 22 var sandbox = evalcx('');
michael@0 23 sandbox.window = window;
michael@0 24 sandbox.print = print;
michael@0 25 sandbox.expect = expect;
michael@0 26 var hard = evalcx('Object.create(window)', sandbox);
michael@0 27 expect.expected = hard;
michael@0 28 hard.x = "a setter through proxy -> native";
michael@0 29 hard.y = 6;
michael@0 30 reportCompare(5, window.y, "window.y remains as it was through a proxy");
michael@0 31 reportCompare(6, hard.y, "shadowing works on proxies");
michael@0 32
michael@0 33 hard.__proto__ = { 'passed': true }
michael@0 34 reportCompare(true, hard.passed, "can set proxy.__proto__ through a native");
michael@0 35
michael@0 36 var inverse = evalcx('({ set x(y) { expect(this, y); }, y: 4 })', sandbox);
michael@0 37 expect.expected = inverse;
michael@0 38 inverse.x = "setting through a proxy directly";
michael@0 39 inverse.y = 5;
michael@0 40 reportCompare(5, inverse.y, "setting properties works on proxies");
michael@0 41
michael@0 42 var inversehard = Object.create(inverse);
michael@0 43 expect.expected = inversehard;
michael@0 44 inversehard.x = "setting through a setter with a proxy on the proto chain";
michael@0 45 inversehard.y = 6;
michael@0 46 reportCompare(5, inverse.y, "inverse.y remains as it was");
michael@0 47 reportCompare(6, inversehard.y, "shadowing works native -> proxy");
michael@0 48
michael@0 49 inversehard.__proto__ = { 'passed': true }
michael@0 50 reportCompare(true, inversehard.passed, "can set native.__proto__ through a proxy");

mercurial