bug-1663741.js (872B)
1 const thisGlobal = this; 2 const otherGlobalSameCompartment = newGlobal({sameCompartmentAs: thisGlobal}); 3 const otherGlobalNewCompartment = newGlobal({newCompartment: true}); 4 5 const globals = [thisGlobal, otherGlobalSameCompartment, otherGlobalNewCompartment]; 6 7 function testProperties(global, count) { 8 let {object: source, transplant} = transplantableObject(); 9 10 // Create a bunch properties on |source|, which force allocation of dynamic 11 // slots. 12 for (let i = 0; i < count; i++) { 13 source["foo" + i] = i; 14 } 15 16 // Calling |transplant| transplants the object and then returns undefined. 17 transplant(global); 18 19 // Check the properties were copied over to the swapped object. 20 for (let i = 0; i < count; i++) { 21 assertEq(source["foo" + i], i); 22 } 23 } 24 25 for (let global of globals) { 26 for (let count of [0, 10, 30]) { 27 testProperties(global, count); 28 } 29 }