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

Unified Diff: LayoutTests/screen_orientation/lockOrientation-bad-array-argument.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/lockOrientation-bad-array-argument.html
diff --git a/LayoutTests/screen_orientation/lockOrientation-bad-array-argument.html b/LayoutTests/screen_orientation/lockOrientation-bad-array-argument.html
new file mode 100644
index 0000000000000000000000000000000000000000..6d251fbc1e5607481c4ea6f30e935e5c2d464e6e
--- /dev/null
+++ b/LayoutTests/screen_orientation/lockOrientation-bad-array-argument.html
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../resources/js-test.js"></script>
+<script>
+description("Validates that lockOrientation() can take an array in argument.");
+window.jsTestIsAsync = true;
+
+var orientationChangeCount = 0;
+var currentTestOrientation = 0;
+var testOrientations = [
+ "portrait-secondary",
+ "landscape-primary",
+ "landscape-secondary",
+ "portrait-primary"
+];
+
+function testComplete() {
+ screen.unlockOrientation();
+ internals.setScreenOrientation(document, "portrait-primary");
+ finishJSTest();
+}
+
+var testEvent;
+function onOrientationChangeEvent(ev) {
+ ++orientationChangeCount;
+ testEvent = ev;
+
+ testPassed("Received an 'orientationchange' event.");
+ shouldBeEqualToString("testEvent.type", "orientationchange");
+ shouldBe("orientationChangeCount", "1");
+ shouldBeEqualToString("screen.orientation", "landscape-primary");
+ testComplete();
+}
+
+function changeOrientation() {
+ internals.setScreenOrientation(document, testOrientations[currentTestOrientation++]);
+ if (currentTestOrientation < testOrientations.length)
+ setTimeout(changeOrientation, 0);
+}
+
+internals.setScreenOrientationClientMock(document);
+screen.addEventListener("orientationchange", onOrientationChangeEvent);
+
+shouldBeEqualToString("screen.orientation", "portrait-primary");
+// Bad argument to lockOrientation(), we should not get locked.
+shouldBeFalse("screen.lockOrientation(['portrait-primary', 'invalid-orientation'])");
+shouldBeFalse("screen.lockOrientation(['portrait-primary', null])");
+shouldBeFalse("screen.lockOrientation(['portrait-primary', undefined])");
+shouldBeFalse("screen.lockOrientation(['portrait-primary', 123])");
+shouldBeFalse("screen.lockOrientation(['portrait-primary', window])");
+debug("Faking device screen orientation change to 'landscape-primary'...");
+internals.setScreenOrientation(document, "landscape-primary");
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698