mirror of
https://github.com/servo/servo.git
synced 2025-08-26 07:38:21 +01:00
Update web-platform-tests to revision b'b728032f59a396243864b0f8584e7211e3632005'
This commit is contained in:
parent
ace9b32b1c
commit
df68c4e5d1
15632 changed files with 514865 additions and 155000 deletions
|
@ -1,101 +1,93 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset="utf-8">
|
||||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Geolocation Test: PositionOptions tests</title>
|
||||
<link rel="help" href="http://www.w3.org/TR/geolocation-API/#position_options_interface">
|
||||
<link
|
||||
rel="help"
|
||||
href="http://www.w3.org/TR/geolocation-API/#position_options_interface"
|
||||
/>
|
||||
<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>
|
||||
<script src='support.js'></script>
|
||||
|
||||
<script>
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00123
|
||||
test(function() {
|
||||
try {
|
||||
geo.getCurrentPosition(dummyFunction, null, {enableHighAccuracy: "boom"});
|
||||
geo.getCurrentPosition(dummyFunction, null, {enableHighAccuracy: 321});
|
||||
geo.getCurrentPosition(dummyFunction, null, {enableHighAccuracy: -Infinity});
|
||||
geo.getCurrentPosition(dummyFunction, null, {enableHighAccuracy: {foo: 5}});
|
||||
} catch(e) {
|
||||
assert_unreached('An exception was thrown unexpectedly: ' + e.message);
|
||||
}
|
||||
}, 'Call getCurrentPosition with wrong type for enableHighAccuracy. No exception expected.');
|
||||
const resetPermission = () => {
|
||||
return test_driver.set_permission({ name: "geolocation" }, "prompt");
|
||||
};
|
||||
const invalidValues = ["boom", 321, -Infinity, { foo: 5 }];
|
||||
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00124
|
||||
test(function() {
|
||||
try {
|
||||
geo.watchPosition(dummyFunction, null, {enableHighAccuracy: "boom"});
|
||||
geo.watchPosition(dummyFunction, null, {enableHighAccuracy: 321});
|
||||
geo.watchPosition(dummyFunction, null, {enableHighAccuracy: -Infinity});
|
||||
geo.watchPosition(dummyFunction, null, {enableHighAccuracy: {foo: 5}});
|
||||
} catch(e) {
|
||||
assert_unreached('An exception was thrown unexpectedly: ' + e.message);
|
||||
}
|
||||
}, 'Call watchPosition with wrong type for enableHighAccuracy. No exception expected.');
|
||||
promise_test(async (t) => {
|
||||
t.add_cleanup(resetPermission);
|
||||
await test_driver.set_permission({ name: "geolocation" }, "granted");
|
||||
for (const enableHighAccuracy of invalidValues) {
|
||||
navigator.geolocation.getCurrentPosition(() => {}, null, {
|
||||
enableHighAccuracy,
|
||||
});
|
||||
}
|
||||
}, "Call getCurrentPosition with wrong type for enableHighAccuracy. No exception expected.");
|
||||
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00086, 00088, 00091 and 00092
|
||||
promise_test(async function() {
|
||||
await test_driver.set_permission({name: 'geolocation'}, 'granted');
|
||||
promise_test(async (t) => {
|
||||
t.add_cleanup(resetPermission);
|
||||
await test_driver.set_permission({ name: "geolocation" }, "granted");
|
||||
for (const enableHighAccuracy of invalidValues) {
|
||||
const id = navigator.geolocation.watchPosition(() => {}, null, {
|
||||
enableHighAccuracy,
|
||||
});
|
||||
navigator.geolocation.clearWatch(id);
|
||||
}
|
||||
}, "Call watchPosition with wrong type for enableHighAccuracy. No exception expected.");
|
||||
|
||||
var t86 = async_test('Set timeout and maximumAge to 0, check that timeout error raised (getCurrentPosition)'),
|
||||
t88 = async_test('Set timeout and maximumAge to 0, check that timeout error raised (watchPosition)'),
|
||||
t91 = async_test('Check that a negative timeout value is equivalent to a 0 timeout value (getCurrentLocation)'),
|
||||
t92 = async_test('Check that a negative timeout value is equivalent to a 0 timeout value (watchPosition)');
|
||||
|
||||
try {
|
||||
geo.getCurrentPosition(
|
||||
t86.unreached_func('A success callback was invoked unexpectedly'),
|
||||
t86.step_func_done(function(err) {
|
||||
assert_equals(err.code, err.TIMEOUT);
|
||||
}),
|
||||
{timeout: 0, maximumAge: 0}
|
||||
);
|
||||
} catch(e) {
|
||||
t86.step(function() {
|
||||
assert_unreached('An exception was thrown unexpectedly: ' + e.message);
|
||||
promise_test(async (t) => {
|
||||
t.add_cleanup(resetPermission);
|
||||
await test_driver.set_permission({ name: "geolocation" }, "granted");
|
||||
const error = await new Promise((resolve, reject) => {
|
||||
navigator.geolocation.getCurrentPosition(reject, resolve, {
|
||||
timeout: 0,
|
||||
maxAge: 0,
|
||||
});
|
||||
});
|
||||
}
|
||||
assert_equals(error.code, GeolocationPositionError.TIMEOUT);
|
||||
}, "Set timeout and maximumAge to 0, check that timeout error raised (getCurrentPosition)");
|
||||
|
||||
try {
|
||||
geo.watchPosition(
|
||||
t88.unreached_func('A success callback was invoked unexpectedly'),
|
||||
t88.step_func_done(function(err) {
|
||||
assert_equals(err.code, err.TIMEOUT);
|
||||
}),
|
||||
{timeout: 0, maximumAge: 0}
|
||||
);
|
||||
} catch(e) {
|
||||
t88.step(function() {
|
||||
assert_unreached('An exception was thrown unexpectedly: ' + e.message);
|
||||
promise_test(async (t) => {
|
||||
t.add_cleanup(resetPermission);
|
||||
await test_driver.set_permission({ name: "geolocation" }, "granted");
|
||||
let watchId;
|
||||
const error = await new Promise((resolve, reject) => {
|
||||
watchId = navigator.geolocation.watchPosition(reject, resolve, {
|
||||
timeout: 0,
|
||||
maxAge: 0,
|
||||
});
|
||||
});
|
||||
}
|
||||
assert_equals(error.code, GeolocationPositionError.TIMEOUT);
|
||||
navigator.geolocation.clearWatch(watchId);
|
||||
}, "Set timeout and maximumAge to 0, check that timeout error raised (watchPosition)");
|
||||
|
||||
try {
|
||||
geo.getCurrentPosition(
|
||||
t91.unreached_func('A success callback was invoked unexpectedly'),
|
||||
t91.step_func_done(function(err) {
|
||||
assert_equals(err.code, err.TIMEOUT);
|
||||
}),
|
||||
{timeout:-1, maximumAge: 0}
|
||||
);
|
||||
} catch(e) {
|
||||
t91.step(function() {
|
||||
assert_unreached('An exception was thrown unexpectedly: ' + e.message);
|
||||
promise_test(async (t) => {
|
||||
t.add_cleanup(resetPermission);
|
||||
await test_driver.set_permission({ name: "geolocation" }, "granted");
|
||||
let watchId;
|
||||
const error = await new Promise((resolve, reject) => {
|
||||
watchId = navigator.geolocation.getCurrentPosition(reject, resolve, {
|
||||
timeout: -100,
|
||||
maxAge: -100,
|
||||
});
|
||||
});
|
||||
}
|
||||
assert_equals(error.code, GeolocationPositionError.TIMEOUT);
|
||||
navigator.geolocation.clearWatch(watchId);
|
||||
}, "Check that a negative timeout and maxAge values are clamped to 0 (getCurrentPosition)");
|
||||
|
||||
try {
|
||||
geo.watchPosition(
|
||||
t92.unreached_func('A success callback was invoked unexpectedly'),
|
||||
t92.step_func_done(function(err) {
|
||||
assert_equals(err.code, err.TIMEOUT);
|
||||
}),
|
||||
{timeout: -1, maximumAge: 0}
|
||||
);
|
||||
} catch(e) {
|
||||
t92.step(function() {
|
||||
assert_unreached('An exception was thrown unexpectedly: ' + e.message);
|
||||
promise_test(async (t) => {
|
||||
t.add_cleanup(resetPermission);
|
||||
await test_driver.set_permission({ name: "geolocation" }, "granted");
|
||||
let watchId;
|
||||
const error = await new Promise((resolve, reject) => {
|
||||
watchId = navigator.geolocation.watchPosition(reject, resolve, {
|
||||
timeout: -100,
|
||||
maxAge: -100,
|
||||
});
|
||||
});
|
||||
}
|
||||
}, 'PositionOptions tests');
|
||||
assert_equals(error.code, GeolocationPositionError.TIMEOUT);
|
||||
navigator.geolocation.clearWatch(watchId);
|
||||
}, "Check that a negative timeout and maxAge values are clamped to 0 (watchPosition)");
|
||||
</script>
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset='utf-8'>
|
||||
<title>Geolocation Test: clearWatch TypeError tests</title>
|
||||
<link rel='help' href='http://www.w3.org/TR/geolocation-API/#clear-watch'>
|
||||
<script src='/resources/testharness.js'></script>
|
||||
<script src='/resources/testharnessreport.js'></script>
|
||||
<script src='support.js'></script>
|
||||
|
||||
<div id='log'></div>
|
||||
|
||||
<script>
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00080
|
||||
test(function() {
|
||||
try {
|
||||
geo.clearWatch(-1);
|
||||
geo.clearWatch(0);
|
||||
geo.clearWatch(1);
|
||||
} catch(e) {
|
||||
assert_unreached('An exception was thrown unexpectedly: ' + e.message);
|
||||
}
|
||||
}, 'Test that calling clearWatch with invalid watch IDs does not cause an exception');
|
||||
</script>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Geolocation Test: clearWatch TypeError tests</title>
|
||||
<link rel="help" href="http://www.w3.org/TR/geolocation-API/#clear-watch" />
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
for (const invalidId of [NaN, -1, 0, 1, 2147483648, Infinity, -Infinity]) {
|
||||
test(() => {
|
||||
navigator.geolocation.clearWatch(invalidId);
|
||||
}, `Test that calling clearWatch with invalid watch ID (${invalidId}) does not cause an exception`);
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,71 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<body>
|
||||
<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>
|
||||
<script src="/feature-policy/resources/featurepolicy.js"></script>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
const same_origin_src =
|
||||
"/feature-policy/resources/feature-policy-geolocation.html";
|
||||
const cross_origin_src =
|
||||
"https://{{domains[www]}}:{{ports[https][0]}}" + same_origin_src;
|
||||
|
||||
promise_test(async (t) => {
|
||||
await test_driver.set_permission(
|
||||
{ name: "geolocation" },
|
||||
"granted",
|
||||
false
|
||||
);
|
||||
|
||||
const posError = await new Promise((resolve, reject) => {
|
||||
navigator.geolocation.getCurrentPosition(reject, resolve);
|
||||
});
|
||||
|
||||
assert_true(
|
||||
posError instanceof GeolocationPositionError,
|
||||
"Expected instance of GeolocationPositionError"
|
||||
);
|
||||
|
||||
assert_equals(
|
||||
posError.code,
|
||||
GeolocationPositionError.prototype.PERMISSION_DENIED,
|
||||
"Expected PERMISSION_DENIED"
|
||||
);
|
||||
|
||||
const watchError = await new Promise((resolve, reject) => {
|
||||
navigator.geolocation.watchPosition(reject, resolve);
|
||||
});
|
||||
assert_true(
|
||||
watchError instanceof GeolocationPositionError,
|
||||
"Expected instance of GeolocationPositionError"
|
||||
);
|
||||
assert_equals(
|
||||
watchError.code,
|
||||
GeolocationPositionError.prototype.PERMISSION_DENIED,
|
||||
"Expected PERMISSION_DENIED"
|
||||
);
|
||||
}, "Feature-Policy header geolocation : 'none' disallows the top-level document.");
|
||||
|
||||
async_test((t) => {
|
||||
test_feature_availability(
|
||||
"geolocation",
|
||||
t,
|
||||
same_origin_src,
|
||||
expect_feature_unavailable_default
|
||||
);
|
||||
}, "Feature-Policy header geolocation : 'none' disallows same-origin iframes.");
|
||||
|
||||
async_test((t) => {
|
||||
test_feature_availability(
|
||||
"geolocation",
|
||||
t,
|
||||
cross_origin_src,
|
||||
expect_feature_unavailable_default
|
||||
);
|
||||
}, "Feature-Policy header geolocation 'none' disallows cross-origin iframes.");
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1 @@
|
|||
Feature-Policy: geolocation 'none'
|
|
@ -0,0 +1,36 @@
|
|||
<!DOCTYPE html>
|
||||
<body>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/feature-policy/resources/featurepolicy.js"></script>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
const relative_path = "/feature-policy/resources/feature-policy-geolocation.html";
|
||||
const base_src = "/feature-policy/resources/redirect-on-load.html#";
|
||||
const same_origin_src = base_src + relative_path;
|
||||
const cross_origin_src =
|
||||
base_src + "https://{{domains[www]}}:{{ports[https][0]}}" + relative_path;
|
||||
|
||||
async_test(t => {
|
||||
test_feature_availability(
|
||||
'geolocation',
|
||||
t,
|
||||
same_origin_src,
|
||||
expect_feature_available_default,
|
||||
"geolocation"
|
||||
);
|
||||
}, 'Feature-Policy allow="geolocation" allows same-origin relocation');
|
||||
|
||||
async_test(t => {
|
||||
test_feature_availability(
|
||||
'geolocation',
|
||||
t,
|
||||
cross_origin_src,
|
||||
expect_feature_unavailable_default,
|
||||
"geolocation"
|
||||
);
|
||||
}, 'Feature-Policy allow="geolocation" disallows cross-origin relocation');
|
||||
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1,34 @@
|
|||
<!DOCTYPE html>
|
||||
<body>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/feature-policy/resources/featurepolicy.js"></script>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
const same_origin_src =
|
||||
"/feature-policy/resources/feature-policy-geolocation.html";
|
||||
const cross_origin_src =
|
||||
"https://{{domains[www]}}:{{ports[https][0]}}" + same_origin_src;
|
||||
|
||||
async_test(t => {
|
||||
test_feature_availability(
|
||||
"geolocation",
|
||||
t,
|
||||
same_origin_src,
|
||||
expect_feature_available_default,
|
||||
"geolocation"
|
||||
);
|
||||
}, 'Feature policy "geolocation" can be enabled in same-origin iframe using allow="geolocation" attribute');
|
||||
|
||||
async_test(t => {
|
||||
test_feature_availability(
|
||||
"geolocation",
|
||||
t,
|
||||
cross_origin_src,
|
||||
expect_feature_available_default,
|
||||
"geolocation"
|
||||
);
|
||||
}, 'Feature policy "geolocation" can be enabled in cross-origin iframe using allow="geolocation" attribute');
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1,51 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<body>
|
||||
<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>
|
||||
<script src="/feature-policy/resources/featurepolicy.js"></script>
|
||||
<script>
|
||||
const same_origin_src =
|
||||
"/feature-policy/resources/feature-policy-geolocation.html";
|
||||
const cross_origin_src =
|
||||
"https://{{domains[www]}}:{{ports[https][0]}}" + same_origin_src;
|
||||
|
||||
promise_test(async (t) => {
|
||||
|
||||
await test_driver.set_permission(
|
||||
{ name: "geolocation" },
|
||||
"granted",
|
||||
false
|
||||
);
|
||||
|
||||
const result = await new Promise((resolve, reject) => {
|
||||
navigator.geolocation.getCurrentPosition(resolve, reject);
|
||||
});
|
||||
|
||||
assert_true(
|
||||
result instanceof GeolocationPosition,
|
||||
"Expected a GeolocationPosition"
|
||||
);
|
||||
}, "Feature-Policy header geolocation: * allows the top-level document.");
|
||||
|
||||
async_test((t) => {
|
||||
test_feature_availability(
|
||||
"geolocation",
|
||||
t,
|
||||
same_origin_src,
|
||||
expect_feature_available_default
|
||||
);
|
||||
}, "Feature-Policy header geolocation: * allows same-origin iframes.");
|
||||
|
||||
async_test((t) => {
|
||||
test_feature_availability(
|
||||
"geolocation",
|
||||
t,
|
||||
cross_origin_src,
|
||||
expect_feature_available_default
|
||||
);
|
||||
}, "Feature-Policy header geolocation: * allows cross-origin iframes.");
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1 @@
|
|||
Feature-Policy: geolocation *
|
|
@ -0,0 +1,46 @@
|
|||
<!DOCTYPE html>
|
||||
<body>
|
||||
<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>
|
||||
<script src="/feature-policy/resources/featurepolicy.js"></script>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
const same_origin_src =
|
||||
"/feature-policy/resources/feature-policy-geolocation.html";
|
||||
const cross_origin_src =
|
||||
"https://{{domains[www]}}:{{ports[https][0]}}" + same_origin_src;
|
||||
|
||||
promise_test(async (t) => {
|
||||
await test_driver.set_permission(
|
||||
{ name: "geolocation" },
|
||||
"granted",
|
||||
false
|
||||
);
|
||||
await new Promise(resolve => {
|
||||
navigator.geolocation.getCurrentPosition(resolve);
|
||||
})
|
||||
}, 'Feature-Policy header geolocation "self" allows the top-level document.');
|
||||
|
||||
async_test((t) => {
|
||||
test_feature_availability(
|
||||
"geolocation",
|
||||
t,
|
||||
same_origin_src,
|
||||
expect_feature_available_default
|
||||
);
|
||||
}, 'Feature-Policy header geolocation "self" allows same-origin iframes.');
|
||||
|
||||
async_test((t) => {
|
||||
test_feature_availability(
|
||||
"geolocation",
|
||||
t,
|
||||
cross_origin_src,
|
||||
expect_feature_unavailable_default
|
||||
);
|
||||
}, 'Feature-Policy header geolocation "self" disallows cross-origin iframes.');
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1 @@
|
|||
Feature-Policy: geolocation 'self'
|
|
@ -1,151 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset="utf-8">
|
||||
<meta name=timeout content=long>
|
||||
<title>Geolocation Test: getCurrentPosition tests</title>
|
||||
<link rel="help" href="http://www.w3.org/TR/geolocation-API/">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<p>Clear all Geolocation permissions before running this test. If prompted for permission, please allow.</p>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
var geo, success, fail;
|
||||
|
||||
setup(function() {
|
||||
geo = navigator.geolocation;
|
||||
}, {explicit_done: true});
|
||||
|
||||
function successCallback(position)
|
||||
{
|
||||
var ii, oldval;
|
||||
|
||||
/*
|
||||
interface GeolocationPosition {
|
||||
readonly attribute GeolocationCoordinates coords;
|
||||
readonly attribute DOMTimeStamp timestamp;
|
||||
};
|
||||
*/
|
||||
|
||||
test(function() {
|
||||
assert_equals(position.toString(), "[object GeolocationPosition]",
|
||||
"position.toString should result in '[object GeolocationPosition]' was: " + position.toString());
|
||||
}, "GeolocationPosition toString");
|
||||
|
||||
test(function() {
|
||||
assert_equals(position.coords.toString(), "[object GeolocationCoordinates]",
|
||||
"position.coords.toString should result in '[object GeolocationCoordinates]' was: " + position.coords.toString());
|
||||
}, "GeolocationCoordinates toString");
|
||||
|
||||
test(function() {
|
||||
assert_equals(typeof(position.timestamp), "number",
|
||||
"position.timestamp should be of type 'number' was: " + typeof(position.timestamp));
|
||||
}, "GeolocationPosition.timestamp is type number");
|
||||
|
||||
/*
|
||||
interface GeolocationCoordinates {
|
||||
readonly attribute double latitude;
|
||||
readonly attribute double longitude;
|
||||
readonly attribute double? altitude;
|
||||
readonly attribute double accuracy;
|
||||
readonly attribute double? altitudeAccuracy;
|
||||
readonly attribute double? heading;
|
||||
readonly attribute double? speed;
|
||||
};
|
||||
*/
|
||||
|
||||
for (ii in position.coords) {
|
||||
// these four can be numbers or null
|
||||
if (ii == "altitude" || ii == "altitudeAccuracy" || ii == "heading" || ii == "speed") {
|
||||
test(function() {
|
||||
assert_true(position.coords[ii] === null || typeof(position.coords[ii]) === "number",
|
||||
ii + " must be null or 'number' type, was: " + typeof(position.coords[ii]));
|
||||
}, ii+ " is null or number");
|
||||
} else {
|
||||
test(function() {
|
||||
assert_equals(typeof(position.coords[ii]), "number",
|
||||
ii + " should be type 'number' but typeof returned: " + typeof(position.coords[ii]));
|
||||
}, ii + " is type number");
|
||||
}
|
||||
|
||||
oldval = position.coords[ii];
|
||||
position.coords[ii] = 666;
|
||||
|
||||
test(function() {
|
||||
assert_equals(position.coords[ii], oldval,
|
||||
ii + " should be readonly, wrote: " + position.coords[ii] + " old value was " + oldval);
|
||||
}, ii + " readonly");
|
||||
|
||||
}
|
||||
|
||||
success.done();
|
||||
done();
|
||||
}
|
||||
|
||||
function BadErrorCallback(error)
|
||||
{
|
||||
success.step(function() {
|
||||
assert_unreached("Error callback called in error");
|
||||
});
|
||||
success.done();
|
||||
done();
|
||||
}
|
||||
|
||||
function BadSuccessCallback(position)
|
||||
{
|
||||
fail.step(function() {
|
||||
assert_unreached("Success callback called in error");
|
||||
});
|
||||
fail.done();
|
||||
}
|
||||
|
||||
function errorCallback(error)
|
||||
{
|
||||
test(function() {
|
||||
assert_equals(error.toString(), "[object GeolocationPositionError]",
|
||||
"error.toString should result in '[object GeolocationPositionError]' was: " +
|
||||
error.toString());
|
||||
}, "GeolocationPositionError toString");
|
||||
|
||||
test(function() {
|
||||
assert_equals(error.PERMISSION_DENIED, 1,
|
||||
"PERMISSION_DENIED should be 1 was: " + error.POSITION_DENIED);
|
||||
}, "PERMISSION_DENIED value is 1");
|
||||
|
||||
test(function() {
|
||||
assert_equals(error.POSITION_UNAVAILABLE, 2,
|
||||
"POSITION_UNAVAILABLE should be 2' was: " + error.POSITION_UNAVAILABLE);
|
||||
}, "POSITION_UNAVAILABLE is 2");
|
||||
|
||||
test(function() {
|
||||
assert_equals(error.TIMEOUT, 3,
|
||||
"TIMEOUT should be 3 was: " + error.TIMEOUT);
|
||||
}, "TIMEOUT value is 3");
|
||||
|
||||
fail.done();
|
||||
}
|
||||
|
||||
success = async_test("getCurrentPosition success callback tests");
|
||||
|
||||
// with a longer timeout and with the user accepting the position request,
|
||||
// this should test the successcallback
|
||||
success.step(function() {
|
||||
geo.getCurrentPosition(
|
||||
successCallback,
|
||||
BadErrorCallback,
|
||||
{maximumAge:600000, timeout:10000}
|
||||
);
|
||||
});
|
||||
|
||||
fail = async_test("getCurrentPosition error callback tests");
|
||||
|
||||
// with a timeout of 0 the error callback is hopefully consistently called
|
||||
fail.step(function() {
|
||||
geo.getCurrentPosition(
|
||||
BadSuccessCallback,
|
||||
errorCallback,
|
||||
{maximumAge:00, timeout:0}
|
||||
);
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
@ -4,52 +4,58 @@
|
|||
<link rel='help' href='http://www.w3.org/TR/geolocation-API/'>
|
||||
<script src='/resources/testharness.js'></script>
|
||||
<script src='/resources/testharnessreport.js'></script>
|
||||
<script src='support.js'></script>
|
||||
|
||||
<div id='log'></div>
|
||||
|
||||
<script>
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00027
|
||||
test(function() {
|
||||
assert_throws_js(TypeError, function() {
|
||||
geo.getCurrentPosition();
|
||||
navigator.geolocation.getCurrentPosition();
|
||||
});
|
||||
}, 'Call getCurrentPosition without arguments, check that exception is thrown');
|
||||
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00011
|
||||
test(function() {
|
||||
assert_throws_js(TypeError, function() {
|
||||
geo.getCurrentPosition(null);
|
||||
navigator.geolocation.getCurrentPosition(null);
|
||||
});
|
||||
}, 'Call getCurrentPosition with null success callback, check that exception is thrown');
|
||||
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00013
|
||||
test(function() {
|
||||
assert_throws_js(TypeError, function() {
|
||||
geo.getCurrentPosition(null, null);
|
||||
navigator.geolocation.getCurrentPosition(null, null);
|
||||
});
|
||||
}, 'Call getCurrentPosition with null success and error callbacks, check that exception is thrown');
|
||||
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00028
|
||||
test(function() {
|
||||
assert_throws_js(TypeError, function() {
|
||||
geo.getCurrentPosition(3);
|
||||
navigator.geolocation.getCurrentPosition(3);
|
||||
});
|
||||
}, 'Call getCurrentPosition() with wrong type for first argument. Exception expected.');
|
||||
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00029
|
||||
test(function() {
|
||||
assert_throws_js(TypeError, function() {
|
||||
geo.getCurrentPosition(dummyFunction, 4);
|
||||
navigator.geolocation.getCurrentPosition(()=>{}, 4);
|
||||
});
|
||||
}, 'Call getCurrentPosition() with wrong type for second argument. Exception expected.');
|
||||
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00030
|
||||
test(function() {
|
||||
assert_throws_js(TypeError, function() {
|
||||
geo.getCurrentPosition(dummyFunction, dummyFunction, 4);
|
||||
navigator.geolocation.getCurrentPosition(()=>{}, ()=>{}, 4);
|
||||
});
|
||||
}, 'Call getCurrentPosition() with wrong type for third argument. Exception expected.');
|
||||
|
||||
done();
|
||||
test(function () {
|
||||
const handleEvent = ()=>{};
|
||||
assert_throws_js(TypeError, function () {
|
||||
navigator.geolocation.getCurrentPosition({ handleEvent });
|
||||
});
|
||||
|
||||
assert_throws_js(TypeError, function () {
|
||||
navigator.geolocation.getCurrentPosition(()=>{}, { handleEvent });
|
||||
});
|
||||
}, "Calling getCurrentPosition() with a legacy event handler objects.");
|
||||
</script>
|
|
@ -1,21 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset='utf-8'>
|
||||
<title>Call getCurrentPosition, check that there is UI appearing with the document host</title>
|
||||
<link rel='help' href='http://www.w3.org/TR/geolocation-API/#privacy_for_uas'>
|
||||
|
||||
<p>Clear all Geolocation permissions before running this test.</p>
|
||||
|
||||
<p>Test passes if there is a permission prompt including the host <strong id='host'></strong> and no FAIL.</p>
|
||||
<div id='log'></div>
|
||||
|
||||
<script>
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00018
|
||||
try {
|
||||
var dummyFunction = function() {};
|
||||
window.navigator.geolocation.getCurrentPosition(dummyFunction, dummyFunction);
|
||||
|
||||
document.getElementById('host').innerHTML = window.location.hostname;
|
||||
} catch (e) {
|
||||
document.getElementById('log').innerHTML = 'FAIL: an exception was thrown unexpectedly: ' + e.message;
|
||||
}
|
||||
</script>
|
|
@ -1,32 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset='utf-8'>
|
||||
<title>User asked to approve/remember, then asked to revoke, then reload. The permission dialogue should reappear</title>
|
||||
<link rel='help' href='http://www.w3.org/TR/geolocation-API/#get-current-position'>
|
||||
|
||||
<p>Clear all Geolocation permissions before running this test. If prompted for permission, please allow.</p>
|
||||
|
||||
<div id='log'></div>
|
||||
|
||||
<script>
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00141
|
||||
var nextStep, onError, isUsingPreemptivePermission = false;
|
||||
|
||||
nextStep = function() {
|
||||
document.querySelector('p').innerHTML =
|
||||
'Now revoke permissions for this origin (where applicable) and reload the page. Tests passes if there is a permission prompt again and no FAIL.';
|
||||
};
|
||||
|
||||
onError = function(err) {
|
||||
if (!isUsingPreemptivePermission && err.code === err.POSITION_UNAVAILABLE) {
|
||||
nextStep();
|
||||
} else {
|
||||
document.getElementById('log').innerHTML = 'FAIL: an error callback was invoked unexpectedly: ' + err.message;
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
window.navigator.geolocation.getCurrentPosition(nextStep, onError);
|
||||
} catch (e) {
|
||||
document.getElementById('log').innerHTML = 'FAIL: an exception was thrown unexpectedly: ' + e.message;
|
||||
}
|
||||
</script>
|
|
@ -1,34 +1,52 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset='utf-8'>
|
||||
<title>Geolocation Test: getCurrentPosition location access allowed</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='support.js'></script>
|
||||
|
||||
<p>Clear all Geolocation permissions before running this test. If prompted for permission, please allow.</p>
|
||||
<div id='log'></div>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Geolocation Test: getCurrentPosition() location access</title>
|
||||
<link
|
||||
rel="help"
|
||||
href="https://www.w3.org/TR/geolocation/#getcurrentposition-method"
|
||||
/>
|
||||
<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>
|
||||
<script>
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00002
|
||||
var t = async_test('User allows access, check that success callback is called or error callback is called with correct code.'),
|
||||
onSuccess, onError, hasMethodReturned = false;
|
||||
|
||||
t.step(function() {
|
||||
onSuccess = t.step_func_done(function(pos) {
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00031
|
||||
assert_true(hasMethodReturned);
|
||||
});
|
||||
|
||||
onError = t.step_func_done(function(err) {
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00031
|
||||
assert_true(hasMethodReturned);
|
||||
assert_false(isUsingPreemptivePermission);
|
||||
assert_equals(err.code, err.POSITION_UNAVAILABLE, errorToString(err));
|
||||
});
|
||||
|
||||
geo.getCurrentPosition(onSuccess, onError);
|
||||
hasMethodReturned = true;
|
||||
});
|
||||
promise_test(async (t) => {
|
||||
t.add_cleanup(() => {
|
||||
return test_driver.set_permission({ name: "geolocation" }, "prompt");
|
||||
});
|
||||
await test_driver.set_permission({ name: "geolocation" }, "granted");
|
||||
const position = await new Promise((resolve, reject) => {
|
||||
let calledAsync = false;
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
t.step_func((position) => {
|
||||
assert_true(calledAsync, "Expected callback to be called asynchronously")
|
||||
resolve(position);
|
||||
}),
|
||||
reject
|
||||
);
|
||||
calledAsync = true;
|
||||
});
|
||||
assert_true(
|
||||
position instanceof GeolocationPosition,
|
||||
"Expected GeolocationPosition"
|
||||
);
|
||||
}, "User allows access, check that success callback is called.");
|
||||
|
||||
promise_test(async (t) => {
|
||||
t.add_cleanup(() => {
|
||||
return test_driver.set_permission({ name: "geolocation" }, "prompt");
|
||||
});
|
||||
await test_driver.set_permission({ name: "geolocation" }, "granted");
|
||||
const position = await new Promise((resolve, reject) => {
|
||||
try {
|
||||
navigator.geolocation.getCurrentPosition(resolve, null);
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
assert_true(
|
||||
position instanceof GeolocationPosition,
|
||||
"Expected GeolocationPosition"
|
||||
);
|
||||
}, "Error callback is nullable for getCurrentPosition().");
|
||||
</script>
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset='utf-8'>
|
||||
<title>User asked to deny/remember, then asked to revoke, then reload. The permission dialogue should reappear</title>
|
||||
<link rel='help' href='http://www.w3.org/TR/geolocation-API/#get-current-position'>
|
||||
|
||||
<p>Clear all Geolocation permissions before running this test. If prompted for permission, please deny.</p>
|
||||
|
||||
<div id='log'></div>
|
||||
|
||||
<script>
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00142
|
||||
var onSuccess, nextStep, isUsingPreemptivePermission = false;
|
||||
|
||||
onSuccess = function() {
|
||||
document.getElementById('log').innerHTML = 'FAIL: a success callback was invoked unexpectedly.';
|
||||
};
|
||||
|
||||
nextStep = function(err) {
|
||||
if ((err.code === err.PERMISSION_DENIED) ||
|
||||
(!isUsingPreemptivePermission && err.code === err.POSITION_UNAVAILABLE)) {
|
||||
document.querySelector('p').innerHTML =
|
||||
'Now revoke permissions for this origin (where applicable) and reload the page. Tests passes if there is a permission prompt again and no FAIL.';
|
||||
} else {
|
||||
document.getElementById('log').innerHTML =
|
||||
'FAIL: an error callback was invoked with unexpected error code: ' + err.code + ', error message: ' + err.message;
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
navigator.geolocation.getCurrentPosition(onSuccess, nextStep);
|
||||
} catch (e) {
|
||||
document.getElementById('log').innerHTML = 'FAIL: an exception was thrown unexpectedly: ' + e.message;
|
||||
}
|
||||
</script>
|
|
@ -1,32 +1,29 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset='utf-8'>
|
||||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Geolocation Test: getCurrentPosition location access denied</title>
|
||||
<link rel='help' href='http://www.w3.org/TR/geolocation-API/#privacy_for_uas'>
|
||||
<script src='/resources/testharness.js'></script>
|
||||
<script src='/resources/testharnessreport.js'></script>
|
||||
<script src='support.js'></script>
|
||||
|
||||
<p>Clear all Geolocation permissions before running this test. If prompted for permission, please deny.</p>
|
||||
<div id='log'></div>
|
||||
|
||||
<link rel="help" href="http://www.w3.org/TR/geolocation-API/#privacy_for_uas" />
|
||||
<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>
|
||||
<script>
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00001
|
||||
var t = async_test('User denies access, check that error callback is called with correct code'),
|
||||
onSuccess, onError, hasMethodReturned = false;
|
||||
|
||||
t.step(function() {
|
||||
onSuccess = t.step_func_done(function(pos) {
|
||||
assert_unreached('A success callback was invoked unexpectedly with position ' + positionToString(pos));
|
||||
});
|
||||
|
||||
onError = t.step_func_done(function(err) {
|
||||
// http://dev.w3.org/geo/api/test-suite/t.html?00031
|
||||
assert_true(hasMethodReturned, 'Check that getCurrentPosition returns synchronously before any callbacks are invoked');
|
||||
assert_equals(err.code, err.PERMISSION_DENIED, errorToString(err));
|
||||
});
|
||||
|
||||
geo.getCurrentPosition(onSuccess, onError);
|
||||
hasMethodReturned = true;
|
||||
});
|
||||
|
||||
promise_test(async (t) => {
|
||||
t.add_cleanup(() => {
|
||||
return test_driver.set_permission({ name: "geolocation" }, "prompt");
|
||||
});
|
||||
await test_driver.set_permission({ name: "geolocation" }, "denied");
|
||||
const error = await new Promise((resolve, reject) => {
|
||||
let calledAsync = false;
|
||||
navigator.geolocation.getCurrentPosition(reject, t.step_func((error) => {
|
||||
assert_true(calledAsync, "Expected callback to be called asynchronously");
|
||||
resolve(error);
|
||||
}));
|
||||
calledAsync = true;
|
||||
});
|
||||
assert_true(
|
||||
error instanceof GeolocationPositionError,
|
||||
"should be a GeolocationPositionError"
|
||||
);
|
||||
assert_equals(error.code, error.PERMISSION_DENIED);
|
||||
}, "User denies access, check that error callback is called with correct code");
|
||||
</script>
|
||||
|
|
|
@ -1,17 +1,28 @@
|
|||
// META: script=/resources/WebIDLParser.js
|
||||
// META: script=/resources/idlharness.js
|
||||
// META: script=/resources/testdriver.js
|
||||
// META: script=/resources/testdriver-vendor.js
|
||||
|
||||
// https://www.w3.org/TR/geolocation-API/
|
||||
|
||||
idl_test(
|
||||
['geolocation'],
|
||||
['hr-time', 'html'],
|
||||
idl_array => {
|
||||
self.audio = document.createElement('audio');
|
||||
self.video = document.createElement('video');
|
||||
window.onload = async () => {
|
||||
await test_driver.set_permission({ name: "geolocation" }, "denied");
|
||||
const positionError = await new Promise((resolve, reject) => {
|
||||
navigator.geolocation.getCurrentPosition(reject, resolve);
|
||||
});
|
||||
|
||||
await test_driver.set_permission({ name: "geolocation" }, "granted");
|
||||
const position = await new Promise((resolve, reject) => {
|
||||
navigator.geolocation.getCurrentPosition(resolve, reject);
|
||||
});
|
||||
|
||||
idl_test(["geolocation"], ["hr-time", "html"], (idl_array) => {
|
||||
idl_array.add_objects({
|
||||
Navigator: ['navigator'],
|
||||
Geolocation: ['navigator.geolocation'],
|
||||
Navigator: ["navigator"],
|
||||
Geolocation: ["navigator.geolocation"],
|
||||
GeolocationPositionError: [positionError],
|
||||
GeolocationPosition: [position],
|
||||
GeolocationCoordinates: [position.coords],
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -9,7 +9,10 @@
|
|||
<script src="support.js"></script>
|
||||
<body></body>
|
||||
<script>
|
||||
promise_test(async function () {
|
||||
promise_test(async (t) => {
|
||||
t.add_cleanup(() => {
|
||||
return test_driver.set_permission({ name: "geolocation" }, "prompt");
|
||||
});
|
||||
await test_driver.set_permission({ name: "geolocation" }, "granted");
|
||||
|
||||
// Create the iframe, wait for it to load...
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>Test geolocation is a powerful feature via Permissions API</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
|
||||
<script>
|
||||
promise_test(async (test) => {
|
||||
const status = await navigator.permissions.query({ name: "geolocation" });
|
||||
assert_true(status instanceof PermissionStatus);
|
||||
assert_equals(status.name, "geolocation", `permission's name must be "geolocation"`);
|
||||
assert_equals(status.state, "prompt", `permission's state must be "prompt" by default`);
|
||||
}, `Query "geolocation" powerful feature`);
|
||||
</script>
|
|
@ -1,55 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset='utf-8'>
|
||||
<title>Geolocation Test: watchPosition TypeError tests</title>
|
||||
<link rel='help' href='http://www.w3.org/TR/geolocation-API/'>
|
||||
<script src='/resources/testharness.js'></script>
|
||||
<script src='/resources/testharnessreport.js'></script>
|
||||
<script src='support.js'></script>
|
||||
|
||||
<div id='log'></div>
|
||||
|
||||
<script>
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00058
|
||||
test(function() {
|
||||
assert_throws_js(TypeError, function() {
|
||||
geo.watchPosition();
|
||||
});
|
||||
}, 'Call watchPosition without arguments, check that exception is thrown');
|
||||
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00015
|
||||
test(function() {
|
||||
assert_throws_js(TypeError, function() {
|
||||
geo.watchPosition(null);
|
||||
});
|
||||
}, 'Call watchPosition with null success callback, check that exception is thrown');
|
||||
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00017
|
||||
test(function() {
|
||||
assert_throws_js(TypeError, function() {
|
||||
geo.watchPosition(null, null);
|
||||
});
|
||||
}, 'Call watchPosition with null success and error callbacks, check that exception is thrown');
|
||||
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00059
|
||||
test(function() {
|
||||
assert_throws_js(TypeError, function() {
|
||||
geo.watchPosition(3);
|
||||
});
|
||||
}, 'Call watchPosition() with wrong type for first argument. Exception expected.');
|
||||
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00060
|
||||
test(function() {
|
||||
assert_throws_js(TypeError, function() {
|
||||
geo.watchPosition(dummyFunction, 4);
|
||||
});
|
||||
}, 'Call watchPosition() with wrong type for second argument. Exception expected.');
|
||||
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00061
|
||||
test(function() {
|
||||
assert_throws_js(TypeError, function() {
|
||||
geo.watchPosition(dummyFunction, dummyFunction, 4);
|
||||
});
|
||||
}, 'Call watchPosition() with wrong type for third argument. Exception expected.');
|
||||
|
||||
done();
|
||||
</script>
|
|
@ -0,0 +1,65 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Geolocation Test: watchPosition TypeError tests</title>
|
||||
<link rel="help" href="http://www.w3.org/TR/geolocation-API/" />
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
|
||||
<script>
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00058
|
||||
test(() => {
|
||||
assert_throws_js(TypeError, () => {
|
||||
navigator.geolocation.watchPosition();
|
||||
});
|
||||
}, "Call watchPosition without arguments, check that exception is thrown");
|
||||
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00015
|
||||
test(() => {
|
||||
assert_throws_js(TypeError, () => {
|
||||
navigator.geolocation.watchPosition(null);
|
||||
});
|
||||
}, "Call watchPosition with null success callback, check that exception is thrown");
|
||||
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00017
|
||||
test(() => {
|
||||
assert_throws_js(TypeError, () => {
|
||||
navigator.geolocation.watchPosition(null, null);
|
||||
});
|
||||
}, "Call watchPosition with null success and error callbacks, check that exception is thrown");
|
||||
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00059
|
||||
test(() => {
|
||||
assert_throws_js(TypeError, () => {
|
||||
navigator.geolocation.watchPosition(3);
|
||||
});
|
||||
}, "Call watchPosition() with wrong type for first argument. Exception expected.");
|
||||
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00060
|
||||
test(() => {
|
||||
assert_throws_js(TypeError, () => {
|
||||
navigator.geolocation.watchPosition(() => {}, 4);
|
||||
});
|
||||
}, "Call watchPosition() with wrong type for second argument. Exception expected.");
|
||||
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00061
|
||||
test(() => {
|
||||
assert_throws_js(TypeError, () => {
|
||||
navigator.geolocation.watchPosition(
|
||||
() => {},
|
||||
() => {},
|
||||
4
|
||||
);
|
||||
});
|
||||
}, "Call watchPosition() with wrong type for third argument. Exception expected.");
|
||||
|
||||
test(function () {
|
||||
const handleEvent = function(){};
|
||||
assert_throws_js(TypeError, function () {
|
||||
navigator.geolocation.watchPosition({ handleEvent });
|
||||
});
|
||||
|
||||
assert_throws_js(TypeError, function () {
|
||||
navigator.geolocation.watchPosition(()=>{}, { handleEvent });
|
||||
});
|
||||
}, "Calling watchPosition() with a legacy event handler object.");
|
||||
</script>
|
|
@ -1,21 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset='utf-8'>
|
||||
<title>Call watchPosition, check that there is UI appearing with the document host</title>
|
||||
<link rel='help' href='http://www.w3.org/TR/geolocation-API/#privacy_for_uas'>
|
||||
|
||||
<p>Clear all Geolocation permissions before running this test.</p>
|
||||
|
||||
<p>Test passes if there is a permission prompt including the host <strong id='host'></strong> and no FAIL.</p>
|
||||
<div id='log'></div>
|
||||
|
||||
<script>
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00019
|
||||
try {
|
||||
var dummyFunction = function() {};
|
||||
window.navigator.geolocation.watchPosition(dummyFunction, dummyFunction);
|
||||
|
||||
document.getElementById('host').innerHTML = window.location.hostname;
|
||||
} catch (e) {
|
||||
document.getElementById('log').innerHTML = 'FAIL: ' + e.message;
|
||||
}
|
||||
</script>
|
|
@ -1,33 +1,45 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset='utf-8'>
|
||||
<!DOCTYPE html>
|
||||
<meta charset="utf-8" />
|
||||
<title>Geolocation Test: watchPosition location access denied</title>
|
||||
<link rel='help' href='http://www.w3.org/TR/geolocation-API/#watch-position'>
|
||||
<script src='/resources/testharness.js'></script>
|
||||
<script src='/resources/testharnessreport.js'></script>
|
||||
<script src='support.js'></script>
|
||||
|
||||
<p>Clear all Geolocation permissions before running this test. If prompted for permission, please deny.</p>
|
||||
<div id='log'></div>
|
||||
|
||||
<link rel="help" href="http://www.w3.org/TR/geolocation-API/#privacy_for_uas" />
|
||||
<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>
|
||||
<script>
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00062
|
||||
var t = async_test('Check that watchPosition returns synchronously before any callbacks are invoked.'),
|
||||
id, checkMethodHasReturned, hasMethodReturned = false;
|
||||
const resetPermission = () => {
|
||||
return test_driver.set_permission({ name: "geolocation" }, "prompt");
|
||||
};
|
||||
|
||||
checkMethodHasReturned = t.step_func_done(function() {
|
||||
assert_true(hasMethodReturned);
|
||||
});
|
||||
promise_test(async (t) => {
|
||||
t.add_cleanup(resetPermission);
|
||||
await test_driver.set_permission({ name: "geolocation" }, "denied");
|
||||
let errorCBCalled = false;
|
||||
let id;
|
||||
const errorPromise = new Promise((resolve, reject) => {
|
||||
id = navigator.geolocation.watchPosition(reject, () => {
|
||||
errorCBCalled = true;
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
assert_false(
|
||||
errorCBCalled,
|
||||
"error callback must not be called synchronously"
|
||||
);
|
||||
await errorPromise;
|
||||
navigator.geolocation.clearWatch(id);
|
||||
}, "Check that watchPosition returns synchronously before any callbacks are invoked.");
|
||||
|
||||
try {
|
||||
id = geo.watchPosition(checkMethodHasReturned, checkMethodHasReturned);
|
||||
hasMethodReturned = true;
|
||||
} catch(e) {
|
||||
t.unreached_func('An exception was thrown unexpectedly: ' + e.message);
|
||||
}
|
||||
|
||||
// Rewrite http://dev.w3.org/geo/api/test-suite/t.html?00151
|
||||
test(function() {
|
||||
assert_greater_than_equal(id, -2147483648);
|
||||
assert_less_than_equal(id, 2147483647);
|
||||
}, 'Check that watchPosition returns a long');
|
||||
promise_test(async (t) => {
|
||||
t.add_cleanup(resetPermission);
|
||||
await test_driver.set_permission({ name: "geolocation" }, "denied");
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
navigator.geolocation.watchPosition(reject, resolve);
|
||||
});
|
||||
const result = await promise;
|
||||
assert_true(
|
||||
result instanceof GeolocationPositionError,
|
||||
"expected GeolocationPositionError"
|
||||
);
|
||||
}, "User denies access, check that error callback is called.");
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue