| <html> |
| <head> |
| <script src="../resources/js-test-pre.js"></script> |
| </head> |
| <body> |
| <script> |
| description('Tests using DeviceProximity from multiple frames.'); |
| |
| var DeviceProximityEvent; |
| function checkProximity(event) { |
| DeviceProximityEvent = event; |
| shouldBe('DeviceProximityEvent.value', 'firedEvent.value'); |
| shouldBe('DeviceProximityEvent.min', 'firedEvent.min'); |
| shouldBe('DeviceProximityEvent.max', 'firedEvent.max'); |
| } |
| |
| var hasMainFrameEventFired = false; |
| function mainFrameListener(event) { |
| checkProximity(event); |
| hasMainFrameEventFired = true; |
| maybeFinishTest(); |
| } |
| |
| var hasChildFrameEventFired = false; |
| function childFrameListener(event) { |
| checkProximity(event); |
| hasChildFrameEventFired = true; |
| maybeFinishTest(); |
| } |
| |
| function maybeFinishTest() { |
| if (hasMainFrameEventFired && hasChildFrameEventFired) |
| finishJSTest(); |
| } |
| |
| var childFrame = document.createElement('iframe'); |
| document.body.appendChild(childFrame); |
| childFrame.contentWindow.addEventListener('webkitdeviceproximity', childFrameListener); |
| |
| window.addEventListener('webkitdeviceproximity', mainFrameListener); |
| var firedEvent = {value: 2.2, min: 1.1, max: 3.3}; |
| internals.setDeviceProximity('webkitdeviceproximity', firedEvent.value, firedEvent.min, firedEvent.max); |
| |
| window.jsTestIsAsync = true; |
| </script> |
| <script src="../resources/js-test-post.js"></script> |
| </body> |
| </html> |