4 <script src=
"../../../resources/js-test.js"></script>
6 description('Tests using DeviceOrientation from multiple frames.');
8 var mockEvent
= {alpha
: 1.1, beta
: 2.2, gamma
: 3.3, absolute
: true};
10 testRunner
.setMockDeviceOrientation(true, mockEvent
.alpha
, true, mockEvent
.beta
, true, mockEvent
.gamma
, true, mockEvent
.absolute
);
12 debug('This test can not be run without the TestRunner');
14 var deviceOrientationEvent
;
15 function checkOrientation(event
) {
16 deviceOrientationEvent
= event
;
17 shouldBe('deviceOrientationEvent.alpha', 'mockEvent.alpha');
18 shouldBe('deviceOrientationEvent.beta', 'mockEvent.beta');
19 shouldBe('deviceOrientationEvent.gamma', 'mockEvent.gamma');
20 shouldBe('deviceOrientationEvent.absolute', 'mockEvent.absolute');
23 var hasMainFrameEventFired
= false;
24 function mainFrameListener(event
) {
25 checkOrientation(event
);
26 hasMainFrameEventFired
= true;
30 var hasChildFrameEventFired
= false;
31 function childFrameListener(event
) {
32 checkOrientation(event
);
33 hasChildFrameEventFired
= true;
37 function maybeFinishTest() {
38 if (hasMainFrameEventFired
&& hasChildFrameEventFired
)
42 var childFrame
= document
.createElement('iframe');
43 document
.body
.appendChild(childFrame
);
44 childFrame
.contentWindow
.addEventListener('deviceorientation', childFrameListener
);
46 window
.addEventListener('deviceorientation', mainFrameListener
);
48 window
.jsTestIsAsync
= true;