Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/forms/listbox-selection-2.html

Issue 1509853008: Move select/option/optgroup-related tests in fast/forms to fast/forms/select. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script>
10 description('&lt;select> selection test for scrolling.');
11
12 var parent = document.createElement('div');
13 parent.innerHTML = '<select id="sl1" multiple size=5>'
14 + '<option>one</option>'
15 + '<option>two</option>'
16 + '<option>three</option>'
17 + '<option>four</option>'
18 + '<option>five</option>'
19 + '<option>six</option>'
20 + '<option>seven</option>'
21 + '<option>eight</option>'
22 + '<option>nine</option>'
23 + '<option>ten</option>'
24 + '<option>eleven</option>'
25 + '<option>twelve</option>'
26 + '<option>thirteen</option>'
27 + '<option>fourteen</option>'
28 + '<option>fifteen</option>'
29 + '<option>sixteen</option>'
30 + '<option>seventeen</option>'
31 + '</select>'
32 + '<select id="sl2" multiple style="height: 135px; border: 10px solid; paddi ng: 5px;">'
33 + '<option>one</option>'
34 + '<option>two</option>'
35 + '<option>three</option>'
36 + '</select>';
37 document.body.appendChild(parent);
38
39 // Determine the item height.
40 var sl1 = document.getElementById('sl1');
41 var sl2 = document.getElementById('sl2');
42 var itemHeight = Math.floor(sl1.offsetHeight / sl1.size);
43 sl1.removeAttribute('size');
44 var height = itemHeight * 9 + 9;
45 sl1.setAttribute('style', 'height: ' + height + 'px; border: 10px solid; padding : 5px;');
46
47 function mouseDownOnSelect(selId, index)
48 {
49 var sl = document.getElementById(selId);
50 var borderPaddingTop = 15;
51 var borderPaddingLeft = 15;
52 var y = index * itemHeight + itemHeight / 2 - window.pageYOffset + borderPad dingTop;
53 eventSender.mouseMoveTo(sl.offsetLeft + borderPaddingLeft, sl.offsetTop + y );
54 eventSender.mouseDown();
55 eventSender.mouseUp();
56 }
57
58 function selectionPattern(selectId)
59 {
60 var select = document.getElementById(selectId);
61 var result = "";
62 for (var i = 0; i < select.options.length; i++)
63 result += select.options[i].selected ? '1' : '0';
64 return result;
65 }
66
67 mouseDownOnSelect("sl1", 0);
68 shouldBe('selectionPattern("sl1")', '"10000000000000000"');
69
70 mouseDownOnSelect("sl1", 1);
71 shouldBe('selectionPattern("sl1")', '"01000000000000000"');
72
73 mouseDownOnSelect("sl1", 6);
74 shouldBe('selectionPattern("sl1")', '"00000010000000000"');
75
76 mouseDownOnSelect("sl1", 7);
77 shouldBe('selectionPattern("sl1")', '"00000001000000000"');
78
79 mouseDownOnSelect("sl1", 8);
80 shouldBe('selectionPattern("sl1")', '"00000001000000000"');
81
82 mouseDownOnSelect("sl1", 0);
83 shouldBe('selectionPattern("sl1")', '"10000000000000000"');
84
85 for (i = 0; i < 9; i++)
86 mouseDownOnSelect("sl1", 7);
87 shouldBe('selectionPattern("sl1")', '"00000001000000000"');
88
89 mouseDownOnSelect("sl2", 1);
90 shouldBe('selectionPattern("sl2")', '"010"');
91
92 mouseDownOnSelect("sl2", 3);
93 shouldBe('selectionPattern("sl2")', '"010"');
94
95 mouseDownOnSelect("sl2", 2);
96 shouldBe('selectionPattern("sl2")', '"001"');
97 </script>
98 </body>
99 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698