| OLD | NEW |
| 1 description('Tests using DeviceOrientation from multiple frames.'); | 1 description('Tests using DeviceOrientation from multiple frames.'); |
| 2 | 2 |
| 3 var mockEvent = {alpha: 1.1, beta: 2.2, gamma: 3.3, absolute: true}; |
| 4 if (window.testRunner) |
| 5 testRunner.setMockDeviceOrientation(true, mockEvent.alpha, true, mockEvent.b
eta, true, mockEvent.gamma, true, mockEvent.absolute); |
| 6 else |
| 7 debug('This test can not be run without the TestRunner'); |
| 8 |
| 3 var deviceOrientationEvent; | 9 var deviceOrientationEvent; |
| 4 function checkOrientation(event) { | 10 function checkOrientation(event) { |
| 5 deviceOrientationEvent = event; | 11 deviceOrientationEvent = event; |
| 6 shouldBe('deviceOrientationEvent.alpha', 'mockEvent.alpha'); | 12 shouldBe('deviceOrientationEvent.alpha', 'mockEvent.alpha'); |
| 7 shouldBe('deviceOrientationEvent.beta', 'mockEvent.beta'); | 13 shouldBe('deviceOrientationEvent.beta', 'mockEvent.beta'); |
| 8 shouldBe('deviceOrientationEvent.gamma', 'mockEvent.gamma'); | 14 shouldBe('deviceOrientationEvent.gamma', 'mockEvent.gamma'); |
| 15 shouldBe('deviceOrientationEvent.absolute', 'mockEvent.absolute'); |
| 9 } | 16 } |
| 10 | 17 |
| 11 var hasMainFrameEventFired = false; | 18 var hasMainFrameEventFired = false; |
| 12 function mainFrameListener(event) { | 19 function mainFrameListener(event) { |
| 13 checkOrientation(event); | 20 checkOrientation(event); |
| 14 hasMainFrameEventFired = true; | 21 hasMainFrameEventFired = true; |
| 15 maybeFinishTest(); | 22 maybeFinishTest(); |
| 16 } | 23 } |
| 17 | 24 |
| 18 var hasChildFrameEventFired = false; | 25 var hasChildFrameEventFired = false; |
| 19 function childFrameListener(event) { | 26 function childFrameListener(event) { |
| 20 checkOrientation(event); | 27 checkOrientation(event); |
| 21 hasChildFrameEventFired = true; | 28 hasChildFrameEventFired = true; |
| 22 maybeFinishTest(); | 29 maybeFinishTest(); |
| 23 } | 30 } |
| 24 | 31 |
| 25 function maybeFinishTest() { | 32 function maybeFinishTest() { |
| 26 if (hasMainFrameEventFired && hasChildFrameEventFired) | 33 if (hasMainFrameEventFired && hasChildFrameEventFired) |
| 27 finishJSTest(); | 34 finishJSTest(); |
| 28 } | 35 } |
| 29 | 36 |
| 30 var mockEvent = {alpha: 1.1, beta: 2.2, gamma: 3.3}; | |
| 31 if (window.testRunner) | |
| 32 testRunner.setMockDeviceOrientation(true, mockEvent.alpha, true, mockEvent.b
eta, true, mockEvent.gamma); | |
| 33 else | |
| 34 debug('This test can not be run without the TestRunner'); | |
| 35 | |
| 36 var childFrame = document.createElement('iframe'); | 37 var childFrame = document.createElement('iframe'); |
| 37 document.body.appendChild(childFrame); | 38 document.body.appendChild(childFrame); |
| 38 childFrame.contentWindow.addEventListener('deviceorientation', childFrameListene
r); | 39 childFrame.contentWindow.addEventListener('deviceorientation', childFrameListene
r); |
| 39 | 40 |
| 40 window.addEventListener('deviceorientation', mainFrameListener); | 41 window.addEventListener('deviceorientation', mainFrameListener); |
| 41 | 42 |
| 42 window.jsTestIsAsync = true; | 43 window.jsTestIsAsync = true; |
| OLD | NEW |