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
|
class Base {
constructor(o) {
return o;
}
}
class A extends Base {
#x = 10;
static gx(o) {
return o.#x
}
static sx(o, v) {
o.#x = v;
}
}
function transplantTest(transplantOptions, global) {
var {object, transplant} = transplantableObject(transplantOptions);
new A(object);
assertEq(A.gx(object), 10);
A.sx(object, 15);
assertEq(A.gx(object), 15);
transplant(global);
assertEq(A.gx(object), 15);
A.sx(object, 29);
assertEq(A.gx(object), 29);
}
// Structure helpfully provided by bug1403679.js
const thisGlobal = this;
const otherGlobalSameCompartment = newGlobal({sameCompartmentAs: thisGlobal});
const otherGlobalNewCompartment = newGlobal({newCompartment: true});
const globals =
[thisGlobal, otherGlobalSameCompartment, otherGlobalNewCompartment];
function testWithOptions(fn) {
for (let global of globals) {
for (let options of [{}, {proxy: true}, {object: new FakeDOMObject()}, ]) {
fn(options, global);
}
}
}
testWithOptions(transplantTest)
|