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

Side by Side Diff: LayoutTests/screen_orientation/orientationchange-event.html

Issue 381753002: Revert of [screen-orientation] Update implementation to match recent spec changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 months 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <body> 3 <body>
4 <script src="../resources/testharness.js"></script> 4 <script src="../resources/testharness.js"></script>
5 <script src="../resources/testharnessreport.js"></script> 5 <script src="../resources/testharnessreport.js"></script>
6 <script> 6 <script>
7 7
8 var orientations = [ 8 var orientations = [
9 'portrait-primary', 9 'portrait-primary',
10 'portrait-secondary', 10 'portrait-secondary',
11 'landscape-primary', 11 'landscape-primary',
12 'landscape-secondary' 12 'landscape-secondary'
13 ]; 13 ];
14 14
15 var currentIndex = orientations.indexOf(window.screen.orientation.type); 15 var currentIndex = orientations.indexOf(window.screen.orientation);
16 // Count the number of calls received from the EventHandler set on screen.orient ation.onchange. 16 // Count the number of calls received from the EventHandler set on window.onorie ntationchange.
17 var orientationChangeEventHandlerCalls = 0; 17 var orientationChangeEventHandlerCalls = 0;
18 // Count the number of calls received from the listener set with screen.orientat ion.addEventListene(). 18 // Count the number of calls received from the listener set with window.addEvent Listene().
19 var orientationChangeEventListenerCalls = 0; 19 var orientationChangeEventListenerCalls = 0;
20 20
21 // TODO: window.onorientationchange is enabled on Android only. We will enable
22 // it with ScreenOrientation later, at which point this test will fail. We will
23 // then have to fix it.
24 function todo_equals(actual, expected) {
25 assert_not_equals(actual, expected, "TODO: if this fails, it means that someth ing got fixed.");
26 }
27
21 function getNextIndex() { 28 function getNextIndex() {
22 return (currentIndex + 1) % orientations.length; 29 return (currentIndex + 1) % orientations.length;
23 } 30 }
24 31
25 window.screen.orientation.onchange = function() { 32 window.onorientationchange = function() {
26 orientationChangeEventHandlerCalls++; 33 orientationChangeEventHandlerCalls++;
27 }; 34 };
28 35
29 window.screen.orientation.addEventListener('change', function() { 36 window.addEventListener('orientationchange', function() {
30 orientationChangeEventListenerCalls++; 37 orientationChangeEventListenerCalls++;
31 }); 38 });
32 39
33 for (var i = 0; i < 4; ++i) { 40 for (var i = 0; i < 4; ++i) {
34 test(function() { 41 test(function() {
35 window.testRunner.setMockScreenOrientation(orientations[getNextIndex()]); 42 window.testRunner.setMockScreenOrientation(orientations[getNextIndex()]);
36 43
37 currentIndex = getNextIndex(); 44 currentIndex = getNextIndex();
38 assert_equals(screen.orientation.type, orientations[currentIndex]); 45 assert_equals(screen.orientation, orientations[currentIndex]);
39 46
40 assert_equals(orientationChangeEventHandlerCalls, i + 1); 47 todo_equals(orientationChangeEventHandlerCalls, i + 1);
41 assert_equals(orientationChangeEventListenerCalls, i + 1); 48 assert_equals(orientationChangeEventListenerCalls, i + 1);
42 }, "Test that orientationchange event is fired when the orientation changes"); 49 }, "Test that orientationchange event is fired when the orientation changes");
43 } 50 }
44 51
45 test(function() { 52 test(function() {
46 window.testRunner.setMockScreenOrientation(orientations[currentIndex]); 53 window.testRunner.setMockScreenOrientation(orientations[currentIndex]);
47 assert_equals(screen.orientation.type, orientations[currentIndex]); 54 assert_equals(screen.orientation, orientations[currentIndex]);
48 55
49 assert_equals(orientationChangeEventHandlerCalls, 4); 56 todo_equals(orientationChangeEventHandlerCalls, 4);
50 assert_equals(orientationChangeEventListenerCalls, 4); 57 assert_equals(orientationChangeEventListenerCalls, 4);
51 }, "Test that orientationchange event is not fired when the orientation does not change"); 58 }, "Test that orientationchange event is not fired when the orientation does not change");
52 59
53 </script> 60 </script>
54 </body> 61 </body>
55 </html> 62 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698