tor-browser

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

document-base-url-window-open-about-blank.https.window.js (946B)


      1 // Basic test that a popup about:blank window inherits its base url from
      2 // the initiator (which in this case is also the opener).
      3 const runTest = (description) => {
      4  // In this test the opener and the initiator will be the same.
      5  const initiator_base_uri = document.baseURI;
      6  test(() => {
      7    const popup = window.open();
      8 
      9    // Window.open synchronously loads the initial empty document.
     10    assert_equals("about:blank", popup.location.href);
     11    assert_equals(initiator_base_uri, popup.document.baseURI);
     12 
     13    // Verify the popup's base url is properly snapshotted, and doesn't change
     14    // if the parent's base url changes.
     15    const base_element = document.createElement('base');
     16    base_element.href = "https://example.com";
     17    document.head.appendChild(base_element);
     18    assert_equals(initiator_base_uri, popup.document.baseURI);
     19  }, description);
     20 };
     21 
     22 onload = () => {
     23  runTest("window.open() gets base url from initiator.");
     24 };