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

Side by Side Diff: LayoutTests/screen_orientation/lockOrientation-array-argument.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 lockOrientation() can take an array as 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 finishJSTest();
21 }
22
23 var testEvent;
24 function onOrientationChangeEvent(ev) {
25 ++orientationChangeCount;
26 testEvent = ev;
27 if (screen.orientation != "portrait-primary" && screen.orientation != "lands cape-primary") {
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", "landscape-primary");
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
54 debug("locking orientation to ['portrait-primary', 'landscape-primary'].");
55 shouldBeTrue("screen.lockOrientation(['portrait-primary', 'landscape-primary'])" );
56 setTimeout(changeOrientation, 0);
57 </script>
58 </body>
59 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698