Closed Bug 1367484 Opened 7 years ago Closed 4 years ago

Requests from web extension can't be modified / redirected

Categories

(WebExtensions :: Request Handling, defect, P3)

53 Branch
defect

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: lcz970, Unassigned)

Details

(Whiteboard: triaged)

Attachments

(1 file)

1.05 KB, application/x-zip-compressed
Details
Every request fired by an web extension itself can't be modified or redirected, and seems affect all current firefox build. 
Example extension has a content script for stackoverflow.com fires two request to /?test_redirect and /?test_modify. 
The background script should redirect /?test_redirect to /?after_redirect, and modify user-agent of /?test_modify to "curl". 

https://estertion.win/wp-content/uploads/2017/05/c7cfcad04faf94f1b60c480a69f08b822d6d9549.png

In chrome, everything works as expected. 
https://estertion.win/wp-content/uploads/2017/05/70fb9b02d664320cdb5d9dbb5ad2fc576cf9312f.png
Kind of a bad chrome screenshot, here's another prove. 
https://estertion.win/wp-content/uploads/2017/05/86c93f56bcf4e6d2784d96d76f9d0db8d1bf798a.png
Maybe I'm unaware of something obvious, but Firefox's WebExtension API namespace is "browser" rather than "chrome". Your attached ZIP appears to use "chrome". Try using "browser.webRequest.onBeforeRequest..." instead?
(In reply to none11given from comment #2)
> Maybe I'm unaware of something obvious, but Firefox's WebExtension API
> namespace is "browser" rather than "chrome". Your attached ZIP appears to
> use "chrome". Try using "browser.webRequest.onBeforeRequest..." instead?

Well, that is not the main problem, and it doesn't make any difference as I tried. 
Web extension aims for compatibility with chrome, and the api namespace "browser" and "chrome" are the same pointer, so it should not be a problem in any case. So does Edge Extension works. Currently one chrome extension should works on all three different browsers, although may have some different bugs or, features as they performs differently.
Flags: needinfo?(mixedpuppy)
Your test extension works as expected on nightly.  You might be running into bug 1345893 which as fixed for Fx54.  Please try 54 or later.
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → WORKSFORME
Flags: needinfo?(mixedpuppy)
(In reply to Shane Caraveo (:mixedpuppy) from comment #4)
> Your test extension works as expected on nightly.  You might be running into
> bug 1345893 which as fixed for Fx54.  Please try 54 or later.

I'm guessing you might misunderstand the bug. 
I reported that request from the *content script or background script* are not modified. 
Tried 54b13, not working right now. 
55a1 can't even open debug window to see if it's working. I need the extension debug window to check the request from content script, they aren't visible in normal devtool context.
Setted a proxy for 55a1(2017-06-08), still have the bug. 
https://estertion.win/wp-content/uploads/2017/06/518df86999a76df9104b347435559306bfd2777d.png
Status: RESOLVED → UNCONFIRMED
Resolution: WORKSFORME → ---
Flags: needinfo?(mixedpuppy)
Verified.  canChange is false due to XHR [from a content script] using an expanded principal.

Potential fix:
John-Galt: Probably add a subsumesPrincipal method to MatchPattern and MatchPatternSet and check if the add-on's allowedOrigins subsumes all of the sub-principals of the expanded principal.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(mixedpuppy)
Priority: -- → P2
Whiteboard: triaged
Priority: P2 → P3
Hi, I almost forgot this but received notify mail today. 
I think this problem is actually gone after 57, probably because of main rewriting. 
Maybe check the status and set to fixed?
Product: Toolkit → WebExtensions
Status: NEW → RESOLVED
Closed: 7 years ago4 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: