tor-browser

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

browser_caching_document_props.js (2886B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 /* import-globals-from ../../mochitest/role.js */
      8 loadScripts({ name: "role.js", dir: MOCHITESTS_DIR });
      9 
     10 addAccessibleTask(
     11  "e10s/doc_treeupdate_whitespace.html",
     12  async function (browser, docAcc) {
     13    info("Testing top level doc");
     14    queryInterfaces(docAcc, [nsIAccessibleDocument]);
     15    const topUrl =
     16      (browser.isRemoteBrowser ? CURRENT_CONTENT_DIR : CURRENT_DIR) +
     17      "e10s/doc_treeupdate_whitespace.html";
     18    is(docAcc.URL, topUrl, "Initial URL correct");
     19    is(docAcc.mimeType, "text/html", "Mime type is correct");
     20    info("Changing URL");
     21    await invokeContentTask(browser, [], () => {
     22      content.history.pushState(
     23        null,
     24        "",
     25        content.document.location.href + "/after"
     26      );
     27    });
     28    is(docAcc.URL, topUrl + "/after", "URL correct after change");
     29 
     30    // We can't use the harness to manage iframes for us because it uses data
     31    // URIs for in-process iframes, but data URIs don't support
     32    // history.pushState.
     33 
     34    async function testIframe() {
     35      queryInterfaces(iframeDocAcc, [nsIAccessibleDocument]);
     36      is(iframeDocAcc.URL, src, "Initial URL correct");
     37      is(iframeDocAcc.mimeType, "text/html", "Mime type is correct");
     38      info("Changing URL");
     39      await invokeContentTask(browser, [], async () => {
     40        await SpecialPowers.spawn(content.iframe, [], () => {
     41          content.history.pushState(
     42            null,
     43            "",
     44            content.document.location.href + "/after"
     45          );
     46        });
     47      });
     48      is(iframeDocAcc.URL, src + "/after", "URL correct after change");
     49    }
     50 
     51    info("Testing same origin (in-process) iframe");
     52    // eslint-disable-next-line @microsoft/sdl/no-insecure-url
     53    let src = "https://example.com/initial.html";
     54    let loaded = waitForEvent(
     55      EVENT_DOCUMENT_LOAD_COMPLETE,
     56      evt => evt.accessible.parent.parent == docAcc
     57    );
     58    await invokeContentTask(browser, [src], cSrc => {
     59      content.iframe = content.document.createElement("iframe");
     60      content.iframe.src = cSrc;
     61      content.document.body.append(content.iframe);
     62    });
     63    let iframeDocAcc = (await loaded).accessible;
     64    await testIframe();
     65 
     66    info("Testing different origin (out-of-process) iframe");
     67    // eslint-disable-next-line @microsoft/sdl/no-insecure-url
     68    src = "https://example.net/initial.html";
     69    loaded = waitForEvent(
     70      EVENT_DOCUMENT_LOAD_COMPLETE,
     71      evt => evt.accessible.parent.parent == docAcc
     72    );
     73    await invokeContentTask(browser, [src], cSrc => {
     74      content.iframe.src = cSrc;
     75    });
     76    iframeDocAcc = (await loaded).accessible;
     77    await testIframe();
     78  },
     79  { chrome: true, topLevel: true }
     80 );