OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <body> |
| 4 <script src="../resources/js-test.js"></script> |
| 5 <script> |
| 6 description("Validates that lockOrientation() can take an array in argument."); |
| 7 window.jsTestIsAsync = true; |
| 8 |
| 9 var orientationChangeCount = 0; |
| 10 var currentTestOrientation = 0; |
| 11 var testOrientations = [ |
| 12 "portrait-secondary", |
| 13 "landscape-primary", |
| 14 "landscape-secondary", |
| 15 "portrait-primary" |
| 16 ]; |
| 17 |
| 18 function testComplete() { |
| 19 screen.unlockOrientation(); |
| 20 internals.setScreenOrientation(document, "portrait-primary"); |
| 21 finishJSTest(); |
| 22 } |
| 23 |
| 24 var testEvent; |
| 25 function onOrientationChangeEvent(ev) { |
| 26 ++orientationChangeCount; |
| 27 testEvent = ev; |
| 28 |
| 29 testPassed("Received an 'orientationchange' event."); |
| 30 shouldBeEqualToString("testEvent.type", "orientationchange"); |
| 31 shouldBe("orientationChangeCount", "1"); |
| 32 shouldBeEqualToString("screen.orientation", "landscape-primary"); |
| 33 testComplete(); |
| 34 } |
| 35 |
| 36 function changeOrientation() { |
| 37 internals.setScreenOrientation(document, testOrientations[currentTestOrienta
tion++]); |
| 38 if (currentTestOrientation < testOrientations.length) |
| 39 setTimeout(changeOrientation, 0); |
| 40 } |
| 41 |
| 42 internals.setScreenOrientationClientMock(document); |
| 43 screen.addEventListener("orientationchange", onOrientationChangeEvent); |
| 44 |
| 45 shouldBeEqualToString("screen.orientation", "portrait-primary"); |
| 46 // Bad argument to lockOrientation(), we should not get locked. |
| 47 shouldBeFalse("screen.lockOrientation(['portrait-primary', 'invalid-orientation'
])"); |
| 48 shouldBeFalse("screen.lockOrientation(['portrait-primary', null])"); |
| 49 shouldBeFalse("screen.lockOrientation(['portrait-primary', undefined])"); |
| 50 shouldBeFalse("screen.lockOrientation(['portrait-primary', 123])"); |
| 51 shouldBeFalse("screen.lockOrientation(['portrait-primary', window])"); |
| 52 debug("Faking device screen orientation change to 'landscape-primary'..."); |
| 53 internals.setScreenOrientation(document, "landscape-primary"); |
| 54 </script> |
| 55 </body> |
| 56 </html> |
OLD | NEW |