tor-browser

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

test_popup_unknown_protocol.html (1111B)


      1 <!doctype html>
      2 <html>
      3  <head>
      4    <title>Test for loading unknown protocols in a popup window</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 
     10 <script>
     11 "use strict";
     12 
     13 add_task(async function() {
     14  let consoleMessagePromise = new Promise(resolve => {
     15    info("registering console listener");
     16    SpecialPowers.registerConsoleListener(msg => {
     17      info(`Got console message: ${msg.errorMessage}`);
     18      if (msg.errorMessage && msg.errorMessage.includes("unknown-protocol")) {
     19        SpecialPowers.executeSoon(() => {
     20          SpecialPowers.postConsoleSentinel();
     21          resolve();
     22        });
     23      }
     24    });
     25  });
     26 
     27  info("opening pop-up");
     28  let popup = window.open("unknown-protocol://example", "_blank");
     29 
     30  info("waiting for console message error");
     31  await consoleMessagePromise;
     32 
     33  is(popup.location.href, "about:blank");
     34  ok(!SpecialPowers.wrap(popup).docShell.failedChannel,
     35     "no failed channel specified, as no error page is being loaded");
     36 });
     37 </script>
     38 </body>
     39 </html>