Bug 1106075 - Fix for double click to try again for offline errors. r=Dao

This commit is contained in:
Jim Mathies 2015-01-14 04:46:55 -06:00
parent f2389f4bbb
commit 55c70f3624
3 changed files with 25 additions and 15 deletions

View File

@ -2562,7 +2562,7 @@ let BrowserOnClick = {
let mm = window.messageManager;
mm.addMessageListener("Browser:CertExceptionError", this);
mm.addMessageListener("Browser:SiteBlockedError", this);
mm.addMessageListener("Browser:NetworkError", this);
mm.addMessageListener("Browser:EnableOnlineMode", this);
mm.addMessageListener("Browser:SendSSLErrorReport", this);
mm.addMessageListener("Browser:SetSSLErrorReportAuto", this);
},
@ -2571,7 +2571,7 @@ let BrowserOnClick = {
let mm = window.messageManager;
mm.removeMessageListener("Browser:CertExceptionError", this);
mm.removeMessageListener("Browser:SiteBlockedError", this);
mm.removeMessageListener("Browser:NetworkError", this);
mm.removeMessageListener("Browser:EnableOnlineMode", this);
mm.removeMessageListener("Browser:SendSSLErrorReport", this);
mm.removeMessageListener("Browser:SetSSLErrorReportAuto", this);
},
@ -2605,9 +2605,12 @@ let BrowserOnClick = {
this.onAboutBlocked(msg.data.elementId, msg.data.isMalware,
msg.data.isTopFrame, msg.data.location);
break;
case "Browser:NetworkError":
// Reset network state, the error page will refresh on its own.
Services.io.offline = false;
case "Browser:EnableOnlineMode":
if (Services.io.offline) {
// Reset network state and refresh the page.
Services.io.offline = false;
msg.target.reload();
}
break;
case "Browser:SendSSLErrorReport":
this.onSSLErrorReport(msg.target, msg.data.elementId,

View File

@ -568,7 +568,8 @@ let ClickEventHandler = {
this.onAboutBlocked(originalTarget, ownerDoc);
return;
} else if (ownerDoc.documentURI.startsWith("about:neterror")) {
this.onAboutNetError(originalTarget, ownerDoc);
this.onAboutNetError(event, ownerDoc.documentURI);
return;
}
let [href, node] = this._hrefAndLinkNodeForClickEvent(event);
@ -635,12 +636,18 @@ let ClickEventHandler = {
});
},
onAboutNetError: function (targetElement, ownerDoc) {
let elmId = targetElement.getAttribute("id");
if (elmId != "errorTryAgain" || !/e=netOffline/.test(ownerDoc.documentURI)) {
onAboutNetError: function (event, documentURI) {
let elmId = event.originalTarget.getAttribute("id");
if (elmId != "errorTryAgain" || !/e=netOffline/.test(documentURI)) {
return;
}
sendSyncMessage("Browser:NetworkError", {});
// browser front end will handle clearing offline mode and refreshing
// the page *if* we're in offline mode now. Otherwise let the error page
// handle the click.
if (Services.io.offline) {
event.preventDefault();
sendAsyncMessage("Browser:EnableOnlineMode", {});
}
},
/**

View File

@ -56,12 +56,12 @@ function checkPage() {
// the actual example.com.
Services.prefs.setIntPref("network.proxy.type", proxyPrefValue);
Services.obs.addObserver(function observer(aSubject, aTopic) {
ok(!Services.io.offline, "After clicking the Try Again button, we're back " +
"online.");
finish();
}, "network:offline-status-changed", false);
gBrowser.contentDocument.getElementById("errorTryAgain").click();
ok(!Services.io.offline, "After clicking the Try Again button, we're back " +
"online.");
finish();
}
registerCleanupFunction(function() {