| 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 |
*/ |
| 6 |
|
| 7 |
//----------------------------------------------------------------------------- |
| 8 |
var BUGNUMBER = 770344; |
| 9 |
var summary = "Object.getPrototypeOf behavior across compartments"; |
| 10 |
|
| 11 |
print(BUGNUMBER + ": " + summary); |
| 12 |
|
| 13 |
/************** |
| 14 |
* BEGIN TEST * |
| 15 |
**************/ |
| 16 |
|
| 17 |
var other = newGlobal(); |
| 18 |
|
| 19 |
var getProto = Object.getPrototypeOf; |
| 20 |
var otherGetProto = other.Object.getPrototypeOf; |
| 21 |
|
| 22 |
var proto = {}; |
| 23 |
var obj = Object.create(proto); |
| 24 |
assertEq(getProto(obj), proto); |
| 25 |
assertEq(otherGetProto(obj), proto); |
| 26 |
|
| 27 |
other.proto = proto; |
| 28 |
var otherObj = other.evaluate("Object.create(proto)"); |
| 29 |
assertEq(getProto(otherObj), proto); |
| 30 |
assertEq(otherGetProto(otherObj), proto); |
| 31 |
|
| 32 |
var p = other.evaluate("({})"); |
| 33 |
var objOtherProto = Object.create(p); |
| 34 |
assertEq(getProto(objOtherProto), p); |
| 35 |
assertEq(otherGetProto(objOtherProto), p); |
| 36 |
|
| 37 |
other.evaluate("var otherProto = { otherProto: 1 }; " + |
| 38 |
"var otherObj = Object.create(otherProto);"); |
| 39 |
assertEq(getProto(other.otherObj), other.otherProto); |
| 40 |
assertEq(otherGetProto(other.otherObj), other.otherProto); |
| 41 |
|
| 42 |
other.evaluate("var newOtherProto = { newOtherProto: 1 }; " + |
| 43 |
"otherObj.__proto__ = newOtherProto;"); |
| 44 |
assertEq(otherGetProto(other.otherObj), other.newOtherProto); |
| 45 |
|
| 46 |
// TODO This assertion fails due to bug 764307 |
| 47 |
//assertEq(getProto(other.otherObj), other.newOtherProto); |
| 48 |
|
| 49 |
|
| 50 |
/******************************************************************************/ |
| 51 |
|
| 52 |
if (typeof reportCompare === "function") |
| 53 |
reportCompare(true, true); |
| 54 |
|
| 55 |
print("Tests complete"); |