summaryrefslogtreecommitdiffstats
path: root/accessible/tests/mochitest/text/test_words.html
blob: 7e4fba9154ea2510d9d0543976000c92eb1c28d8 (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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html>
<html>
<head>
  <title>nsIAccessibleText getText related function tests for html:input,html:div and html:textarea</title>
  <meta charset="utf-8" />
  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />

  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript"
          src="../common.js"></script>
  <script type="application/javascript"
          src="../text.js"></script>
  <script type="application/javascript">
    if (navigator.platform.startsWith("Mac")) {
      SimpleTest.expectAssertions(0, 1);
    } else {
      SimpleTest.expectAssertions(0, 1);
    }

    function doTest() {
      // "one two"
      testWords("div1", ["one", "two"]);

      // "one  two"
      testWords("div2", ["one", "two"]);

      // "one,two"
      testWordCount("div3", 2, kOk);
      testWordAt("div3", 0, "one", kTodo);
      testWordAt("div3", 1, "two", kOk);

      // "one, two"
      testWordCount("div4", 2, kOk);
      testWordAt("div4", 0, "one", kTodo);
      testWordAt("div4", 1, "two", kOk);

      // "one+two"
      testWordCount("div5", 2, kOk);
      testWordAt("div5", 0, "one", kTodo);
      testWordAt("div5", 1, "two", kOk);

      // "one+two   "
      testWordCount("div6", 2, kOk);
      testWordAt("div6", 0, "one", kTodo);
      testWordAt("div6", 1, "two", kOk);

      // "one\ntwo"
      testWordCount("div7", 2, kOk);
      testWordAt("div7", 0, "one", kOk);
      testWordAt("div7", 1, "two", kTodo);

      // "one.two"
      testWordCount("div8", 2, kOk);
      testWordAt("div8", 0, "one", kTodo);
      testWordAt("div8", 1, "two", kOk);

      // "345"
      testWords("div9", ["345"]);

      // "3a A4"
      testWords("div10", ["3a", "A4"]);

      // "3.1416"
      testWords("div11", ["3.1416"], kTodo);

      // "4,261.01"
      testWords("div12", ["4,261.01"], kTodo);

      // "カタカナ"
      testWords("div13", ["カタカナ"], kOk);

      // "Peter's car"
      testWords("div14", ["Peter's", "car"], kTodo);

      // "N.A.T.O."
      testWords("div15", ["N.A.T.O."], kTodo);

      // "3+4*5=23"
      testWordCount("div16", 4, kOk);
      testWordAt("div15", 0, "3", kTodo);
      testWordAt("div15", 1, "4", kTodo);
      testWordAt("div15", 2, "5", kTodo);
      testWordAt("div15", 3, "23", kTodo);

      // "Hello. Friend, are you here?!"
      testWordCount("div17", 5, kOk);
      testWordAt("div17", 0, "Hello", kTodo);
      testWordAt("div17", 1, "Friend", kTodo);
      testWordAt("div17", 2, "are", kOk);
      testWordAt("div17", 3, "you", kOk);
      testWordAt("div17", 4, "here", kTodo);

      testWords("input_1", ["foo", "bar"]);

      SimpleTest.finish();
    }

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

  <a target="_blank"
     title="nsIAccessibleText test word boundaries"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=452769">Mozilla Bug 452769</a>
  <p id="display"></p>
  <div id="content" style="display: none"></div>
  <pre id="test">
  <div id="div1">one two</div>
  <div id="div2">one  two</div>
  <div id="div3">one,two</div>
  <div id="div4">one, two</div>
  <div id="div5">one+two</div>
  <div id="div6">one+two   </div>
  <div id="div7">one<br/>two</div>
  <div id="div8">one.two</div>
  <div id="div9">345</div>
  <div id="div10">3a A4</div>
  <div id="div11">3.1416</div>
  <div id="div12">4,261.01</div>
  <div id="div13">カタカナ</div>
  <div id="div14">Peter's car</div>
  <div id="div15">N.A.T.O.</div>
  <div id="div16">3+4*5=23</div>
  <div id="div17">Hello. Friend, are you here?!</div>
  </pre>
  <input id="input_1" type="text" value="foo bar" placeholder="something or other">

</body>
</html>