Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / screen_orientation / page-visibility.html
blob73c19e4cf23e52428171d497c9b656c0fa7455a5
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <script src="../resources/testharness.js"></script>
5 <script src="../resources/testharnessreport.js"></script>
6 <iframe src='about:blank'></iframe>
7 <script>
9 var eventVisibleTest = async_test("Test that a change event is fired when the page is visible.");
10 var noEventHiddenTest = async_test("Test that change event is not fired when the page is not visible.");
11 var orientationUnchangeHiddenTest = async_test("Test that screen.orientation keeps returning the same orientation when the page is not visible.");
12 var orientationUpdateVisibleTest = async_test("Test that screen.orientation is updated once the page is visible again.");
13 var frameEventsTest = async_test("Test that the iframe got as many events as the main frame.");
15 var orientationChangeContinuation = null;
16 var orientationChangeEventListenerCalls = 0;
17 var orientationChangeEventListenerCallsForFrame = 0;
19 screen.orientation.addEventListener('change', function() {
20 orientationChangeEventListenerCalls++;
21 if (orientationChangeEventContinuation) {
22 setTimeout(orientationChangeEventContinuation);
23 orientationChangeEventContinuation = null;
25 });
27 window.frames[0].screen.orientation.addEventListener('change', function() {
28 orientationChangeEventListenerCallsForFrame++;
29 });
31 function runEventVisibleTest() {
32 eventVisibleTest.step(function() {
33 assert_false(document.hidden);
34 });
36 if (window.testRunner)
37 window.testRunner.setMockScreenOrientation("landscape-primary");
39 orientationChangeEventContinuation = function() {
40 eventVisibleTest.step(function() {
41 assert_equals(orientationChangeEventListenerCalls, 1);
42 assert_equals(screen.orientation.type, "landscape-primary");
43 });
44 eventVisibleTest.done();
46 runNoEventHiddenTest();
50 function runNoEventHiddenTest() {
51 if (window.testRunner)
52 testRunner.setPageVisibility("hidden");
54 noEventHiddenTest.step(function() {
55 assert_true(document.hidden);
56 });
58 if (window.testRunner)
59 window.testRunner.setMockScreenOrientation("portrait-primary");
61 noEventHiddenTest.step(function() {
62 assert_equals(orientationChangeEventListenerCalls, 1);
63 });
64 noEventHiddenTest.done();
66 runOrientationUnchangeHiddenTest();
69 function runOrientationUnchangeHiddenTest() {
70 orientationUnchangeHiddenTest.step(function() {
71 assert_equals(screen.orientation.type, "landscape-primary");
72 });
73 orientationUnchangeHiddenTest.done();
75 runOrientationUpdateVisibleTest();
78 function runOrientationUpdateVisibleTest() {
79 if (window.testRunner)
80 testRunner.setPageVisibility("visible");
82 orientationChangeEventContinuation = function() {
83 orientationUpdateVisibleTest.step(function() {
84 assert_false(document.hidden);
85 // A change event should have been fired.
86 assert_equals(orientationChangeEventListenerCalls, 2);
87 // Should keep returning the start returning the orientation value.
88 assert_equals(screen.orientation.type, "portrait-primary");
89 });
91 orientationUpdateVisibleTest.done();
93 runFrameEventsTest();
97 function runFrameEventsTest() {
98 frameEventsTest.step(function() {
99 assert_equals(orientationChangeEventListenerCallsForFrame, orientationChangeEventListenerCalls);
101 frameEventsTest.done();
104 runEventVisibleTest();
106 </script>
107 </body>
108 </html>