summaryrefslogtreecommitdiffstats
path: root/accessible/tests/browser/e10s/browser_treeupdate_gencontent.js
blob: 12641928880e4444f3e6d669e9d7ba2e6029b467 (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
/* 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';

/* global EVENT_REORDER */

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>`,
  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
    yield ContentTask.spawn(browser, id1, id => {
      let node = content.document.createElement('div');
      node.textContent = 'text';
      node.setAttribute('class', 'gentext');
      content.document.getElementById(id).appendChild(node);
    });
    yield onReorder;

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

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

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