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

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

Issue 23705010: Add page visibility observer support for Device Motion (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Improve the test Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/fast/dom/DeviceMotion/page-visibility-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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()
34 {
35 testPassed("Received a devicemotion event");
36 window.removeEventListener('devicemotion', deviceMotionListener);
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 function deviceMotionListener(event) {
46 setTimeout(testWithPageHidden, 0);
47 }
48
49 if (window.testRunner)
50 testRunner.setMockDeviceMotion(true, 0, true, 0, true, 0,
51 true, 0, true, 0, true, 0,
52 true, 0, true, 0, true, 0,
53 0);
54
55 debug("* Page is visible");
56 window.addEventListener('devicemotion', deviceMotionListener);
57 </script>
58 <script src="../../js/resources/js-test-post.js"></script>
59 </body>
60 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/dom/DeviceMotion/page-visibility-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698