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

Unified Diff: LayoutTests/screen_orientation/exit-fullscreen-unlock-orientation.html

Issue 261983005: Stop firing orientationchange events at pages that are not visible (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Simplify test case 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
Index: LayoutTests/screen_orientation/exit-fullscreen-unlock-orientation.html
diff --git a/LayoutTests/screen_orientation/exit-fullscreen-unlock-orientation.html b/LayoutTests/screen_orientation/exit-fullscreen-unlock-orientation.html
new file mode 100644
index 0000000000000000000000000000000000000000..1d3c021fc833d25f8e0034e6970662e7b201630f
--- /dev/null
+++ b/LayoutTests/screen_orientation/exit-fullscreen-unlock-orientation.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../fullscreen/full-screen-test.js"></script>
+<script src="../resources/js-test.js"></script>
+<script>
+description("Tests that when the document fully exits fullscreen, the orientation is locked back to its default value.");
+window.jsTestIsAsync = true;
+
+var orientationChangeEventCount = 0;
+var callback;
+
+window.addEventListener('orientationchange', function() {
+ orientationChangeEventCount++;
+});
+
+function testOrientationChanged() {
+ shouldBe("orientationChangeEventCount", "1");
+ shouldBeEqualToString("screen.orientation", "landscape-primary");
+ finishJSTest();
+}
+
+function changeOrientation() {
+ window.testRunner.setMockScreenOrientation('landscape-primary');
+ // We are locked in 'portrait-primary' so we should not get
+ // an orientationchange event.
+ shouldBe("orientationChangeEventCount", "0");
+ shouldBeEqualToString("screen.orientation", "portrait-primary");
+ callback = testOrientationChanged;
+ // Exiting fullscreen mode should reset the screen lock and an orientationchange
+ // event should be fired since the device is now in 'landscape-primary' and we
+ // we locked in 'portrait-primary'.
+ document.webkitCancelFullScreen();
+}
+
+function testLockOrientation() {
+ shouldBeEqualToString("screen.orientation", "portrait-primary");
+ shouldBeTrue("screen.lockOrientation('portrait-primary')");
+ shouldBe("orientationChangeEventCount", "0");
+ setTimeout(changeOrientation, 0);
+}
+
+function fullscreenChanged() {
+ if (callback)
+ callback()
+}
+waitForEvent(document, 'webkitfullscreenchange', fullscreenChanged);
+callback = testLockOrientation;
+runWithKeyDown(function(){document.documentElement.webkitRequestFullScreen()});
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698