Index: LayoutTests/screen_orientation/locking-then-unlocking.html |
diff --git a/LayoutTests/screen_orientation/locking-then-unlocking.html b/LayoutTests/screen_orientation/locking-then-unlocking.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e33f919f8aed58de5412c6989a4ce53171e0cb36 |
--- /dev/null |
+++ b/LayoutTests/screen_orientation/locking-then-unlocking.html |
@@ -0,0 +1,55 @@ |
+<!DOCTYPE html> |
+<html> |
+<body> |
+<script src="../resources/js-test.js"></script> |
+<script> |
+description("Validates that screen orientation can be unlocked"); |
+window.jsTestIsAsync = true; |
+ |
+var orientationChangeEventCount = 0; |
+var locked = false; |
+ |
+function checkNoOrientationChangeThenContinue() { |
+ shouldBeEqualToString("screen.orientation", "portrait-primary"); |
+ shouldBe("orientationChangeEventCount", "0"); |
+ debug("Unlocking orientation..."); |
+ locked = false; |
+ screen.unlockOrientation(); |
+} |
+ |
+function completeTest() { |
+ screen.removeEventListener("orientationchange", onOrientationChangeEvent); |
+ internals.setScreenOrientation(document, "portrait-primary"); |
+ finishJSTest(); |
+} |
+ |
+var testEvent; |
+function onOrientationChangeEvent(ev) { |
+ ++orientationChangeEventCount; |
+ testEvent = ev; |
+ debug("Received an 'orientationchange' event."); |
+ shouldBeFalse('locked'); |
+ shouldBe("orientationChangeEventCount", "1"); |
+ shouldBeEqualToString("testEvent.type", "orientationchange"); |
+ shouldBeEqualToString("screen.orientation", "landscape-primary"); |
+ completeTest(); |
+} |
+ |
+function setScreenOrientationtoLandscapePrimary() { |
+ debug("Faking device screen orientation change to 'landscape-primary'..."); |
+ internals.setScreenOrientation(document, "landscape-primary"); |
+ setTimeout(checkNoOrientationChangeThenContinue, 200); |
+} |
+ |
+internals.setScreenOrientationClientMock(document); |
+screen.addEventListener("orientationchange", onOrientationChangeEvent); |
+ |
+shouldBeEqualToString("screen.orientation", "portrait-primary"); |
kenneth.r.christiansen
2014/02/12 13:42:37
according to the spec a platform can say that it o
Inactive
2014/02/12 16:03:11
Yes, this has to happen on Chromium side as this m
|
+debug("locking orientation to 'portrait-primary'."); |
+locked = true; |
+shouldBeTrue("screen.lockOrientation('portrait-primary')"); |
+// Doing this asynchronously as lockOrientation() is asynchronous. |
+setTimeout(setScreenOrientationtoLandscapePrimary, 0); |
+</script> |
+</body> |
+</html> |