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

Side by Side Diff: LayoutTests/screen_orientation/lockOrientation-bad-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 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>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698