Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: LayoutTests/fast/dom/DeviceLight/page-visibility.html

Issue 490773003: [DeviceLight] Add Layout tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix tim's comments Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698