Closed Bug 1343996 Opened 7 years ago Closed 7 years ago

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

Categories

(WebExtensions :: Untriaged, defect)

54 Branch
defect
Not set
normal

Tracking

(firefox54 fixed)

RESOLVED FIXED
mozilla54
Tracking Status
firefox54 --- fixed

People

(Reporter: imprec, Assigned: kmag)

References

Details

Attachments

(1 file)

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
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
Closed: 7 years ago
Resolution: --- → WONTFIX
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.
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
Thanks for the appropriate change in the title :+1:
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+
Assignee: nobody → kmaglione+bmo
Status: REOPENED → ASSIGNED
Pushed by maglione.k@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/f58322b06308
Forbid empty types and urls request filter arrays. r=rpl
https://hg.mozilla.org/mozilla-central/rev/f58322b06308
Status: ASSIGNED → RESOLVED
Closed: 7 years ago7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla54
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.