ccw-2.js (484B)
1 // |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) 2 3 var g = newGlobal({newCompartment: true}); 4 5 var sr = new ShadowRealm(); 6 7 var f = sr.evaluate(` 8 var wrappedCCW; 9 (f => { wrappedCCW = f; }); 10 `); 11 12 f(g.evaluate(`x => x()`)); 13 14 var h = sr.evaluate(` 15 // Pass an object from the ShadowRealm's compartment to the CCW function. 16 wrappedCCW(() => { return "ok"; }) 17 `); 18 19 assertEq(h, "ok"); 20 21 if (typeof reportCompare === 'function') 22 reportCompare(true, true);