Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / screen_orientation / window-orientationchange-event.html
blobb8ac7135aedec22643c873ebd135865463edfd40
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 window's orientationchange event is fired when the orientation changes.");
9 var noChangeTest = async_test("Test that window's orientationchange event is not fired when the orientation does not change.");
11 if (window.internals && internals.runtimeFlags.orientationEventEnabled) {
12 var orientations = [
13 'portrait-primary',
14 'portrait-secondary',
15 'landscape-primary',
16 'landscape-secondary'
19 var orientationAngles = [
21 180,
22 90,
23 -90
26 var currentIndex = 0;
27 // Count the number of calls received from the EventHandler set on window.onorientationchange
28 var orientationChangeEventHandlerCalls = 0;
29 // Count the number of calls received from the listener set with window.addEventListener("orientationchange",...)
30 var orientationChangeEventListenerCalls = 0;
32 function getNextIndex() {
33 return (currentIndex + 1) % orientationAngles.length;
36 window.onorientationchange = function(event) {
37 orientationChangeEventHandlerCalls++;
40 window.addEventListener('orientationchange', function() {
41 orientationChangeEventListenerCalls++;
42 });
44 function runNoChangeTest() {
45 window.testRunner.setMockScreenOrientation(orientations[currentIndex]);
47 setTimeout(function() {
48 noChangeTest.step(function() {
49 assert_equals(window.orientation, orientationAngles[currentIndex]);
50 assert_equals(orientationChangeEventHandlerCalls, 4);
51 assert_equals(orientationChangeEventListenerCalls, 4);
52 });
54 noChangeTest.done();
55 });
58 var i = 0;
59 function runChangeTest() {
60 window.testRunner.setMockScreenOrientation(orientations[getNextIndex()]);
61 currentIndex = getNextIndex();
63 setTimeout(function() {
64 changeTest.step(function() {
65 assert_equals(window.orientation, orientationAngles[currentIndex]);
66 assert_equals(orientationChangeEventHandlerCalls, i + 1);
67 assert_equals(orientationChangeEventListenerCalls, i + 1);
68 });
70 ++i;
71 if (i == 4) {
72 changeTest.done();
73 runNoChangeTest();
74 } else {
75 runChangeTest();
77 });
80 runChangeTest();
81 } else {
82 console.error("This test requires window.internals and the orientationchange event to be enabled.");
83 changeTest.done();
84 noChangeTest.done();
87 </script>
88 </body>
89 </html>