Bug 1203233 implement geolocation permission, r=aswan,florian

MozReview-Commit-ID: 8V7bNyeGZNh
This commit is contained in:
Shane Caraveo
2017-02-04 16:10:50 -08:00
parent cad53993ee
commit f737079118
9 changed files with 132 additions and 9 deletions

View File

@@ -40,6 +40,7 @@ support-files =
return_headers.sjs
webrequest_worker.js
!/toolkit/components/passwordmgr/test/authenticate.sjs
!/dom/tests/mochitest/geolocation/network_geolocation.sjs
[test_clipboard.html]
# skip-if = # disabled test case with_permission_allow_copy, see inline comment.
@@ -64,6 +65,8 @@ skip-if = os == 'android' # Android does not support multiple windows.
[test_ext_exclude_include_globs.html]
[test_ext_i18n_css.html]
[test_ext_generate.html]
[test_ext_geolocation.html]
skip-if = os == 'android' # Android support Bug 1336194
[test_ext_notifications.html]
[test_ext_permission_xhr.html]
[test_ext_runtime_connect.html]

View File

@@ -0,0 +1,87 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script>
"use strict";
add_task(function* test_geolocation_nopermission() {
let GEO_URL = "http://mochi.test:8888/tests/dom/tests/mochitest/geolocation/network_geolocation.sjs";
yield SpecialPowers.pushPrefEnv({"set": [["geo.wifi.uri", GEO_URL]]});
});
add_task(function* test_geolocation() {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: [
"geolocation",
],
},
background() {
navigator.geolocation.getCurrentPosition(() => {
browser.test.notifyPass("success geolocation call");
}, (error) => {
browser.test.notifyFail(`geolocation call ${error}`);
});
},
});
yield extension.startup();
yield extension.awaitFinish();
yield extension.unload();
});
add_task(function* test_geolocation_nopermission() {
let extension = ExtensionTestUtils.loadExtension({
background() {
navigator.geolocation.getCurrentPosition(() => {
browser.test.notifyFail("success geolocation call");
}, (error) => {
browser.test.notifyPass(`geolocation call ${error}`);
});
},
});
yield extension.startup();
yield extension.awaitFinish();
yield extension.unload();
});
add_task(function* test_geolocation_prompt() {
let extension = ExtensionTestUtils.loadExtension({
background() {
browser.tabs.create({url: "tab.html"});
},
files: {
"tab.html": `<html><head>
<meta charset="utf-8">
<script src="tab.js"><\/script>
</head></html>`,
"tab.js": () => {
navigator.geolocation.getCurrentPosition(() => {
browser.test.notifyPass("success geolocation call");
}, (error) => {
browser.test.notifyFail(`geolocation call ${error}`);
});
},
},
});
// Bypass the actual prompt, but the prompt result is to allow access.
yield SpecialPowers.pushPrefEnv({"set": [["geo.prompt.testing", true], ["geo.prompt.testing.allow", true]]});
yield extension.startup();
yield extension.awaitFinish();
yield extension.unload();
});
</script>
</head>
<body>
</body>
</html>