OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <body> |
| 4 <script src="../fullscreen/full-screen-test.js"></script> |
| 5 <script src="../resources/js-test.js"></script> |
| 6 <script> |
| 7 description("Tests that when the document fully exits fullscreen, the orientatio
n is locked back to its default value."); |
| 8 window.jsTestIsAsync = true; |
| 9 |
| 10 var orientationChangeEventCount = 0; |
| 11 var callback; |
| 12 |
| 13 window.addEventListener('orientationchange', function() { |
| 14 orientationChangeEventCount++; |
| 15 }); |
| 16 |
| 17 function testOrientationChanged() { |
| 18 shouldBe("orientationChangeEventCount", "1"); |
| 19 shouldBeEqualToString("screen.orientation", "landscape-primary"); |
| 20 finishJSTest(); |
| 21 } |
| 22 |
| 23 function changeOrientation() { |
| 24 window.testRunner.setMockScreenOrientation('landscape-primary'); |
| 25 // We are locked in 'portrait-primary' so we should not get |
| 26 // an orientationchange event. |
| 27 shouldBe("orientationChangeEventCount", "0"); |
| 28 shouldBeEqualToString("screen.orientation", "portrait-primary"); |
| 29 callback = testOrientationChanged; |
| 30 // Exiting fullscreen mode should reset the screen lock and an orientationch
ange |
| 31 // event should be fired since the device is now in 'landscape-primary' and
we |
| 32 // we locked in 'portrait-primary'. |
| 33 document.webkitCancelFullScreen(); |
| 34 } |
| 35 |
| 36 function testLockOrientation() { |
| 37 shouldBeEqualToString("screen.orientation", "portrait-primary"); |
| 38 shouldBeTrue("screen.lockOrientation('portrait-primary')"); |
| 39 shouldBe("orientationChangeEventCount", "0"); |
| 40 setTimeout(changeOrientation, 0); |
| 41 } |
| 42 |
| 43 function fullscreenChanged() { |
| 44 if (callback) |
| 45 callback() |
| 46 } |
| 47 waitForEvent(document, 'webkitfullscreenchange', fullscreenChanged); |
| 48 callback = testLockOrientation; |
| 49 runWithKeyDown(function(){document.documentElement.webkitRequestFullScreen()}); |
| 50 </script> |
| 51 </body> |
| 52 </html> |
OLD | NEW |