forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathgetCurrentPosition_visibility.https.html
42 lines (34 loc) · 1.56 KB
/
getCurrentPosition_visibility.https.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE HTML>
<meta charset='utf-8'>
<title>Geolocation Test: getCurrentPosition returns after visibilityState changes</title>
<link rel='help' href='http://www.w3.org/TR/geolocation-API/#get-current-position'>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<p>Clear all Geolocation permissions before running this test. If prompted for permission, please allow.</p>
<div id='log'></div>
<script>
setup(test_driver.set_permission({name: 'geolocation'}, 'granted', true));
promise_test(async t => {
assert_equals(document.visibilityState, "visible");
const gcp = new Promise(resolve => navigator.geolocation.getCurrentPosition(
p => resolve(pos),
e => resolve(e),
{timeout: 100, maximumAge: 0}))
await gcp;
const changed = new Promise(resolve => document.addEventListener("visibilitychange", resolve, {once:true}));
testRunner.setMainWindowHidden(true);
await changed;
assert_equals(document.visibilityState, "hidden");
const gcp2 = new Promise(resolve => navigator.geolocation.getCurrentPosition(
p => resolve(pos),
e => resolve(e),
{timeout: 100, maximumAge: 0}));
const changed2 = new Promise(resolve => document.addEventListener("visibilitychange", resolve, {once:true}));
testRunner.setMainWindowHidden(false);
await changed2;
assert_equals(document.visibilityState, "visible");
await gcp2;
}, "getCurrentPosition returns after visibilityState changes");
</script>