Bug 1842428 - Part 2: Remove unused imports. r=mccr8
[gecko.git] / js / xpconnect / tests / unit / test_bug872772.js
blobbfb0d7f4f87e2320b8ae6e180f66e8baca7df7bf
1 function run_test() {
3   // Make a content sandbox with an Xrayable object.
4   // NB: We use an nsEP here so that we can have access to Components, but still
5   // have Xray behavior from this scope.
6   var contentSB = new Cu.Sandbox(['http://www.google.com'],
7                                  { wantGlobalProperties: ["XMLHttpRequest"] });
9   // Make an XHR in the content sandbox.
10   Cu.evalInSandbox('xhr = new XMLHttpRequest();', contentSB);
12   // Make sure that waivers can be set as Xray expandos.
13   var xhr = contentSB.xhr;
14   Assert.ok(Cu.isXrayWrapper(xhr));
15   xhr.unwaivedExpando = xhr;
16   Assert.ok(Cu.isXrayWrapper(xhr.unwaivedExpando));
17   var waived = xhr.wrappedJSObject;
18   Assert.ok(!Cu.isXrayWrapper(waived));
19   xhr.waivedExpando = waived;
20   Assert.ok(!Cu.isXrayWrapper(xhr.waivedExpando));
22   // Try the same thing for getters/setters, even though that's kind of
23   // contrived.
24   Cu.evalInSandbox('function f() {}', contentSB);
25   var f = contentSB.f;
26   var fWaiver = Cu.waiveXrays(f);
27   Assert.ok(f != fWaiver);
28   Assert.ok(Cu.unwaiveXrays(fWaiver) === f);
29   Object.defineProperty(xhr, 'waivedAccessors', {get: fWaiver, set: fWaiver});
30   var desc = Object.getOwnPropertyDescriptor(xhr, 'waivedAccessors');
31   Assert.ok(desc.get === fWaiver);
32   Assert.ok(desc.set === fWaiver);