OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <html> | |
3 <body> | |
4 <script src="../resources/testharness.js"></script> | |
5 <script src="../resources/testharnessreport.js"></script> | |
6 <script> | |
7 | |
8 var orientations = [ | |
9 'portrait-primary', | |
10 'portrait-secondary', | |
11 'landscape-primary', | |
12 'landscape-secondary' | |
13 ]; | |
14 | |
15 var currentIndex = orientations.indexOf(window.screen.orientation); | |
16 var eventHandlers = 0; | |
Inactive
2014/04/19 19:14:19
Maybe "eventHandlerCount"? (Something with "Count"
mlamouri (slow - plz ping)
2014/04/19 23:24:20
I changed the variable name and added a comment.
| |
17 var eventAVL = 0; | |
Inactive
2014/04/19 19:14:19
What does AVL stand for? we don't use abbreviation
mlamouri (slow - plz ping)
2014/04/19 23:24:20
ditto
| |
18 | |
19 // TODO: window.onorientationchange is enabled on Android only. We will enable | |
20 // it with ScreenOrientation later, at which point this test will fail. We will | |
21 // then have to fix it. | |
22 function todo_equals(actual, expected) { | |
23 assert_not_equals(actual, expected, "TODO: if this fails, it means that someth ing got fixed."); | |
24 } | |
25 | |
26 function getNextIndex() { | |
27 return (currentIndex + 1) % orientations.length; | |
28 } | |
29 | |
30 window.onorientationchange = function() { | |
31 eventHandlers++; | |
32 }; | |
33 | |
34 window.addEventListener('orientationchange', function() { | |
35 eventAVL++; | |
36 }); | |
37 | |
38 for (var i = 0; i < 4; ++i) { | |
39 test(function() { | |
40 window.testRunner.setMockScreenOrientation(orientations[getNextIndex()]); | |
Inactive
2014/04/19 19:14:19
So this fires the 'orientationchange' event synchr
mlamouri (slow - plz ping)
2014/04/19 23:24:20
Correct.
| |
41 | |
42 currentIndex = getNextIndex(); | |
43 assert_equals(screen.orientation, orientations[currentIndex]); | |
44 | |
45 todo_equals(eventHandlers, i + 1); | |
46 assert_equals(eventAVL, i + 1); | |
47 }, "Test that orientationchange event is fired when the orientation changes"); | |
48 } | |
49 | |
50 test(function() { | |
51 window.testRunner.setMockScreenOrientation(orientations[currentIndex]); | |
52 assert_equals(screen.orientation, orientations[currentIndex]); | |
53 | |
54 todo_equals(eventHandlers, 4); | |
55 assert_equals(eventAVL, 4); | |
56 }, "Test that orientationchange event is not fired when the orientation does not change"); | |
57 | |
58 </script> | |
59 </body> | |
60 </html> | |
OLD | NEW |