tor-browser

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

test_aboutblank_change_process.html (1508B)


      1 <!DOCTYPE html>
      2 <head>
      3  <meta charset="utf-8">
      4  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      5  <link rel="stylesheet" href="/tests/SimpleTest/test.css" />
      6 </head>
      7 <script>
      8 // Open a window and navigate it from https://example.com to about:blank
      9 // With fission, we should switch processes and about:blank should load in
     10 // the same process as this test page.
     11 // This is a crash test.
     12 add_task(async function test_aboutblank_change_process() {
     13  let exampleLoaded = new Promise(resolve => {
     14    function onMessage(event) {
     15      if (event.data == "body-loaded") {
     16        window.removeEventListener("message", onMessage);
     17        resolve();
     18      }
     19    }
     20    window.addEventListener("message", onMessage);
     21  });
     22  let win = window.open();
     23  win.location = "https://example.com/tests/docshell/test/navigation/file_tell_opener.html";
     24  await exampleLoaded;
     25 
     26  win.location = "about:blank";
     27 
     28  // A crash happens somewhere here when about:blank does not go via
     29  // DocumentChannel with fission enabled
     30 
     31  // Wait for about:blank to load in this process
     32  await SimpleTest.promiseWaitForCondition(() => {
     33    try {
     34      return win.location.href == "about:blank";
     35    } catch (e) {
     36      // While the `win` still has example.com page loaded, `win.location` will
     37      // be a cross origin object and querying win.location.href will throw a
     38      // SecurityError. Return false as long as this is the case.
     39      return false;
     40    }
     41  })
     42 
     43  ok(true, "We did not crash");
     44  win.close();
     45 });
     46 </script>