Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / DeviceOrientation / null-values.html
blobd3ef8c15e5b0cb37587f1dbc421d6d368338b2a8
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.');
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.alpha,
14 null != mockEvent.beta, null == mockEvent.beta ? 0 : mockEvent.beta,
15 null != mockEvent.gamma, null == mockEvent.gamma ? 0 : mockEvent.gamma,
16 null != mockEvent.absolute, null == mockEvent.absolute ? false : mockEvent.absolute);
17 else
18 debug('This test can not be run without the TestRunner');
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');
30 function firstListener(event) {
31 checkOrientation(event);
32 window.removeEventListener('deviceorientation', firstListener);
33 setTimeout(function(){initSecondListener();}, 0);
36 function initSecondListener() {
37 setMockOrientation(1.1, null, null, true);
38 window.addEventListener('deviceorientation', secondListener);
41 function secondListener(event) {
42 checkOrientation(event);
43 window.removeEventListener('deviceorientation', secondListener);
44 setTimeout(function(){initThirdListener();}, 0);
47 function initThirdListener() {
48 setMockOrientation(null, 2.2, null, true);
49 window.addEventListener('deviceorientation', thirdListener);
52 function thirdListener(event) {
53 checkOrientation(event);
54 window.removeEventListener('deviceorientation', thirdListener);
55 setTimeout(function(){initFourthListener();}, 0);
58 function initFourthListener() {
59 setMockOrientation(null, null, 3.3, true);
60 window.addEventListener('deviceorientation', fourthListener);
63 function fourthListener(event) {
64 checkOrientation(event);
65 finishJSTest();
68 setMockOrientation(null, null, null, false);
69 window.addEventListener('deviceorientation', firstListener);
71 window.jsTestIsAsync = true;
72 </script>
73 </body>
74 </html>