Index: LayoutTests/screen_orientation/lockOrientation-array-argument.html |
diff --git a/LayoutTests/screen_orientation/lockOrientation-array-argument.html b/LayoutTests/screen_orientation/lockOrientation-array-argument.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f535170cd1a4fba221490109d32c2df11832de90 |
--- /dev/null |
+++ b/LayoutTests/screen_orientation/lockOrientation-array-argument.html |
@@ -0,0 +1,59 @@ |
+<!DOCTYPE html> |
+<html> |
+<body> |
+<script src="../resources/js-test.js"></script> |
+<script> |
+description("Validates that lockOrientation() can take an array as argument."); |
+window.jsTestIsAsync = true; |
+ |
+var orientationChangeCount = 0; |
+var currentTestOrientation = 0; |
+var testOrientations = [ |
+ "portrait-secondary", |
+ "landscape-primary", |
+ "landscape-secondary", |
+ "portrait-primary" |
+]; |
+ |
+function testComplete() { |
+ screen.unlockOrientation(); |
+ finishJSTest(); |
+} |
+ |
+var testEvent; |
+function onOrientationChangeEvent(ev) { |
+ ++orientationChangeCount; |
+ testEvent = ev; |
+ if (screen.orientation != "portrait-primary" && screen.orientation != "landscape-primary") { |
+ ++orientationChangeCount; |
+ testFailed("Unexpected 'orientationchange' event for " + screen.orientation); |
+ testComplete(); |
+ } |
+ testPassed("Received an 'orientationchange' event."); |
+ shouldBeEqualToString("testEvent.type", "orientationchange"); |
+ if (orientationChangeCount == 1) { |
+ shouldBeEqualToString("screen.orientation", "landscape-primary"); |
+ } else { |
+ shouldBe("orientationChangeCount", "2"); |
+ shouldBeEqualToString("screen.orientation", "portrait-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"); |
+ |
+debug("locking orientation to ['portrait-primary', 'landscape-primary']."); |
+shouldBeTrue("screen.lockOrientation(['portrait-primary', 'landscape-primary'])"); |
+setTimeout(changeOrientation, 0); |
+</script> |
+</body> |
+</html> |