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 var deviceLightEvent; |
| 15 function checkLight(event) { |
| 16 deviceLightEvent = event; |
| 17 shouldBe('deviceLightEvent.value', 'mockEvent.value'); |
| 18 } |
| 19 |
| 20 function firstListener(event) { |
| 21 checkLight(event); |
| 22 window.removeEventListener('devicelight', firstListener); |
| 23 window.addEventListener('devicelight', secondListener); |
| 24 setTimeout(function(){finish();}, 100); |
| 25 } |
| 26 |
| 27 var numSecondListenerCalls = 0; |
| 28 function secondListener(event) { |
| 29 ++numSecondListenerCalls; |
| 30 } |
| 31 |
| 32 function finish() { |
| 33 shouldBe('numSecondListenerCalls', '1'); |
| 34 finishJSTest(); |
| 35 } |
| 36 |
| 37 setMockLight(10); |
| 38 window.addEventListener('devicelight', firstListener); |
| 39 |
| 40 window.jsTestIsAsync = true; |
OLD | NEW |