tor-browser

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

window-open-aboutblank.html (3594B)


      1 <!DOCTYPE html>
      2 <meta charset="UTF-8">
      3 <title>Navigations on window.open(about:blank) after waiting for it to load</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script src="resources/helpers.js"></script>
      7 <body></body>
      8 <script>
      9 /*
     10  When a new window is opened through window.open() it will contain the initial
     11  empty document. If the URL parameter is set to about:blank, it will stay on
     12  the initial empty document (unlike iframes with src="about:blank", which will
     13  start a navigation to a non-initial about:blank document).
     14  These tests verify the behavior of navigations that happen on the initial
     15  empty document in that situation. They should all be converted to do a
     16  replacement.
     17 */
     18 "use strict";
     19 const url1 = "resources/code-injector.html?1&pipe=sub(none)&code=" +
     20              encodeURIComponent(postMessageToOpenerOnLoad);
     21 const url2 = "resources/code-injector.html?2&pipe=sub(none)&code=" +
     22              encodeURIComponent(postMessageToOpenerOnLoad);
     23 
     24 promise_test(async t => {
     25  // Open a window with URL about:blank, which will commit the
     26  // initial empty document and stay on it.
     27  const openedWindow = windowOpenAboutBlank(t);
     28 
     29  // Unlike iframe with src="about:blank", window.open("about:blank") won't
     30  // trigger a navigation to a non-initial about:blank document, so it should
     31  // stay on the initial empty document. To verify, wait for 100ms before
     32  // continuing.
     33  await new Promise((resolve) => t.step_timeout(resolve, 100));
     34 
     35  // Navigate away from the initial empty document through location.href.
     36  // This should do a replacement.
     37  openedWindow.location.href = url1;
     38  await waitForMessage(t, "loaded");
     39  assert_equals(openedWindow.history.length, 1,
     40    "history.length should not increase after normal navigation away from initial empty document");
     41 }, "location.href");
     42 
     43 promise_test(async t => {
     44  // Open a window with URL about:blank, which will commit the
     45  // initial empty document and stay on it.
     46  const openedWindow = windowOpenAboutBlank(t);
     47 
     48  // Unlike iframe with src="about:blank", window.open("about:blank") won't
     49  // trigger a navigation to a non-initial about:blank document, so it should
     50  // stay on the initial empty document. To verify, wait for 100ms before
     51  // continuing.
     52  await new Promise((resolve) => t.step_timeout(resolve, 100));
     53 
     54  // Navigate away from the initial empty document through location.assign().
     55  // This should do a replacement.
     56  openedWindow.location.assign(url1);
     57  await waitForMessage(t, "loaded");
     58  assert_equals(openedWindow.history.length, 1,
     59    "history.length should not increase after normal navigation away from initial empty document");
     60 }, "location.assign");
     61 /*
     62 promise_test(async t => {
     63  // Open a window with URL about:blank, which will commit the
     64  // initial empty document and stay on it.
     65  const openedWindow = windowOpenAboutBlank(t);
     66 
     67  // Unlike iframe with src="about:blank", window.open("about:blank") won't
     68  // trigger a navigation to a non-initial about:blank document, so it should
     69  // stay on the initial empty document. To verify, wait for 100ms before
     70  // continuing.
     71  await new Promise((resolve) => t.step_timeout(resolve, 100));
     72 
     73  // Navigate away from the initial empty document through window.open().
     74  // This should do a replacement.
     75  openedWindow.open(url1, "_self");
     76  await waitForMessage(t, "loaded");
     77  assert_equals(openedWindow.history.length, 1,
     78    "history.length should not increase after normal navigation away from initial empty document");
     79 }, "window.open");
     80 */
     81 </script>