tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug660404.html (2197B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=660404
      5 -->
      6 <head>
      7  <title>Test for Bug 660404</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     10 </head>
     11 <body>
     12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=660404">Mozilla Bug 660404</a>
     13 <p id="display"></p>
     14 <div id="content" style="display: none">
     15  
     16 </div>
     17 <pre id="test">
     18 <script type="application/javascript">
     19 
     20 /** Test for Bug 660404 */
     21 SimpleTest.waitForExplicitFinish();
     22 
     23 var textContent =
     24 `
     25  var bc = new BroadcastChannel("bug660404_multipart");
     26  bc.postMessage({command: "finishTest",
     27    textContent: window.document.documentElement.textContent,
     28    innerHTML: window.document.documentElement.innerHTML
     29  });
     30  bc.close();
     31  window.close();
     32 `;
     33 var innerHTML =
     34 `<head><script>
     35  var bc = new BroadcastChannel("bug660404_multipart");
     36  bc.postMessage({command: "finishTest",
     37    textContent: window.document.documentElement.textContent,
     38    innerHTML: window.document.documentElement.innerHTML
     39  });
     40  bc.close();
     41  window.close();
     42 </`
     43 // eslint-disable-next-line no-useless-concat
     44 + `script></head>`
     45 ;
     46 
     47 var bc_multipart = SpecialPowers.wrap(BroadcastChannel).unpartitionedTestingChannel("bug660404_multipart");
     48 bc_multipart.onmessage = (msgEvent) => {
     49    var msg = msgEvent.data;
     50    var command = msg.command;
     51    if (command == "finishTest") {
     52      is(msg.textContent, textContent);
     53      is(msg.innerHTML, innerHTML);
     54      bc_multipart.close();
     55      SimpleTest.finish();
     56    }
     57 }
     58 var bc = SpecialPowers.wrap(BroadcastChannel).unpartitionedTestingChannel("bug660404");
     59 bc.onmessage = (msgEvent) => {
     60    var msg = msgEvent.data;
     61    var command = msg.command;
     62    if (command == "pagehide") {
     63      is(msg.persisted, true, "Should be bfcached when navigating to multipart");
     64      bc.close();
     65    }
     66 }
     67 // If Fission is disabled, the pref is no-op.
     68 SpecialPowers.pushPrefEnv({set: [["fission.bfcacheInParent", true]]}, () => {
     69  // Have to open a new window, since there's no bfcache in subframes
     70  window.open("file_bug660404-1.html", "", "noopener");
     71 });
     72 
     73 </script>
     74 </pre>
     75 </body>
     76 </html>