Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

/* Any copyright is dedicated to the Public Domain.
"use strict";
// This test checks the superfluos auth prompt when HTTPS-First is enabled (Bug 1858565).
const { MockRegistrar } = ChromeUtils.importESModule(
);
let respondMockPromptWithYes = false;
const gMockPromptService = {
firstTimeCalled: false,
confirmExBC() {
return respondMockPromptWithYes ? 0 : 1;
},
QueryInterface: ChromeUtils.generateQI(["nsIPromptService"]),
};
var gMockPromptServiceCID = MockRegistrar.register(
"@mozilla.org/prompter;1",
gMockPromptService
);
registerCleanupFunction(() => {
MockRegistrar.unregister(gMockPromptServiceCID);
});
function checkBrowserLoad(browser) {
return new Promise(resolve => {
BrowserTestUtils.browserLoaded(browser, false, null, true).then(() => {
resolve(true);
});
BrowserTestUtils.browserStopped(browser, false, null, true).then(() => {
resolve(false);
});
});
}
add_task(async function () {
await SpecialPowers.pushPrefEnv({
set: [
["dom.security.https_first", true],
["network.auth.confirmAuth.enabled", true],
],
});
respondMockPromptWithYes = false;
let didBrowserLoadPromise = checkBrowserLoad(gBrowser.selectedBrowser);
BrowserTestUtils.startLoadingURIString(gBrowser.selectedBrowser, TEST_URI);
let didBrowserLoad = await didBrowserLoadPromise;
ok(
!didBrowserLoad,
"The browser should stop the load when the user refuses to load a page with superfluos authentication"
);
respondMockPromptWithYes = true;
didBrowserLoadPromise = checkBrowserLoad(gBrowser.selectedBrowser);
BrowserTestUtils.startLoadingURIString(gBrowser.selectedBrowser, TEST_URI);
didBrowserLoad = await didBrowserLoadPromise;
ok(
didBrowserLoad,
"The browser should load when the user agrees to load a page with superfluos authentication"
);
});