Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: LayoutTests/screen_orientation/multiple-orientations-locking.html

Issue 132113006: Add initial Blink-side support for the Screen Orientation API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update compile-time assertion for matching enum Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <script src="../resources/js-test.js"></script>
5 <script>
6 description("Validates that orientationchange events can fired when several orie ntations are locked.");
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 finishJSTest();
21 }
22
23 var testEvent;
24 function onOrientationChangeEvent(ev) {
25 ++orientationChangeCount;
26 testEvent = ev;
27 if (screen.orientation != "portrait-primary" && screen.orientation != "portr ait-secondary") {
28 ++orientationChangeCount;
29 testFailed("Unexpected 'orientationchange' event for " + screen.orientat ion);
30 testComplete();
31 }
32 testPassed("Received an 'orientationchange' event.");
33 shouldBeEqualToString("testEvent.type", "orientationchange");
34 if (orientationChangeCount == 1) {
35 shouldBeEqualToString("screen.orientation", "portrait-secondary");
36 } else {
37 shouldBe("orientationChangeCount", "2");
38 shouldBeEqualToString("screen.orientation", "portrait-primary");
39 testComplete();
40 }
41 }
42
43 function changeOrientation() {
44 internals.setScreenOrientation(document, testOrientations[currentTestOrienta tion++]);
45 if (currentTestOrientation < testOrientations.length)
46 setTimeout(changeOrientation, 0);
47 }
48
49 internals.setScreenOrientationClientMock(document);
50 screen.addEventListener("orientationchange", onOrientationChangeEvent);
51
52 shouldBeEqualToString("screen.orientation", "portrait-primary");
53 debug("locking orientation to 'portrait'.");
54 shouldBeTrue("screen.lockOrientation('portrait')");
55 setTimeout(changeOrientation, 0);
56 </script>
57 </body>
58 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698