| 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..c7c4261279654edfef4229de6c1c5ccf86dc2c0f
|
| --- /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, 0);
|
| +}
|
| +
|
| +internals.setScreenOrientationClientMock(document);
|
| +screen.addEventListener("orientationchange", onOrientationChangeEvent);
|
| +
|
| +shouldBeEqualToString("screen.orientation", "portrait-primary");
|
| +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>
|
|
|