Note: There are a few cases of duplicates in user autocompletion which are being worked on.

WebRequest API does not support file: requests




WebExtensions: Request Handling
5 months ago
2 months ago


(Reporter: testit, Unassigned)


(Blocks: 1 bug)

Firefox Tracking Flags

(Not tracked)


(Whiteboard: triaged)


(1 attachment)

1011 bytes, application/x-zip-compressed


5 months ago
Created attachment 8839529 [details]

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0
Build ID: 20170125094131

Steps to reproduce:

My extensions registers as a listener to webRequest.onBeforeRequest. This is done to redirect the user to my extension main page if he opens a local epub file.

Here are the steps to reproduce the problem:

- Download and unzip the attached test case. Load the extension via "about:debugging". 

- Open the file explorer and open the file "testit.epub" (included in the zip file) via right click and by selecting "Firefox".

- The standard file save dialog is displayed.

As my extension registered as a listener to webRequest.onBeforeRequest with a filter to all file URLs with the extension ".epub", the request should be redirected to the main page of my extension. The file url should be passed as a parameter.

The reason this didn't happen is, that access to file URLs was not granted to my extension. Currently exists no user interface to grant access to file URLs.

So in general this is not a bug because the extension behaves as expected. I created this bug to show a use case for granting access to file URLs.


5 months ago
Last Resolved: 5 months ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1256122

Comment 2

5 months ago
This is not a duplicate of bug 1256122. 

The redirect in 1256122 fails because it's not allowed to redirect a http:// url to an extension page. An error message is logged.

The redirect in this bug fails, because no access to file URLs is granted. The webRequest.onBeforeRequest listener is not called at all. No error message is logged.
Resolution: DUPLICATE → ---


5 months ago
Summary: Redirect to extension page fails if no access to file URLs is granted → WebRequest API does not support file: requests

Comment 3

5 months ago
I think the problem come from the `browser.webRequest.onBeforeRequest.addListener`'s filter `"urls": ["file://*/*.epub", "file://*/*.EPUB"]`.
The syntax is invalid according to
Should be `"urls": ["file:///*.epub", "file:///*.EPUB"]`

Comment 4

5 months ago
(In reply to Memmie Lenglet from comment #3)
> I think the problem come from the
> `browser.webRequest.onBeforeRequest.addListener`'s filter `"urls":
> ["file://*/*.epub", "file://*/*.EPUB"]`.
> The syntax is invalid according to
> Match_patterns#Invalid_match_patterns
> Should be `"urls": ["file:///*.epub", "file:///*.EPUB"]`

I tried it with the changes you suggested. Unfortunately, this doesn't make a difference, it still doesn't work.

Comment 5

5 months ago
Ok I found the why. In fact the docs says:
"Only requests made using HTTP or HTTPS will trigger events, even though match patterns can match some other protocols"

An API like registerContentHandler should be used, but it's seem impossible to use with WebExtensions:
"For security reasons, it's not possible for an extension or web site to register content handlers targeting other sites"


5 months ago
Blocks: 1341098

Comment 6

5 months ago
file system investigate
Flags: needinfo?(amckay)


5 months ago
Priority: -- → P3
Whiteboard: triaged


3 months ago
See Also: → bug 1266960


2 months ago
Flags: needinfo?(amckay)
You need to log in before you can comment on or make changes to this bug.