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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="../../forms/resources/common.js"></script>
<script src="../../forms/resources/common-wheel-event.js"></script>
<script src="../../forms/resources/picker-common.js"></script>
<script src="resources/suggestion-picker-common.js"></script>
</head>
<body style="background-color: #bbbbbb;">
<p id="description"></p>
<div id="console"></div>
<input type=week id=week value="2012-12-24" list=suggestions>
<datalist id=suggestions>
<option label="This Week">2012-W01</option>
<option>2012-W02</option>
<option>2012-W03</option>
<option>2012-W04</option>
<option>2012-W05</option>
<option>2012-W06</option>
<option>2012-W07</option>
<option>2012-W08</option>
<option>2012-W09</option>
<option>2012-W10</option>
<option>2012-W11</option>
<option>2012-W12</option>
<option>2012-W13</option>
<option>2012-W14</option>
<option>2012-W15</option>
<option>2012-W16</option>
<option>2012-W17</option>
<option>2012-W18</option>
<option>2012-W19</option>
<option>2012-W20</option>
<option>2012-W21</option>
<option>2012-W22</option>
<option>2012-W23</option>
<option>2012-W24</option>
<option>2012-W25</option>
<option>2012-W26</option>
<option>2012-W27</option>
<option>2012-W28</option>
<option>2012-W29</option>
<option>2012-W30</option>
<option>2012-W31</option>
<option>2012-W32</option>
<option>2012-W33</option>
<option>2012-W34</option>
<option>2012-W35</option>
<option>2012-W36</option>
<option>2012-W37</option>
<option>2012-W38</option>
<option>2012-W39</option>
<option>2012-W40</option>
<option>2012-W41</option>
<option>2012-W42</option>
<option>2012-W43</option>
<option>2012-W44</option>
<option>2012-W45</option>
<option>2012-W46</option>
<option>2012-W47</option>
<option>2012-W48</option>
<option>2012-W49</option>
<option>2012-W50</option>
<option>2012-W51</option>
<option>2012-W52</option>
<option>2013-W01</option>
<option>2013-W02</option>
<option>2013-W03</option>
<option>2013-W04</option>
<option>2013-W05</option>
<option>2013-W06</option>
<option>2013-W07</option>
<option>2013-W08</option>
<option>2013-W09</option>
<option>2013-W10</option>
<option>2013-W11</option>
<option>2013-W12</option>
<option>2013-W13</option>
<option>2013-W14</option>
<option>2013-W15</option>
<option>2012-W00</option> <!--invalid-->
<option>2012-01-01</option> <!--invalid-->
<option>foo</option> <!--invalid-->
</datalist>
<script>
debug('Check that page popup doesn\'t exist at first.');
shouldBeNull('$("mock-page-popup")');
openPicker($('week'), test1);
function test1() {
debug('Check that page popup exists.');
shouldBeEqualToString('popupWindow.pagePopupController.toString()', '[object PagePopupController]');
debug('Check that hovering over an entry highlights it.');
hoverOverElement(popupWindow.document.querySelector('.suggestion-list-entry:nth-child(2)'));
shouldBeEqualToString('highlightedEntry()', '2012-W02');
debug('Check that moving the mouse outside the popup de-highlights entries.');
hoverOverElement(document.getElementById('description'));
shouldBeNull('highlightedEntry()');
debug('Check that mouse click closes the popup and sets the value.');
clickElement(popupWindow.document.querySelector('.suggestion-list-entry:nth-child(3)'));
waitUntilClosing(test1AfterClosing);
}
function test1AfterClosing() {
shouldBeNull('$("mock-page-popup")');
shouldBeEqualToString('document.getElementById("week").value', '2012-W03');
openPicker($('week'), test2);
}
var scrollTopBeforeWheelEvent = 0;
var scrollTopAfterWheelEvent = 0;
var suggestionList;
function test2() {
suggestionList = popupWindow.document.getElementsByClassName("suggestion-list")[0];
debug('Check that you can scroll using the mouse wheel.');
function finishTest() {
popupWindow.focus();
eventSender.keyDown('escape');
waitUntilClosing(test2AfterClosing);
}
function scrollUp() {
scrollTopBeforeWheelEvent = suggestionList.scrollTop;
dispatchWheelEvent(suggestionList, 0, 100);
shouldBecomeEqual('scrollTopBeforeWheelEvent > suggestionList.scrollTop', 'true', finishTest)
}
function scrollDown() {
scrollTopBeforeWheelEvent = suggestionList.scrollTop;
dispatchWheelEvent(suggestionList, 0, -100);
shouldBecomeEqual('scrollTopBeforeWheelEvent < suggestionList.scrollTop', 'true', scrollUp);
}
scrollDown();
}
function test2AfterClosing() {
shouldBeNull('$("mock-page-popup")');
openPicker($('week'), test3);
}
function test3() {
debug('Check that you can scroll using the scroll bar.');
var suggestionList = popupWindow.document.getElementsByClassName('suggestion-list')[0];
var suggestionListOffset = cumulativeOffset(suggestionList);
var scrollbarCenterX = suggestionListOffset[0] + suggestionList.offsetWidth - popupWindow.getScrollbarWidth() / 2;
scrollTopBeforeWheelEvent = suggestionList.scrollTop;
eventSender.mouseMoveTo(scrollbarCenterX, suggestionListOffset[1] + 20); // 20 is the height of the up arrow button plus a few pixels
eventSender.mouseDown();
eventSender.mouseMoveTo(scrollbarCenterX, suggestionListOffset[1] + suggestionList.offsetHeight);
eventSender.mouseUp();
scrollTopAfterWheelEvent = suggestionList.scrollTop;
shouldBeTrue('scrollTopBeforeWheelEvent < scrollTopAfterWheelEvent');
finishJSTest();
}
</script>
</body>
</html>
|