4 https://bugzilla.mozilla.org/show_bug.cgi?id=1530146
8 <title>Test for Bug
1530146</title>
9 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"chrome://global/skin"/>
11 <link rel=
"stylesheet" type=
"text/css" href=
"chrome://mochikit/content/tests/SimpleTest/test.css"/>
12 <script type=
"application/javascript">
14 /** Test for Bug
1530146 **/
15 SimpleTest.waitForExplicitFinish();
17 addLoadEvent(setupTest);
21 function setupTest() {
22 // Create a sandbox with an expanded principal for our iframe.
23 sb = new Cu.Sandbox([frames[
0].document.nodePrincipal],
24 {sandboxPrototype: frames[
0]});
25 // Grab a waiver for the subframe in the sandbox to make sure the waiver
26 // stays alive. It would be nice if we could just use waiveXray in the
27 // sandbox: https://bugzilla.mozilla.org/show_bug.cgi?id=
1531614
28 Cu.evalInSandbox('this.waiver = document.querySelector(
"iframe").contentWindow.wrappedJSObject',
30 var ifr = frames[
0].document.querySelector(
"iframe");
32 ifr.src =
"file_bug1530146_inner.html";
36 // Create a new sandbox for the iframe's subframe
37 var sb2 = new Cu.Sandbox([frames[
0][
0].document.nodePrincipal],
38 {sandboxPrototype: frames[
0][
0]});
39 // Reget the waiver; this is where things can go awry.
40 Cu.evalInSandbox('this.waiver = window.wrappedJSObject', sb2);
41 is(Cu.evalInSandbox(
"this.waiver.obj.a", sb2),
"hello",
42 "Should get the right value and not crash");
43 is(Cu.evalInSandbox(
"(new this.waiver.Image()).localName", sb2),
"img",
44 "Should create an image and not crash");
50 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=1530146">Mozilla Bug
1530146</a>
52 <div id=
"content" style=
"display: none">
53 <iframe src=
"http://mochi.test:8888/chrome/js/xpconnect/tests/chrome/file_bug1530146.html"></iframe>