зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1580923 - Fixes problem when opening a certificate from downloadcert.xul.r=johannh
Differential Revision: https://phabricator.services.mozilla.com/D46054 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
6112f19409
Коммит
1ea5f188a8
|
@ -57,7 +57,7 @@ function onLoad() {
|
|||
* Handler for the "View Cert" button.
|
||||
*/
|
||||
function viewCert() {
|
||||
viewCertHelper(window, gCert);
|
||||
viewCertHelper(window, gCert, "window");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,16 +25,16 @@ function setText(id, value) {
|
|||
element.appendChild(document.createTextNode(value));
|
||||
}
|
||||
|
||||
function viewCertHelper(parent, cert) {
|
||||
function viewCertHelper(parent, cert, openingOption = "tab") {
|
||||
if (!cert) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Services.prefs.getBoolPref("security.aboutcertificate.enabled")) {
|
||||
let ownerGlobal = window.docShell.chromeEventHandler.ownerGlobal;
|
||||
let win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
let derb64 = encodeURIComponent(cert.getBase64DERString());
|
||||
let url = `about:certificate?cert=${derb64}`;
|
||||
ownerGlobal.openTrustedLinkIn(url, "tab");
|
||||
win.openTrustedLinkIn(url, openingOption);
|
||||
} else {
|
||||
Services.ww.openWindow(
|
||||
parent,
|
||||
|
|
|
@ -3,7 +3,12 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { ContentTaskUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/ContentTaskUtils.jsm"
|
||||
);
|
||||
const PREF = "security.aboutcertificate.enabled";
|
||||
const TEST_CERT_BASE64 =
|
||||
"MIIGRjCCBS6gAwIBAgIQDJduPkI49CDWPd+G7+u6kDANBgkqhkiG9w0BAQsFADBNMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMScwJQYDVQQDEx5EaWdpQ2VydCBTSEEyIFNlY3VyZSBTZXJ2ZXIgQ0EwHhcNMTgx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QUHAQEEcDBuMCQGCCsGAQUFBzABhhhodHRwOi8vb2NzcC5kaWdpY2VydC5jb20wRgYIKwYBBQUHMAKGOmh0dHA6Ly9jYWNlcnRzLmRpZ2ljZXJ0LmNvbS9EaWdpQ2VydFNIQTJTZWN1cmVTZXJ2ZXJDQS5jcnQwDAYDVR0TAQH/BAIwADCCAQIGCisGAQQB1nkCBAIEgfMEgfAA7gB1AKS5CZC0GFgUh7sTosxncAo8NZgE+RvfuON3zQ7IDdwQAAABZuYWiHwAAAQDAEYwRAIgZnMSH1JdG6NASHWTwD0mlP/zbr0hzP263c02Ym0DU64CIEe4QHJDP47j0b6oTFu6RrZz1NQ9cq8Az1KnMKRuaFAlAHUAh3W/51l8+IxDmV+9827/Vo1HVjb/SrVgwbTq/16ggw8AAAFm5haJAgAABAMARjBEAiAxGLXkUaOAkZhXNeNR3pWyahZeKmSaMXadgu18SfK1ZAIgKtwu5eGxK76rgaszLCZ9edBIjuU0DKorzPUuxUXFY0QwDQYJKoZIhvcNAQELBQADggEBAKLJAFO3wuaP5MM/ed1lhk5Uc2aDokhcM7XyvdhEKSHbgPhcgMoT9YIVoPa70gNC6KHcwoXu0g8wt7X6Vm1ql/68G5q844kFuC6JPl4LVT9mciD+VW6bHUSXD9xifL9DqdJ0Ic0SllTlM+oq5aAeOxUQGXhXIqj6fSQv9fQN6mXxQIoc/gjxteskq/Vl8YmY1FIZP9Bh7g27kxZ9GAAGQtjTL03RzKAuSg6yeImYVdQWasc7UPnBXlRAzZ8+OJThUbzK16a2CI3Rg4agKSJk+uA47h1/ImmngpFLRb/MvRX6H1oWcUuyH6O7PZdl0YpwTpw1THIuqCGl/wpPgyQgcTM=";
|
||||
|
||||
function checkAndClickButton(document, id) {
|
||||
let button = document.getElementById(id);
|
||||
|
@ -16,16 +21,14 @@ function checkAndClickButton(document, id) {
|
|||
button.click();
|
||||
}
|
||||
|
||||
function checksCertTab(tabsCount) {
|
||||
Assert.equal(gBrowser.tabs.length, tabsCount + 1, "New tab was opened");
|
||||
let spec = gBrowser.tabs[tabsCount].linkedBrowser.documentURI.spec;
|
||||
function checkSpec(spec) {
|
||||
Assert.ok(
|
||||
spec.startsWith("about:certificate"),
|
||||
"about:certificate is the new opened tab"
|
||||
"about:certificate was opened"
|
||||
);
|
||||
|
||||
let newTabUrl = new URL(spec);
|
||||
let certEncoded = newTabUrl.searchParams.get("cert");
|
||||
let newUrl = new URL(spec);
|
||||
let certEncoded = newUrl.searchParams.get("cert");
|
||||
let certDecoded = decodeURIComponent(certEncoded);
|
||||
Assert.equal(
|
||||
btoa(atob(certDecoded)),
|
||||
|
@ -34,6 +37,60 @@ function checksCertTab(tabsCount) {
|
|||
);
|
||||
}
|
||||
|
||||
function checksCertTab(tabsCount) {
|
||||
Assert.equal(gBrowser.tabs.length, tabsCount + 1, "New tab was opened");
|
||||
let spec = gBrowser.tabs[tabsCount].linkedBrowser.documentURI.spec;
|
||||
checkSpec(spec);
|
||||
}
|
||||
|
||||
// taken from https://searchfox.org/mozilla-central/rev/7ed8e2d3d1d7a1464ba42763a33fd2e60efcaedc/security/manager/ssl/tests/mochitest/browser/browser_downloadCert_ui.js#47
|
||||
function openCertDownloadDialog(cert) {
|
||||
let returnVals = Cc["@mozilla.org/hash-property-bag;1"].createInstance(
|
||||
Ci.nsIWritablePropertyBag2
|
||||
);
|
||||
let win = window.openDialog(
|
||||
"chrome://pippki/content/downloadcert.xul",
|
||||
"",
|
||||
"",
|
||||
cert,
|
||||
returnVals
|
||||
);
|
||||
return new Promise((resolve, reject) => {
|
||||
win.addEventListener(
|
||||
"load",
|
||||
function() {
|
||||
executeSoon(() => resolve([win]));
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
add_task(async function openFromPopUp() {
|
||||
info("Testing openFromPopUp");
|
||||
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [[PREF, true]],
|
||||
});
|
||||
|
||||
const certdb = Cc["@mozilla.org/security/x509certdb;1"].getService(
|
||||
Ci.nsIX509CertDB
|
||||
);
|
||||
let cert = certdb.constructX509FromBase64(TEST_CERT_BASE64);
|
||||
|
||||
let [win] = await openCertDownloadDialog(cert);
|
||||
let viewCertButton = win.document.getElementById("viewC-button");
|
||||
let newWinOpened = BrowserTestUtils.waitForNewWindow();
|
||||
viewCertButton.click();
|
||||
let topWin = await newWinOpened;
|
||||
let spec = topWin.gBrowser.selectedBrowser.currentURI.spec;
|
||||
checkSpec(spec);
|
||||
|
||||
await BrowserTestUtils.closeWindow(topWin); // closes about:certificate
|
||||
win.document.getElementById("download_cert").cancelDialog();
|
||||
await BrowserTestUtils.windowClosed(win);
|
||||
});
|
||||
|
||||
function injectErrorPageFrame(tab, src) {
|
||||
return ContentTask.spawn(
|
||||
tab.linkedBrowser,
|
||||
|
|
Загрузка…
Ссылка в новой задаче