tor-browser

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

test_dataURL.html (891B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Test for BroadcastChannel in data: URL</title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
      7 </head>
      8 <body>
      9 <div id="dataURL">
     10 var a = new BroadcastChannel('a');
     11 var b = new BroadcastChannel('a');
     12 a.onmessage = function(e) { parent.postMessage(e.data, "*"); };
     13 b.postMessage(42);
     14 </div>
     15 
     16 <script>
     17 
     18 SimpleTest.waitForExplicitFinish();
     19 
     20 onmessage = function(e) {
     21  is(e.data, 42, "BroadcastChannel works with data URLs");
     22  SimpleTest.finish();
     23 };
     24 
     25 // eslint-disable-next-line no-useless-concat
     26 var url = "data:text/html,<script>" + document.getElementById("dataURL").textContent + "</" + "script>";
     27 
     28 var ifr = document.createElement("iframe");
     29 document.body.appendChild(ifr);
     30 
     31 ifr.setAttribute("sandbox", "allow-scripts");
     32 ifr.src = url;
     33 </script>
     34 </body>
     35 </html>