Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
"use strict";
/* Description of the test:
* We load a page which gets upgraded to https. HTTPS-Only Mode then
* sends an 'http' background request which we redirect (using the
* web extension API) to 'same-origin' https. We ensure the HTTPS-Only
* Error page does not occur, but we https page gets loaded.
*/
let extension = null;
add_task(async function test_https_only_background_request_redirect() {
// A longer timeout is necessary for this test since we have to wait
// at least 3 seconds for the https-only background request to happen.
requestLongerTimeout(10);
await SpecialPowers.pushPrefEnv({
set: [["dom.security.https_only_mode", true]],
});
extension = ExtensionTestUtils.loadExtension({
manifest: {
},
background() {
let { browser } = this;
browser.webRequest.onBeforeRequest.addListener(
details => {
browser.test.sendMessage("redir-handled");
return { redirectUrl };
}
return undefined;
},
["blocking"]
);
},
});
await extension.startup();
await BrowserTestUtils.withNewTab("about:blank", async function (browser) {
let loaded = BrowserTestUtils.browserLoaded(browser, false, null, true);
BrowserTestUtils.startLoadingURIString(
browser,
);
await extension.awaitMessage("redir-handled");
await loaded;
await SpecialPowers.spawn(browser, [], async function () {
let innerHTML = content.document.body.innerHTML;
ok(
"No https-only error page"
);
});
});
await extension.unload();
});