summaryrefslogtreecommitdiffstats
path: root/accessible/tests/browser/e10s/browser_treeupdate_gencontent.js
blob: ca1150f9ddd7757b91590076b7cde04fc385fdb3 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* 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(
  `
  <style>
    .gentext:before {
      content: "START"
    }
    .gentext:after {
      content: "END"
    }
  </style>
  <div id="container1"></div>
  <div id="container2"><div id="container2_child">text</div></div>`,
  async function(browser, accDoc) {
    const id1 = "container1";
    const id2 = "container2";
    let container1 = findAccessibleChildByID(accDoc, id1);
    let container2 = findAccessibleChildByID(accDoc, id2);

    let tree = {
      SECTION: [], // container
    };
    testAccessibleTree(container1, tree);

    tree = {
      SECTION: [
        {
          // container2
          SECTION: [
            {
              // container2 child
              TEXT_LEAF: [], // primary text
            },
          ],
        },
      ],
    };
    testAccessibleTree(container2, tree);

    let onReorder = waitForEvent(EVENT_REORDER, id1);
    // Create and add an element with CSS generated content to container1
    await invokeContentTask(browser, [id1], id => {
      let node = content.document.createElement("div");
      node.textContent = "text";
      node.setAttribute("class", "gentext");
      content.document.getElementById(id).appendChild(node);
    });
    await onReorder;

    tree = {
      SECTION: [
        // container
        {
          SECTION: [
            // inserted node
            { STATICTEXT: [] }, // :before
            { TEXT_LEAF: [] }, // primary text
            { STATICTEXT: [] }, // :after
          ],
        },
      ],
    };
    testAccessibleTree(container1, tree);

    onReorder = waitForEvent(EVENT_REORDER, "container2_child");
    // Add CSS generated content to an element in container2's subtree
    await invokeSetAttribute(browser, "container2_child", "class", "gentext");
    await onReorder;

    tree = {
      SECTION: [
        // container2
        {
          SECTION: [
            // container2 child
            { STATICTEXT: [] }, // :before
            { TEXT_LEAF: [] }, // primary text
            { STATICTEXT: [] }, // :after
          ],
        },
      ],
    };
    testAccessibleTree(container2, tree);
  },
  { iframe: true, remoteIframe: true }
);