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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/DeviceOrientation/null-values.html

Issue 2677603003: Move DeviceMotion and DeviceOrientation out from fast/dom/. (Closed)
Patch Set: device_orientation Created 3 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
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <script src="../../../resources/js-test.js"></script>
5 <script>
6 description('Tests using null values for some of the event properties.');
7
8 var mockEvent;
9 function setMockOrientation(alpha, beta, gamma, absolute) {
10 mockEvent = {alpha: alpha, beta: beta, gamma: gamma, absolute: absolute};
11 if (window.testRunner)
12 testRunner.setMockDeviceOrientation(
13 null != mockEvent.alpha, null == mockEvent.alpha ? 0 : mockEvent.alp ha,
14 null != mockEvent.beta, null == mockEvent.beta ? 0 : mockEvent.beta,
15 null != mockEvent.gamma, null == mockEvent.gamma ? 0 : mockEvent.gam ma,
16 mockEvent.absolute);
17 else
18 debug('This test can not be run without the TestRunner');
19 }
20
21 var deviceOrientationEvent;
22 function checkOrientation(event) {
23 deviceOrientationEvent = event;
24 shouldBe('deviceOrientationEvent.alpha', 'mockEvent.alpha');
25 shouldBe('deviceOrientationEvent.beta', 'mockEvent.beta');
26 shouldBe('deviceOrientationEvent.gamma', 'mockEvent.gamma');
27 shouldBe('deviceOrientationEvent.absolute', 'mockEvent.absolute');
28 }
29
30 function firstListener(event) {
31 checkOrientation(event);
32 window.removeEventListener('deviceorientation', firstListener);
33 setTimeout(function(){initSecondListener();}, 0);
34 }
35
36 function initSecondListener() {
37 setMockOrientation(1.1, null, null, true);
38 window.addEventListener('deviceorientation', secondListener);
39 }
40
41 function secondListener(event) {
42 checkOrientation(event);
43 window.removeEventListener('deviceorientation', secondListener);
44 setTimeout(function(){initThirdListener();}, 0);
45 }
46
47 function initThirdListener() {
48 setMockOrientation(null, 2.2, null, true);
49 window.addEventListener('deviceorientation', thirdListener);
50 }
51
52 function thirdListener(event) {
53 checkOrientation(event);
54 window.removeEventListener('deviceorientation', thirdListener);
55 setTimeout(function(){initFourthListener();}, 0);
56 }
57
58 function initFourthListener() {
59 setMockOrientation(null, null, 3.3, true);
60 window.addEventListener('deviceorientation', fourthListener);
61 }
62
63 function fourthListener(event) {
64 checkOrientation(event);
65 finishJSTest();
66 }
67
68 setMockOrientation(null, null, null, false);
69 window.addEventListener('deviceorientation', firstListener);
70
71 window.jsTestIsAsync = true;
72 </script>
73 </body>
74 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698