4 <script src=
"../../../resources/js-test.js"></script>
6 description('Tests that updates to the orientation causes new events to fire.');
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
);
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
);
42 setMockOrientation(1.1, 2.2, 3.3, true);
43 window
.addEventListener('deviceorientation', firstListener
);
45 window
.jsTestIsAsync
= true;