accessible/tests/mochitest/text/test_selection.html

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:b1ba326a220d
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Test text selection functions</title>
5 <link rel="stylesheet" type="text/css"
6 href="chrome://mochikit/content/tests/SimpleTest/test.css" />
7
8 <script type="application/javascript"
9 src="chrome://mochikit/content/MochiKit/packed.js"></script>
10 <script type="application/javascript"
11 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
12 <script type="application/javascript"
13 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
14
15 <script type="application/javascript"
16 src="../common.js"></script>
17 <script type="application/javascript"
18 src="../text.js"></script>
19
20 <script type="application/javascript">
21
22 function doTest()
23 {
24 // Test selection count: clean selection / check count.
25 testTextAddSelection("div0", 0, 2, 1); // |Test selection...
26 cleanTextSelections("div0");
27 testTextSelectionCount("div0", 0);
28
29 // Test addition: adding two equal selections, the second one should
30 // not be added.
31 testTextAddSelection("div1", 7, 9, 1); // Test ad|di|ng two...
32 testTextAddSelection("div1", 7, 9, 1); // Test ad|di|ng two...
33 testTextGetSelection("div1", 7, 9, 0);
34
35 // Test overlapping selections: adding three selections, one adjacent.
36 testTextAddSelection("div2", 0, 3, 1); // |Tes|t adding 3...
37 testTextAddSelection("div2", 7, 9, 2); // |Tes|t ad|di|ng 3...
38 testTextAddSelection("div2", 3, 4, 3); // |Tes||t| ad|di|ng 3...
39 testTextGetSelection("div2", 0, 3, 0);
40 testTextGetSelection("div2", 3, 4, 1);
41 testTextGetSelection("div2", 7, 9, 2);
42
43 // Test selection re-ordering: adding two selections.
44 // NOTE: removeSelections aSelectionIndex is from start of document.
45 testTextAddSelection("div3", 0, 3, 1); // |Tes|t adding 2...
46 testTextAddSelection("div3", 7, 9, 2); // |Tes|t ad|di|ng 2...
47 testTextRemoveSelection("div3", 4, 1); // Test ad|di|ng 2...
48
49 // Test extending existing selection.
50 // NOTE: setSelectionBounds aSelectionIndex is from start of document.
51 testTextAddSelection("div4", 4, 5, 1); // Test| |extending...
52 testTextSetSelection("div4", 4, 9, 6, 1); // Test| exte|nding...
53
54 // Test moving an existing selection.
55 // NOTE: setSelectionBounds aSelectionIndex is from start of document.
56 testTextAddSelection("div5", 1, 3, 1); // T|es|t moving...
57 testTextSetSelection("div5", 5, 9, 6, 1); // Test |movi|ng...
58
59 // Test adding selections to multiple inner elements.
60 testTextAddSelection("div71", 0, 3, 1); // |Tes|t adding...
61 testTextAddSelection("div71", 7, 8, 2); // |Tes|t ad|d|ing...
62 testTextAddSelection("div72", 4, 6, 1); // Test| a|dding...
63 testTextAddSelection("div72", 7, 8, 2); // Test| a|d|d|ing...
64
65 // Test adding selection to parent element.
66 // NOTE: If inner elements are represented as embedded chars
67 // we count their internal selections.
68 testTextAddSelection("div7", 7, 8, 5); // Test ad|d|ing...
69
70 SimpleTest.finish();
71 }
72
73 SimpleTest.waitForExplicitFinish();
74 addA11yLoadEvent(doTest);
75
76 </script>
77 </head>
78
79 <body>
80
81 <p id="display"></p>
82 <div id="content" style="display: none"></div>
83 <pre id="test">
84 </pre>
85
86 <div id="div0">Test selection count</div>
87 </br>
88 <div id="div1">Test adding two equal selections </div>
89 <div id="div2">Test adding 3 selections one adjacent </div>
90 <div id="div3">Test adding 2 selections, remove first one </div>
91 <div id="div4">Test extending a selection </div>
92 <div id="div5">Test moving a selection </div>
93 </br>
94 <div id="div7">Test adding selections to parent element
95 <div id="div71">Test adding selections to inner element1 </div>
96 <div id="div72">Test adding selections to inner element2 </div>
97 </div>
98
99 </body>
100
101 </html>

mercurial