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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/frame/LocalFrame.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/screen_orientation/page-visibility.html
diff --git a/LayoutTests/screen_orientation/page-visibility.html b/LayoutTests/screen_orientation/page-visibility.html
new file mode 100644
index 0000000000000000000000000000000000000000..874988d69d766da069d8168dfaf7a694998f35d6
--- /dev/null
+++ b/LayoutTests/screen_orientation/page-visibility.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script>
+var orientationChangeEventListenerCalls = 0;
+
+window.addEventListener('orientationchange', function() {
+ orientationChangeEventListenerCalls++;
+});
+
+test(function() {
+ assert_false(document.hidden);
+ if (window.testRunner)
+ window.testRunner.setMockScreenOrientation("landscape-primary");
+ assert_equals(orientationChangeEventListenerCalls, 1);
+ assert_equals(screen.orientation, "landscape-primary");
+}, "Test that 'orientationchange' event is fired when the page is visible");
+
+if (window.testRunner)
+ testRunner.setPageVisibility("hidden");
+
+test(function() {
+ assert_true(document.hidden);
+ if (window.testRunner)
+ window.testRunner.setMockScreenOrientation("portrait-primary");
+ assert_equals(orientationChangeEventListenerCalls, 1);
+}, "Test that 'orientationchange' event is not fired when the page is not visible");
+
+test(function() {
+ assert_equals(screen.orientation, "landscape-primary");
+}, "Test that screen.orientation keeps returning the same orientation when the page is not visible");
+
+if (window.testRunner)
+ testRunner.setPageVisibility("visible");
+
+test(function() {
+ assert_false(document.hidden);
+ // An 'orientationchange' event should have been fired.
+ assert_equals(orientationChangeEventListenerCalls, 2);
+ // Should keep returning the start returning the orientation value.
+ assert_equals(screen.orientation, "portrait-primary");
+}, "Test that screen.orientation is updated once the page is visible again");
+</script>
+</body>
+</html>
« 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