Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / DeviceOrientation / updates.html
blobabbc27c5f0a5008b90c2fbbfb938ea9dcc1e16b7
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <script src="../../../resources/js-test.js"></script>
5 <script>
6 description('Tests that updates to the orientation causes new events to fire.');
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(true, mockEvent.alpha, true, mockEvent.beta, true, mockEvent.gamma, true, mockEvent.absolute);
13 else
14 debug('This test can not be run without the TestRunner');
17 var deviceOrientationEvent;
18 function checkOrientation(event) {
19 deviceOrientationEvent = event;
20 shouldBe('deviceOrientationEvent.alpha', 'mockEvent.alpha');
21 shouldBe('deviceOrientationEvent.beta', 'mockEvent.beta');
22 shouldBe('deviceOrientationEvent.gamma', 'mockEvent.gamma');
23 shouldBe('deviceOrientationEvent.absolute', 'mockEvent.absolute');
26 function firstListener(event) {
27 checkOrientation(event);
28 window.removeEventListener('deviceorientation', firstListener);
29 setTimeout(function(){initUpdateListener();}, 0);
32 function initUpdateListener() {
33 setMockOrientation(11.1, 22.2, 33.3, true);
34 window.addEventListener('deviceorientation', updateListener);
37 function updateListener(event) {
38 checkOrientation(event);
39 finishJSTest();
42 setMockOrientation(1.1, 2.2, 3.3, true);
43 window.addEventListener('deviceorientation', firstListener);
45 window.jsTestIsAsync = true;
46 </script>
47 </body>
48 </html>