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

Unified Diff: LayoutTests/screen_orientation/lockOrientation-bad-argument.html

Issue 171683015: Screen Orientation API: Add support for lockOrientation() / unlockOrientation() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase 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/lockOrientation-bad-argument.html
diff --git a/LayoutTests/screen_orientation/lockOrientation-bad-argument.html b/LayoutTests/screen_orientation/lockOrientation-bad-argument.html
new file mode 100644
index 0000000000000000000000000000000000000000..236f254e6862448f3d9500c2aa8e6df147146baf
--- /dev/null
+++ b/LayoutTests/screen_orientation/lockOrientation-bad-argument.html
@@ -0,0 +1,39 @@
+<!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