Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // |reftest| skip-if(!xulRuntime.shell) -- needs newGlobal() |
michael@0 | 2 | /* |
michael@0 | 3 | * Any copyright is dedicated to the Public Domain. |
michael@0 | 4 | * http://creativecommons.org/licenses/publicdomain/ |
michael@0 | 5 | * Contributor: |
michael@0 | 6 | * Jeff Walden <jwalden+code@mit.edu> |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | var gTestfile = 'preventExtensions-cross-global.js'; |
michael@0 | 10 | //----------------------------------------------------------------------------- |
michael@0 | 11 | var BUGNUMBER = 789897; |
michael@0 | 12 | var summary = |
michael@0 | 13 | "Object.preventExtensions and Object.isExtensible should work correctly " + |
michael@0 | 14 | "across globals"; |
michael@0 | 15 | |
michael@0 | 16 | print(BUGNUMBER + ": " + summary); |
michael@0 | 17 | |
michael@0 | 18 | /************** |
michael@0 | 19 | * BEGIN TEST * |
michael@0 | 20 | **************/ |
michael@0 | 21 | |
michael@0 | 22 | var otherGlobal = newGlobal(); |
michael@0 | 23 | |
michael@0 | 24 | var obj = {}; |
michael@0 | 25 | assertEq(otherGlobal.Object.isExtensible(obj), true); |
michael@0 | 26 | assertEq(otherGlobal.Object.preventExtensions(obj), obj); |
michael@0 | 27 | assertEq(otherGlobal.Object.isExtensible(obj), false); |
michael@0 | 28 | |
michael@0 | 29 | var objFromOther = otherGlobal.Object(); |
michael@0 | 30 | assertEq(Object.isExtensible(objFromOther), true); |
michael@0 | 31 | assertEq(Object.preventExtensions(objFromOther), objFromOther); |
michael@0 | 32 | assertEq(Object.isExtensible(objFromOther), false); |
michael@0 | 33 | |
michael@0 | 34 | var proxy = new Proxy({}, {}); |
michael@0 | 35 | assertEq(otherGlobal.Object.isExtensible(proxy), true); |
michael@0 | 36 | assertEq(otherGlobal.Object.preventExtensions(proxy), proxy); |
michael@0 | 37 | assertEq(otherGlobal.Object.isExtensible(proxy), false); |
michael@0 | 38 | |
michael@0 | 39 | var proxyFromOther = otherGlobal.evaluate("new Proxy({}, {})"); |
michael@0 | 40 | assertEq(Object.isExtensible(proxyFromOther), true); |
michael@0 | 41 | assertEq(Object.preventExtensions(proxyFromOther), proxyFromOther); |
michael@0 | 42 | assertEq(Object.isExtensible(proxyFromOther), false); |
michael@0 | 43 | |
michael@0 | 44 | /******************************************************************************/ |
michael@0 | 45 | |
michael@0 | 46 | if (typeof reportCompare === "function") |
michael@0 | 47 | reportCompare(true, true); |
michael@0 | 48 | |
michael@0 | 49 | print("Tests complete"); |