зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset e9d1379c65f5 (bug 1585904) for browser-chrome failures on browser_pageinfo_security.
--HG-- extra : histedit_source : 70a6520faf1fe6c83ae6cba3781d534cc3ae81b6
This commit is contained in:
Родитель
5099e76c5d
Коммит
b1bde23dbf
|
@ -343,7 +343,9 @@ class NetErrorParent extends JSWindowActorParent {
|
|||
let certsStringURL = certs.map(elem => `cert=${elem}`);
|
||||
certsStringURL = certsStringURL.join("&");
|
||||
let url = `about:certificate?${certsStringURL}`;
|
||||
window.switchToTabHavingURI(url, true, {});
|
||||
if (window.openTrustedLinkIn) {
|
||||
window.openTrustedLinkIn(url, "tab");
|
||||
}
|
||||
} else {
|
||||
Services.ww.openWindow(
|
||||
window,
|
||||
|
|
|
@ -39,7 +39,7 @@ var security = {
|
|||
let certsStringURL = certs.map(elem => `cert=${elem}`);
|
||||
certsStringURL = certsStringURL.join("&");
|
||||
let url = `about:certificate?${certsStringURL}`;
|
||||
window.switchToTabHavingURI(url, true, {});
|
||||
openTrustedLinkIn(url, "tab");
|
||||
} else {
|
||||
Services.ww.openWindow(
|
||||
window,
|
||||
|
|
|
@ -34,10 +34,7 @@ function viewCertHelper(parent, cert, openingOption = "tab") {
|
|||
let win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
let derb64 = encodeURIComponent(cert.getBase64DERString());
|
||||
let url = `about:certificate?cert=${derb64}`;
|
||||
let opened = win.switchToTabHavingURI(url, false, {});
|
||||
if (!opened) {
|
||||
win.openTrustedLinkIn(url, openingOption);
|
||||
}
|
||||
win.openTrustedLinkIn(url, openingOption);
|
||||
} else {
|
||||
Services.ww.openWindow(
|
||||
parent && parent.docShell.rootTreeItem.domWindow,
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
[DEFAULT]
|
||||
support-files =
|
||||
head.js
|
||||
adjustedCerts.js
|
||||
[browser_aboutcertificateviewer.js]
|
||||
[browser_checkLongHex.js]
|
||||
[browser_checkNonEmptyFields.js]
|
||||
[browser_checkNonRepeatedCertTabs.js]
|
||||
[browser_checkNonUndefinedStrings.js]
|
||||
[browser_checkOCSP.js]
|
||||
[browser_checkValiditySection.js]
|
||||
|
|
|
@ -1,143 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const PREF = "security.aboutcertificate.enabled";
|
||||
|
||||
function checkCertTabs() {
|
||||
let certificatePages = 0;
|
||||
for (let tab of gBrowser.tabs) {
|
||||
let spec = tab.linkedBrowser.documentURI.spec;
|
||||
if (spec.includes("about:certificate")) {
|
||||
certificatePages++;
|
||||
}
|
||||
}
|
||||
Assert.equal(certificatePages, 1, "Do not open repeated certificate pages!");
|
||||
}
|
||||
|
||||
add_task(async function testBadCert() {
|
||||
info("Testing bad cert");
|
||||
|
||||
let tab = await openErrorPage();
|
||||
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [[PREF, true]],
|
||||
});
|
||||
|
||||
let loaded = BrowserTestUtils.waitForNewTab(gBrowser, null, true);
|
||||
for (let i = 0; i < 2; i++) {
|
||||
// try opening two certificates that are the same
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [], async function() {
|
||||
let advancedButton = content.document.getElementById("advancedButton");
|
||||
Assert.ok(advancedButton, "advancedButton found");
|
||||
Assert.equal(
|
||||
advancedButton.hasAttribute("disabled"),
|
||||
false,
|
||||
"advancedButton should be clickable"
|
||||
);
|
||||
advancedButton.click();
|
||||
let viewCertificate = content.document.getElementById("viewCertificate");
|
||||
Assert.ok(viewCertificate, "viewCertificate found");
|
||||
Assert.equal(
|
||||
viewCertificate.hasAttribute("disabled"),
|
||||
false,
|
||||
"viewCertificate should be clickable"
|
||||
);
|
||||
|
||||
viewCertificate.click();
|
||||
});
|
||||
await loaded;
|
||||
}
|
||||
checkCertTabs();
|
||||
|
||||
gBrowser.removeCurrentTab(); // closes about:certificate
|
||||
gBrowser.removeCurrentTab(); // closes https://expired.example.com/
|
||||
});
|
||||
|
||||
add_task(async function testGoodCert() {
|
||||
info("Testing page info");
|
||||
let url = "https://example.com/";
|
||||
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [[PREF, true]],
|
||||
});
|
||||
|
||||
info(`Loading ${url}`);
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url }, async function() {
|
||||
info("Opening pageinfo");
|
||||
let pageInfo = BrowserPageInfo(url, "securityTab", {});
|
||||
await BrowserTestUtils.waitForEvent(pageInfo, "load");
|
||||
|
||||
let securityTab = pageInfo.document.getElementById("securityTab");
|
||||
await TestUtils.waitForCondition(
|
||||
() => BrowserTestUtils.is_visible(securityTab),
|
||||
"Security tab should be visible."
|
||||
);
|
||||
Assert.ok(securityTab, "Security tab is available");
|
||||
let viewCertButton = pageInfo.document.getElementById("security-view-cert");
|
||||
await TestUtils.waitForCondition(
|
||||
() => BrowserTestUtils.is_visible(viewCertButton),
|
||||
"view cert button should be visible."
|
||||
);
|
||||
|
||||
let loaded = BrowserTestUtils.waitForNewTab(gBrowser, null, true);
|
||||
for (let i = 0; i < 2; i++) {
|
||||
checkAndClickButton(pageInfo.document, "security-view-cert");
|
||||
await loaded;
|
||||
}
|
||||
|
||||
pageInfo.close();
|
||||
checkCertTabs();
|
||||
});
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
add_task(async function testPreferencesCert() {
|
||||
info("Testing preferences cert");
|
||||
let url = "about:preferences#privacy";
|
||||
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [[PREF, true]],
|
||||
});
|
||||
|
||||
info(`Loading ${url}`);
|
||||
await BrowserTestUtils.withNewTab({ gBrowser, url }, async function(browser) {
|
||||
checkAndClickButton(browser.contentDocument, "viewCertificatesButton");
|
||||
|
||||
let certDialogLoaded = promiseLoadSubDialog(
|
||||
"chrome://pippki/content/certManager.xul"
|
||||
);
|
||||
let dialogWin = await certDialogLoaded;
|
||||
let doc = dialogWin.document;
|
||||
Assert.ok(doc, "doc loaded");
|
||||
|
||||
doc.getElementById("certmanagertabs").selectedTab = doc.getElementById(
|
||||
"ca_tab"
|
||||
);
|
||||
let treeView = doc.getElementById("ca-tree").view;
|
||||
let selectedCert;
|
||||
|
||||
for (let i = 0; i < treeView.rowCount; i++) {
|
||||
treeView.selection.select(i);
|
||||
dialogWin.getSelectedCerts();
|
||||
let certs = dialogWin.selected_certs;
|
||||
if (certs && certs.length == 1 && certs[0]) {
|
||||
selectedCert = certs[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
Assert.ok(selectedCert, "A cert should be selected");
|
||||
let viewButton = doc.getElementById("ca_viewButton");
|
||||
Assert.equal(viewButton.disabled, false, "Should enable view button");
|
||||
|
||||
let loaded = BrowserTestUtils.waitForNewTab(gBrowser, null, true);
|
||||
for (let i = 0; i < 2; i++) {
|
||||
viewButton.click();
|
||||
await loaded;
|
||||
}
|
||||
checkCertTabs();
|
||||
});
|
||||
gBrowser.removeCurrentTab(); // closes about:certificate
|
||||
});
|
|
@ -1,88 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
function checkAndClickButton(document, id) {
|
||||
let button = document.getElementById(id);
|
||||
Assert.ok(button, `${id} button found`);
|
||||
Assert.equal(
|
||||
button.hasAttribute("disabled"),
|
||||
false,
|
||||
"button should be clickable"
|
||||
);
|
||||
button.click();
|
||||
}
|
||||
|
||||
function is_element_visible(aElement, aMsg) {
|
||||
isnot(aElement, null, "Element should not be null, when checking visibility");
|
||||
Assert.ok(!BrowserTestUtils.is_hidden(aElement), aMsg);
|
||||
}
|
||||
|
||||
// Extracted from https://searchfox.org/mozilla-central/rev/40ef22080910c2e2c27d9e2120642376b1d8b8b2/browser/components/preferences/in-content/tests/head.js#41
|
||||
function promiseLoadSubDialog(aURL) {
|
||||
return new Promise((resolve, reject) => {
|
||||
content.gSubDialog._dialogStack.addEventListener(
|
||||
"dialogopen",
|
||||
function dialogopen(aEvent) {
|
||||
if (
|
||||
aEvent.detail.dialog._frame.contentWindow.location == "about:blank"
|
||||
) {
|
||||
return;
|
||||
}
|
||||
content.gSubDialog._dialogStack.removeEventListener(
|
||||
"dialogopen",
|
||||
dialogopen
|
||||
);
|
||||
|
||||
Assert.equal(
|
||||
aEvent.detail.dialog._frame.contentWindow.location.toString(),
|
||||
aURL,
|
||||
"Check the proper URL is loaded"
|
||||
);
|
||||
|
||||
// Check visibility
|
||||
is_element_visible(aEvent.detail.dialog._overlay, "Overlay is visible");
|
||||
|
||||
// Check that stylesheets were injected
|
||||
let expectedStyleSheetURLs = aEvent.detail.dialog._injectedStyleSheets.slice(
|
||||
0
|
||||
);
|
||||
for (let styleSheet of aEvent.detail.dialog._frame.contentDocument
|
||||
.styleSheets) {
|
||||
let i = expectedStyleSheetURLs.indexOf(styleSheet.href);
|
||||
if (i >= 0) {
|
||||
info("found " + styleSheet.href);
|
||||
expectedStyleSheetURLs.splice(i, 1);
|
||||
}
|
||||
}
|
||||
Assert.equal(
|
||||
expectedStyleSheetURLs.length,
|
||||
0,
|
||||
"All expectedStyleSheetURLs should have been found"
|
||||
);
|
||||
|
||||
// Wait for the next event tick to make sure the remaining part of the
|
||||
// testcase runs after the dialog gets ready for input.
|
||||
executeSoon(() => resolve(aEvent.detail.dialog._frame.contentWindow));
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
async function openErrorPage() {
|
||||
let src = "https://expired.example.com/";
|
||||
let certErrorLoaded;
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(
|
||||
gBrowser,
|
||||
() => {
|
||||
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, src);
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
certErrorLoaded = BrowserTestUtils.waitForErrorPage(browser);
|
||||
},
|
||||
false
|
||||
);
|
||||
info("Loading and waiting for the cert error");
|
||||
await certErrorLoaded;
|
||||
return tab;
|
||||
}
|
Загрузка…
Ссылка в новой задаче