3 const DIRPATH
= getRootDirectory(gTestPath
).replace(
4 "chrome://mochitests/content/",
7 const PATH
= DIRPATH
+ "file_postMessage_parent.html";
9 const URL1
= `http://mochi.test:8888/${PATH}`;
10 const URL2
= `http://example.com/${PATH}`;
11 const URL3
= `http://example.org/${PATH}`;
13 // A bunch of boilerplate which needs to be dealt with.
14 add_task(async
function () {
15 // Open a window with fission force-enabled in it.
16 let win
= await BrowserTestUtils
.openNewBrowserWindow({
21 // Get the tab & browser to perform the test in.
22 let tab
= win
.gBrowser
.selectedTab
;
23 let browser
= tab
.linkedBrowser
;
25 // Start loading the original URI, then wait until it is loaded.
26 BrowserTestUtils
.startLoadingURIString(browser
, URL1
);
27 await BrowserTestUtils
.browserLoaded(browser
, false, URL1
);
29 info("Chrome script has loaded initial URI.");
30 await SpecialPowers
.spawn(
32 [{ URL1
, URL2
, URL3
}],
33 async ({ URL1
, URL2
, URL3
}) => {
34 let iframe
= content
.document
.createElement("iframe");
35 content
.document
.body
.appendChild(iframe
);
37 info("Chrome script created iframe");
39 // Here and below, we have to store references to things in the
40 // iframes on the content window, because all chrome references
41 // to content will be turned into dead wrappers when the iframes
43 content
.win0
= iframe
.contentWindow
;
44 content
.bc0
= iframe
.browsingContext
;
47 !Cu
.isDeadWrapper(content
.win0
),
48 "win0 shouldn't be a dead wrapper before navigation"
51 // Helper for waiting for a load.
53 return new Promise(resolve
=> {
54 iframe
.addEventListener(
57 info("Got an iframe load event!");
65 function askLoad(url
) {
66 info("Chrome script asking for load of " + url
);
67 iframe
.contentWindow
.postMessage(
74 info("Chrome script done calling PostMessage");
77 // Check that BC and WindowProxy are preserved across navigations.
78 iframe
.contentWindow
.location
= URL1
;
81 content
.win1
= iframe
.contentWindow
;
82 let chromeWin1
= iframe
.contentWindow
;
83 let chromeWin1x
= Cu
.waiveXrays(iframe
.contentWindow
);
84 content
.win1x
= Cu
.waiveXrays(iframe
.contentWindow
);
89 "waiving xrays creates a new thing?"
92 content
.bc1
= iframe
.browsingContext
;
97 "same to same-origin BrowsingContext match"
99 is(content
.win0
, content
.win1
, "same to same-origin WindowProxy match");
102 !Cu
.isDeadWrapper(content
.win1
),
103 "win1 shouldn't be a dead wrapper before navigation"
106 !Cu
.isDeadWrapper(chromeWin1
),
107 "chromeWin1 shouldn't be a dead wrapper before navigation"
113 content
.win2
= iframe
.contentWindow
;
114 content
.bc2
= iframe
.browsingContext
;
116 // When chrome accesses a remote window proxy in content, the result
117 // should be a remote outer window proxy in the chrome compartment, not an
118 // Xray wrapper around the content remote window proxy. The former will
119 // throw a security error, because @@toPrimitive can't be called cross
120 // process, while the latter will result in an opaque wrapper, because
121 // XPConnect doesn't know what to do when trying to create an Xray wrapper
122 // around a remote outer window proxy. See bug 1556845.
125 dump("content.win1 " + content
.win1
+ "\n");
127 /SecurityError: Permission denied to access property Symbol.toPrimitive on cross-origin object/,
128 "Should get a remote outer window proxy when accessing old window proxy"
132 dump("content.win2 " + content
.win2
+ "\n");
134 /SecurityError: Permission denied to access property Symbol.toPrimitive on cross-origin object/,
135 "Should get a remote outer window proxy when accessing new window proxy"
138 // If we fail to transplant existing non-remote outer window proxies, then
139 // after we navigate the iframe existing chrome references to the window will
140 // become dead wrappers. Also check content.win1 for thoroughness, though
141 // we don't nuke content-content references.
143 !Cu
.isDeadWrapper(content
.win1
),
144 "win1 shouldn't be a dead wrapper after navigation"
147 !Cu
.isDeadWrapper(chromeWin1
),
148 "chromeWin1 shouldn't be a dead wrapper after navigation"
151 Cu
.isDeadWrapper(chromeWin1x
),
152 "chromeWin1x should be a dead wrapper after navigation"
155 Cu
.isDeadWrapper(content
.win1x
),
156 "content.win1x should be a dead wrapper after navigation"
162 "same to cross-origin navigation BrowsingContext match"
167 "same to cross-origin navigation WindowProxy match"
171 !Cu
.isDeadWrapper(content
.win1
),
172 "win1 shouldn't be a dead wrapper after navigation"
178 content
.win3
= iframe
.contentWindow
;
179 content
.bc3
= iframe
.browsingContext
;
184 "cross to cross-origin navigation BrowsingContext match"
189 "cross to cross-origin navigation WindowProxy match"
195 content
.win4
= iframe
.contentWindow
;
196 content
.bc4
= iframe
.browsingContext
;
201 "cross to same-origin navigation BrowsingContext match"
206 "cross to same-origin navigation WindowProxy match"
211 await BrowserTestUtils
.closeWindow(win
);