layout/forms/test/test_bug571352.html

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:6bfb9cd7deaa
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=571352
5 -->
6 <head>
7 <title>Test for Bug 571352</title>
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=571352">Mozilla Bug 571352</a>
14 <p id="display"></p>
15 <div id="content" style="display: none">
16
17 </div>
18 <pre id="test">
19 <script type="application/javascript">
20
21 /** Test for Bug 571352 **/
22
23 SimpleTest.waitForExplicitFinish();
24 SimpleTest.waitForFocus(function test() {
25 function createList() {
26 $('display').innerHTML = '<select multiple><option>0<option>1<option>2<option>3<option>4<option>5</select>';
27 $('display').firstChild.focus();
28 }
29 function option(index) {
30 return $('display').firstChild.childNodes[index];
31 }
32 function remove(index) {
33 var sel = $('display').firstChild;
34 sel.removeChild(sel.childNodes[index]);
35 }
36 function up() { synthesizeKey("VK_UP", {}); }
37 function shiftUp() { synthesizeKey("VK_UP", {shiftKey:true}); }
38 function down() { synthesizeKey("VK_DOWN", {}); }
39 function shiftDown() { synthesizeKey("VK_DOWN", {shiftKey:true}); }
40 function mouseEvent(index,event) {
41 synthesizeMouse(option(index), 5, 5, event);
42 }
43
44 const click = {};
45 const shiftClick = {shiftKey:true};
46 const CtrlClick = {CtrlKey:true};
47 createList();
48 mouseEvent(0,click)
49 is(document.activeElement,$('display').firstChild,"<select> is focused");
50 mouseEvent(2,shiftClick)
51 remove(0);
52 ok(option(0).selected && option(1).selected,"first two options are selected");
53 mouseEvent(2,shiftClick)
54 ok(option(0).selected && option(1).selected && option(2).selected,"first three options are selected");
55 shiftUp();
56 ok(option(0).selected && option(1).selected,"first two options are selected");
57 remove(1);
58 ok(option(0).selected,"first option is selected");
59 shiftDown();
60 ok(option(0).selected && option(1).selected,"first two options are selected");
61 down();
62 ok(option(2).selected,"third option is selected");
63 shiftDown();
64 ok(option(2).selected && option(3).selected,"third & fourth option are selected");
65 remove(2);
66 shiftUp();
67 ok(option(1).selected && option(2).selected,"2nd & third option are selected");
68 remove(0);
69 mouseEvent(0,shiftClick)
70 ok(option(0).selected && option(1).selected,"all remaining 2 options are selected");
71 shiftDown();
72 remove(1);
73 ok(!option(0).selected,"first option is unselected");
74 remove(0); // select is now empty
75 ok($('display').firstChild.firstChild==null,"all options were removed");
76
77 SimpleTest.finish();
78 });
79
80
81
82
83 </script>
84 </pre>
85 </body>
86 </html>

mercurial