Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <html> | |
| 2 <head> | |
| 3 <script src="../../js/resources/js-test-pre.js"></script> | |
| 4 </head> | |
| 5 <body> | |
| 6 <script> | |
| 7 | |
| 8 description('Tests to check that devicemotion events are not fired when the page is not visible.'); | |
| 9 window.jsTestIsAsync = true; | |
| 10 | |
| 11 function succeedAndFinish() | |
| 12 { | |
| 13 testPassed("Received a devicemotion event"); | |
| 14 finishJSTest(); | |
| 15 } | |
| 16 | |
| 17 function testWithPageVisible() | |
| 18 { | |
| 19 testPassed("Did not receive a devicemotion event"); | |
| 20 window.removeEventListener('devicemotion', failAndFinish); | |
| 21 if (window.testRunner) | |
| 22 testRunner.setPageVisibility("visible"); | |
| 23 debug("* Page is visible"); | |
| 24 window.addEventListener('devicemotion', succeedAndFinish); | |
| 25 } | |
| 26 | |
| 27 function failAndFinish() | |
| 28 { | |
| 29 testFailed('Should not have received a devicemotion event while the page was hidden'); | |
| 30 finishJSTest(); | |
| 31 } | |
| 32 | |
| 33 function testWithPageHidden() | |
|
timvolodine
2013/09/18 13:49:21
this should be called via setTimeout 0, to make su
do-not-use
2013/09/18 14:04:39
Done.
| |
| 34 { | |
| 35 testPassed("Received a devicemotion event"); | |
| 36 window.removeEventListener('devicemotion', testWithPageHidden); | |
| 37 if (window.testRunner) | |
| 38 testRunner.setPageVisibility("hidden"); | |
| 39 debug("* Page is hidden"); | |
| 40 window.addEventListener('devicemotion', failAndFinish); | |
| 41 | |
| 42 setTimeout(testWithPageVisible, 100); | |
| 43 } | |
| 44 | |
| 45 if (window.testRunner) | |
| 46 testRunner.setMockDeviceMotion(true, 0, true, 0, true, 0, | |
| 47 true, 0, true, 0, true, 0, | |
| 48 true, 0, true, 0, true, 0, | |
| 49 0); | |
| 50 | |
| 51 debug("* Page is visible"); | |
| 52 window.addEventListener('devicemotion', testWithPageHidden); | |
| 53 </script> | |
| 54 <script src="../../js/resources/js-test-post.js"></script> | |
| 55 </body> | |
| 56 </html> | |
| OLD | NEW |