Backed out changeset 4f2748dbe5ed (bug 684722) for Android timeouts.

This commit is contained in:
Ryan VanderMeulen 2013-10-08 10:01:40 -04:00
parent 7fd039d08b
commit a6f51028c2
6 changed files with 7 additions and 87 deletions

View File

@ -79,7 +79,6 @@ class nsGeolocationRequest
void SendLocation(nsIDOMGeoPosition* location);
bool WantsHighAccuracy() {return mOptions && mOptions->mEnableHighAccuracy;}
void SetTimeoutTimer();
void NotifyErrorAndShutdown(uint16_t);
nsIPrincipal* GetPrincipal();
~nsGeolocationRequest();
@ -367,13 +366,6 @@ NS_IMPL_CYCLE_COLLECTION_3(nsGeolocationRequest, mCallback, mErrorCallback, mLoc
NS_IMETHODIMP
nsGeolocationRequest::Notify(nsITimer* aTimer)
{
NotifyErrorAndShutdown(nsIDOMGeoPositionError::TIMEOUT);
return NS_OK;
}
void
nsGeolocationRequest::NotifyErrorAndShutdown(uint16_t aErrorCode)
{
MOZ_ASSERT(!mShutdown, "timeout after shutdown");
@ -382,11 +374,13 @@ nsGeolocationRequest::NotifyErrorAndShutdown(uint16_t aErrorCode)
mLocator->RemoveRequest(this);
}
NotifyError(aErrorCode);
NotifyError(nsIDOMGeoPositionError::TIMEOUT);
if (!mShutdown) {
SetTimeoutTimer();
}
return NS_OK;
}
NS_IMETHODIMP
@ -1160,13 +1154,13 @@ Geolocation::NotifyError(uint16_t aErrorCode)
}
for (uint32_t i = mPendingCallbacks.Length(); i > 0; i--) {
mPendingCallbacks[i-1]->NotifyErrorAndShutdown(aErrorCode);
//NotifyErrorAndShutdown() removes the request from the array
mPendingCallbacks[i-1]->NotifyError(aErrorCode);
RemoveRequest(mPendingCallbacks[i-1]);
}
// notify everyone that is watching
for (uint32_t i = 0; i < mWatchingCallbacks.Length(); i++) {
mWatchingCallbacks[i]->NotifyErrorAndShutdown(aErrorCode);
mWatchingCallbacks[i]->NotifyError(aErrorCode);
}
return NS_OK;

View File

@ -170,30 +170,22 @@ WifiGeoPositionProvider.prototype = {
// This is a background load
try {
xhr.open("POST", url, true);
} catch (e) {
triggerError();
return;
}
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
xhr.responseType = "json";
xhr.mozBackgroundRequest = true;
xhr.channel.loadFlags = Ci.nsIChannel.LOAD_ANONYMOUS;
xhr.onerror = function() {
LOG("onerror: " + xhr);
triggerError();
};
xhr.onload = function() {
LOG("gls returned status: " + xhr.status + " --> " + JSON.stringify(xhr.response));
if (xhr.channel instanceof Ci.nsIHttpChannel && xhr.status != 200) {
triggerError();
return;
}
if (!xhr.response || !xhr.response.location) {
triggerError();
return;
}
@ -226,8 +218,4 @@ WifiGeoPositionProvider.prototype = {
},
};
function triggerError() {
Cc["@mozilla.org/geolocation/service;1"].getService(Ci.nsIGeolocationUpdate)
.notifyError(Ci.nsIDOMGeoPositionError.POSITION_UNAVAILABLE);
}
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([WifiGeoPositionProvider]);

View File

@ -51,11 +51,6 @@ function delay_geolocationProvider(delay, callback)
SpecialPowers.pushPrefEnv({"set": [["geo.wifi.uri", "http://mochi.test:8888/tests/dom/tests/mochitest/geolocation/network_geolocation.sjs?delay=" + delay]]}, callback);
}
function send404_geolocationProvider(callback)
{
SpecialPowers.pushPrefEnv({"set": [["geo.wifi.uri", "http://mochi.test:8888/tests/dom/tests/mochitest/geolocation/network_geolocation.sjs?action=send404"]]}, callback);
}
function check_geolocation(location) {
ok(location, "Check to see if this location is non-null");

View File

@ -12,7 +12,6 @@ support-files =
[test_cancelWatch.html]
[test_clearWatch.html]
[test_clearWatch_invalid.html]
[test_errorcheck.html]
[test_geolocation_is_undefined_when_pref_is_off.html]
[test_handlerSpinsEventLoop.html]
[test_manyCurrentConcurrent.html]

View File

@ -37,7 +37,6 @@ function handleRequest(request, response)
var params = parseQueryString(request.queryString);
if (params.action == "stop-responding") {
response.processAsync();
return;
}
@ -65,11 +64,6 @@ function handleRequest(request, response)
if ('delay' in params) {
delay = params.delay;
}
if (params.action === "send404") {
response.setStatusLine("1.0", 404, "Not Found");
response.finish();
return;
}
timer = Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer);
timer.initWithCallback(function() {
response.write(position);

View File

@ -1,50 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=684722
-->
<head>
<title>Test for ErrorChecking </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=684722">Mozilla Bug 684722</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
resume_geolocationProvider(function() {
force_prompt(true, test1);
});
function test1() {
send404_geolocationProvider(test2);
}
function errorCallback(error) {
is(error.code,
SpecialPowers.Ci.nsIDOMGeoPositionError.POSITION_UNAVAILABLE, "Geolocation error handler fired");
SimpleTest.finish();
}
function successCallback(position) {
ok(0,"Success callback called, which shouldn't be done");
SimpleTest.finish();
}
function test2() {
navigator.geolocation.getCurrentPosition(successCallback, errorCallback);
}
</script>
</pre>
</body>
</html>