зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1545163 add incognito flag to proxy and webrequest details r=robwu
Differential Revision: https://phabricator.services.mozilla.com/D28925 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
fdfa7dd694
Коммит
0873aa1a01
|
@ -258,12 +258,14 @@ class ProxyChannelFilter {
|
|||
|
||||
// Copy from WebRequest.jsm with small changes.
|
||||
getRequestData(channel, extraData) {
|
||||
let originAttributes = channel.loadInfo && channel.loadInfo.originAttributes;
|
||||
let data = {
|
||||
requestId: String(channel.id),
|
||||
url: channel.finalURL,
|
||||
method: channel.method,
|
||||
type: channel.type,
|
||||
fromCache: !!channel.fromCache,
|
||||
incognito: originAttributes && originAttributes.privateBrowsingId > 0,
|
||||
|
||||
originUrl: channel.originURL || undefined,
|
||||
documentUrl: channel.documentURL || undefined,
|
||||
|
|
|
@ -24,7 +24,9 @@ function registerEvent(extension, eventName, fire, filter, info, remoteTab = nul
|
|||
|
||||
let event = data.serialize(eventName);
|
||||
event.tabId = browserData.tabId;
|
||||
|
||||
if (data.originAttributes) {
|
||||
event.incognito = data.originAttributes.privateBrowsingId > 0;
|
||||
}
|
||||
if (data.registerTraceableChannel) {
|
||||
// If this is a primed listener, no tabParent was passed in here,
|
||||
// but the convert() callback later in this function will be called
|
||||
|
|
|
@ -147,6 +147,7 @@
|
|||
"method": {"type": "string", "description": "Standard HTTP method."},
|
||||
"frameId": {"type": "integer", "description": "The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code> or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame. Frame IDs are unique within a tab."},
|
||||
"parentFrameId": {"type": "integer", "description": "ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists."},
|
||||
"incognito": {"type": "boolean", "optional": true, "description": "True for private browsing requests."},
|
||||
"originUrl": {"type": "string", "optional": true, "description": "URL of the resource that triggered this request."},
|
||||
"documentUrl": {"type": "string", "optional": true, "description": "URL of the page into which the requested resource will be loaded."},
|
||||
"tabId": {"type": "integer", "description": "The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab."},
|
||||
|
|
|
@ -425,6 +425,7 @@
|
|||
"method": {"type": "string", "description": "Standard HTTP method."},
|
||||
"frameId": {"type": "integer", "description": "The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code> or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame. Frame IDs are unique within a tab."},
|
||||
"parentFrameId": {"type": "integer", "description": "ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists."},
|
||||
"incognito": {"type": "boolean", "optional": true, "description": "True for private browsing requests."},
|
||||
"originUrl": {"type": "string", "optional": true, "description": "URL of the resource that triggered this request."},
|
||||
"documentUrl": {"type": "string", "optional": true, "description": "URL of the page into which the requested resource will be loaded."},
|
||||
"requestBody": {
|
||||
|
@ -493,6 +494,7 @@
|
|||
"method": {"type": "string", "description": "Standard HTTP method."},
|
||||
"frameId": {"type": "integer", "description": "The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code> or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame. Frame IDs are unique within a tab."},
|
||||
"parentFrameId": {"type": "integer", "description": "ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists."},
|
||||
"incognito": {"type": "boolean", "optional": true, "description": "True for private browsing requests."},
|
||||
"originUrl": {"type": "string", "optional": true, "description": "URL of the resource that triggered this request."},
|
||||
"documentUrl": {"type": "string", "optional": true, "description": "URL of the page into which the requested resource will be loaded."},
|
||||
"tabId": {"type": "integer", "description": "The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab."},
|
||||
|
@ -538,6 +540,7 @@
|
|||
"method": {"type": "string", "description": "Standard HTTP method."},
|
||||
"frameId": {"type": "integer", "description": "The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code> or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame. Frame IDs are unique within a tab."},
|
||||
"parentFrameId": {"type": "integer", "description": "ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists."},
|
||||
"incognito": {"type": "boolean", "optional": true, "description": "True for private browsing requests."},
|
||||
"originUrl": {"type": "string", "optional": true, "description": "URL of the resource that triggered this request."},
|
||||
"documentUrl": {"type": "string", "optional": true, "description": "URL of the page into which the requested resource will be loaded."},
|
||||
"tabId": {"type": "integer", "description": "The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab."},
|
||||
|
@ -578,6 +581,7 @@
|
|||
"method": {"type": "string", "description": "Standard HTTP method."},
|
||||
"frameId": {"type": "integer", "description": "The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code> or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame. Frame IDs are unique within a tab."},
|
||||
"parentFrameId": {"type": "integer", "description": "ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists."},
|
||||
"incognito": {"type": "boolean", "optional": true, "description": "True for private browsing requests."},
|
||||
"originUrl": {"type": "string", "optional": true, "description": "URL of the resource that triggered this request."},
|
||||
"documentUrl": {"type": "string", "optional": true, "description": "URL of the page into which the requested resource will be loaded."},
|
||||
"tabId": {"type": "integer", "description": "The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab."},
|
||||
|
@ -625,6 +629,7 @@
|
|||
"method": {"type": "string", "description": "Standard HTTP method."},
|
||||
"frameId": {"type": "integer", "description": "The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code> or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame. Frame IDs are unique within a tab."},
|
||||
"parentFrameId": {"type": "integer", "description": "ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists."},
|
||||
"incognito": {"type": "boolean", "optional": true, "description": "True for private browsing requests."},
|
||||
"originUrl": {"type": "string", "optional": true, "description": "URL of the resource that triggered this request."},
|
||||
"documentUrl": {"type": "string", "optional": true, "description": "URL of the page into which the requested resource will be loaded."},
|
||||
"tabId": {"type": "integer", "description": "The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab."},
|
||||
|
@ -684,6 +689,7 @@
|
|||
"method": {"type": "string", "description": "Standard HTTP method."},
|
||||
"frameId": {"type": "integer", "description": "The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code> or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame. Frame IDs are unique within a tab."},
|
||||
"parentFrameId": {"type": "integer", "description": "ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists."},
|
||||
"incognito": {"type": "boolean", "optional": true, "description": "True for private browsing requests."},
|
||||
"originUrl": {"type": "string", "optional": true, "description": "URL of the resource that triggered this request."},
|
||||
"documentUrl": {"type": "string", "optional": true, "description": "URL of the page into which the requested resource will be loaded."},
|
||||
"tabId": {"type": "integer", "description": "The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab."},
|
||||
|
@ -728,6 +734,7 @@
|
|||
"method": {"type": "string", "description": "Standard HTTP method."},
|
||||
"frameId": {"type": "integer", "description": "The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code> or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame. Frame IDs are unique within a tab."},
|
||||
"parentFrameId": {"type": "integer", "description": "ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists."},
|
||||
"incognito": {"type": "boolean", "optional": true, "description": "True for private browsing requests."},
|
||||
"originUrl": {"type": "string", "optional": true, "description": "URL of the resource that triggered this request."},
|
||||
"documentUrl": {"type": "string", "optional": true, "description": "URL of the page into which the requested resource will be loaded."},
|
||||
"tabId": {"type": "integer", "description": "The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab."},
|
||||
|
@ -773,6 +780,7 @@
|
|||
"method": {"type": "string", "description": "Standard HTTP method."},
|
||||
"frameId": {"type": "integer", "description": "The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code> or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame. Frame IDs are unique within a tab."},
|
||||
"parentFrameId": {"type": "integer", "description": "ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists."},
|
||||
"incognito": {"type": "boolean", "optional": true, "description": "True for private browsing requests."},
|
||||
"originUrl": {"type": "string", "optional": true, "description": "URL of the resource that triggered this request."},
|
||||
"documentUrl": {"type": "string", "optional": true, "description": "URL of the page into which the requested resource will be loaded."},
|
||||
"tabId": {"type": "integer", "description": "The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab."},
|
||||
|
@ -817,6 +825,7 @@
|
|||
"method": {"type": "string", "description": "Standard HTTP method."},
|
||||
"frameId": {"type": "integer", "description": "The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code> or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame. Frame IDs are unique within a tab."},
|
||||
"parentFrameId": {"type": "integer", "description": "ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists."},
|
||||
"incognito": {"type": "boolean", "optional": true, "description": "True for private browsing requests."},
|
||||
"originUrl": {"type": "string", "optional": true, "description": "URL of the resource that triggered this request."},
|
||||
"documentUrl": {"type": "string", "optional": true, "description": "URL of the page into which the requested resource will be loaded."},
|
||||
"tabId": {"type": "integer", "description": "The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab."},
|
||||
|
|
|
@ -11,21 +11,41 @@ server.registerPathHandler("/dummy", (request, response) => {
|
|||
add_task(async function test_incognito_webrequest_access() {
|
||||
Services.prefs.setBoolPref("extensions.allowPrivateBrowsingByDefault", false);
|
||||
|
||||
// This extension will fail if it gets a request
|
||||
let pb_extension = ExtensionTestUtils.loadExtension({
|
||||
incognitoOverride: "spanning",
|
||||
manifest: {
|
||||
permissions: ["webRequest", "webRequestBlocking", "<all_urls>"],
|
||||
},
|
||||
background() {
|
||||
browser.webRequest.onBeforeRequest.addListener(async (details) => {
|
||||
browser.test.assertTrue(details.incognito, "incognito flag is set");
|
||||
browser.test.notifyPass("webRequest.private");
|
||||
}, {urls: ["<all_urls>"]}, ["blocking"]);
|
||||
},
|
||||
});
|
||||
await pb_extension.startup();
|
||||
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
permissions: ["webRequest", "webRequestBlocking", "<all_urls>"],
|
||||
},
|
||||
background() {
|
||||
browser.webRequest.onBeforeRequest.addListener(async (details) => {
|
||||
browser.test.fail("webrequest received incognito request");
|
||||
browser.test.assertFalse(details.incognito, "incognito flag is not set");
|
||||
browser.test.notifyPass("webRequest");
|
||||
}, {urls: ["<all_urls>"]}, ["blocking"]);
|
||||
},
|
||||
});
|
||||
// Load non-incognito extension to check that private requests are invisible to it.
|
||||
await extension.startup();
|
||||
|
||||
let contentPage = await ExtensionTestUtils.loadContentPage("http://example.com/dummy", {privateBrowsing: true});
|
||||
await pb_extension.awaitFinish("webRequest.private");
|
||||
await pb_extension.unload();
|
||||
await contentPage.close();
|
||||
|
||||
contentPage = await ExtensionTestUtils.loadContentPage("http://example.com/dummy");
|
||||
await extension.awaitFinish("webRequest");
|
||||
await extension.unload();
|
||||
await contentPage.close();
|
||||
|
||||
|
|
|
@ -18,14 +18,15 @@ add_task(async function test_incognito_proxy_onRequest_access() {
|
|||
// extension does not have permission.
|
||||
Services.prefs.setBoolPref("extensions.allowPrivateBrowsingByDefault", false);
|
||||
|
||||
// This extension will fail if it gets a request
|
||||
// This extension will fail if it gets a private request.
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
permissions: ["proxy", "<all_urls>"],
|
||||
},
|
||||
async background() {
|
||||
browser.proxy.onRequest.addListener(async (details) => {
|
||||
browser.test.fail("proxy.onRequest received incognito request");
|
||||
browser.test.assertFalse(details.incognito, "incognito flag is not set");
|
||||
browser.test.notifyPass("proxy.onRequest");
|
||||
}, {urls: ["<all_urls>"]});
|
||||
|
||||
// Actual call arguments do not matter here.
|
||||
|
@ -42,7 +43,6 @@ add_task(async function test_incognito_proxy_onRequest_access() {
|
|||
await extension.startup();
|
||||
await extension.awaitMessage("ready");
|
||||
|
||||
// This extension will succeed if it gets a request
|
||||
let pextension = ExtensionTestUtils.loadExtension({
|
||||
incognitoOverride: "spanning",
|
||||
manifest: {
|
||||
|
@ -50,18 +50,22 @@ add_task(async function test_incognito_proxy_onRequest_access() {
|
|||
},
|
||||
background() {
|
||||
browser.proxy.onRequest.addListener(async (details) => {
|
||||
browser.test.notifyPass("proxy.onRequest");
|
||||
browser.test.assertTrue(details.incognito, "incognito flag is set");
|
||||
browser.test.notifyPass("proxy.onRequest.private");
|
||||
}, {urls: ["<all_urls>"]});
|
||||
},
|
||||
});
|
||||
await pextension.startup();
|
||||
|
||||
let finished = pextension.awaitFinish("proxy.onRequest");
|
||||
let contentPage = await ExtensionTestUtils.loadContentPage("http://example.com/dummy", {privateBrowsing: true});
|
||||
await finished;
|
||||
await pextension.awaitFinish("proxy.onRequest.private");
|
||||
await pextension.unload();
|
||||
await contentPage.close();
|
||||
|
||||
contentPage = await ExtensionTestUtils.loadContentPage("http://example.com/dummy");
|
||||
await extension.awaitFinish("proxy.onRequest");
|
||||
|
||||
await extension.unload();
|
||||
await pextension.unload();
|
||||
await contentPage.close();
|
||||
|
||||
Services.prefs.clearUserPref("extensions.allowPrivateBrowsingByDefault");
|
||||
|
|
|
@ -664,6 +664,7 @@ HttpObserverManager = {
|
|||
},
|
||||
|
||||
getRequestData(channel, extraData) {
|
||||
let originAttributes = channel.loadInfo && channel.loadInfo.originAttributes;
|
||||
let data = {
|
||||
requestId: String(channel.id),
|
||||
url: channel.finalURL,
|
||||
|
@ -671,6 +672,7 @@ HttpObserverManager = {
|
|||
browser: channel.browserElement,
|
||||
type: channel.type,
|
||||
fromCache: channel.fromCache,
|
||||
originAttributes,
|
||||
|
||||
originUrl: channel.originURL || undefined,
|
||||
documentUrl: channel.documentURL || undefined,
|
||||
|
|
Загрузка…
Ссылка в новой задаче