summaryrefslogtreecommitdiffstats
path: root/accessible/tests/mochitest/hittest/test_general.html
blob: 74ff4fe298d71a911d55bb473babb946afa491de (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!DOCTYPE html>
<html>
<head>
  <title>nsIAccessible::childAtPoint() tests</title>
  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />

  <script type="application/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>

  <script type="application/javascript"
          src="../common.js"></script>
  <script type="application/javascript"
          src="../layout.js"></script>
  <script type="application/javascript"
          src="../events.js"></script>

  <script type="application/javascript">
    function doPreTest()
    {
      waitForImageMap("imgmap", doTest);
    }

    function doTest()
    {
      // Not specific case, child and deepchild testing.
      var list = getAccessible("list");
      var listitem = getAccessible("listitem");
      var image = getAccessible("image");
if (!MAC) {
      testChildAtPoint(list, 1, 1, listitem, image.firstChild);
} else {
      todo(false, "Bug 746974 - children must match on all platforms, disable failing test on Mac");
}

      // ::MustPrune case (in this case childAtPoint doesn't look inside a
      // textbox), point is inside of textbox.
      var txt = getAccessible("txt");
      testChildAtPoint(txt, 1, 1, txt, txt);

      // ::MustPrune case, point is outside of textbox accessible but is in
      // document.
      testChildAtPoint(txt, -1, 1, null, null);

      // ::MustPrune case, point is outside of root accessible.
      testChildAtPoint(txt, -10000, 10000, null, null);

      // Not specific case, point is inside of btn accessible.
      var btn = getAccessible("btn");
      var btnText = btn.firstChild;
      testChildAtPoint(btn, 1, 1, btn, btn);
  
      // Not specific case, point is outside of btn accessible.
      testChildAtPoint(btn, -1, 1, null, null);

      // Out of flow accessible testing, do not return out of flow accessible
      // because it's not a child of the accessible even visually it is.
      var rectArea = getNode("area").getBoundingClientRect();
      var outOfFlow = getNode("outofflow");
      outOfFlow.style.left = rectArea.left + "px";
      outOfFlow.style.top = rectArea.top + "px";

      testChildAtPoint("area", 1, 1, "area", "area");

      // Test image maps. Their children are not in the layout tree.
      var theLetterA = getAccessible("imgmap").firstChild;
      hitTest("imgmap", theLetterA, theLetterA);
      hitTest("container", "imgmap", theLetterA);

      // hit testing for element contained by zero-width element
      hitTest("container2", "container2_input", "container2_input");
      SimpleTest.finish();
    }

    SimpleTest.waitForExplicitFinish();
    addA11yLoadEvent(doPreTest);
  </script>
</head>
<body>

  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=491657"
     title="nsIAccessible::childAtPoint() tests">Mozilla Bug 491657</a>
  <p id="display"></p>
  <div id="content" style="display: none"></div>
  <pre id="test">
  </pre>

  <div role="list" id="list">
    <div role="listitem" id="listitem"><span role="image" id="image">img</span>item</div>
  </div>

  <span role="button">button1</span><span role="button" id="btn">button2</span>

  <span role="textbox">textbox1</span><span role="textbox" id="txt">textbox2</span>

  <div id="outofflow" style="width: 10px; height: 10px; position: absolute; left: 0px; top: 0px; background-color: yellow;">
  </div>
  <div id="area" style="width: 100px; height: 100px; background-color: blue;"></div>

  <map name="atoz_map">
    <area href="http://www.bbc.co.uk/radio4/atoz/index.shtml#a"
          coords="0,0,15,15" alt="thelettera" shape="rect"/>
  </map>

  <div id="container">
    <img id="imgmap" width="447" height="15" usemap="#atoz_map" src="../letters.gif"/>
  </div>

  <div id="container2" style="width: 0px">
    <input id="container2_input">
  </div>
</body>
</html>