forked from mirrors/gecko-dev
This changes the policy to use the pref and permissions rather than a boolean flag. Using permissions gets us proper settings on startup without introducing any new overhead. Going this way flips our tests around so rather than testing an override to turn off private browsing support, we test overrides to enable private browsing support. Differential Revision: https://phabricator.services.mozilla.com/D14482 --HG-- extra : moz-landing-system : lando
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
"use strict";
|
|
|
|
const server = createHttpServer({hosts: ["example.com"]});
|
|
|
|
server.registerPathHandler("/dummy", (request, response) => {
|
|
response.setStatusLine(request.httpVersion, 200, "OK");
|
|
response.setHeader("Content-Type", "text/html", false);
|
|
response.write("<!DOCTYPE html><html></html>");
|
|
});
|
|
|
|
add_task(async function test_incognito_webrequest_access() {
|
|
Services.prefs.setBoolPref("extensions.allowPrivateBrowsingByDefault", false);
|
|
|
|
// This extension will fail if it gets a request
|
|
let extension = ExtensionTestUtils.loadExtension({
|
|
manifest: {
|
|
permissions: ["webRequest", "webRequestBlocking", "<all_urls>"],
|
|
},
|
|
background() {
|
|
browser.webRequest.onBeforeRequest.addListener(async (details) => {
|
|
browser.test.fail("webrequest received incognito request");
|
|
}, {urls: ["<all_urls>"]}, ["blocking"]);
|
|
},
|
|
});
|
|
await extension.startup();
|
|
|
|
let contentPage = await ExtensionTestUtils.loadContentPage("http://example.com/dummy", {privateBrowsing: true});
|
|
|
|
await extension.unload();
|
|
await contentPage.close();
|
|
|
|
Services.prefs.clearUserPref("extensions.allowPrivateBrowsingByDefault");
|
|
});
|