зеркало из https://github.com/mozilla/pjs.git
Bug 488862 - crash while geolocation is retrieving data [@ nsGeolocation::RemoveRequest]. r=dbaron, sr=smaug, r=ctalbert on tests
This commit is contained in:
Родитель
6288b288fa
Коммит
049a7b887e
|
@ -179,7 +179,7 @@ NS_INTERFACE_MAP_END
|
|||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsGeolocationRequest)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsGeolocationRequest)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_3(nsGeolocationRequest, mCallback, mErrorCallback, mOptions)
|
||||
NS_IMPL_CYCLE_COLLECTION_4(nsGeolocationRequest, mCallback, mErrorCallback, mOptions, mLocator)
|
||||
|
||||
|
||||
void
|
||||
|
|
|
@ -94,7 +94,7 @@ class nsGeolocationRequest : public nsIGeolocationRequest, public nsITimerCallba
|
|||
nsCOMPtr<nsIDOMGeoPositionErrorCallback> mErrorCallback;
|
||||
nsCOMPtr<nsIDOMGeoPositionOptions> mOptions;
|
||||
|
||||
nsGeolocation* mLocator; // The locator exists longer than this object.
|
||||
nsRefPtr<nsGeolocation> mLocator;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,8 +1,69 @@
|
|||
<html> <head>
|
||||
<title>Simple access of geolocation</title>
|
||||
<head>
|
||||
<script>
|
||||
|
||||
document.writeln(navigator.geolocation);
|
||||
// This is copied from geolocation-common.js. We do this so
|
||||
// that we do not document write ANYTHING to this page.
|
||||
|
||||
function getNotificationBox()
|
||||
{
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
function getChromeWindow(aWindow) {
|
||||
var chromeWin = aWindow
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShellTreeItem)
|
||||
.rootTreeItem
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindow)
|
||||
.QueryInterface(Ci.nsIDOMChromeWindow);
|
||||
return chromeWin;
|
||||
}
|
||||
|
||||
var notifyWindow = window.top;
|
||||
|
||||
var chromeWin = getChromeWindow(notifyWindow);
|
||||
|
||||
var notifyBox = chromeWin.getNotificationBox(notifyWindow);
|
||||
|
||||
return notifyBox;
|
||||
}
|
||||
|
||||
|
||||
function clickNotificationButton(aButtonIndex) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
|
||||
// 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();
|
||||
var bar = box.getNotificationWithValue("geolocation");
|
||||
var button = bar.getElementsByTagName("button").item(aButtonIndex);
|
||||
button.doCommand();
|
||||
}
|
||||
|
||||
const kAcceptButton = 0;
|
||||
const kDenyButton = 1;
|
||||
|
||||
gotPosition = function(location){
|
||||
document.location.href="http://www.mozilla.org";
|
||||
};
|
||||
|
||||
failPosition = function(error){
|
||||
document.location.href="http://www.mozilla.org";
|
||||
};
|
||||
|
||||
function accept() {
|
||||
clickNotificationButton(kAcceptButton);
|
||||
}
|
||||
|
||||
navigator.geolocation.getCurrentPosition(gotPosition,
|
||||
failPosition,
|
||||
{timeout:30000});
|
||||
|
||||
setTimeout(accept, 1000);
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
|
|
@ -23,7 +23,7 @@ href="https://bugzilla.mozilla.org/show_bug.cgi?id=478911">Crash in Multiple Win
|
|||
|
||||
/** Test for Bug **/
|
||||
|
||||
var numberOfWindows = 2; // 20 seems to be the default max popups during the mochitest run
|
||||
var numberOfWindows = 5; // 20 seems to be the default max popups during the mochitest run
|
||||
var totalWindows = numberOfWindows;
|
||||
|
||||
var windows = new Array(numberOfWindows);
|
||||
|
@ -32,9 +32,12 @@ for(var i = 0; i < numberOfWindows; i++) {
|
|||
windows[i] = window.open("geolocation.html", "_blank", "width=700,height=400");
|
||||
}
|
||||
|
||||
for(var i = 0; i < numberOfWindows; i++) {
|
||||
windows[i].close();
|
||||
totalWindows --;
|
||||
function closeWindows()
|
||||
{
|
||||
for(var i = 0; i < numberOfWindows; i++) {
|
||||
windows[i].close();
|
||||
totalWindows --;
|
||||
}
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
@ -51,6 +54,8 @@ function checkDone()
|
|||
|
||||
var timer = setInterval(checkDone, 1000);
|
||||
|
||||
setTimeout(closeWindows, 5000);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -684,4 +684,19 @@ NS_CYCLE_COLLECTION_PARTICIPANT_INSTANCE
|
|||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f3) \
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
#define NS_IMPL_CYCLE_COLLECTION_4(_class, _f1, _f2, _f3, _f4) \
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(_class) \
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(_class) \
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f1) \
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f2) \
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f3) \
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(_f4) \
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END \
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(_class) \
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f1) \
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f2) \
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f3) \
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_f4) \
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
#endif // nsCycleCollectionParticipant_h__
|
||||
|
|
Загрузка…
Ссылка в новой задаче