Bug 779680 - about:neterror's GoOnline() should be invoked from events, not nsDOMWindowUtils. r=bz,dolske

This commit is contained in:
Blair McBride 2012-08-10 15:43:54 +12:00
parent 8f541ca7c2
commit 7a29a9894a
2 changed files with 14 additions and 8 deletions

View File

@ -2515,6 +2515,9 @@ let BrowserOnClick = {
else if (/^about:blocked/.test(ownerDoc.documentURI)) {
this.onAboutBlocked(originalTarget, ownerDoc);
}
else if (/^about:neterror/.test(ownerDoc.documentURI)) {
this.onAboutNetError(originalTarget, ownerDoc);
}
else if (/^about:home$/i.test(ownerDoc.documentURI)) {
this.onAboutHome(originalTarget, ownerDoc);
}
@ -2681,6 +2684,13 @@ let BrowserOnClick = {
notification.persistence = -1;
},
onAboutNetError: function BrowserOnClick_onAboutNetError(aTargetElm, aOwnerDoc) {
let elmId = aTargetElm.getAttribute("id");
if (elmId != "errorTryAgain" || !/e=netOffline/.test(aOwnerDoc.documentURI))
return;
Services.io.offline = false;
},
onAboutHome: function BrowserOnClick_onAboutHome(aTargetElm, aOwnerDoc) {
let elmId = aTargetElm.getAttribute("id");
@ -4476,11 +4486,11 @@ var TabsProgressListener = {
if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
Components.isSuccessCode(aStatus) &&
/^about:/.test(aWebProgress.DOMWindow.document.documentURI)) {
aBrowser.addEventListener("click", BrowserOnClick, false);
aBrowser.addEventListener("click", BrowserOnClick, true);
aBrowser.addEventListener("pagehide", function onPageHide(event) {
if (event.target.defaultView.frameElement)
return;
aBrowser.removeEventListener("click", BrowserOnClick, false);
aBrowser.removeEventListener("click", BrowserOnClick, true);
aBrowser.removeEventListener("pagehide", onPageHide, true);
}, true);

View File

@ -75,12 +75,8 @@
function retryThis(buttonEl)
{
// If this is the "Offline mode" page, go online!
if (getErrorCode() == "netOffline") {
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils)
.goOnline();
}
// Note: The application may wish to handle switching off "offline mode"
// before this event handler runs, but using a capturing event handler.
// Session history has the URL of the page that failed
// to load, not the one of the error page. So, just call