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

Side by Side Diff: LayoutTests/screen_orientation/page-visibility.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 <iframe src='about:blank'></iframe> 6 <iframe src='about:blank'></iframe>
7 <script> 7 <script>
8 var orientationChangeEventListenerCalls = 0; 8 var orientationChangeEventListenerCalls = 0;
9 var orientationChangeEventListenerCallsForFrame = 0; 9 var orientationChangeEventListenerCallsForFrame = 0;
10 10
11 screen.orientation.addEventListener('change', function() { 11 window.addEventListener('orientationchange', function() {
12 orientationChangeEventListenerCalls++; 12 orientationChangeEventListenerCalls++;
13 }); 13 });
14 14
15 window.frames[0].screen.orientation.addEventListener('change', function() { 15 window.frames[0].addEventListener('orientationchange', function() {
16 orientationChangeEventListenerCallsForFrame++; 16 orientationChangeEventListenerCallsForFrame++;
17 }); 17 });
18 18
19 test(function() { 19 test(function() {
20 assert_false(document.hidden); 20 assert_false(document.hidden);
21 if (window.testRunner) 21 if (window.testRunner)
22 window.testRunner.setMockScreenOrientation("landscape-primary"); 22 window.testRunner.setMockScreenOrientation("landscape-primary");
23 assert_equals(orientationChangeEventListenerCalls, 1); 23 assert_equals(orientationChangeEventListenerCalls, 1);
24 assert_equals(screen.orientation.type, "landscape-primary"); 24 assert_equals(screen.orientation, "landscape-primary");
25 }, "Test that a change event is fired when the page is visible"); 25 }, "Test that 'orientationchange' event is fired when the page is visible");
26 26
27 if (window.testRunner) 27 if (window.testRunner)
28 testRunner.setPageVisibility("hidden"); 28 testRunner.setPageVisibility("hidden");
29 29
30 test(function() { 30 test(function() {
31 assert_true(document.hidden); 31 assert_true(document.hidden);
32 if (window.testRunner) 32 if (window.testRunner)
33 window.testRunner.setMockScreenOrientation("portrait-primary"); 33 window.testRunner.setMockScreenOrientation("portrait-primary");
34 assert_equals(orientationChangeEventListenerCalls, 1); 34 assert_equals(orientationChangeEventListenerCalls, 1);
35 }, "Test that change event is not fired when the page is not visible"); 35 }, "Test that 'orientationchange' event is not fired when the page is not visibl e");
36 36
37 test(function() { 37 test(function() {
38 assert_equals(screen.orientation.type, "landscape-primary"); 38 assert_equals(screen.orientation, "landscape-primary");
39 }, "Test that screen.orientation keeps returning the same orientation when the p age is not visible"); 39 }, "Test that screen.orientation keeps returning the same orientation when the p age is not visible");
40 40
41 if (window.testRunner) 41 if (window.testRunner)
42 testRunner.setPageVisibility("visible"); 42 testRunner.setPageVisibility("visible");
43 43
44 test(function() { 44 test(function() {
45 assert_false(document.hidden); 45 assert_false(document.hidden);
46 // A change event should have been fired. 46 // An 'orientationchange' event should have been fired.
47 assert_equals(orientationChangeEventListenerCalls, 2); 47 assert_equals(orientationChangeEventListenerCalls, 2);
48 // Should keep returning the start returning the orientation value. 48 // Should keep returning the start returning the orientation value.
49 assert_equals(screen.orientation.type, "portrait-primary"); 49 assert_equals(screen.orientation, "portrait-primary");
50 }, "Test that screen.orientation is updated once the page is visible again"); 50 }, "Test that screen.orientation is updated once the page is visible again");
51 51
52 test(function() { 52 test(function() {
53 assert_equals(orientationChangeEventListenerCallsForFrame, orientationChange EventListenerCalls); 53 assert_equals(orientationChangeEventListenerCallsForFrame, orientationChange EventListenerCalls);
54 }, "Test that the iframe got as many events as the main frame.") 54 }, "Test that the iframe got as many events as the main frame.")
55 55
56 </script> 56 </script>
57 </body> 57 </body>
58 </html> 58 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698