| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <body> | |
| 4 <script src="../../../resources/js-test.js"></script> | |
| 5 <script> | |
| 6 | |
| 7 description('Tests to check that devicelight events are not fired when the page
is not visible.'); | |
| 8 window.jsTestIsAsync = true; | |
| 9 | |
| 10 function succeedAndFinish() | |
| 11 { | |
| 12 testPassed("Received a devicelight event"); | |
| 13 setTimeout(finishJSTest, 0); | |
| 14 } | |
| 15 | |
| 16 function testWithPageVisible() | |
| 17 { | |
| 18 testPassed("Did not receive a devicelight event"); | |
| 19 window.removeEventListener('devicelight', failAndFinish); | |
| 20 testRunner.setPageVisibility("visible"); | |
| 21 debug("* Page is visible"); | |
| 22 window.addEventListener('devicelight', succeedAndFinish); | |
| 23 } | |
| 24 | |
| 25 function failAndFinish() | |
| 26 { | |
| 27 testFailed('Should not have received a devicelight event while the page was
hidden'); | |
| 28 setTimeout(finishJSTest, 0); | |
| 29 } | |
| 30 | |
| 31 function deviceLightListener(event) | |
| 32 { | |
| 33 testPassed("Received a devicelight event"); | |
| 34 window.removeEventListener('devicelight', deviceLightListener); | |
| 35 testRunner.setPageVisibility("hidden"); | |
| 36 debug("* Page is hidden"); | |
| 37 window.addEventListener('devicelight', failAndFinish); | |
| 38 | |
| 39 setTimeout(testWithPageVisible, 0); | |
| 40 } | |
| 41 | |
| 42 if (window.testRunner) | |
| 43 testRunner.setMockDeviceLight(100); | |
| 44 else | |
| 45 debug('This test can not be run without the TestRunner'); | |
| 46 | |
| 47 debug("* Page is visible"); | |
| 48 window.addEventListener('devicelight', deviceLightListener); | |
| 49 </script> | |
| 50 </body> | |
| 51 </html> | |
| OLD | NEW |