Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / screen_orientation / orientationchange-event.html
blob2d1d728f2f431a4fad54fb4890c94cd73f381950
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <script src="../resources/testharness.js"></script>
5 <script src="../resources/testharnessreport.js"></script>
6 <script>
8 var changeTest = async_test("Test that orientationchange event is fired when the orientation changes.");
9 var noChangeTest = async_test("Test that orientationchange event is not fired when the orientation does not change.");
11 var orientations = [
12 'portrait-primary',
13 'portrait-secondary',
14 'landscape-primary',
15 'landscape-secondary'
18 var currentIndex = orientations.indexOf(window.screen.orientation.type);
19 // Count the number of calls received from the EventHandler set on screen.orientation.onchange.
20 var orientationChangeEventHandlerCalls = 0;
21 // Count the number of calls received from the listener set with screen.orientation.addEventListene().
22 var orientationChangeEventListenerCalls = 0;
24 var orientationChangeContinuation = null;
26 function getNextIndex() {
27 return (currentIndex + 1) % orientations.length;
30 window.screen.orientation.onchange = function() {
31 orientationChangeEventHandlerCalls++;
32 if (orientationChangeEventContinuation) {
33 setTimeout(orientationChangeEventContinuation);
34 orientationChangeEventContinuation = null;
38 window.screen.orientation.addEventListener('change', function() {
39 orientationChangeEventListenerCalls++;
40 });
42 function runNoChangeTest() {
43 window.testRunner.setMockScreenOrientation(orientations[currentIndex]);
45 noChangeTest.step(function() {
46 assert_equals(screen.orientation.type, orientations[currentIndex]);
47 assert_equals(orientationChangeEventHandlerCalls, 4);
48 assert_equals(orientationChangeEventListenerCalls, 4);
49 });
51 noChangeTest.done();
54 var i = 0;
55 function runChangeTest() {
56 window.testRunner.setMockScreenOrientation(orientations[getNextIndex()]);
57 currentIndex = getNextIndex();
59 orientationChangeEventContinuation = function() {
60 changeTest.step(function() {
61 assert_equals(screen.orientation.type, orientations[currentIndex]);
62 assert_equals(orientationChangeEventHandlerCalls, i + 1);
63 assert_equals(orientationChangeEventListenerCalls, i + 1);
64 });
66 ++i;
67 if (i == 4) {
68 changeTest.done();
69 runNoChangeTest();
70 } else {
71 runChangeTest();
76 runChangeTest();
78 </script>
79 </body>
80 </html>