3 // Make sure we don't throw for primitive values.
5 try { result = XPCNativeWrapper.unwrap(2); } catch (e) {}
6 Assert.equal(result, 2);
8 try { result = XPCNativeWrapper(2); } catch (e) {}
9 Assert.equal(result, 2);
11 // Make sure we throw when using `new` with primitives.
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)));