summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/infrastructure/urls/base-url/document-base-url-window-open-about-blank.https.window.js
blob: 1a60809023287f721faa7c96de40d38dd82d82a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Basic test that a popup about:blank window inherits its base url from
// the initiator (which in this case is also the opener).
const runTest = (description) => {
  // In this test the opener and the initiator will be the same.
  const initiator_base_uri = document.baseURI;
  test(() => {
    const popup = window.open();

    // Window.open synchronously loads the initial empty document.
    assert_equals("about:blank", popup.location.href);
    assert_equals(initiator_base_uri, popup.document.baseURI);

    // Verify the popup's base url is properly snapshotted, and doesn't change
    // if the parent's base url changes.
    const base_element = document.createElement('base');
    base_element.href = "https://example.com";
    document.head.appendChild(base_element);
    assert_equals(initiator_base_uri, popup.document.baseURI);
  }, description);
};

onload = () => {
  runTest("window.open() gets base url from initiator.");
};