tor-browser

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

messageport-incumbent.html (1304B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Making the incumbent page become non-active must not prevent message transmission</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 
      7 <!-- This is the entry global -->
      8 
      9 <iframe src="support/incumbent.html" id="incumbent"></iframe>
     10 <iframe src="support/current.html" id="current"></iframe>
     11 
     12 <script>
     13 "use strict";
     14 const incumbentIframe = document.querySelector("#incumbent");
     15 const currentIframe = document.querySelector("#current");
     16 
     17 window.addEventListener("load", () => {
     18  promise_test(async () => {
     19    // This will invoke the constructor from currentIframe, but with incumbentIframe as the incumbent.
     20    const messageChannel = incumbentIframe.contentWindow.createMessageChannel();
     21 
     22    await new Promise((resolve, reject) => {
     23      incumbentIframe.onload = () => resolve();
     24      incumbentIframe.onerror = () => reject(new Error("Could not navigate the iframe"));
     25      incumbentIframe.src = "/common/blank.html";
     26    });
     27 
     28    await new Promise((resolve, reject) => {
     29      messageChannel.port1.onmessage = () => resolve();
     30      messageChannel.port1.onmessageerror = () => reject("messageerror event recieved");
     31      messageChannel.port2.postMessage("boo");
     32    });
     33  });
     34 });
     35 </script>