Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

/* Any copyright is dedicated to the Public Domain.
ChromeUtils.defineLazyGetter(this, "UrlbarTestUtils", () => {
const { UrlbarTestUtils: module } = ChromeUtils.importESModule(
);
module.init(this);
return module;
});
add_setup(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [
["security.qwacs.enabled", true],
["security.qwacs.enable_test_trust_anchors", true],
],
});
registerCleanupFunction(async () => {
await PlacesUtils.history.clear();
});
});
add_task(async function test_https() {
const tab = await BrowserTestUtils.openNewForegroundTab({
gBrowser,
opening: "https://example.com",
waitForLoad: true,
});
await UrlbarTestUtils.openTrustPanel(window);
await UrlbarTestUtils.openTrustPanelSubview(
window,
"trustpanel-securityInformationView"
);
Assert.ok(
BrowserTestUtils.isVisible(
document.getElementById("identity-popup-content-verifier-label")
),
"'Verified by:' label visible"
);
let issuerOrganization = document.getElementById(
"identity-popup-content-verifier"
);
Assert.ok(
BrowserTestUtils.isVisible(issuerOrganization),
"issuer (verifier) organization text visible"
);
Assert.equal(
issuerOrganization.textContent,
"Mozilla Testing",
"issuer (verifier) text as expected"
);
Assert.ok(
BrowserTestUtils.isVisible(
document.getElementById("identity-popup-content-verifier-unknown")
),
"custom root warning in sub panel is visible"
);
Assert.ok(
BrowserTestUtils.isHidden(
document.getElementById(
"identity-popup-content-cert-exception-overridden"
)
),
"user-added certificate error exception text is not visible"
);
Assert.ok(
BrowserTestUtils.isHidden(
document.getElementById("identity-popup-content-tls-key-logging")
),
"TLS key logging warning should not be visible"
);
await UrlbarTestUtils.closeTrustPanel(window);
await BrowserTestUtils.removeTab(tab);
});
add_task(async function test_https_with_tls_key_logging() {
// Setting the environment variable at this point should not actually
// enable TLS key logging, because NSS has already been initialized. This
// just makes the front-end think it has.
Services.env.set("SSLKEYLOGFILE", "nonexistent");
const tab = await BrowserTestUtils.openNewForegroundTab({
gBrowser,
opening: "https://example.com",
waitForLoad: true,
});
await UrlbarTestUtils.openTrustPanel(window);
await UrlbarTestUtils.openTrustPanelSubview(
window,
"trustpanel-securityInformationView"
);
Assert.ok(
BrowserTestUtils.isVisible(
document.getElementById("identity-popup-content-tls-key-logging")
),
"TLS key logging warning should be visible"
);
await UrlbarTestUtils.closeTrustPanel(window);
await BrowserTestUtils.removeTab(tab);
Services.env.set("SSLKEYLOGFILE", "");
});
add_task(async function test_http() {
const tab = await BrowserTestUtils.openNewForegroundTab({
gBrowser,
// eslint-disable-next-line sdl/no-insecure-url
opening: "http://example.com",
waitForLoad: true,
});
await UrlbarTestUtils.openTrustPanel(window);
await UrlbarTestUtils.openTrustPanelSubview(
window,
"trustpanel-securityInformationView"
);
Assert.ok(
BrowserTestUtils.isHidden(
document.getElementById("identity-popup-content-verifier-unknown")
),
"custom root warning in sub panel is hidden"
);
await UrlbarTestUtils.closeTrustPanel(window);
await BrowserTestUtils.removeTab(tab);
});
add_task(async function test_1_qwac() {
const tab = await BrowserTestUtils.openNewForegroundTab({
gBrowser,
waitForLoad: true,
});
await UrlbarTestUtils.openTrustPanel(window);
await UrlbarTestUtils.openTrustPanelSubview(
window,
"trustpanel-securityInformationView"
);
// Wait for the QWAC status to be determined.
await gTrustPanelHandler.qwacStatusPromise;
Assert.ok(
BrowserTestUtils.isVisible(
document.getElementById("identity-popup-content-etsi")
),
"etsi qualified text visible"
);
Assert.ok(
BrowserTestUtils.isVisible(
document.getElementById("identity-popup-content-owner-label")
),
"'Certificate issued to:' label visible"
);
let qwacOrganization = document.getElementById(
"identity-popup-content-owner"
);
Assert.ok(
BrowserTestUtils.isVisible(qwacOrganization),
"QWAC organization text visible"
);
Assert.equal(
qwacOrganization.textContent,
"Test 1-QWAC Organization",
"QWAC organization text as expected"
);
let qwacLocation = document.getElementById(
"identity-popup-content-supplemental"
);
Assert.ok(
BrowserTestUtils.isVisible(qwacLocation),
"QWAC location text visible"
);
Assert.equal(
qwacLocation.textContent,
"1-QWAC Test Locality\nEX",
"QWAC location text as expected"
);
let euTrustMark = document.getElementById(
"identity-popup-content-eu-trust-mark"
);
Assert.ok(BrowserTestUtils.isVisible(euTrustMark), "EU trust mark visible");
await UrlbarTestUtils.closeTrustPanel(window);
await BrowserTestUtils.removeTab(tab);
});
add_task(async function test_2_qwac() {
const tab = await BrowserTestUtils.openNewForegroundTab({
gBrowser,
opening:
waitForLoad: true,
});
await UrlbarTestUtils.openTrustPanel(window);
await UrlbarTestUtils.openTrustPanelSubview(
window,
"trustpanel-securityInformationView"
);
// Wait for the QWAC status to be determined.
await gTrustPanelHandler.qwacStatusPromise;
Assert.ok(
BrowserTestUtils.isVisible(
document.getElementById("identity-popup-content-verifier-label")
),
"'Verified by:' label visible"
);
let issuerOrganization = document.getElementById(
"identity-popup-content-verifier"
);
Assert.ok(
BrowserTestUtils.isVisible(issuerOrganization),
"issuer (verifier) organization text visible"
);
Assert.equal(
issuerOrganization.textContent,
"Test CA",
"issuer (verifier) text as expected"
);
Assert.ok(
BrowserTestUtils.isVisible(
document.getElementById("identity-popup-content-etsi")
),
"etsi qualified text visible"
);
Assert.ok(
BrowserTestUtils.isVisible(
document.getElementById("identity-popup-content-owner-label")
),
"'Certificate issued to:' label visible"
);
let qwacOrganization = document.getElementById(
"identity-popup-content-owner"
);
Assert.ok(
BrowserTestUtils.isVisible(qwacOrganization),
"QWAC organization text visible"
);
Assert.equal(
qwacOrganization.textContent,
"Test 2-QWAC Organization",
"QWAC organization text as expected"
);
let qwacLocation = document.getElementById(
"identity-popup-content-supplemental"
);
Assert.ok(
BrowserTestUtils.isVisible(qwacLocation),
"QWAC location text visible"
);
Assert.equal(
qwacLocation.textContent,
"2-QWAC Test Locality\nEX",
"QWAC location text as expected"
);
let euTrustMark = document.getElementById(
"identity-popup-content-eu-trust-mark"
);
Assert.ok(BrowserTestUtils.isVisible(euTrustMark), "EU trust mark visible");
await UrlbarTestUtils.closeTrustPanel(window);
await BrowserTestUtils.removeTab(tab);
});
add_task(async function test_non_qwac() {
let uris = [
// eslint-disable-next-line sdl/no-insecure-url
"data:,Hello%2C World!",
];
for (let uri of uris) {
const tab = await BrowserTestUtils.openNewForegroundTab({
gBrowser,
opening: uri,
waitForLoad: true,
});
await UrlbarTestUtils.openTrustPanel(window);
await UrlbarTestUtils.openTrustPanelSubview(
window,
"trustpanel-securityInformationView"
);
// Wait for the QWAC status to be determined.
await gTrustPanelHandler.qwacStatusPromise;
Assert.ok(
BrowserTestUtils.isHidden(
document.getElementById("identity-popup-content-etsi")
),
"etsi qualified text not visible"
);
Assert.ok(
BrowserTestUtils.isHidden(
document.getElementById("identity-popup-content-owner-label")
),
"'Certificate issued to:' label not visible"
);
Assert.ok(
BrowserTestUtils.isHidden(
document.getElementById("identity-popup-content-owner")
),
"QWAC organization text not visible"
);
Assert.ok(
BrowserTestUtils.isHidden(
document.getElementById("identity-popup-content-supplemental")
),
"QWAC location text not visible"
);
let euTrustMark = document.getElementById(
"identity-popup-content-eu-trust-mark"
);
Assert.ok(
!BrowserTestUtils.isVisible(euTrustMark),
"EU trust mark not visible"
);
await UrlbarTestUtils.closeTrustPanel(window);
await BrowserTestUtils.removeTab(tab);
}
});