Chrome Version: 65.0.3325.181 (Official Build)
OS: macOS Sierra 10.12.6
What steps will reproduce the problem?
(1) In Chrome extension, use webRequest.onBeforeSendHeaders.addListener() to hook outgoing requests.
(2) Send a web request from Chrome extension by fetch().
What is the expected result?
The callback is invoked with initiator = "chrome-extension://<extension-ID>"
What happens instead?
The callback is invoked with initiator = undefined
The documentation [1] says initiator field is available since M63, and until a few days ago it worked for me. I guess it is a bug introduced in M63.
BTW, it works fine on canary (68.0.3400.0).
[1] https://developer.chrome.com/extensions/webRequest#event-onBeforeRequest
Comment 1 by nya@chromium.org
, Apr 19 2018Here is a repro code. I also attached a zipped extension. ================ manifest.json { "manifest_version": 2, "name": "WebRequest Example", "description": "WebRequest Example", "version": "1.0.0", "background": { "scripts": ["background.js"], "persistent": true }, "browser_action": {}, "permissions": [ "webRequest", "https://example.com/*" ] } ================ background.js function onBeforeSendHeaders(details) { console.log(details.initiator); console.log(details); } function onClicked() { fetch('https://example.com/'); } chrome.webRequest.onBeforeSendHeaders.addListener( onBeforeSendHeaders, { urls: ['https://example.com/*'] }); chrome.browserAction.onClicked.addListener(onClicked);885 bytes
885 bytes Download