OLD | NEW |
(Empty) | |
| 1 description('Test no fire listeners added during event dispatch.'); |
| 2 |
| 3 var mockEvent; |
| 4 function setMockLight(value) { |
| 5 |
| 6 mockEvent = {value: value}; |
| 7 |
| 8 if (window.testRunner) |
| 9 testRunner.setMockDeviceLight(null != mockEvent.value, null == mockEvent
.value ? 0 : mockEvent.value); |
| 10 else |
| 11 debug('This test can not be run without the TestRunner'); |
| 12 } |
| 13 |
| 14 |
| 15 var deviceMotionLight; |
| 16 function checkLight(event) { |
| 17 deviceLightEvent = event; |
| 18 shouldBe('deviceLightEvent.value', 'mockEvent.value'); |
| 19 } |
| 20 |
| 21 function firstListener(event) { |
| 22 checkLight(event); |
| 23 window.removeEventListener('devicelight', firstListener); |
| 24 window.addEventListener('devicelight', secondListener); |
| 25 setTimeout(function(){finish();}, 100); |
| 26 } |
| 27 |
| 28 var numSecondListenerCalls = 0; |
| 29 function secondListener(event) { |
| 30 ++numSecondListenerCalls; |
| 31 } |
| 32 |
| 33 function finish() { |
| 34 shouldBe('numSecondListenerCalls', '1'); |
| 35 finishJSTest(); |
| 36 } |
| 37 |
| 38 setMockLight(1, 10); |
| 39 window.addEventListener('devicelight', firstListener); |
| 40 |
| 41 window.jsTestIsAsync = true; |
OLD | NEW |