commit c13924a9e0820e7661fa0c53e3b4c29869ab3c09
parent 29b0098fccac21323bcba0ddf411ce6df24734ef
Author: Maile Lucks <maile.lucks@gmail.com>
Date: Mon, 17 Nov 2025 18:01:46 +0000
Bug 1990925 - Update testing for error page certificate info actions - r=niklas
Differential Revision: https://phabricator.services.mozilla.com/D267612
Diffstat:
2 files changed, 114 insertions(+), 18 deletions(-)
diff --git a/toolkit/components/certviewer/tests/browser/browser_openTabAndSendCertInfo.js b/toolkit/components/certviewer/tests/browser/browser_openTabAndSendCertInfo.js
@@ -113,10 +113,111 @@ add_task(async function openFromPopUp() {
await BrowserTestUtils.windowClosed(win);
});
-add_task(async function testBadCert() {
+add_task(async function testBadCert_feltPrivacyToTrue() {
info("Testing bad cert");
+ await SpecialPowers.pushPrefEnv({
+ set: [["security.certerrors.felt-privacy-v1", true]],
+ });
let tab = await openErrorPage();
+ let tabsCount = gBrowser.tabs.length;
+ let loaded = BrowserTestUtils.waitForNewTab(gBrowser, null, true);
+
+ await SpecialPowers.spawn(tab.linkedBrowser, [], async function () {
+ const netErrorCard =
+ content.document.querySelector("net-error-card").wrappedJSObject;
+ await netErrorCard.getUpdateComplete();
+ Assert.ok(netErrorCard.advancedButton, "advancedButton found");
+ Assert.ok(
+ !netErrorCard.advancedButton.hasAttribute("disabled"),
+ "advancedButton should be clickable"
+ );
+ EventUtils.synthesizeMouseAtCenter(
+ netErrorCard.advancedButton,
+ {},
+ content
+ );
+ await netErrorCard.getUpdateComplete();
+ await ContentTaskUtils.waitForCondition(
+ () =>
+ netErrorCard.viewCertificate &&
+ ContentTaskUtils.isVisible(netErrorCard.viewCertificate),
+ "Waiting for viewCertificate link"
+ );
+ Assert.ok(netErrorCard.viewCertificate, "viewCertificate link found");
+ Assert.ok(
+ !netErrorCard.viewCertificate.hasAttribute("disabled"),
+ "viewCertificate should be clickable"
+ );
+ netErrorCard.viewCertificate.scrollIntoView();
+ EventUtils.synthesizeMouseAtCenter(
+ netErrorCard.viewCertificate,
+ {},
+ content
+ );
+ });
+ await loaded;
+ checksCertTab(tabsCount);
+ await checkCertChain(gBrowser.selectedBrowser);
+ await SpecialPowers.flushPrefEnv();
+ gBrowser.removeCurrentTab(); // closes about:certificate
+ gBrowser.removeCurrentTab(); // closes https://expired.example.com/
+});
+
+add_task(async function testBadCertIframe_feltPrivacyToTrue() {
+ info("Testing bad cert in an iframe");
+ await SpecialPowers.pushPrefEnv({
+ set: [["security.certerrors.felt-privacy-v1", true]],
+ });
+
+ let tab = await openErrorPage(true);
+ let tabsCount = gBrowser.tabs.length;
+ let loaded = BrowserTestUtils.waitForNewTab(gBrowser, null, true);
+
+ await SpecialPowers.spawn(tab.linkedBrowser, [], async function () {
+ let iframe = content.document.querySelector("iframe");
+ let doc = iframe.contentDocument;
+ const netErrorCard = doc.querySelector("net-error-card").wrappedJSObject;
+ await netErrorCard.getUpdateComplete();
+ Assert.ok(netErrorCard.advancedButton, "advancedButton found");
+ Assert.ok(
+ !netErrorCard.advancedButton.hasAttribute("disabled"),
+ "advancedButton should be clickable"
+ );
+ netErrorCard.advancedButton.click();
+ await ContentTaskUtils.waitForCondition(
+ () =>
+ netErrorCard.viewCertificate &&
+ ContentTaskUtils.isVisible(netErrorCard.viewCertificate),
+ "Waiting for view certificate link"
+ );
+ Assert.ok(netErrorCard.viewCertificate, "viewCertificate found");
+ Assert.ok(
+ !netErrorCard.viewCertificate.hasAttribute("disabled"),
+ "viewCertificate should be clickable"
+ );
+ netErrorCard.viewCertificate.scrollIntoView();
+ const iframeRect = iframe.getBoundingClientRect();
+ const linkRect = netErrorCard.viewCertificate.getBoundingClientRect();
+
+ EventUtils.synthesizeMouseAtPoint(
+ iframeRect.x + linkRect.x + linkRect.width / 2,
+ iframeRect.y + linkRect.y + linkRect.height / 2,
+ {},
+ content
+ );
+ });
+ await loaded;
+ checksCertTab(tabsCount);
+ await checkCertChain(gBrowser.selectedBrowser);
+ await SpecialPowers.flushPrefEnv();
+ gBrowser.removeCurrentTab(); // closes about:certificate
+ gBrowser.removeCurrentTab(); // closes https://expired.example.com/
+});
+
+add_task(async function testBadCert() {
+ info("Testing bad cert");
+ let tab = await openErrorPage();
let tabsCount = gBrowser.tabs.length;
let loaded = BrowserTestUtils.waitForNewTab(gBrowser, null, true);
@@ -124,17 +225,15 @@ add_task(async function testBadCert() {
await SpecialPowers.spawn(tab.linkedBrowser, [], async function () {
let advancedButton = content.document.getElementById("advancedButton");
Assert.ok(advancedButton, "advancedButton found");
- Assert.equal(
- advancedButton.hasAttribute("disabled"),
- false,
+ Assert.ok(
+ !advancedButton.hasAttribute("disabled"),
"advancedButton should be clickable"
);
advancedButton.click();
let viewCertificate = content.document.getElementById("viewCertificate");
Assert.ok(viewCertificate, "viewCertificate found");
- Assert.equal(
- viewCertificate.hasAttribute("disabled"),
- false,
+ Assert.ok(
+ !viewCertificate.hasAttribute("disabled"),
"viewCertificate should be clickable"
);
@@ -143,14 +242,12 @@ add_task(async function testBadCert() {
await loaded;
checksCertTab(tabsCount);
await checkCertChain(gBrowser.selectedBrowser);
-
gBrowser.removeCurrentTab(); // closes about:certificate
gBrowser.removeCurrentTab(); // closes https://expired.example.com/
});
add_task(async function testBadCertIframe() {
info("Testing bad cert in an iframe");
-
let tab = await openErrorPage(true);
let tabsCount = gBrowser.tabs.length;
@@ -160,20 +257,17 @@ add_task(async function testBadCertIframe() {
let doc = content.document.querySelector("iframe").contentDocument;
let advancedButton = doc.getElementById("advancedButton");
Assert.ok(advancedButton, "advancedButton found");
- Assert.equal(
- advancedButton.hasAttribute("disabled"),
- false,
+ Assert.ok(
+ !advancedButton.hasAttribute("disabled"),
"advancedButton should be clickable"
);
advancedButton.click();
let viewCertificate = doc.getElementById("viewCertificate");
Assert.ok(viewCertificate, "viewCertificate found");
- Assert.equal(
- viewCertificate.hasAttribute("disabled"),
- false,
+ Assert.ok(
+ !viewCertificate.hasAttribute("disabled"),
"viewCertificate should be clickable"
);
-
viewCertificate.click();
});
await loaded;
diff --git a/toolkit/components/certviewer/tests/browser/head.js b/toolkit/components/certviewer/tests/browser/head.js
@@ -85,8 +85,10 @@ function injectErrorPageFrame(tab, src) {
// We will have race conditions when accessing the frame content after setting a src,
// so we can't wait for AboutNetErrorLoad. Let's wait for the certerror class to
// appear instead (which should happen at the same time as AboutNetErrorLoad).
- await ContentTaskUtils.waitForCondition(() =>
- iframe.contentDocument.body.classList.contains("certerror")
+ await ContentTaskUtils.waitForCondition(
+ () =>
+ iframe.contentDocument.body.classList.contains("certerror") ||
+ iframe.contentDocument.body.classList.contains("felt-privacy-body")
);
}
);