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

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

Issue 27368003: Add page visibility observer for Geolocation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix nit Created 7 years, 2 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/Geolocation/watchPosition-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 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../js/resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <script>
8 description("Tests that watchPosition does not report position changes when the page is not visible.");
9 window.jsTestIsAsync = true;
10
11 var mockLatitude = 51.478;
12 var mockLongitude = -0.166;
13 var mockAccuracy = 100.0;
14
15 debug("* Page is visible");
16
17 function updatePosition() {
18 if (!window.testRunner)
19 return;
20 ++mockLatitude;
21 ++mockLongitude;
22 testRunner.setMockGeolocationPosition(mockLatitude, mockLongitude, mockAccur acy);
23 debug('device moved to (' + mockLatitude + ', ' + mockLongitude + ')');
24 }
25
26 if (window.testRunner) {
27 testRunner.setGeolocationPermission(true);
28 updatePosition();
29 } else
30 debug('This test can not be run without the testRunner');
31
32 var state = 0;
33 var position;
34 var error;
35 var isPageVisible = true;
36
37 function checkPosition(p) {
38 position = p;
39 shouldBe('position.coords.latitude', '' + mockLatitude);
40 shouldBe('position.coords.longitude', '' + mockLongitude);
41 debug('');
42 }
43
44 function showPageAndUpdatePosition() {
45 shouldBeFalse('isPageVisible');
46 debug('');
47 state++;
48 if (window.testRunner) {
49 debug("*Showing page");
50 testRunner.setPageVisibility("visible");
51 isPageVisible = true;
52 }
53 updatePosition();
54 }
55
56 navigator.geolocation.watchPosition(function(p) {
57 debug("Page is notified of the position change");
58 shouldBeTrue('isPageVisible');
59 state++;
60 checkPosition(p);
61 switch(state) {
62 case 2: {
63 if (window.testRunner) {
64 debug("* Hiding page");
65 testRunner.setPageVisibility("hidden");
66 isPageVisible = false;
67 }
68 setTimeout(showPageAndUpdatePosition, 100);
69 break;
70 }
71 case 4:
72 finishJSTest();
73 return;
74 }
75 updatePosition();
76 }, function(e) {
77 testFailed('Error callback invoked unexpectedly');
78 finishJSTest();
79 });
80
81 </script>
82 <script src="../../js/resources/js-test-post.js"></script>
83 </body>
84 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/dom/Geolocation/watchPosition-page-visibility-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698