summaryrefslogtreecommitdiffstats
path: root/accessible/tests/browser/e10s/browser_caching_document_props.js
blob: cf3a4e5721fd5391759a4bb65cb19984a1ee82d6 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

/* import-globals-from ../../mochitest/role.js */
loadScripts({ name: "role.js", dir: MOCHITESTS_DIR });

addAccessibleTask(
  "e10s/doc_treeupdate_whitespace.html",
  async function (browser, docAcc) {
    info("Testing top level doc");
    queryInterfaces(docAcc, [nsIAccessibleDocument]);
    const topUrl =
      (browser.isRemoteBrowser ? CURRENT_CONTENT_DIR : CURRENT_DIR) +
      "e10s/doc_treeupdate_whitespace.html";
    is(docAcc.URL, topUrl, "Initial URL correct");
    is(docAcc.mimeType, "text/html", "Mime type is correct");
    info("Changing URL");
    await invokeContentTask(browser, [], () => {
      content.history.pushState(
        null,
        "",
        content.document.location.href + "/after"
      );
    });
    is(docAcc.URL, topUrl + "/after", "URL correct after change");

    // We can't use the harness to manage iframes for us because it uses data
    // URIs for in-process iframes, but data URIs don't support
    // history.pushState.

    async function testIframe() {
      queryInterfaces(iframeDocAcc, [nsIAccessibleDocument]);
      is(iframeDocAcc.URL, src, "Initial URL correct");
      is(iframeDocAcc.mimeType, "text/html", "Mime type is correct");
      info("Changing URL");
      await invokeContentTask(browser, [], async () => {
        await SpecialPowers.spawn(content.iframe, [], () => {
          content.history.pushState(
            null,
            "",
            content.document.location.href + "/after"
          );
        });
      });
      is(iframeDocAcc.URL, src + "/after", "URL correct after change");
    }

    info("Testing same origin (in-process) iframe");
    // eslint-disable-next-line @microsoft/sdl/no-insecure-url
    let src = "https://example.com/initial.html";
    let loaded = waitForEvent(
      EVENT_DOCUMENT_LOAD_COMPLETE,
      evt => evt.accessible.parent.parent == docAcc
    );
    await invokeContentTask(browser, [src], cSrc => {
      content.iframe = content.document.createElement("iframe");
      content.iframe.src = cSrc;
      content.document.body.append(content.iframe);
    });
    let iframeDocAcc = (await loaded).accessible;
    await testIframe();

    info("Testing different origin (out-of-process) iframe");
    // eslint-disable-next-line @microsoft/sdl/no-insecure-url
    src = "https://example.net/initial.html";
    loaded = waitForEvent(
      EVENT_DOCUMENT_LOAD_COMPLETE,
      evt => evt.accessible.parent.parent == docAcc
    );
    await invokeContentTask(browser, [src], cSrc => {
      content.iframe.src = cSrc;
    });
    iframeDocAcc = (await await loaded).accessible;
    await testIframe();
  },
  { chrome: true, topLevel: true }
);