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

Side by Side Diff: LayoutTests/screen_orientation/page-visibility.html

Issue 280283002: Stop firing orientationchange events at pages that are not visible (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Take feedback into consideration Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/frame/LocalFrame.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 var orientationChangeEventListenerCalls = 0;
8
9 window.addEventListener('orientationchange', function() {
10 orientationChangeEventListenerCalls++;
11 });
12
13 test(function() {
14 assert_false(document.hidden);
15 if (window.testRunner)
16 window.testRunner.setMockScreenOrientation("landscape-primary");
17 assert_equals(orientationChangeEventListenerCalls, 1);
18 assert_equals(screen.orientation, "landscape-primary");
19 }, "Test that 'orientationchange' event is fired when the page is visible");
20
21 if (window.testRunner)
22 testRunner.setPageVisibility("hidden");
23
24 test(function() {
25 assert_true(document.hidden);
26 if (window.testRunner)
27 window.testRunner.setMockScreenOrientation("portrait-primary");
28 assert_equals(orientationChangeEventListenerCalls, 1);
29 }, "Test that 'orientationchange' event is not fired when the page is not visibl e");
30
31 test(function() {
32 assert_equals(screen.orientation, "landscape-primary");
33 }, "Test that screen.orientation keeps returning the same orientation when the p age is not visible");
34
35 if (window.testRunner)
36 testRunner.setPageVisibility("visible");
37
38 test(function() {
39 assert_false(document.hidden);
40 // An 'orientationchange' event should have been fired.
41 assert_equals(orientationChangeEventListenerCalls, 2);
42 // Should keep returning the start returning the orientation value.
43 assert_equals(screen.orientation, "portrait-primary");
44 }, "Test that screen.orientation is updated once the page is visible again");
45 </script>
46 </body>
47 </html>
OLDNEW
« no previous file with comments | « no previous file | Source/core/frame/LocalFrame.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698