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

Unified Diff: LayoutTests/screen_orientation/locked-no-orientation-change-event.html

Issue 132113006: Add initial Blink-side support for the Screen Orientation API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Take feedback into consideration Created 6 years, 10 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/locked-no-orientation-change-event.html
diff --git a/LayoutTests/screen_orientation/locked-no-orientation-change-event.html b/LayoutTests/screen_orientation/locked-no-orientation-change-event.html
new file mode 100644
index 0000000000000000000000000000000000000000..0db2d0f5d2f08861bb39c71863c6df66194db440
--- /dev/null
+++ b/LayoutTests/screen_orientation/locked-no-orientation-change-event.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../resources/js-test.js"></script>
+<script>
+description("Validates that no orientationchange event is fired when we are locked.");
mlamouri (slow - plz ping) 2014/02/12 20:11:26 This test seems to essentially test the mock objec
Inactive 2014/02/12 21:08:04 So you want to remove this layout test?
mlamouri (slow - plz ping) 2014/02/13 16:12:08 I guess we could remove it yes. There is no point
Inactive 2014/02/13 17:03:24 Done.
+window.jsTestIsAsync = true;
+
+var orientationChangeCount = 0;
+var currentTestOrientation = 0;
+var testOrientations = [
+ "portrait-secondary",
+ "landscape-primary",
+ "landscape-secondary",
+ "portrait-primary"
+];
+
+function testComplete() {
+ screen.unlockOrientation();
+ finishJSTest();
+}
+
+function onOrientationChangeEvent(ev) {
+ ++orientationChangeCount;
+ testFailed("Unexpected 'orientationchange' event.");
+}
+
+function changeOrientation() {
+ shouldBeEqualToString("screen.orientation", "portrait-primary");
+ if (currentTestOrientation == testOrientations.length) {
+ if (orientationChangeCount)
+ testFailed("Received " + orientationChangeCount + " unexpected 'orientationchange' event(s).");
+ else
+ testPassed("Received no 'orientationchange' event, as expected.");
+ testComplete();
+ return;
+ }
+ debug("Faking device screen orientation change to '" + testOrientations[currentTestOrientation] +"'...");
+ internals.setScreenOrientation(document, testOrientations[currentTestOrientation++]);
+ setTimeout(changeOrientation, 100);
+}
+
+internals.setScreenOrientationClientMock(document);
+screen.addEventListener("orientationchange", onOrientationChangeEvent);
+
+shouldBeEqualToString("screen.orientation", "portrait-primary");
+debug("locking orientation to 'portrait-primary'.");
+shouldBeTrue("screen.lockOrientation('portrait-primary')");
+setTimeout(changeOrientation, 100);
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698