Chromium Code Reviews| 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 finishJSTest(); | |
|
riju_
2015/03/31 11:03:41
I guess it is better to use setTimeout(finishJSTes
| |
| 14 } | |
| 15 | |
| 16 function testWithPageVisible() | |
| 17 { | |
| 18 testPassed("Did not receive a devicelight event"); | |
| 19 window.removeEventListener('devicelight', failAndFinish); | |
| 20 if (window.testRunner) | |
|
timvolodine
2015/03/30 13:00:54
no need for this if you add a check for window.tes
riju_
2015/03/31 11:03:42
Done.
| |
| 21 testRunner.setPageVisibility("visible"); | |
| 22 debug("* Page is visible"); | |
| 23 window.addEventListener('devicelight', succeedAndFinish); | |
| 24 } | |
| 25 | |
| 26 function failAndFinish() | |
| 27 { | |
| 28 testFailed('Should not have received a devicelight event while the page was hidden'); | |
| 29 finishJSTest(); | |
|
timvolodine
2015/03/30 13:00:54
also better to use setTimeout(finishJSTest, 0); be
riju_
2015/03/31 11:03:41
Done.
| |
| 30 } | |
| 31 | |
| 32 function deviceLightListener(event) | |
| 33 { | |
| 34 testPassed("Received a devicelight event"); | |
| 35 window.removeEventListener('devicelight', deviceLightListener); | |
| 36 if (window.testRunner) | |
|
timvolodine
2015/03/30 13:00:55
same here
riju_
2015/03/31 11:03:41
Done.
| |
| 37 testRunner.setPageVisibility("hidden"); | |
| 38 debug("* Page is hidden"); | |
| 39 window.addEventListener('devicelight', failAndFinish); | |
| 40 | |
| 41 testWithPageVisible(); | |
|
timvolodine
2015/03/30 13:00:54
should use setTimeout(testWithPageVisible, 0); bec
riju_
2015/03/31 11:03:41
Done.
| |
| 42 } | |
| 43 | |
| 44 if (window.testRunner) | |
| 45 testRunner.setMockDeviceLight(100); | |
|
timvolodine
2015/03/30 13:00:54
nit: in other test you have debug('This test can n
riju_
2015/03/31 11:03:41
Done.
| |
| 46 | |
| 47 debug("* Page is visible"); | |
| 48 window.addEventListener('devicelight', deviceLightListener); | |
| 49 </script> | |
| 50 </body> | |
| 51 </html> | |
| OLD | NEW |