Bug 1484873 - Add a "View Certificate" link to all cert error pages. r=nhnt11

Differential Revision: https://phabricator.services.mozilla.com/D8966

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Johann Hofmann 2018-10-17 14:16:41 +00:00
Родитель 9cb02d0163
Коммит 4dfe346a4b
5 изменённых файлов: 42 добавлений и 2 удалений

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

@ -198,6 +198,7 @@
<div id="advancedPanelContainer">
<div id="badCertAdvancedPanel" class="advanced-panel">
<p id="badCertTechnicalInfo"/>
<a id="viewCertificate" href="javascript:void(0)">&viewCertificate.label;</a>
<div id="advancedPanelButtonContainer" class="button-container">
<button id="advancedPanelReturnButton" class="primary" autocomplete="off" data-telemetry-id="return_button_adv">&returnToPreviousPage1.label;</button>
<button id="advancedPanelErrorTryAgain" class="primary" autocomplete="off">&retry.label;</button>

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

@ -3039,8 +3039,15 @@ var BrowserOnClick = {
onCertError(browser, elementId, isTopFrame, location, securityInfoAsString, frameId) {
let securityInfo;
let cert;
switch (elementId) {
case "viewCertificate":
securityInfo = getSecurityInfo(securityInfoAsString);
cert = securityInfo.serverCert;
Services.ww.openWindow(window, "chrome://pippki/content/certViewer.xul",
"_blank", "centerscreen,chrome", cert);
break;
case "exceptionDialogButton":
securityInfo = getSecurityInfo(securityInfoAsString);
let params = { exceptionAdded: false,
@ -3059,7 +3066,7 @@ var BrowserOnClick = {
flags |= overrideService.ERROR_TIME;
}
let uri = Services.uriFixup.createFixupURI(location, 0);
let cert = securityInfo.serverCert;
cert = securityInfo.serverCert;
overrideService.rememberValidityOverride(
uri.asciiHost, uri.port,
cert,

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

@ -482,6 +482,32 @@ add_task(async function checkCautionClass() {
}
});
add_task(async function checkViewCertificate() {
info("Loading a cert error and checking that the certificate can be shown.");
for (let useFrame of [false, true]) {
let tab = await openErrorPage(UNKNOWN_ISSUER, useFrame);
let browser = tab.linkedBrowser;
let dialogOpened = BrowserTestUtils.domWindowOpened();
await ContentTask.spawn(browser, {frame: useFrame}, async function({frame}) {
let doc = frame ? content.document.querySelector("iframe").contentDocument : content.document;
let viewCertificate = doc.getElementById("viewCertificate");
viewCertificate.click();
});
let win = await dialogOpened;
await BrowserTestUtils.waitForEvent(win, "load");
is(win.document.documentURI, "chrome://pippki/content/certViewer.xul",
"Opened the cert viewer dialog");
is(win.document.getElementById("commonname").value, "self-signed.example.com",
"Shows the correct certificate in the dialog");
win.close();
BrowserTestUtils.removeTab(gBrowser.selectedTab);
}
});
function getCertChain(securityInfoAsString) {
let certChain = "";
const serhelper = Cc["@mozilla.org/network/serialization-helper;1"]

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

@ -12,6 +12,7 @@
<!ENTITY advanced.label "Advanced">
<!ENTITY continue2.label "More…">
<!ENTITY moreInformation.label "More Information">
<!ENTITY viewCertificate.label "View Certificate">
<!-- Specific error messages -->

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

@ -64,6 +64,7 @@ button:disabled {
display: flex;
justify-content: end;
padding: 5px;
margin-top: 2em;
}
body:not(.neterror) #certErrorAndCaptivePortalButtonContainer {
@ -158,8 +159,12 @@ span#hostname {
white-space: nowrap;
}
#viewCertificate {
margin: 0 3em;
}
#badCertTechnicalInfo {
margin: 3em;
margin: 3em 3em 1em;
overflow: auto;
white-space: pre-wrap;
}