mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Backed out changeset 1d8d2deb3644
This commit is contained in:
parent
3123a8d709
commit
6f2ed7d68e
@ -330,7 +330,6 @@ 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
|
||||
|
||||
|
@ -71,7 +71,6 @@
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch2.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
@ -98,75 +97,6 @@
|
||||
|
||||
using mozilla::unused; // <snicker>
|
||||
|
||||
class RequestPromptEvent : public nsRunnable
|
||||
{
|
||||
public:
|
||||
RequestPromptEvent(nsGeolocationRequest* request)
|
||||
: mRequest(request)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHOD Run() {
|
||||
nsCOMPtr<nsIGeolocationPrompt> prompt = do_GetService(NS_GEOLOCATION_PROMPT_CONTRACTID);
|
||||
NS_ASSERTION(prompt, "null geolocation prompt");
|
||||
if (prompt)
|
||||
prompt->Prompt(mRequest);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
nsRefPtr<nsGeolocationRequest> 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<nsGeolocationRequest> 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<nsIDOMGeoPosition> mPosition;
|
||||
nsRefPtr<nsGeolocationRequest> mRequest;
|
||||
|
||||
nsRefPtr<nsGeolocation> mLocator;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// nsDOMGeoPositionError
|
||||
////////////////////////////////////////////////////
|
||||
@ -239,6 +169,7 @@ nsGeolocationRequest::nsGeolocationRequest(nsGeolocation* aLocator,
|
||||
nsIDOMGeoPositionOptions* aOptions)
|
||||
: mAllowed(PR_FALSE),
|
||||
mCleared(PR_FALSE),
|
||||
mHasSentData(PR_FALSE),
|
||||
mCallback(aCallback),
|
||||
mErrorCallback(aErrorCallback),
|
||||
mOptions(aOptions),
|
||||
@ -295,9 +226,11 @@ nsGeolocationRequest::Notify(nsITimer* aTimer)
|
||||
// provider yet, cancel the request. Same logic as
|
||||
// ::Cancel, just a different error
|
||||
|
||||
NotifyError(nsIDOMGeoPositionError::TIMEOUT);
|
||||
// remove ourselves from the locator's callback lists.
|
||||
mLocator->RemoveRequest(this);
|
||||
if (!mHasSentData) {
|
||||
NotifyError(nsIDOMGeoPositionError::TIMEOUT);
|
||||
// remove ourselves from the locator's callback lists.
|
||||
mLocator->RemoveRequest(this);
|
||||
}
|
||||
|
||||
mTimeoutTimer = nsnull;
|
||||
return NS_OK;
|
||||
@ -385,23 +318,10 @@ nsGeolocationRequest::Allow()
|
||||
// okay, we can return a cached position
|
||||
mAllowed = PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsIRunnable> ev = new RequestSendLocationEvent(lastPosition, this, mLocator);
|
||||
NS_DispatchToMainThread(ev);
|
||||
// send the cached location
|
||||
SendLocation(lastPosition);
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@ -411,6 +331,9 @@ nsGeolocationRequest::SetTimeoutTimer()
|
||||
mTimeoutTimer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
mTimeoutTimer->InitWithCallback(this, timeout, nsITimer::TYPE_ONE_SHOT);
|
||||
}
|
||||
|
||||
mAllowed = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
@ -425,11 +348,6 @@ 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);
|
||||
@ -447,7 +365,7 @@ nsGeolocationRequest::SendLocation(nsIDOMGeoPosition* aPosition)
|
||||
JSContext* cx;
|
||||
stack->Pop(&cx);
|
||||
|
||||
SetTimeoutTimer();
|
||||
mHasSentData = PR_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
@ -482,8 +400,6 @@ NS_IMPL_THREADSAFE_RELEASE(nsGeolocationService)
|
||||
|
||||
|
||||
static PRBool sGeoEnabled = PR_TRUE;
|
||||
static PRBool sGeoIgnoreLocationFilter = PR_FALSE;
|
||||
|
||||
static int
|
||||
GeoEnabledChangedCallback(const char *aPrefName, void *aClosure)
|
||||
{
|
||||
@ -491,26 +407,10 @@ 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);
|
||||
@ -870,6 +770,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsGeolocation)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
nsGeolocation::nsGeolocation()
|
||||
: mUpdateInProgress(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
@ -957,26 +858,33 @@ nsGeolocation::RemoveRequest(nsGeolocationRequest* aRequest)
|
||||
void
|
||||
nsGeolocation::Update(nsIDOMGeoPosition *aSomewhere)
|
||||
{
|
||||
if (!WindowOwnerStillExists())
|
||||
return Shutdown();
|
||||
// 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.
|
||||
|
||||
printf("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= nsGeolocation::Update called and there are %d / %d pending\n", mPendingCallbacks.Length(), mWatchingCallbacks.Length());
|
||||
if (mUpdateInProgress)
|
||||
return;
|
||||
|
||||
mUpdateInProgress = PR_TRUE;
|
||||
|
||||
if (!WindowOwnerStillExists())
|
||||
{
|
||||
Shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
// notify anyone that has been waiting
|
||||
for (PRUint32 i = 0; i< mPendingCallbacks.Length(); i++) {
|
||||
nsCOMPtr<nsIRunnable> ev = new RequestSendLocationEvent(aSomewhere, mPendingCallbacks[i]);
|
||||
NS_DispatchToMainThread(ev);
|
||||
}
|
||||
for (PRUint32 i = 0; i< mPendingCallbacks.Length(); i++)
|
||||
mPendingCallbacks[i]->SendLocation(aSomewhere);
|
||||
mPendingCallbacks.Clear();
|
||||
|
||||
// notify everyone that is watching
|
||||
for (PRUint32 i = 0; i< mWatchingCallbacks.Length(); i++) {
|
||||
nsCOMPtr<nsIRunnable> ev = new RequestSendLocationEvent(aSomewhere, mWatchingCallbacks[i]);
|
||||
NS_DispatchToMainThread(ev);
|
||||
}
|
||||
|
||||
printf("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= nsGeolocation::Update DONE\n");
|
||||
for (PRUint32 i = 0; i< mWatchingCallbacks.Length(); i++)
|
||||
mWatchingCallbacks[i]->SendLocation(aSomewhere);
|
||||
|
||||
mUpdateInProgress = PR_FALSE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1002,16 +910,16 @@ nsGeolocation::GetCurrentPosition(nsIDOMGeoPositionCallback *callback,
|
||||
if (mOwner) {
|
||||
RegisterRequestWithPrompt(request);
|
||||
mPendingCallbacks.AppendElement(request);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!nsContentUtils::IsCallerChrome())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mPendingCallbacks.AppendElement(request);
|
||||
request->Allow();
|
||||
|
||||
nsCOMPtr<nsIRunnable> ev = new RequestAllowEvent(true, request);
|
||||
NS_DispatchToMainThread(ev);
|
||||
mPendingCallbacks.AppendElement(request);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1133,16 +1041,10 @@ nsGeolocation::RegisterRequestWithPrompt(nsGeolocationRequest* request)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (nsContentUtils::GetBoolPref("geo.prompt.testing", PR_FALSE))
|
||||
{
|
||||
printf("************** Geolocation Prompt is in test mode.\n");
|
||||
nsCOMPtr<nsIRunnable> ev = new RequestAllowEvent(nsContentUtils::GetBoolPref("geo.prompt.testing.allow", PR_FALSE), request);
|
||||
NS_DispatchToMainThread(ev);
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRunnable> ev = new RequestPromptEvent(request);
|
||||
NS_DispatchToMainThread(ev);
|
||||
nsCOMPtr<nsIGeolocationPrompt> 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 !defined(WINCE_WINDOWS_MOBILE) && !defined(MOZ_MAEMO_LIBLOCATION) && !defined(ANDROID)
|
||||
|
@ -94,7 +94,6 @@ class nsGeolocationRequest
|
||||
void SendLocation(nsIDOMGeoPosition* location);
|
||||
void MarkCleared();
|
||||
PRBool Allowed() {return mAllowed;}
|
||||
void SetTimeoutTimer();
|
||||
|
||||
~nsGeolocationRequest();
|
||||
|
||||
@ -107,6 +106,7 @@ class nsGeolocationRequest
|
||||
void NotifyError(PRInt16 errorCode);
|
||||
PRPackedBool mAllowed;
|
||||
PRPackedBool mCleared;
|
||||
PRPackedBool mHasSentData;
|
||||
|
||||
nsCOMPtr<nsITimer> mTimeoutTimer;
|
||||
nsCOMPtr<nsIDOMGeoPositionCallback> mCallback;
|
||||
@ -232,6 +232,8 @@ private:
|
||||
nsTArray<nsRefPtr<nsGeolocationRequest> > mPendingCallbacks;
|
||||
nsTArray<nsRefPtr<nsGeolocationRequest> > mWatchingCallbacks;
|
||||
|
||||
PRBool mUpdateInProgress;
|
||||
|
||||
// window that this was created for. Weak reference.
|
||||
nsWeakPtr mOwner;
|
||||
|
||||
|
@ -24,11 +24,13 @@ 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();
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -45,26 +45,31 @@ include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_TEST_FILES = \
|
||||
test_allowCurrent.html \
|
||||
test_allowWatch.html \
|
||||
test_cancelCurrent.html \
|
||||
test_cancelWatch.html \
|
||||
test_clearWatch.html \
|
||||
test_clearWatch_invalid.html \
|
||||
test_manyCurrentConcurrent.html \
|
||||
test_manyCurrentSerial.html \
|
||||
test_manyCurrentConcurrent.html \
|
||||
test_garbageWatch.html \
|
||||
test_manyWatchConcurrent.html \
|
||||
test_manyWatchSerial.html \
|
||||
test_manyWindows.html \
|
||||
test_optional_api_params.html \
|
||||
test_allowCurrent.html \
|
||||
test_allowWatch.html \
|
||||
test_clearWatch.html \
|
||||
test_clearWatch_invalid.html \
|
||||
test_timeoutWatch.html \
|
||||
test_windowClose.html \
|
||||
test_timerRestartWatch.html \
|
||||
geolocation.html \
|
||||
geolocation_common.js \
|
||||
network_geolocation.sjs \
|
||||
windowTest.html \
|
||||
geolocation_common.js \
|
||||
geolocation.html \
|
||||
test_optional_api_params.html \
|
||||
network_geolocation.sjs \
|
||||
$(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)
|
||||
|
||||
|
@ -1,33 +1,10 @@
|
||||
|
||||
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()
|
||||
@ -35,9 +12,6 @@ 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()
|
||||
@ -45,9 +19,6 @@ 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()
|
||||
@ -81,4 +52,60 @@ 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")[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;
|
||||
|
@ -20,19 +20,29 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=478911
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
resume_geolocationProvider();
|
||||
force_prompt(true);
|
||||
var hasAccepted = false;
|
||||
|
||||
function successCallback(position) {
|
||||
|
||||
dump("aaaaaaaaaaaaaa!!!\n");
|
||||
ok(hasAccepted, "Ensure that accept was pressed");
|
||||
check_geolocation(position);
|
||||
reset_prompt();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
navigator.geolocation.getCurrentPosition(successCallback);
|
||||
function accept() {
|
||||
hasAccepted = true;
|
||||
clickNotificationButton(kAcceptButton);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var options = {
|
||||
maximumAge: 0,
|
||||
};
|
||||
|
||||
// one-shot position requests
|
||||
navigator.geolocation.getCurrentPosition(successCallback, null, options);
|
||||
|
||||
setTimeout(accept, 50);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
@ -20,21 +20,31 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=478911
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
resume_geolocationProvider();
|
||||
force_prompt(true);
|
||||
|
||||
var watchID;
|
||||
var hasAccepted = false;
|
||||
|
||||
function successCallback(position) {
|
||||
ok(hasAccepted, "Ensure that accept was pressed");
|
||||
check_geolocation(position);
|
||||
|
||||
navigator.geolocation.clearWatch(watchID);
|
||||
reset_prompt();
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function accept() {
|
||||
hasAccepted = true;
|
||||
clickNotificationButton(kAcceptButton);
|
||||
}
|
||||
|
||||
/** Test for Bug **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
watchID = navigator.geolocation.watchPosition(successCallback, null, null);
|
||||
|
||||
setTimeout(accept, 50);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
@ -20,24 +20,25 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=478911
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
resume_geolocationProvider();
|
||||
force_prompt(false);
|
||||
|
||||
function failureCallback(error) {
|
||||
ok(error.code == error.PERMISSION_DENIED, "Ensure that the error was PERMISSION_DENIED");
|
||||
reset_prompt();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function successCallback(position){
|
||||
ok(0, "Success was called when it shouldn't have been. major problem");
|
||||
reset_prompt();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
/** Test for Bug **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
navigator.geolocation.getCurrentPosition(successCallback, failureCallback, null);
|
||||
|
||||
// click deny
|
||||
setTimeout(clickNotificationButton, 50, kDenyButton);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
@ -20,26 +20,27 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=478911
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
resume_geolocationProvider();
|
||||
force_prompt(false);
|
||||
|
||||
var watchID;
|
||||
|
||||
function failureCallback(error) {
|
||||
ok(error.code == error.PERMISSION_DENIED, "Ensure that the error was PERMISSION_DENIED");
|
||||
reset_prompt();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function successCallback(position){
|
||||
ok(0, "Success was called when it shouldn't have been. major problem");
|
||||
reset_prompt();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
/** Test for Bug **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
watchID = navigator.geolocation.watchPosition(successCallback, failureCallback, null);
|
||||
|
||||
// click deny
|
||||
setTimeout(clickNotificationButton, 50, kDenyButton);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
@ -20,13 +20,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=478911
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
resume_geolocationProvider();
|
||||
force_prompt(true)
|
||||
|
||||
var watchID;
|
||||
var hasBeenCleared = false;
|
||||
var successWasCalledAfterClear = false;
|
||||
|
||||
function failureCallback(error)
|
||||
{
|
||||
ok(0, "we should not be seeing failures from this watchPosition");
|
||||
@ -34,7 +29,8 @@ function failureCallback(error)
|
||||
|
||||
function successCallback(position) {
|
||||
if (hasBeenCleared == true) {
|
||||
successWasCalledAfterClear = true;
|
||||
// we should not be called here
|
||||
ok(0, "successCallback was called after clear");
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,17 +40,22 @@ function clearWatch() {
|
||||
}
|
||||
|
||||
function testAccepted() {
|
||||
ok(!successWasCalledAfterClear, "The successCallback should not be called after clear");
|
||||
reset_prompt();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
||||
/** Test for Bug **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
watchID = navigator.geolocation.watchPosition(successCallback, failureCallback, null);
|
||||
|
||||
setTimeout(clearWatch, 250);
|
||||
setTimeout(clickNotificationButton, 10, kAcceptButton);
|
||||
|
||||
setTimeout(testAccepted, 2000);
|
||||
setTimeout(clearWatch, 50);
|
||||
|
||||
// wait for position changes
|
||||
setTimeout(testAccepted, 1000);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
@ -19,6 +19,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=463039
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/** Test for Bug 463039 **/
|
||||
|
||||
// there are no watches, so this should always throw
|
||||
for (x=-10; x<10; x++) {
|
||||
navigator.geolocation.clearWatch(x);
|
||||
|
@ -22,23 +22,18 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=482260
|
||||
/** Test for Bug **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
resume_geolocationProvider();
|
||||
force_prompt(true);
|
||||
|
||||
start_sending_garbage();
|
||||
|
||||
function successCallback(pos){
|
||||
ok(false, "success should have never been called.");
|
||||
dump("success callback sent: " + pos + "\n");
|
||||
stop_sending_garbage();
|
||||
reset_prompt();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function errorCallback(err) {
|
||||
ok(err.code == err.TIMEOUT, "ensure error is a timeout.");
|
||||
stop_sending_garbage();
|
||||
reset_prompt();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
@ -52,6 +47,8 @@ navigator.geolocation.watchPosition(successCallback,
|
||||
errorCallback,
|
||||
options);
|
||||
|
||||
setTimeout(clickNotificationButton, 10, kAcceptButton);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
@ -20,25 +20,40 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=482260
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
resume_geolocationProvider();
|
||||
force_prompt(true);
|
||||
var completeCount = 100;
|
||||
|
||||
var hasAccepted = false;
|
||||
|
||||
var successCallbackCalled = false;
|
||||
|
||||
function successCallback(position) {
|
||||
successCallbackCalled = true;
|
||||
check_geolocation(position);
|
||||
}
|
||||
|
||||
for (var x = 0; x < 100; x++)
|
||||
navigator.geolocation.getCurrentPosition(successCallback);
|
||||
function accept() {
|
||||
hasAccepted = true;
|
||||
clickNotificationButton(kAcceptButton);
|
||||
}
|
||||
|
||||
function testPassed() {
|
||||
ok(successCallbackCalled, "if nothing crashed, all okay");
|
||||
reset_prompt();
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// one-shot position requests
|
||||
|
||||
var options = {
|
||||
maximumAge: 0,
|
||||
};
|
||||
|
||||
var y = completeCount;
|
||||
for (var x=0; x< y; x++)
|
||||
navigator.geolocation.getCurrentPosition(successCallback, null, options);
|
||||
|
||||
setTimeout(accept, 50);
|
||||
setTimeout(done, 1000);
|
||||
|
||||
function done() {
|
||||
completeCount--;
|
||||
ok(1, "Saw all successCallbacks");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
setTimeout(testPassed, 1000);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
@ -20,27 +20,33 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=482260
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
var completeCount = 1000;
|
||||
|
||||
resume_geolocationProvider();
|
||||
force_prompt(true)
|
||||
|
||||
var keepGoing = 10;
|
||||
var hasAccepted = false;
|
||||
|
||||
function successCallback(position) {
|
||||
dump("----------> "+ keepGoing +"\n");
|
||||
|
||||
if (keepGoing-- > 0) {
|
||||
setTimeout(function() {navigator.geolocation.getCurrentPosition(successCallback);}, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
ok(1, "100 successful calls");
|
||||
reset_prompt();
|
||||
check_geolocation(position);
|
||||
completeCount--;
|
||||
if (completeCount > 0)
|
||||
navigator.geolocation.getCurrentPosition(successCallback, null, null);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
navigator.geolocation.getCurrentPosition(successCallback);
|
||||
function accept() {
|
||||
hasAccepted = true;
|
||||
clickNotificationButton(kAcceptButton);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var options = {
|
||||
maximumAge: 0,
|
||||
};
|
||||
|
||||
// one-shot position requests
|
||||
navigator.geolocation.getCurrentPosition(successCallback, null, options);
|
||||
|
||||
setTimeout(accept, 50);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
@ -20,25 +20,40 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=482260
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
resume_geolocationProvider();
|
||||
force_prompt(true);
|
||||
var completeCount = 100;
|
||||
|
||||
var hasAccepted = false;
|
||||
|
||||
var successCallbackCalled = false;
|
||||
|
||||
function successCallback(position) {
|
||||
successCallbackCalled = true;
|
||||
check_geolocation(position);
|
||||
}
|
||||
|
||||
for (var x = 0; x < 100; x++)
|
||||
navigator.geolocation.watchPosition(successCallback);
|
||||
function accept() {
|
||||
hasAccepted = true;
|
||||
clickNotificationButton(kAcceptButton);
|
||||
}
|
||||
|
||||
function testPassed() {
|
||||
ok(successCallbackCalled, "if nothing crashed, all okay");
|
||||
reset_prompt();
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// one-shot position requests
|
||||
|
||||
var options = {
|
||||
maximumAge: 0,
|
||||
};
|
||||
|
||||
var y = completeCount;
|
||||
for (var x=0; x< y; x++)
|
||||
navigator.geolocation.watchPosition(successCallback, null, options);
|
||||
|
||||
setTimeout(accept, 50);
|
||||
setTimeout(done, 1000);
|
||||
|
||||
function done() {
|
||||
completeCount--;
|
||||
ok(1, "Saw all successCallbacks");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
setTimeout(testPassed, 1000);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
@ -20,15 +20,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=482260
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
resume_geolocationProvider();
|
||||
force_prompt(true);
|
||||
|
||||
var hasAccepted = false;
|
||||
var watchID = 0;
|
||||
var completeCount = 10;
|
||||
|
||||
var options = {
|
||||
maximumAge: 0,
|
||||
};
|
||||
|
||||
function successCallback(position) {
|
||||
check_geolocation(position);
|
||||
|
||||
navigator.geolocation.clearWatch(watchID);
|
||||
|
||||
@ -36,15 +37,23 @@ function successCallback(position) {
|
||||
|
||||
if (completeCount==0) {
|
||||
ok(1, "all watchPosition successCallbacks called");
|
||||
reset_prompt();
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
} else {
|
||||
watchID = navigator.geolocation.watchPosition(successCallback, null, options);
|
||||
setTimeout(accept, 50);
|
||||
}
|
||||
|
||||
watchID = navigator.geolocation.watchPosition(successCallback);
|
||||
}
|
||||
|
||||
watchID = navigator.geolocation.watchPosition(successCallback);
|
||||
function accept() {
|
||||
hasAccepted = true;
|
||||
clickNotificationButton(kAcceptButton);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// one-shot position requests
|
||||
watchID = navigator.geolocation.watchPosition(successCallback, null, options);
|
||||
setTimeout(accept, 50);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
@ -21,10 +21,6 @@ href="https://bugzilla.mozilla.org/show_bug.cgi?id=478911">Crash in Multiple Win
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
// ensure we are using the right testing provider
|
||||
resume_geolocationProvider();
|
||||
force_prompt(true);
|
||||
|
||||
/** Test for Bug **/
|
||||
|
||||
var numberOfWindows = 5; // 20 seems to be the default max popups during the mochitest run
|
||||
@ -52,7 +48,6 @@ function checkDone()
|
||||
{
|
||||
ok(navigator.geolocation, "Opened a bunch of windows and didn't crash.");
|
||||
clearInterval(timer);
|
||||
reset_prompt();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=452566
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
// ensure we are using the right testing provider
|
||||
resume_geolocationProvider();
|
||||
force_prompt(true)
|
||||
|
||||
/** Test for Bug 452566 **/
|
||||
|
||||
const NOT_ENOUGH_ARGS = 2153185281;
|
||||
@ -109,8 +105,9 @@ try {
|
||||
}
|
||||
ok(!exception, exception);
|
||||
|
||||
// Successful calls trigger a geolocation notification,
|
||||
// so clean up ready for the next test.
|
||||
reset_prompt();
|
||||
clickNotificationButton(kAcceptButton);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
@ -21,10 +21,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=455327
|
||||
<script class="testbody" type="text/javascript">
|
||||
/** Test for Bug **/
|
||||
|
||||
// ensure we are using the right testing provider
|
||||
resume_geolocationProvider();
|
||||
force_prompt(true);
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
stop_geolocationProvider();
|
||||
@ -32,7 +28,6 @@ stop_geolocationProvider();
|
||||
function successCallback(pos){
|
||||
ok(false, "success should have never been called.");
|
||||
resume_geolocationProvider();
|
||||
reset_prompt()
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
@ -42,7 +37,6 @@ function errorCallback(err) {
|
||||
else
|
||||
ok(err.code == err.TIMEOUT, "ensure error is a timeout.");
|
||||
resume_geolocationProvider();
|
||||
reset_prompt()
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
@ -55,6 +49,9 @@ var options = {
|
||||
navigator.geolocation.watchPosition(successCallback,
|
||||
errorCallback,
|
||||
options);
|
||||
|
||||
setTimeout(clickNotificationButton, 10, kAcceptButton);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
@ -1,55 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=526326
|
||||
-->
|
||||
<head>
|
||||
<title>Test for watchPosition </title>
|
||||
<script type="text/javascript" src="/MochiKit/packed.js"></script>
|
||||
<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=526326">Mozilla Bug 526326</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// ensure we are using the right testing provider
|
||||
resume_geolocationProvider();
|
||||
force_prompt(true);
|
||||
|
||||
var watchID;
|
||||
|
||||
function errorCallback(err) {
|
||||
ok(err.code == err.TIMEOUT, "ensure error is a timeout.");
|
||||
resume_geolocationProvider();
|
||||
reset_prompt();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function successCallback(position) {
|
||||
// Now that we got a success callback, lets try to ensure
|
||||
// that we get a timeout error.
|
||||
stop_geolocationProvider();
|
||||
}
|
||||
|
||||
var options = {
|
||||
maximumAge: 0,
|
||||
timeout: 1000
|
||||
};
|
||||
|
||||
watchID = navigator.geolocation.watchPosition(successCallback, errorCallback, options);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -21,13 +21,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=493615
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
function done() {
|
||||
ok(1, "no crash, so pass.");
|
||||
SimpleTest.finish();
|
||||
reset_prompt();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
force_prompt(true);
|
||||
|
||||
window.open("windowTest.html");
|
||||
|
||||
|
@ -26,7 +26,13 @@ function successCallback(position) {
|
||||
opener.done();
|
||||
}
|
||||
|
||||
function accept() {
|
||||
clickNotificationButton(kAcceptButton);
|
||||
}
|
||||
|
||||
navigator.geolocation.watchPosition(successCallback, null, null);
|
||||
setTimeout(accept, 50);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user