Opened on 03/20/2019 at 11:10:37 AM
Closed on 03/29/2019 at 10:18:24 AM
Last modified on 07/21/2019 at 09:03:20 PM
#7384 closed change (fixed)
Polyfill browser.webRequest.ResourceType for Edge
Reported by: | kzar | Assignee: | kzar |
---|---|---|---|
Priority: | P2 | Milestone: | Adblock-Plus-for-Chrome-Opera-Firefox-next |
Module: | Platform | Keywords: | |
Cc: | sebastian, geo, greiner | Blocked By: | |
Blocking: | Platform: | Edge | |
Ready: | yes | Confidential: | no |
Tester: | Ross | Verified working: | yes |
Review URL(s): |
https://gitlab.com/eyeo/adblockplus/adblockpluschrome/merge_requests/51 |
Description (last modified by kzar)
Background
Both Firefox and Chrome provide an Object browser.webRequest.ResourceType which lists the support resource types which can be used to filter webRequest events. Edge does not provide that, but does list the valid resource types when an listener is incorrectly created.
What to change
- In adblockpluschrome/polyfill.js, if browser.webRequest.ResourceType isn't defined, attempt to create a listener for the browser.webRequest.onBeforeRequest event with an invalid resource type filter. Then attempt to obtain the list of valid resource types from the exception's message.
For example:
browser.webRequest.onBeforeRequest.addListener(details => {}, {urls:["<all_urls>"], types:["foo"]})
Results in the following exception on Edge 42.17134.1.0:
Error: Invalid value for argument 2. Property 'types': Value must be one of: [main_frame,sub_frame,stylesheet,script,image,object,xmlhttprequest,fetch,ping,other].
From that, browser.webRequest.ResourceType should look something like this:
{MAIN_FRAME: "main_frame", SUB_FRAME: "sub_frame", STYLESHEET: "stylesheet", SCRIPT: "script", IMAGE: "image", OBJECT: "object", XMLHTTPREQUEST: "xmlhttprequest", FETCH: "fetch", PING: "ping", OTHER: "other"}
- Modify any code which assumes browser.webRequest.ResourceType doesn't exist on Edge, for example in adblockpluschrome/lib/requestBlocker.js.
- Modify webRequest listeners (e.g. in adblockpluschrome/ext/background.js) that we've so far avoided passing the types filter for, to use that instead of manually checking the event's type property.
Notes
- Edge seems to provide the exception as a String, where as the other browsers provide it as an Object which contains a message property which references the String.
- No need to handle them, but here's how the exception message looks on
- Chrome 72.0.3626.119: Error at parameter 'filter': Error at property 'types': Error at index 0: Value must be one of csp_report, font, image, main_frame, media, object, other, ping, script, stylesheet, sub_frame, websocket, xmlhttprequest.
- Firefox 64.0: Type error for parameter filter (Error processing types.0: Invalid enumeration value "foo") for webRequest.onBeforeRequest.
Hints for testers
- Ensure request blocking works properly on Chrome (both new and old), Firefox and Edge.
- Ensure that #7305 is still fixed.
- Ensure there aren't any new exceptions thrown by the content scripts.
Attachments (0)
Change History (17)
comment:2 Changed on 03/20/2019 at 11:12:50 AM by kzar
- Platform changed from Unknown / Cross platform to Edge
comment:3 Changed on 03/20/2019 at 12:18:45 PM by kzar
- Blocking 7305 removed
comment:8 Changed on 03/20/2019 at 03:41:03 PM by kzar
- Owner set to geo
comment:9 Changed on 03/21/2019 at 10:48:35 AM by greiner
- Cc greiner added
comment:10 Changed on 03/21/2019 at 12:22:03 PM by kzar
- Owner changed from geo to kzar
- Review URL(s) modified (diff)
comment:11 Changed on 03/21/2019 at 12:22:17 PM by kzar
- Status changed from new to reviewing
comment:12 Changed on 03/29/2019 at 10:14:32 AM by abpbot
comment:13 Changed on 03/29/2019 at 10:18:24 AM by kzar
- Description modified (diff)
- Milestone set to Adblock-Plus-for-Chrome-Opera-Firefox-next
- Resolution set to fixed
- Status changed from reviewing to closed
comment:14 Changed on 04/02/2019 at 02:31:34 PM by abpbot
A commit referencing this issue has landed:
Issue 7384 - Only polyfill webRequest.ResourceType in background page
comment:15 Changed on 04/02/2019 at 02:33:16 PM by kzar
- Description modified (diff)
comment:16 Changed on 04/02/2019 at 02:33:40 PM by kzar
- Review URL(s) modified (diff)
comment:17 Changed on 07/21/2019 at 09:03:20 PM by Ross
- Tester changed from Unknown to Ross
- Verified working set
Done. Working as described.
ABP 3.5.2.2339
Microsoft Edge 44.17763.1.0
A commit referencing this issue has landed:
Issue 7384 - Polyfill webRequest.ResourceType and Object.values