Forbid empty "types" and "urls" properties in request filters

RESOLVED FIXED in Firefox 54

Status

()

Toolkit
WebExtensions: Untriaged
RESOLVED FIXED
6 months ago
6 months ago

People

(Reporter: Romain Neutron, Assigned: kmag)

Tracking

54 Branch
mozilla54
Points:
---

Firefox Tracking Flags

(firefox54 fixed)

Details

MozReview Requests

()

Submitter Diff Changes Open Issues Last Updated
Loading...
Error loading review requests:

Attachments

(1 attachment)

(Reporter)

Description

6 months ago
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:54.0) Gecko/20100101 Firefox/54.0
Build ID: 20170302030206

Steps to reproduce:

I wrote the following code use ResourceType (https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/webRequest/ResourceType)

```
chrome.webRequest.onCompleted.addListener((details) => console.log('onCompleted', details.url), { urls: [] });

fetch('https://blackfire.io');
```

On Chrome, the `console.log` call is triggered, because Chrome considers the "urls" property that equals to an empty array as "<all_urls>" property

On Firefox result is different:



Actual results:

No console.log is triggered, the event is not caught


Expected results:

As a an experimented Chrome extension developer, I expected my code work.
I realized I should declare the { urls: "<all_urls>" } property to match any URL
(Assignee)

Comment 1

6 months ago
This is intentional. If you omit the `urls` property, we ignore it, but if you provide an empty array, we treat it the same way we treat any other urls array. Though perhaps we should treat an empty array as an error, since I can't think of any valid use case for it.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 6 months ago
Resolution: --- → WONTFIX
(Assignee)

Updated

6 months ago
Duplicate of this bug: 1343997
(Reporter)

Comment 3

6 months ago
I'm surprised the way you're closing my issues. This is definitely a developer experience issue.
The interface here is the WebExtension interface, shared by several vendors including Firefox. All these interfaces should share the same behavior and they actually not.

Please consider this kind of feedback.
(Assignee)

Comment 4

6 months ago
There is no spec for this behavior, and we've never aimed for bug-for-bug compatibility. In particular, the behavior that you're depending on is not documented, and our behavior is consistent with what is documented.
Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: WONTFIX → ---
Summary: Difference of implementation of WebRequest ResourceType "urls" property between Firefox and Chrome → Forbid empty "types" and "urls" properties in request filters
Comment hidden (mozreview-request)
(Reporter)

Comment 6

6 months ago
Thanks for the appropriate change in the title :+1:

Comment 7

6 months ago
mozreview-review
Comment on attachment 8843035 [details]
Bug 1343996: Forbid empty types and urls request filter arrays.

https://reviewboard.mozilla.org/r/116786/#review118652

It sounds reasonable to me, raise an explicit error is better given the incompatible behavior between Chrome and Firefox when this properties are set to empty arrays.

Also, it is consistent to how we handled a similar scenario on the webNavigation EventUrlFilter type (http://searchfox.org/mozilla-central/rev/546a05fec017cb785fca62a5199d42812a6a1fd3/toolkit/components/extensions/schemas/web_navigation.json#36-47), that has already this validation for the exactly same reason.
Attachment #8843035 - Flags: review?(lgreco) → review+

Updated

6 months ago
Assignee: nobody → kmaglione+bmo
Status: REOPENED → ASSIGNED

Comment 8

6 months ago
Pushed by maglione.k@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/f58322b06308
Forbid empty types and urls request filter arrays. r=rpl

Comment 9

6 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/f58322b06308
Status: ASSIGNED → RESOLVED
Last Resolved: 6 months ago6 months ago
status-firefox54: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla54
You need to log in before you can comment on or make changes to this bug.