Backed out changeset 9d8b4c0b99ed (bug 1945683) for causing btime failures. CLOSED...
[gecko.git] / dom / tests / browser / file_postMessage_parent.html
blobe9cb8a1d34f13e22dae813bf8f3d2b96e095dbfb
1 <!doctype html>
2 <script>
3 dump("Content running top level script " + window.location.href + "\n");
5 var winID = SpecialPowers.wrap(this).windowGlobalChild.innerWindowId;
7 var observer = {
8 observe(subject) {
9 var currID = SpecialPowers.wrap(subject).QueryInterface(SpecialPowers.Ci.nsISupportsPRUint64).data;
10 if (currID != winID) {
11 return;
13 // We should be able to wrap the inner window when the outer
14 // window has navigated out of process.
15 SpecialPowers.Cu.getGlobalForObject({});
17 SpecialPowers.removeObserver(observer, "inner-window-nuked");
20 SpecialPowers.addObserver(observer, "inner-window-nuked");
22 // Unfortunately, we don't currently fire the onload event on a remote iframe,
23 // so we can't listen for the load event directly on the iframe. Instead, we
24 // postMessage from the iframe when the load event would be fired.
25 window.addEventListener("load", function onload() {
26 dump("Content got load of " + window.location.href + "\n");
27 if (window.parent) {
28 window.parent.postMessage({
29 event: "load",
30 location: window.location.href,
31 }, "*");
34 let h1 = document.createElement("h1");
35 h1.textContent = window.location.href;
36 document.body.appendChild(h1);
37 }, { once: true });
39 // In addition, we listen to the message event to trigger navigations of
40 // ourself when requested, as we don't fully support our embedder triggering
41 // us being navigated yet for Totally Not Buggy Reasons.
42 window.addEventListener("message", function onmessage(event) {
43 dump("Content got event " + window.location.href + " " + JSON.stringify(event.data) + "\n");
44 if (event.data.action === "navigate") {
45 window.location = event.data.location;
47 });
48 </script>