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

Unified Diff: LayoutTests/screen_orientation/locking-failure.html

Issue 132113006: Add initial Blink-side support for the Screen Orientation API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update compile-time assertion for matching enum 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/locking-failure.html
diff --git a/LayoutTests/screen_orientation/locking-failure.html b/LayoutTests/screen_orientation/locking-failure.html
new file mode 100644
index 0000000000000000000000000000000000000000..07cc83f0d6f31b8ce34f0590590d5f22dc5832a4
--- /dev/null
+++ b/LayoutTests/screen_orientation/locking-failure.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../resources/js-test.js"></script>
+<script>
+description("Validates that screen.lockOrientation() returns false on bad input");
+window.jsTestIsAsync = true;
+
+function onOrientationChangeEvent(ev) {
+ testFailed("Unexpected 'orientationchange' event");
+}
+
+function completeTest() {
+ shouldBeEqualToString("screen.orientation", "portrait-primary");
+ screen.unlockOrientation();
+ finishJSTest();
+}
+
+screen.addEventListener("orientationchange", onOrientationChangeEvent);
+
+shouldBeEqualToString("screen.orientation", "portrait-primary");
+shouldBeFalse("screen.lockOrientation('invalid-orientation')");
+shouldBeEqualToString("screen.orientation", "portrait-primary");
+shouldBeFalse("screen.lockOrientation(null)");
+shouldBeEqualToString("screen.orientation", "portrait-primary");
+shouldBeFalse("screen.lockOrientation(undefined)");
+shouldBeEqualToString("screen.orientation", "portrait-primary");
+shouldBeFalse("screen.lockOrientation(123)");
+shouldBeEqualToString("screen.orientation", "portrait-primary");
+shouldBeFalse("screen.lockOrientation(window)");
+shouldBeEqualToString("screen.orientation", "portrait-primary");
+shouldThrow("screen.lockOrientation()", '"TypeError: Failed to execute \'lockOrientation\' on \'Screen\': 1 argument required, but only 0 present."');
+
+// Finish asynchronously to give events a chance to fire.
+setTimeout(completeTest, 0);
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698