Bug 884921 - navigator.geolocation should never be null. r=dougt

This commit is contained in:
Guilherme Gonçalves 2013-07-26 16:12:12 -04:00
Родитель 268ee517df
Коммит 74cb7450ea
4 изменённых файлов: 38 добавлений и 10 удалений

Просмотреть файл

@ -961,10 +961,6 @@ Navigator::GetDeviceStorages(const nsAString& aType,
Geolocation*
Navigator::GetGeolocation(ErrorResult& aRv)
{
if (!Preferences::GetBool("geo.enabled", true)) {
return nullptr;
}
if (mGeolocation) {
return mGeolocation;
}

Просмотреть файл

@ -18,6 +18,7 @@ MOCHITEST_FILES = \
test_cancelWatch.html \
test_clearWatch.html \
test_clearWatch_invalid.html \
test_geolocation_is_undefined_when_pref_is_off.html \
test_manyCurrentConcurrent.html \
test_manyCurrentSerial.html \
test_manyWatchConcurrent.html \

Просмотреть файл

@ -0,0 +1,35 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=884921
-->
<head>
<title>Test for getCurrentPosition </title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="geolocation_common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=884921">Mozilla Bug 884921</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({set: [["geo.enabled", false]]}, function() {
is(navigator.geolocation, undefined);
is("geolocation" in navigator, false);
SimpleTest.finish();
});
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -94,12 +94,8 @@ partial interface Navigator {
// http://www.w3.org/TR/geolocation-API/#geolocation_interface
[NoInterfaceObject]
interface NavigatorGeolocation {
// XXXbz This should perhaps be controleld by the "geo.enabled" pref, instead
// of checking it in the C++. Let's not for now to reduce risk.
// Also, we violate the spec as a result, since we can return null. See bug
// 884921.
[Throws]
readonly attribute Geolocation? geolocation;
[Throws, Pref="geo.enabled"]
readonly attribute Geolocation geolocation;
};
Navigator implements NavigatorGeolocation;