summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/extensions/cross-global-getPrototypeOf.js
blob: 1480a8ea15e6aa7932e2d01b76e823b8e1d131c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// |reftest| skip-if(!xulRuntime.shell) -- needs newGlobal()
/*
 * Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/licenses/publicdomain/
 */

//-----------------------------------------------------------------------------
var BUGNUMBER = 770344;
var summary = "Object.getPrototypeOf behavior across compartments";

print(BUGNUMBER + ": " + summary);

/**************
 * BEGIN TEST *
 **************/

var other = newGlobal();

var getProto = Object.getPrototypeOf;
var otherGetProto = other.Object.getPrototypeOf;

var proto = {};
var obj = Object.create(proto);
assertEq(getProto(obj), proto);
assertEq(otherGetProto(obj), proto);

other.proto = proto;
var otherObj = other.evaluate("Object.create(proto)");
assertEq(getProto(otherObj), proto);
assertEq(otherGetProto(otherObj), proto);

var p = other.evaluate("({})");
var objOtherProto = Object.create(p);
assertEq(getProto(objOtherProto), p);
assertEq(otherGetProto(objOtherProto), p);

other.evaluate("var otherProto = { otherProto: 1 }; " +
               "var otherObj = Object.create(otherProto);");
assertEq(getProto(other.otherObj), other.otherProto);
assertEq(otherGetProto(other.otherObj), other.otherProto);

other.evaluate("var newOtherProto = { newOtherProto: 1 }; " +
               "otherObj.__proto__ = newOtherProto;");
assertEq(otherGetProto(other.otherObj), other.newOtherProto);

// TODO This assertion fails due to bug 764307
//assertEq(getProto(other.otherObj), other.newOtherProto);


/******************************************************************************/

if (typeof reportCompare === "function")
  reportCompare(true, true);

print("Tests complete");