OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <script src="../../../../resources/js-test.js"></script> | |
5 <style type="text/css"> | |
6 #box { | |
7 width: 300px; | |
8 height: 50px; | |
9 } | |
10 | |
11 #overflowBox { | |
12 width: 300px; | |
13 height: 600px; | |
14 } | |
15 | |
16 #container { | |
17 width: 300px; | |
18 height: 50px; | |
19 overflow-y: scroll; | |
20 overflow-x: hidden; | |
21 margin: 10px 0 10px 0; | |
22 } | |
23 | |
24 .interactive { background-color: blue; } | |
25 | |
26 .interactive:hover { background-color: red; } | |
27 | |
28 .interactive:active { background-color: green; } | |
29 | |
30 .interactive:hover:active { background-color: yellow; } | |
31 | |
32 #scroller { | |
33 display: none; | |
34 width: 100px; | |
35 height: 600px; | |
36 } | |
37 </style> | |
38 </head> | |
39 <body> | |
40 <div id="box" class="interactive">Gestures go here</div> | |
41 <div id="container"> | |
42 <div id="overflowBox" class="interactive">Gestures go here</div> | |
43 </div> | |
44 | |
45 <p id="description"></p> | |
46 <p>See http://crbug.com/316974 for details</p> | |
47 | |
48 <div id="console"></div> | |
49 | |
50 <div id="scroller"></div> | |
51 | |
52 <script> | |
53 if (window.internals) { | |
54 internals.settings.setViewportEnabled(true); | |
55 internals.settings.setViewportMetaEnabled(true); | |
56 | |
57 // Now append meta tag so that it is handled properly | |
58 var meta = document.createElement('meta'); | |
59 meta.name = 'viewport'; | |
60 meta.content = 'width=device-width, initial-scale=1, user-scalable=no'; | |
61 document.head.appendChild(meta); | |
62 } | |
63 | |
64 var color; | |
65 | |
66 function isBoxOfColor(id, givenColor) | |
67 { | |
68 var b = document.getElementById(id); | |
69 color = window.getComputedStyle(b).backgroundColor; | |
70 if (color == givenColor) | |
71 return true; | |
72 | |
73 testFailed('Box had backgroundColor: ' + color); | |
74 return false; | |
75 } | |
76 | |
77 function isBoxHoverActive(id) | |
78 { | |
79 return isBoxOfColor(id, "rgb(255, 255, 0)"); | |
80 } | |
81 | |
82 function isBoxDefault(id) | |
83 { | |
84 return isBoxOfColor(id, "rgb(0, 0, 255)"); | |
85 } | |
86 | |
87 description("Tests gesture tapdown behaviour when page is scrollable or not."); | |
88 | |
89 function runTests() | |
90 { | |
91 if (!window.eventSender) { | |
92 debug('This test requires DRT.'); | |
93 return; | |
94 } | |
95 | |
96 if (!eventSender.gestureTapDown | |
97 || !eventSender.gestureShowPress) { | |
98 debug('Gesture events are not supported by this platform'); | |
99 return; | |
100 } | |
101 | |
102 /* Verify behaviour when page isn't scrollable or pinchable */ | |
103 debug("Verify hover, active aren't initially set (page isn't scrollable)."); | |
104 shouldBeTrue("isBoxDefault('box')"); | |
105 | |
106 debug("tapdown on element should activate."); | |
107 eventSender.gestureTapDown(50, 25); | |
108 shouldBeTrue("isBoxHoverActive('box')"); | |
109 | |
110 debug("showpress on element should keep hover and active."); | |
111 eventSender.gestureShowPress(50, 25); | |
112 shouldBeTrue("isBoxHoverActive('box')"); | |
113 | |
Rick Byers
2014/02/21 03:35:52
you should be sending a tapCancel (or tap) gesture
Zeeshan Qureshi
2014/02/24 03:14:26
Yes, I was planning to do a sweep of the layout te
| |
114 | |
115 /* Verify behaviour when ancestor is scrollable */ | |
116 debug("Verify hover, active aren't initially set (overflowBox with scrollabl e ancestor)."); | |
117 shouldBeTrue("isBoxDefault('overflowBox')"); | |
118 | |
119 debug("tapdown on element should not activate."); | |
120 eventSender.gestureTapDown(50, 80); | |
121 shouldBeTrue("isBoxDefault('overflowBox')"); | |
122 | |
123 debug("showpress on element should activate."); | |
124 eventSender.gestureShowPress(50, 80); | |
125 shouldBeTrue("isBoxHoverActive('overflowBox')"); | |
126 | |
127 /* Now check when page becomes scrollable */ | |
128 document.getElementById('scroller').style.display = 'block'; | |
129 debug("Verify hover, active aren't initially set (page is scrollable)."); | |
130 shouldBeTrue("isBoxDefault('box')"); | |
131 | |
132 debug("tapdown on element should not activate."); | |
133 eventSender.gestureTapDown(50, 25); | |
134 shouldBeTrue("isBoxDefault('box')"); | |
135 | |
136 debug("showpress on element should activate."); | |
137 eventSender.gestureShowPress(50, 25); | |
138 shouldBeTrue("isBoxHoverActive('box')"); | |
139 } | |
140 | |
141 runTests(); | |
142 </script> | |
143 </body> | |
144 </html> | |
145 | |
OLD | NEW |