summaryrefslogtreecommitdiffstats
path: root/docshell/test/mochitest/test_bug660404.html
blob: 94e3f67aa1b45ec4e51bd081aae36fe6d74183a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=660404
-->
<head>
  <title>Test for Bug 660404</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=660404">Mozilla Bug 660404</a>
<p id="display"></p>
<div id="content" style="display: none">
  
</div>
<pre id="test">
<script type="application/javascript">

/** Test for Bug 660404 */
SimpleTest.waitForExplicitFinish();

var textContent =
`
  var bc = new BroadcastChannel("bug660404_multipart");
  bc.postMessage({command: "finishTest",
    textContent: window.document.documentElement.textContent,
    innerHTML: window.document.documentElement.innerHTML
  });
  bc.close();
  window.close();
`;
var innerHTML =
`<head><script>
  var bc = new BroadcastChannel("bug660404_multipart");
  bc.postMessage({command: "finishTest",
    textContent: window.document.documentElement.textContent,
    innerHTML: window.document.documentElement.innerHTML
  });
  bc.close();
  window.close();
</`
// eslint-disable-next-line no-useless-concat
+ `script></head>`
;
var bc_multipart = new BroadcastChannel("bug660404_multipart");
bc_multipart.onmessage = (msgEvent) => {
    var msg = msgEvent.data;
    var command = msg.command;
    if (command == "finishTest") {
      is(msg.textContent, textContent);
      is(msg.innerHTML, innerHTML);
      bc_multipart.close();
      SimpleTest.finish();
    }
}
var bc = new BroadcastChannel("bug660404");
bc.onmessage = (msgEvent) => {
    var msg = msgEvent.data;
    var command = msg.command;
    if (command == "pagehide") {
      is(msg.persisted, true, "Should be bfcached when navigating to multipart");
      bc.close();
    }
}

// If Fission is disabled, the pref is no-op.
SpecialPowers.pushPrefEnv({set: [["fission.bfcacheInParent", true]]}, () => {
  // Have to open a new window, since there's no bfcache in subframes
  window.open("file_bug660404-1.html", "", "noopener");
});

</script>
</pre>
</body>
</html>