1 function checkThrows(f, rgxp) { try { f(); do_check_false(); } catch (e) { Assert.ok(rgxp.test(e)); } }
3 var o = { foo: 42, bar : { tick: 'tock' } };
4 function checkClone(clone, frozen) {
5 var waived = Cu.waiveXrays(clone);
6 function touchFoo() { "use strict"; waived.foo = 12; Assert.equal(waived.foo, 12); }
7 function touchBar() { "use strict"; waived.bar.tick = 'tack'; Assert.equal(waived.bar.tick, 'tack'); }
8 function addProp() { "use strict"; waived.newProp = 100; Assert.equal(waived.newProp, 100); }
14 checkThrows(touchFoo, /read-only/);
15 checkThrows(touchBar, /read-only/);
16 checkThrows(addProp, /extensible/);
19 var desc = Object.getOwnPropertyDescriptor(waived, 'foo');
20 Assert.equal(desc.writable, !frozen);
21 Assert.equal(desc.configurable, !frozen);
22 desc = Object.getOwnPropertyDescriptor(waived.bar, 'tick');
23 Assert.equal(desc.writable, !frozen);
24 Assert.equal(desc.configurable, !frozen);
28 var sb = new Cu.Sandbox(null);
29 checkClone(Cu.waiveXrays(Cu.cloneInto(o, sb)), false);
30 checkClone(Cu.cloneInto(o, sb, { deepFreeze: true }), true);