Bug 1842428 - Part 2: Remove unused imports. r=mccr8
[gecko.git] / js / xpconnect / tests / unit / test_bug868675.js
blob7f5e94f83b6e1f6ee147caca4e9ed86b57e6135e
1 function run_test() {
3   // Make sure we don't throw for primitive values.
4   var result = "threw";
5   try { result = XPCNativeWrapper.unwrap(2); } catch (e) {}
6   Assert.equal(result, 2);
7   result = "threw";
8   try { result = XPCNativeWrapper(2); } catch (e) {}
9   Assert.equal(result, 2);
11   // Make sure we throw when using `new` with primitives.
12   result = null;
13   try { result = new XPCNativeWrapper(2); } catch (e) { result = "catch"; }
14   Assert.equal(result, "catch");
16   // Make sure that we can waive on a non-Xrayable object, and that we preserve
17   // transitive waiving behavior.
18   var sb = new Cu.Sandbox('http://www.example.com', { wantGlobalProperties: ["XMLHttpRequest"] });
19   Cu.evalInSandbox('this.xhr = new XMLHttpRequest();', sb);
20   Cu.evalInSandbox('this.jsobj = {mynative: xhr};', sb);
21   Assert.ok(!Cu.isXrayWrapper(XPCNativeWrapper.unwrap(sb.xhr)));
22   Assert.ok(Cu.isXrayWrapper(sb.jsobj.mynative));
23   Assert.ok(!Cu.isXrayWrapper(XPCNativeWrapper.unwrap(sb.jsobj).mynative));
25   // Test the new Cu API.
26   var waived = Cu.waiveXrays(sb.xhr);
27   Assert.ok(!Cu.isXrayWrapper(waived));
28   Assert.ok(Cu.isXrayWrapper(Cu.unwaiveXrays(waived)));