From ab58de8c8945257560164db20837915b7741fcb0 Mon Sep 17 00:00:00 2001 From: Doug Turner Date: Tue, 31 Aug 2010 09:15:52 -0700 Subject: [PATCH] Bug 489813 - Fire timeout error if provider fails to response after initial response. Also cleans up test. r=smaug a=jst --- build/automation.py.in | 1 + dom/src/geolocation/nsGeolocation.cpp | 176 +++++++++++++----- dom/src/geolocation/nsGeolocation.h | 4 +- dom/system/GPSDGeolocationProvider.js | 19 +- dom/system/NetworkGeolocationProvider.js | 80 ++++---- .../mochitest/chrome/test_geolocation.xul | 2 - dom/tests/mochitest/geolocation/Makefile.in | 29 ++- .../geolocation/geolocation_common.js | 85 +++------ .../geolocation/test_allowCurrent.html | 22 +-- .../geolocation/test_allowWatch.html | 20 +- .../geolocation/test_cancelCurrent.html | 13 +- .../geolocation/test_cancelWatch.html | 13 +- .../geolocation/test_clearWatch.html | 23 ++- .../geolocation/test_clearWatch_invalid.html | 2 - .../geolocation/test_garbageWatch.html | 6 +- .../test_manyCurrentConcurrent.html | 37 ++-- .../geolocation/test_manyCurrentSerial.html | 34 ++-- .../geolocation/test_manyWatchConcurrent.html | 37 ++-- .../geolocation/test_manyWatchSerial.html | 27 +-- .../geolocation/test_manyWindows.html | 5 + .../geolocation/test_optional_api_params.html | 7 +- .../geolocation/test_timeoutWatch.html | 9 +- .../geolocation/test_timerRestartWatch.html | 55 ++++++ .../geolocation/test_windowClose.html | 3 + .../mochitest/geolocation/windowTest.html | 6 - 25 files changed, 387 insertions(+), 328 deletions(-) create mode 100644 dom/tests/mochitest/geolocation/test_timerRestartWatch.html diff --git a/build/automation.py.in b/build/automation.py.in index 26d7a518e65..088d72b4a79 100644 --- a/build/automation.py.in +++ b/build/automation.py.in @@ -363,6 +363,7 @@ user_pref("extensions.testpilot.runStudies", false); user_pref("geo.wifi.uri", "http://%(server)s/tests/dom/tests/mochitest/geolocation/network_geolocation.sjs"); user_pref("geo.wifi.testing", true); +user_pref("geo.ignore.location_filter", true); user_pref("camino.warn_when_closing", false); // Camino-only, harmless to others diff --git a/dom/src/geolocation/nsGeolocation.cpp b/dom/src/geolocation/nsGeolocation.cpp index 2037e2dc557..bbba1109334 100644 --- a/dom/src/geolocation/nsGeolocation.cpp +++ b/dom/src/geolocation/nsGeolocation.cpp @@ -71,6 +71,7 @@ #include "nsIPrefService.h" #include "nsIPrefBranch2.h" #include "nsIJSContextStack.h" +#include "nsThreadUtils.h" #include "mozilla/Services.h" #include "mozilla/unused.h" @@ -98,6 +99,75 @@ using mozilla::unused; // using namespace mozilla::dom; +class RequestPromptEvent : public nsRunnable +{ +public: + RequestPromptEvent(nsGeolocationRequest* request) + : mRequest(request) + { + } + + NS_IMETHOD Run() { + nsCOMPtr prompt = do_GetService(NS_GEOLOCATION_PROMPT_CONTRACTID); + NS_ASSERTION(prompt, "null geolocation prompt"); + if (prompt) + prompt->Prompt(mRequest); + return NS_OK; + } + +private: + nsRefPtr mRequest; +}; + +class RequestAllowEvent : public nsRunnable +{ +public: + RequestAllowEvent(int allow, nsGeolocationRequest* request) + : mAllow(allow), + mRequest(request) + { + } + + NS_IMETHOD Run() { + if (mAllow) + mRequest->Allow(); + else + mRequest->Cancel(); + return NS_OK; + } + +private: + PRBool mAllow; + nsRefPtr mRequest; +}; + +class RequestSendLocationEvent : public nsRunnable +{ +public: + // a bit funky. if locator is passed, that means this + // event should remove the request from it. If we ever + // have to do more, then we can change this around. + RequestSendLocationEvent(nsIDOMGeoPosition* aPosition, nsGeolocationRequest* aRequest, nsGeolocation* aLocator = nsnull) + : mPosition(aPosition), + mRequest(aRequest), + mLocator(aLocator) + { + } + + NS_IMETHOD Run() { + mRequest->SendLocation(mPosition); + if (mLocator) + mLocator->RemoveRequest(mRequest); + return NS_OK; + } + +private: + nsCOMPtr mPosition; + nsRefPtr mRequest; + + nsRefPtr mLocator; +}; + //////////////////////////////////////////////////// // nsDOMGeoPositionError //////////////////////////////////////////////////// @@ -170,7 +240,6 @@ nsGeolocationRequest::nsGeolocationRequest(nsGeolocation* aLocator, nsIDOMGeoPositionOptions* aOptions) : mAllowed(PR_FALSE), mCleared(PR_FALSE), - mHasSentData(PR_FALSE), mCallback(aCallback), mErrorCallback(aErrorCallback), mOptions(aOptions), @@ -227,11 +296,9 @@ nsGeolocationRequest::Notify(nsITimer* aTimer) // provider yet, cancel the request. Same logic as // ::Cancel, just a different error - if (!mHasSentData) { - NotifyError(nsIDOMGeoPositionError::TIMEOUT); - // remove ourselves from the locator's callback lists. - mLocator->RemoveRequest(this); - } + NotifyError(nsIDOMGeoPositionError::TIMEOUT); + // remove ourselves from the locator's callback lists. + mLocator->RemoveRequest(this); mTimeoutTimer = nsnull; return NS_OK; @@ -319,10 +386,23 @@ nsGeolocationRequest::Allow() // okay, we can return a cached position mAllowed = PR_TRUE; - // send the cached location - SendLocation(lastPosition); + nsCOMPtr ev = new RequestSendLocationEvent(lastPosition, this, mLocator); + NS_DispatchToMainThread(ev); } + SetTimeoutTimer(); + + mAllowed = PR_TRUE; + return NS_OK; +} + +void +nsGeolocationRequest::SetTimeoutTimer() +{ + if (mTimeoutTimer) { + mTimeoutTimer->Cancel(); + mTimeoutTimer = nsnull; + } PRInt32 timeout; if (mOptions && NS_SUCCEEDED(mOptions->GetTimeout(&timeout)) && timeout > 0) { @@ -332,9 +412,6 @@ nsGeolocationRequest::Allow() mTimeoutTimer = do_CreateInstance("@mozilla.org/timer;1"); mTimeoutTimer->InitWithCallback(this, timeout, nsITimer::TYPE_ONE_SHOT); } - - mAllowed = PR_TRUE; - return NS_OK; } void @@ -349,6 +426,11 @@ nsGeolocationRequest::SendLocation(nsIDOMGeoPosition* aPosition) if (mCleared || !mAllowed) return; + if (mTimeoutTimer) { + mTimeoutTimer->Cancel(); + mTimeoutTimer = nsnull; + } + // we should not pass null back to the DOM. if (!aPosition) { NotifyError(nsIDOMGeoPositionError::POSITION_UNAVAILABLE); @@ -366,7 +448,7 @@ nsGeolocationRequest::SendLocation(nsIDOMGeoPosition* aPosition) JSContext* cx; stack->Pop(&cx); - mHasSentData = PR_TRUE; + SetTimeoutTimer(); } void @@ -401,6 +483,8 @@ NS_IMPL_THREADSAFE_RELEASE(nsGeolocationService) static PRBool sGeoEnabled = PR_TRUE; +static PRBool sGeoIgnoreLocationFilter = PR_FALSE; + static int GeoEnabledChangedCallback(const char *aPrefName, void *aClosure) { @@ -408,10 +492,26 @@ GeoEnabledChangedCallback(const char *aPrefName, void *aClosure) return 0; } +static int +GeoIgnoreLocationFilterChangedCallback(const char *aPrefName, void *aClosure) +{ + sGeoIgnoreLocationFilter = nsContentUtils::GetBoolPref("geo.ignore.location_filter", + PR_TRUE); + return 0; +} + + nsresult nsGeolocationService::Init() { mTimeout = nsContentUtils::GetIntPref("geo.timeout", 6000); + nsContentUtils::RegisterPrefCallback("geo.ignore.location_filter", + GeoIgnoreLocationFilterChangedCallback, + nsnull); + + GeoIgnoreLocationFilterChangedCallback("geo.ignore.location_filter", nsnull); + + nsContentUtils::RegisterPrefCallback("geo.enabled", GeoEnabledChangedCallback, nsnull); @@ -771,7 +871,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsGeolocation) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END nsGeolocation::nsGeolocation() -: mUpdateInProgress(PR_FALSE) { } @@ -859,33 +958,21 @@ nsGeolocation::RemoveRequest(nsGeolocationRequest* aRequest) void nsGeolocation::Update(nsIDOMGeoPosition *aSomewhere) { - // This method calls out to objects which may spin and - // event loop which may add new location objects into - // mPendingCallbacks, and mWatchingCallbacks. Since this - // function can only be called on the primary thread, we - // can lock this method with a member var. - - if (mUpdateInProgress) - return; - - mUpdateInProgress = PR_TRUE; - if (!WindowOwnerStillExists()) - { - Shutdown(); - return; - } + return Shutdown(); - // notify anyone that has been waiting - for (PRUint32 i = 0; i< mPendingCallbacks.Length(); i++) - mPendingCallbacks[i]->SendLocation(aSomewhere); + for (PRUint32 i = 0; i< mPendingCallbacks.Length(); i++) { + nsCOMPtr ev = new RequestSendLocationEvent(aSomewhere, + mPendingCallbacks[i]); + NS_DispatchToMainThread(ev); + } mPendingCallbacks.Clear(); // notify everyone that is watching - for (PRUint32 i = 0; i< mWatchingCallbacks.Length(); i++) - mWatchingCallbacks[i]->SendLocation(aSomewhere); - - mUpdateInProgress = PR_FALSE; + for (PRUint32 i = 0; i< mWatchingCallbacks.Length(); i++) { + nsCOMPtr ev = new RequestSendLocationEvent(aSomewhere, mWatchingCallbacks[i]); + NS_DispatchToMainThread(ev); + } } NS_IMETHODIMP @@ -911,17 +998,17 @@ nsGeolocation::GetCurrentPosition(nsIDOMGeoPositionCallback *callback, if (mOwner) { RegisterRequestWithPrompt(request); mPendingCallbacks.AppendElement(request); - return NS_OK; } if (!nsContentUtils::IsCallerChrome()) return NS_ERROR_FAILURE; - request->Allow(); - mPendingCallbacks.AppendElement(request); + nsCOMPtr ev = new RequestAllowEvent(true, request); + NS_DispatchToMainThread(ev); + return NS_OK; } @@ -1030,10 +1117,15 @@ nsGeolocation::RegisterRequestWithPrompt(nsGeolocationRequest* request) } #endif - nsCOMPtr prompt = do_GetService(NS_GEOLOCATION_PROMPT_CONTRACTID); - NS_ASSERTION(prompt, "null geolocation prompt. geolocation will not work without one."); - if (prompt) - prompt->Prompt(request); + if (nsContentUtils::GetBoolPref("geo.prompt.testing", PR_FALSE)) + { + nsCOMPtr ev = new RequestAllowEvent(nsContentUtils::GetBoolPref("geo.prompt.testing.allow", PR_FALSE), request); + NS_DispatchToMainThread(ev); + return; + } + + nsCOMPtr ev = new RequestPromptEvent(request); + NS_DispatchToMainThread(ev); } #if !defined(WINCE_WINDOWS_MOBILE) && !defined(MOZ_MAEMO_LIBLOCATION) && !defined(ANDROID) diff --git a/dom/src/geolocation/nsGeolocation.h b/dom/src/geolocation/nsGeolocation.h index 71d48c7dfd1..8ca1e825696 100644 --- a/dom/src/geolocation/nsGeolocation.h +++ b/dom/src/geolocation/nsGeolocation.h @@ -94,6 +94,7 @@ class nsGeolocationRequest void SendLocation(nsIDOMGeoPosition* location); void MarkCleared(); PRBool Allowed() {return mAllowed;} + void SetTimeoutTimer(); ~nsGeolocationRequest(); @@ -106,7 +107,6 @@ class nsGeolocationRequest void NotifyError(PRInt16 errorCode); PRPackedBool mAllowed; PRPackedBool mCleared; - PRPackedBool mHasSentData; nsCOMPtr mTimeoutTimer; nsCOMPtr mCallback; @@ -232,8 +232,6 @@ private: nsTArray > mPendingCallbacks; nsTArray > mWatchingCallbacks; - PRBool mUpdateInProgress; - // window that this was created for. Weak reference. nsWeakPtr mOwner; diff --git a/dom/system/GPSDGeolocationProvider.js b/dom/system/GPSDGeolocationProvider.js index d02cfbc18e4..9392f94f895 100644 --- a/dom/system/GPSDGeolocationProvider.js +++ b/dom/system/GPSDGeolocationProvider.js @@ -177,16 +177,17 @@ GPSDProvider.prototype = { watch: function(c) { LOG("watch called\n"); + try { + // Turn GPSD buffer on, results in smoother data points which I think we want. + // Required due to the way that different data arrives in different NMEA sentences. + var bufferOption = "J=1\n"; + this.outputStream.write(bufferOption, bufferOption.length); + + // Go into "watcher" mode + var mode = "w\n"; + this.outputStream.write(mode, mode.length); + } catch (e) { return; } - // Turn GPSD buffer on, results in smoother data points which I think we want. - // Required due to the way that different data arrives in different NMEA sentences. - var bufferOption = "J=1\n"; - this.outputStream.write(bufferOption, bufferOption.length); - - // Go into "watcher" mode - var mode = "w\n"; - this.outputStream.write(mode, mode.length); - var dataListener = { onStartRequest: function(request, context) {}, onStopRequest: function(request, context, status) {}, diff --git a/dom/system/NetworkGeolocationProvider.js b/dom/system/NetworkGeolocationProvider.js index 673d6b4afaa..6652246c6c7 100755 --- a/dom/system/NetworkGeolocationProvider.js +++ b/dom/system/NetworkGeolocationProvider.js @@ -14,7 +14,7 @@ function nowInSeconds() function LOG(aMsg) { if (gLoggingEnabled) { - aMsg = ("*** WIFI GEO: " + aMsg); + aMsg = "*** WIFI GEO: " + aMsg + "\n"; Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService).logStringMessage(aMsg); dump(aMsg); } @@ -227,25 +227,18 @@ WifiGeoPositionProvider.prototype = { Ci.nsITimerCallback]), prefService: null, - - provider_url: null, wifi_service: null, timer: null, - protocol: null, hasSeenWiFi: false, + started: false, startup: function() { - LOG("startup called"); + if (this.started == true) + return; - this.provider_url = this.prefService.getCharPref("geo.wifi.uri"); - LOG("provider url = " + this.provider_url); + this.started = true; - try { - this.protocol = this.prefService.getIntPref("geo.wifi.protocol"); - LOG("protocol = " + this.protocol); - } catch (e) { - this.protocol = 0; - } + LOG("startup called. testing mode is" + gTestingEnabled); // if we don't see anything in 5 seconds, kick of one IP geo lookup. // if we are testing, just hammer this callback so that we are more or less // always sending data. It doesn't matter if we have an access point or not. @@ -284,6 +277,8 @@ WifiGeoPositionProvider.prototype = { let prefBranch = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); if (prefBranch.getIntPref("network.cookie.lifetimePolicy") != 0) prefBranch.deleteBranch("geo.wifi.access_token."); + + this.started = false; }, getAccessTokenForURL: function(url) @@ -308,7 +303,6 @@ WifiGeoPositionProvider.prototype = { } catch (e) { accessToken = ""; - LOG("Error: "+ e); } return accessToken; }, @@ -318,16 +312,22 @@ WifiGeoPositionProvider.prototype = { LOG("onChange called"); this.hasSeenWiFi = true; - // Cache the preferred protocol for use inside the XHR callback - var protocol = this.protocol; - // send our request to a wifi geolocation network provider: - var xhr = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest); + var xhr = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"] + .createInstance(Ci.nsIXMLHttpRequest); // This is a background load xhr.mozBackgroundRequest = true; - xhr.open("POST", this.provider_url, false); + var provider_url = this.prefService.getCharPref("geo.wifi.uri"); + var provider_protocol = 0; + try { + provider_protocol = this.prefService.getIntPref("geo.wifi.protocol"); + } catch (e) {} + + LOG("provider url = " + provider_url); + + xhr.open("POST", provider_url, false); // set something so that we can strip cookies xhr.channel.loadFlags = Ci.nsIChannel.LOAD_ANONYMOUS; @@ -340,17 +340,22 @@ WifiGeoPositionProvider.prototype = { LOG("xhr onload..."); - // if we get a bad response, we will throw and never report a location - var response; - switch (protocol) { - case 1: - LOG("service returned: " + req.target.responseXML); - response = HELD.decode(req.target.responseXML); - break; - case 0: - default: - LOG("service returned: " + req.target.responseText); - response = JSON.parse(req.target.responseText); + try { + // if we get a bad response, we will throw and never report a location + var response; + switch (provider_protocol) { + case 1: + LOG("service returned: " + req.target.responseXML); + response = HELD.decode(req.target.responseXML); + break; + case 0: + default: + LOG("service returned: " + req.target.responseText); + response = JSON.parse(req.target.responseText); + } + } catch (e) { + LOG("Parse failed"); + return; } // response looks something like: @@ -393,7 +398,7 @@ WifiGeoPositionProvider.prototype = { update.update(newLocation); }; - var accessToken = this.getAccessTokenForURL(this.provider_url); + var accessToken = this.getAccessTokenForURL(provider_url); var request = { version: "1.1.0", @@ -414,7 +419,7 @@ WifiGeoPositionProvider.prototype = { } var requestString; - switch (protocol) { + switch (provider_protocol) { case 1: requestString = HELD.encode(request); break; @@ -434,9 +439,14 @@ WifiGeoPositionProvider.prototype = { }, notify: function (timer) { - if (this.hasSeenWiFi == false) - this.onChange(null); - this.timer = null; + if (!gTestingEnabled) { + if (this.hasSeenWiFi == false) + this.onChange(null); + this.timer = null; + return; + } + // if we are testing, we need to hammer this. + this.onChange(null); }, }; diff --git a/dom/tests/mochitest/chrome/test_geolocation.xul b/dom/tests/mochitest/chrome/test_geolocation.xul index 98d3b2e7432..ce7c5807e58 100644 --- a/dom/tests/mochitest/chrome/test_geolocation.xul +++ b/dom/tests/mochitest/chrome/test_geolocation.xul @@ -24,13 +24,11 @@ function error(error) { ok(0, "error occured trying to get geolocation from chrome"); SimpleTest.finish(); - newwindow.close(); } function done(position) { ok(position, "geolocation was found from chrome"); SimpleTest.finish(); - newwindow.close(); } diff --git a/dom/tests/mochitest/geolocation/Makefile.in b/dom/tests/mochitest/geolocation/Makefile.in index 35e8d39e0cd..11b882c177c 100644 --- a/dom/tests/mochitest/geolocation/Makefile.in +++ b/dom/tests/mochitest/geolocation/Makefile.in @@ -45,31 +45,26 @@ include $(DEPTH)/config/autoconf.mk include $(topsrcdir)/config/rules.mk _TEST_FILES = \ - test_manyCurrentSerial.html \ + test_allowCurrent.html \ + test_allowWatch.html \ + test_cancelCurrent.html \ + test_cancelWatch.html \ + test_clearWatch.html \ + test_clearWatch_invalid.html \ test_manyCurrentConcurrent.html \ - test_garbageWatch.html \ + test_manyCurrentSerial.html \ test_manyWatchConcurrent.html \ test_manyWatchSerial.html \ test_manyWindows.html \ - test_allowCurrent.html \ - test_allowWatch.html \ - test_clearWatch.html \ - test_clearWatch_invalid.html \ - test_timeoutWatch.html \ - test_windowClose.html \ - windowTest.html \ - geolocation_common.js \ - geolocation.html \ test_optional_api_params.html \ + test_windowClose.html \ + test_timerRestartWatch.html \ + geolocation.html \ + geolocation_common.js \ network_geolocation.sjs \ + windowTest.html \ $(NULL) -ifndef MOZ_PHOENIX -_TEST_FILES += test_cancelCurrent.html \ - test_cancelWatch.html \ - $(NULL) -endif - libs:: $(_TEST_FILES) $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir) diff --git a/dom/tests/mochitest/geolocation/geolocation_common.js b/dom/tests/mochitest/geolocation/geolocation_common.js index e900da0ca44..5a88afbdb60 100644 --- a/dom/tests/mochitest/geolocation/geolocation_common.js +++ b/dom/tests/mochitest/geolocation/geolocation_common.js @@ -1,10 +1,33 @@ +function sleep(delay) +{ + var start = Date.now(); + while (Date.now() < start + delay); +} + +function force_prompt(allow) { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); + prefs.setBoolPref("geo.prompt.testing", true); + prefs.setBoolPref("geo.prompt.testing.allow", allow); +} + +function reset_prompt() { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); + prefs.setBoolPref("geo.prompt.testing", false); + prefs.setBoolPref("geo.prompt.testing.allow", false); +} + function start_sending_garbage() { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); prefs.setCharPref("geo.wifi.uri", "http://mochi.test:8888/tests/dom/tests/mochitest/geolocation/network_geolocation.sjs?action=respond-garbage"); + + // we need to be sure that all location data has been purged/set. + sleep(1000); } function stop_sending_garbage() @@ -12,6 +35,9 @@ function stop_sending_garbage() netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); prefs.setCharPref("geo.wifi.uri", "http://mochi.test:8888/tests/dom/tests/mochitest/geolocation/network_geolocation.sjs"); + + // we need to be sure that all location data has been purged/set. + sleep(1000); } function stop_geolocationProvider() @@ -19,6 +45,9 @@ function stop_geolocationProvider() netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); prefs.setCharPref("geo.wifi.uri", "http://mochi.test:8888/tests/dom/tests/mochitest/geolocation/network_geolocation.sjs?action=stop-responding"); + + // we need to be sure that all location data has been purged/set. + sleep(1000); } function resume_geolocationProvider() @@ -52,60 +81,4 @@ function check_geolocation(location) { ok (location.coords.longitude == -122.08769, "lon matches known value"); ok(location.coords.altitude == 42, "alt matches known value"); ok(location.coords.altitudeAccuracy == 42, "alt acc matches known value"); - } - - -function getChromeWindow() -{ - const Ci = Components.interfaces; - var chromeWin = window.top - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem) - .rootTreeItem - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDOMWindow) - .QueryInterface(Ci.nsIDOMChromeWindow); - return chromeWin; -} - -function getNotificationBox() -{ - var chromeWin = getChromeWindow(); - var notifyBox = chromeWin.getNotificationBox(window.top); - - return notifyBox; -} - -function clickNotificationButton(aButtonIndex) { - netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); - - // First, check for new-style Firefox notifications - var chromeWin = getChromeWindow(); - if (chromeWin.PopupNotifications) { - var panel = chromeWin.PopupNotifications.panel; - var notificationEl = panel.getElementsByAttribute("id", "geolocation-notification")[0]; - if (aButtonIndex == kAcceptButton) - notificationEl.button.doCommand(); - else if (aButtonIndex == kDenyButton) - throw "clickNotificationButton(kDenyButton) isn't supported in Firefox"; - - return; - } - - // Otherwise, fall back to looking for a notificationbox - // This is a bit of a hack. The notification doesn't have an API to - // trigger buttons, so we dive down into the implementation and twiddle - // the buttons directly. - var box = getNotificationBox(); - ok(box, "Got notification box"); - var bar = box.getNotificationWithValue("geolocation"); - ok(bar, "Got geolocation notification"); - var button = bar.getElementsByTagName("button").item(aButtonIndex); - ok(button, "Got button"); - button.doCommand(); -} - -const kAcceptButton = 0; -const kDenyButton = 1; diff --git a/dom/tests/mochitest/geolocation/test_allowCurrent.html b/dom/tests/mochitest/geolocation/test_allowCurrent.html index 57520a03007..d49d75c6218 100644 --- a/dom/tests/mochitest/geolocation/test_allowCurrent.html +++ b/dom/tests/mochitest/geolocation/test_allowCurrent.html @@ -20,29 +20,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=478911
 
 
diff --git a/dom/tests/mochitest/geolocation/test_allowWatch.html b/dom/tests/mochitest/geolocation/test_allowWatch.html index 5bd42a80af5..5aa29086d76 100644 --- a/dom/tests/mochitest/geolocation/test_allowWatch.html +++ b/dom/tests/mochitest/geolocation/test_allowWatch.html @@ -20,31 +20,21 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=478911
 
 
diff --git a/dom/tests/mochitest/geolocation/test_cancelCurrent.html b/dom/tests/mochitest/geolocation/test_cancelCurrent.html index 4aee3925b51..fd016da21a2 100644 --- a/dom/tests/mochitest/geolocation/test_cancelCurrent.html +++ b/dom/tests/mochitest/geolocation/test_cancelCurrent.html @@ -20,25 +20,24 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=478911
 
 
diff --git a/dom/tests/mochitest/geolocation/test_cancelWatch.html b/dom/tests/mochitest/geolocation/test_cancelWatch.html index 1eb03a26d59..e30b0ebb22d 100644 --- a/dom/tests/mochitest/geolocation/test_cancelWatch.html +++ b/dom/tests/mochitest/geolocation/test_cancelWatch.html @@ -20,27 +20,26 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=478911
 
 
diff --git a/dom/tests/mochitest/geolocation/test_clearWatch.html b/dom/tests/mochitest/geolocation/test_clearWatch.html index 3863aef282e..84b9cef166d 100644 --- a/dom/tests/mochitest/geolocation/test_clearWatch.html +++ b/dom/tests/mochitest/geolocation/test_clearWatch.html @@ -20,8 +20,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=478911
 
 
diff --git a/dom/tests/mochitest/geolocation/test_clearWatch_invalid.html b/dom/tests/mochitest/geolocation/test_clearWatch_invalid.html index 8c444452343..8e99733fdb3 100644 --- a/dom/tests/mochitest/geolocation/test_clearWatch_invalid.html +++ b/dom/tests/mochitest/geolocation/test_clearWatch_invalid.html @@ -19,8 +19,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=463039
 
 
diff --git a/dom/tests/mochitest/geolocation/test_manyCurrentConcurrent.html b/dom/tests/mochitest/geolocation/test_manyCurrentConcurrent.html index 1ae0aa09152..d2ed31a4deb 100644 --- a/dom/tests/mochitest/geolocation/test_manyCurrentConcurrent.html +++ b/dom/tests/mochitest/geolocation/test_manyCurrentConcurrent.html @@ -20,40 +20,25 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=482260
 
 
diff --git a/dom/tests/mochitest/geolocation/test_manyCurrentSerial.html b/dom/tests/mochitest/geolocation/test_manyCurrentSerial.html index e99c73b046d..cb915e3fcc5 100644 --- a/dom/tests/mochitest/geolocation/test_manyCurrentSerial.html +++ b/dom/tests/mochitest/geolocation/test_manyCurrentSerial.html @@ -20,33 +20,25 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=482260
 
 
diff --git a/dom/tests/mochitest/geolocation/test_manyWatchConcurrent.html b/dom/tests/mochitest/geolocation/test_manyWatchConcurrent.html index dc5dacb594d..dd952848f3f 100644 --- a/dom/tests/mochitest/geolocation/test_manyWatchConcurrent.html +++ b/dom/tests/mochitest/geolocation/test_manyWatchConcurrent.html @@ -20,40 +20,25 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=482260
 
 
diff --git a/dom/tests/mochitest/geolocation/test_manyWatchSerial.html b/dom/tests/mochitest/geolocation/test_manyWatchSerial.html index 12b86dfa3c9..e8e08977e8c 100644 --- a/dom/tests/mochitest/geolocation/test_manyWatchSerial.html +++ b/dom/tests/mochitest/geolocation/test_manyWatchSerial.html @@ -20,16 +20,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=482260
 
 
diff --git a/dom/tests/mochitest/geolocation/test_manyWindows.html b/dom/tests/mochitest/geolocation/test_manyWindows.html index 31d2ebe98c4..65463f4a691 100644 --- a/dom/tests/mochitest/geolocation/test_manyWindows.html +++ b/dom/tests/mochitest/geolocation/test_manyWindows.html @@ -21,6 +21,10 @@ href="https://bugzilla.mozilla.org/show_bug.cgi?id=478911">Crash in Multiple Win
 
 
diff --git a/dom/tests/mochitest/geolocation/test_timeoutWatch.html b/dom/tests/mochitest/geolocation/test_timeoutWatch.html index 68851cf966e..a9d212508ac 100644 --- a/dom/tests/mochitest/geolocation/test_timeoutWatch.html +++ b/dom/tests/mochitest/geolocation/test_timeoutWatch.html @@ -21,6 +21,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=455327 diff --git a/dom/tests/mochitest/geolocation/test_timerRestartWatch.html b/dom/tests/mochitest/geolocation/test_timerRestartWatch.html new file mode 100644 index 00000000000..3db01c44e81 --- /dev/null +++ b/dom/tests/mochitest/geolocation/test_timerRestartWatch.html @@ -0,0 +1,55 @@ + + + + + Test for watchPosition + + + + + + + +Mozilla Bug 526326 +

+ +
+
+
+ + + diff --git a/dom/tests/mochitest/geolocation/test_windowClose.html b/dom/tests/mochitest/geolocation/test_windowClose.html index 9d8dc5bb59d..62804f09ed3 100644 --- a/dom/tests/mochitest/geolocation/test_windowClose.html +++ b/dom/tests/mochitest/geolocation/test_windowClose.html @@ -21,10 +21,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=493615