Backed out changeset a09f27b6dceb (bug 1297630) for bc failures on content/test/about/browser_aboutNetError.js and en-us failures on functional/security/test_ssl_disabled_error_page.py on a CLOSED TREE

This commit is contained in:
Gurzau Raul 2018-03-16 18:27:17 +02:00
Родитель c5a476ff39
Коммит 15dec6f886
2 изменённых файлов: 61 добавлений и 70 удалений

Просмотреть файл

@ -3008,8 +3008,7 @@ var BrowserOnClick = {
case "Browser:CertExceptionError": case "Browser:CertExceptionError":
this.onCertError(msg.target, msg.data.elementId, this.onCertError(msg.target, msg.data.elementId,
msg.data.isTopFrame, msg.data.location, msg.data.isTopFrame, msg.data.location,
msg.data.securityInfoAsString, msg.data.securityInfoAsString);
msg.data.frameId);
break; break;
case "Browser:OpenCaptivePortalPage": case "Browser:OpenCaptivePortalPage":
CaptivePortalWatcher.ensureCaptivePortalTab(); CaptivePortalWatcher.ensureCaptivePortalTab();
@ -3054,7 +3053,7 @@ var BrowserOnClick = {
} }
}, },
onCertError(browser, elementId, isTopFrame, location, securityInfoAsString, frameId) { onCertError(browser, elementId, isTopFrame, location, securityInfoAsString) {
let secHistogram = Services.telemetry.getHistogramById("SECURITY_UI"); let secHistogram = Services.telemetry.getHistogramById("SECURITY_UI");
let securityInfo; let securityInfo;
@ -3105,10 +3104,9 @@ var BrowserOnClick = {
securityInfo = getSecurityInfo(securityInfoAsString); securityInfo = getSecurityInfo(securityInfoAsString);
let errorInfo = getDetailedCertErrorInfo(location, let errorInfo = getDetailedCertErrorInfo(location,
securityInfo); securityInfo);
browser.messageManager.sendAsyncMessage("CertErrorDetails", { browser.messageManager.sendAsyncMessage( "CertErrorDetails", {
code: securityInfo.errorCode, code: securityInfo.errorCode,
info: errorInfo, info: errorInfo
frameId,
}); });
break; break;

Просмотреть файл

@ -234,35 +234,30 @@ var AboutNetAndCertErrorListener = {
chromeGlobal.addEventListener("AboutNetErrorResetPreferences", this, false, true); chromeGlobal.addEventListener("AboutNetErrorResetPreferences", this, false, true);
}, },
isAboutNetError(doc) { get isAboutNetError() {
return doc.documentURI.startsWith("about:neterror"); return content.document.documentURI.startsWith("about:neterror");
}, },
isAboutCertError(doc) { get isAboutCertError() {
return doc.documentURI.startsWith("about:certerror"); return content.document.documentURI.startsWith("about:certerror");
}, },
receiveMessage(msg) { receiveMessage(msg) {
if (msg.name == "CertErrorDetails") { if (!this.isAboutCertError) {
let frameDocShell = WebNavigationFrames.findDocShell(msg.data.frameId, docShell); return;
// We need nsIWebNavigation to access docShell.document. }
frameDocShell && frameDocShell.QueryInterface(Ci.nsIWebNavigation);
if (!frameDocShell || !this.isAboutCertError(frameDocShell.document)) {
return;
}
this.onCertErrorDetails(msg, frameDocShell); switch (msg.name) {
} else if (msg.name == "Browser:CaptivePortalFreed") { case "CertErrorDetails":
// TODO: This check is not correct for frames. this.onCertErrorDetails(msg);
if (!this.isAboutCertError(content.document)) { break;
return; case "Browser:CaptivePortalFreed":
} this.onCaptivePortalFreed(msg);
break;
this.onCaptivePortalFreed(msg);
} }
}, },
_getCertValidityRange(docShell) { _getCertValidityRange() {
let {securityInfo} = docShell.failedChannel; let {securityInfo} = docShell.failedChannel;
securityInfo.QueryInterface(Ci.nsITransportSecurityInfo); securityInfo.QueryInterface(Ci.nsITransportSecurityInfo);
let certs = securityInfo.failedCertChain.getEnumerator(); let certs = securityInfo.failedCertChain.getEnumerator();
@ -280,12 +275,10 @@ var AboutNetAndCertErrorListener = {
return {notBefore, notAfter}; return {notBefore, notAfter};
}, },
onCertErrorDetails(msg, docShell) { onCertErrorDetails(msg) {
let doc = docShell.document; let div = content.document.getElementById("certificateErrorText");
let div = doc.getElementById("certificateErrorText");
div.textContent = msg.data.info; div.textContent = msg.data.info;
let learnMoreLink = doc.getElementById("learnMoreLink"); let learnMoreLink = content.document.getElementById("learnMoreLink");
let baseURL = Services.urlFormatter.formatURLPref("app.support.baseURL"); let baseURL = Services.urlFormatter.formatURLPref("app.support.baseURL");
switch (msg.data.code) { switch (msg.data.code) {
@ -308,7 +301,7 @@ var AboutNetAndCertErrorListener = {
let lastFetched = Services.prefs.getIntPref(PREF_BLOCKLIST_LAST_FETCHED, 0) * 1000; let lastFetched = Services.prefs.getIntPref(PREF_BLOCKLIST_LAST_FETCHED, 0) * 1000;
let now = Date.now(); let now = Date.now();
let certRange = this._getCertValidityRange(docShell); let certRange = this._getCertValidityRange();
let approximateDate = now - difference * 1000; let approximateDate = now - difference * 1000;
// If the difference is more than a day, we last fetched the date in the last 5 days, // If the difference is more than a day, we last fetched the date in the last 5 days,
@ -322,12 +315,17 @@ var AboutNetAndCertErrorListener = {
// negative difference means local time is behind server time // negative difference means local time is behind server time
approximateDate = formatter.format(new Date(approximateDate)); approximateDate = formatter.format(new Date(approximateDate));
doc.getElementById("wrongSystemTime_URL").textContent = doc.location.hostname; content.document.getElementById("wrongSystemTime_URL")
doc.getElementById("wrongSystemTime_systemDate").textContent = systemDate; .textContent = content.document.location.hostname;
doc.getElementById("wrongSystemTime_actualDate").textContent = approximateDate; content.document.getElementById("wrongSystemTime_systemDate")
.textContent = systemDate;
content.document.getElementById("wrongSystemTime_actualDate")
.textContent = approximateDate;
doc.getElementById("errorShortDesc").style.display = "none"; content.document.getElementById("errorShortDesc")
doc.getElementById("wrongSystemTimePanel").style.display = "block"; .style.display = "none";
content.document.getElementById("wrongSystemTimePanel")
.style.display = "block";
// If there is no clock skew with Kinto servers, check against the build date. // If there is no clock skew with Kinto servers, check against the build date.
// (The Kinto ping could have happened when the time was still right, or not at all) // (The Kinto ping could have happened when the time was still right, or not at all)
@ -350,13 +348,15 @@ var AboutNetAndCertErrorListener = {
dateStyle: "short" dateStyle: "short"
}); });
doc.getElementById("wrongSystemTimeWithoutReference_URL") content.document.getElementById("wrongSystemTimeWithoutReference_URL")
.textContent = doc.location.hostname; .textContent = content.document.location.hostname;
doc.getElementById("wrongSystemTimeWithoutReference_systemDate") content.document.getElementById("wrongSystemTimeWithoutReference_systemDate")
.textContent = formatter.format(systemDate); .textContent = formatter.format(systemDate);
doc.getElementById("errorShortDesc").style.display = "none"; content.document.getElementById("errorShortDesc")
doc.getElementById("wrongSystemTimeWithoutReferencePanel").style.display = "block"; .style.display = "none";
content.document.getElementById("wrongSystemTimeWithoutReferencePanel")
.style.display = "block";
} }
} }
learnMoreLink.href = baseURL + "time-errors"; learnMoreLink.href = baseURL + "time-errors";
@ -369,14 +369,7 @@ var AboutNetAndCertErrorListener = {
}, },
handleEvent(aEvent) { handleEvent(aEvent) {
let doc; if (!this.isAboutNetError && !this.isAboutCertError) {
if (aEvent.originalTarget instanceof Ci.nsIDOMDocument) {
doc = aEvent.originalTarget;
} else {
doc = aEvent.originalTarget.ownerDocument;
}
if (!this.isAboutNetError(doc) && !this.isAboutCertError(doc)) {
return; return;
} }
@ -413,17 +406,14 @@ var AboutNetAndCertErrorListener = {
// Values for telemtery bins: see TLS_ERROR_REPORT_UI in Histograms.json // Values for telemtery bins: see TLS_ERROR_REPORT_UI in Histograms.json
const TLS_ERROR_REPORT_TELEMETRY_UI_SHOWN = 0; const TLS_ERROR_REPORT_TELEMETRY_UI_SHOWN = 0;
let originalTarget = evt.originalTarget; if (this.isAboutCertError) {
let ownerDoc = originalTarget.ownerDocument; let originalTarget = evt.originalTarget;
let ownerDoc = originalTarget.ownerDocument;
if (this.isAboutCertError(ownerDoc)) { ClickEventHandler.onCertError(originalTarget, ownerDoc);
ClickEventHandler.onCertError(originalTarget);
} }
let win = originalTarget.ownerGlobal;
let automatic = Services.prefs.getBoolPref("security.ssl.errorReporting.automatic"); let automatic = Services.prefs.getBoolPref("security.ssl.errorReporting.automatic");
win.dispatchEvent(new win.CustomEvent("AboutNetErrorOptions", { content.dispatchEvent(new content.CustomEvent("AboutNetErrorOptions", {
detail: JSON.stringify({ detail: JSON.stringify({
enabled: Services.prefs.getBoolPref("security.ssl.errorReporting.enabled"), enabled: Services.prefs.getBoolPref("security.ssl.errorReporting.enabled"),
changedCertPrefs: this.changedCertPrefs(), changedCertPrefs: this.changedCertPrefs(),
@ -452,7 +442,9 @@ var AboutNetAndCertErrorListener = {
// If we're enabling reports, send a report for this failure. // If we're enabling reports, send a report for this failure.
if (evt.detail) { if (evt.detail) {
let win = evt.originalTarget.ownerGlobal; let win = evt.originalTarget.ownerGlobal;
let docShell = win.document.docShell; let docShell = win.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell);
let {securityInfo} = docShell.failedChannel; let {securityInfo} = docShell.failedChannel;
securityInfo.QueryInterface(Ci.nsITransportSecurityInfo); securityInfo.QueryInterface(Ci.nsITransportSecurityInfo);
@ -486,13 +478,13 @@ var ClickEventHandler = {
// Handle click events from about pages // Handle click events from about pages
if (event.button == 0) { if (event.button == 0) {
if (AboutNetAndCertErrorListener.isAboutCertError(ownerDoc)) { if (ownerDoc.documentURI.startsWith("about:certerror")) {
this.onCertError(originalTarget); this.onCertError(originalTarget, ownerDoc);
return; return;
} else if (ownerDoc.documentURI.startsWith("about:blocked")) { } else if (ownerDoc.documentURI.startsWith("about:blocked")) {
this.onAboutBlocked(originalTarget, ownerDoc); this.onAboutBlocked(originalTarget, ownerDoc);
return; return;
} else if (AboutNetAndCertErrorListener.isAboutNetError(ownerDoc)) { } else if (ownerDoc.documentURI.startsWith("about:neterror")) {
this.onAboutNetError(event, ownerDoc.documentURI); this.onAboutNetError(event, ownerDoc.documentURI);
return; return;
} }
@ -546,7 +538,9 @@ var ClickEventHandler = {
// Only when the owner doc has |mixedContentChannel| and the same origin // Only when the owner doc has |mixedContentChannel| and the same origin
// should we allow mixed content. // should we allow mixed content.
json.allowMixedContent = false; json.allowMixedContent = false;
let docshell = ownerDoc.docShell; let docshell = ownerDoc.defaultView.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell);
if (docShell.mixedContentChannel) { if (docShell.mixedContentChannel) {
const sm = Services.scriptSecurityManager; const sm = Services.scriptSecurityManager;
try { try {
@ -568,15 +562,14 @@ var ClickEventHandler = {
} }
}, },
onCertError(targetElement) { onCertError(targetElement, ownerDoc) {
let win = targetElement.ownerGlobal; let docShell = ownerDoc.defaultView.QueryInterface(Ci.nsIInterfaceRequestor)
let frameId = WebNavigationFrames.getFrameId(win); .getInterface(Ci.nsIWebNavigation)
let docShell = win.document.docShell; .QueryInterface(Ci.nsIDocShell);
sendAsyncMessage("Browser:CertExceptionError", { sendAsyncMessage("Browser:CertExceptionError", {
frameId, location: ownerDoc.location.href,
location: win.document.location.href,
elementId: targetElement.getAttribute("id"), elementId: targetElement.getAttribute("id"),
isTopFrame: (win.parent === win), isTopFrame: (ownerDoc.defaultView.parent === ownerDoc.defaultView),
securityInfoAsString: getSerializedSecurityInfo(docShell), securityInfoAsString: getSerializedSecurityInfo(docShell),
}); });
}, },