Requests from web extension can't be modified / redirected

NEW
Unassigned

Status

()

Toolkit
WebExtensions: Request Handling
P3
normal
a year ago
2 months ago

People

(Reporter: esterTion, Unassigned)

Tracking

53 Branch
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: triaged)

Attachments

(1 attachment)

1.05 KB, application/x-zip-compressed
Details
(Reporter)

Description

a year ago
Created attachment 8870881 [details]
firefox-modify-test.zip

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
(Reporter)

Comment 1

a year ago
Kind of a bad chrome screenshot, here's another prove. 
https://estertion.win/wp-content/uploads/2017/05/86c93f56bcf4e6d2784d96d76f9d0db8d1bf798a.png

Comment 2

a year ago
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?
(Reporter)

Comment 3

a year ago
(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.

Updated

a year ago
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
Last Resolved: a year ago
Resolution: --- → WORKSFORME
Flags: needinfo?(mixedpuppy)
(Reporter)

Comment 5

a year ago
(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.
(Reporter)

Comment 6

a year ago
Setted a proxy for 55a1(2017-06-08), still have the bug. 
https://estertion.win/wp-content/uploads/2017/06/518df86999a76df9104b347435559306bfd2777d.png
(Reporter)

Updated

a year ago
Status: RESOLVED → UNCONFIRMED
Resolution: WORKSFORME → ---

Updated

a year ago
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
(Reporter)

Comment 8

2 months ago
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?
You need to log in before you can comment on or make changes to this bug.