| 1 |
// |reftest| skip-if(!xulRuntime.shell) -- needs newGlobal() |
| 2 |
/* |
| 3 |
* Any copyright is dedicated to the Public Domain. |
| 4 |
* http://creativecommons.org/licenses/publicdomain/ |
| 5 |
* Contributor: |
| 6 |
* Jeff Walden <[email protected]> |
| 7 |
*/ |
| 8 |
|
| 9 |
var gTestfile = 'preventExtensions-cross-global.js'; |
| 10 |
//----------------------------------------------------------------------------- |
| 11 |
var BUGNUMBER = 789897; |
| 12 |
var summary = |
| 13 |
"Object.preventExtensions and Object.isExtensible should work correctly " + |
| 14 |
"across globals"; |
| 15 |
|
| 16 |
print(BUGNUMBER + ": " + summary); |
| 17 |
|
| 18 |
/************** |
| 19 |
* BEGIN TEST * |
| 20 |
**************/ |
| 21 |
|
| 22 |
var otherGlobal = newGlobal(); |
| 23 |
|
| 24 |
var obj = {}; |
| 25 |
assertEq(otherGlobal.Object.isExtensible(obj), true); |
| 26 |
assertEq(otherGlobal.Object.preventExtensions(obj), obj); |
| 27 |
assertEq(otherGlobal.Object.isExtensible(obj), false); |
| 28 |
|
| 29 |
var objFromOther = otherGlobal.Object(); |
| 30 |
assertEq(Object.isExtensible(objFromOther), true); |
| 31 |
assertEq(Object.preventExtensions(objFromOther), objFromOther); |
| 32 |
assertEq(Object.isExtensible(objFromOther), false); |
| 33 |
|
| 34 |
var proxy = new Proxy({}, {}); |
| 35 |
assertEq(otherGlobal.Object.isExtensible(proxy), true); |
| 36 |
assertEq(otherGlobal.Object.preventExtensions(proxy), proxy); |
| 37 |
assertEq(otherGlobal.Object.isExtensible(proxy), false); |
| 38 |
|
| 39 |
var proxyFromOther = otherGlobal.evaluate("new Proxy({}, {})"); |
| 40 |
assertEq(Object.isExtensible(proxyFromOther), true); |
| 41 |
assertEq(Object.preventExtensions(proxyFromOther), proxyFromOther); |
| 42 |
assertEq(Object.isExtensible(proxyFromOther), false); |
| 43 |
|
| 44 |
/******************************************************************************/ |
| 45 |
|
| 46 |
if (typeof reportCompare === "function") |
| 47 |
reportCompare(true, true); |
| 48 |
|
| 49 |
print("Tests complete"); |