Bug 1345474 - Check incognito access for webRequest api r=kmag
Depends on D4112 Differential Revision: https://phabricator.services.mozilla.com/D5571
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
"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() {
|
||||
// This extension will fail if it gets a request
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
permissions: ["webRequest", "webRequestBlocking", "<all_urls>"],
|
||||
},
|
||||
incognitoOverride: "not_allowed",
|
||||
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();
|
||||
});
|
||||
@@ -136,6 +136,8 @@ skip-if = true # Too frequent intermittent failures
|
||||
skip-if = os == "android" && debug
|
||||
[test_ext_webRequest_filterResponseData.js]
|
||||
skip-if = os == "android" && debug
|
||||
[test_ext_webRequest_incognito.js]
|
||||
skip-if = os == "android" && debug
|
||||
[test_ext_webRequest_permission.js]
|
||||
skip-if = os == "android" && debug
|
||||
[test_ext_webRequest_responseBody.js]
|
||||
|
||||
@@ -522,6 +522,14 @@ bool ChannelWrapper::Matches(
|
||||
}
|
||||
|
||||
if (aExtension) {
|
||||
// Verify extension access to private requests
|
||||
if (!aExtension->PrivateBrowsingAllowed()) {
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = GetLoadInfo();
|
||||
if (loadInfo && loadInfo->GetOriginAttributes().mPrivateBrowsingId > 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool isProxy =
|
||||
aOptions.mIsProxy && aExtension->HasPermission(nsGkAtoms::proxy);
|
||||
// Proxies are allowed access to all urls, including restricted urls.
|
||||
|
||||
Reference in New Issue
Block a user