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

Side by Side Diff: LayoutTests/screen_orientation/locking-then-unlocking.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 screen orientation can be unlocked");
7 window.jsTestIsAsync = true;
8
9 var orientationChangeEventCount = 0;
10 var locked = false;
11
12 function checkNoOrientationChangeThenContinue() {
13 shouldBeEqualToString("screen.orientation", "portrait-primary");
14 shouldBe("orientationChangeEventCount", "0");
15 debug("Unlocking orientation...");
16 locked = false;
17 screen.unlockOrientation();
18 }
19
20 function completeTest() {
21 screen.removeEventListener("orientationchange", onOrientationChangeEvent);
22 internals.setScreenOrientation(document, "portrait-primary");
23 finishJSTest();
24 }
25
26 var testEvent;
27 function onOrientationChangeEvent(ev) {
28 ++orientationChangeEventCount;
29 testEvent = ev;
30 debug("Received an 'orientationchange' event.");
31 shouldBeFalse('locked');
32 shouldBe("orientationChangeEventCount", "1");
33 shouldBeEqualToString("testEvent.type", "orientationchange");
34 shouldBeEqualToString("screen.orientation", "landscape-primary");
35 completeTest();
36 }
37
38 function setScreenOrientationtoLandscapePrimary() {
39 debug("Faking device screen orientation change to 'landscape-primary'...");
40 internals.setScreenOrientation(document, "landscape-primary");
41 setTimeout(checkNoOrientationChangeThenContinue, 0);
42 }
43
44 internals.setScreenOrientationClientMock(document);
45 screen.addEventListener("orientationchange", onOrientationChangeEvent);
46
47 shouldBeEqualToString("screen.orientation", "portrait-primary");
48 debug("locking orientation to 'portrait-primary'.");
49 locked = true;
50 shouldBeTrue("screen.lockOrientation('portrait-primary')");
51 // Doing this asynchronously as lockOrientation() is asynchronous.
52 setTimeout(setScreenOrientationtoLandscapePrimary, 0);
53 </script>
54 </body>
55 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698