Closed Bug 1317366 Opened 8 years ago Closed 8 years ago

webRequest throws when a blocking listener returns undefined

Categories

(WebExtensions :: Untriaged, defect)

x86_64
Linux
defect
Not set
normal

Tracking

(firefox51 unaffected, firefox52 verified, firefox53 verified)

VERIFIED FIXED
mozilla53
Tracking Status
firefox51 --- unaffected
firefox52 --- verified
firefox53 --- verified

People

(Reporter: u287251, Assigned: kmag)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0
Build ID: 20161028133011

Steps to reproduce:

Tested the WebExtensions version of uBlock Origin 1.9.17b9:
https://github.com/gorhill/uBlock/releases/tag/1.9.17b9



Actual results:

When loading any web page, the browser console is filled with entries like:

result is undefined WebRequest.jsm:752
	HttpObserverManager.applyChanges< resource://gre/modules/WebRequest.jsm:752:1
	next self-hosted:1120:9
	TaskImpl_run resource://gre/modules/Task.jsm:319:42
	bound TaskImpl_run self-hosted:957:17

This is because the code at WebRequest.jsm:752 does not 1st check whether the returned value from a webRequest.onBeforeRequest listener is undefined, it assumes an Object is always returned.

However, the documentation regarding listeners for chrome.webRequest.onBeforeRequest et al says[1]:

> the callback can return a webRequest.BlockingResponse that determines
> the further life cycle of the request.

So as per documentation, a callback CAN return a BlockingResponse object for when a request has to be canceled or redirected. However, when no cancellation of redirection is needed, it is ok to return nothing, i.e. `undefined`.

[1] https://developer.chrome.com/extensions/webRequest


Expected results:

No such error in the browser console.
OS: Unspecified → Linux
Hardware: Unspecified → x86_64
Version: 49 Branch → 52 Branch
Version: 52 Branch → Trunk
Component: Untriaged → WebExtensions: Untriaged
Product: Firefox → Toolkit
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: webRequest API throws when an onBeforeRequest handler returns `undefined` → webRequest throws when a blocking listener returns undefined
Assignee: nobody → kmaglione+bmo
Comment on attachment 8810721 [details]
Bug 1317366: Handle blocking WebRequest listeners returning non-object values.

https://reviewboard.mozilla.org/r/93030/#review92938
Attachment #8810721 - Flags: review?(mixedpuppy) → review+
Pushed by maglione.k@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/69cd55731647
Handle blocking WebRequest listeners returning non-object values. r=mixedpuppy
https://hg.mozilla.org/mozilla-central/rev/69cd55731647
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
Comment on attachment 8810721 [details]
Bug 1317366: Handle blocking WebRequest listeners returning non-object values.

Approval Request Comment
[Feature/regressing bug #]: But 1305217
[User impact if declined]: This bug prevents certain WebExtension request listeners from modifying or canceling requests.
[Describe test coverage new/current, TreeHerder]: The feature in question is extensively tested, and new tests have been added for this feature.
[Risks and why]: Very low. This patch simply adds an additional null check to promise resolution values which we previously performed only for non-promise values.
[String/UUID change made/needed]: None.
Attachment #8810721 - Flags: approval-mozilla-aurora?
Comment on attachment 8810721 [details]
Bug 1317366: Handle blocking WebRequest listeners returning non-object values.

let's fix this regression from a couple of days ago in 52 aurora
Attachment #8810721 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
I can reproduce this issue on Firefox 53.0a1 (20161114043454) under Windows 7 64-bit and Ubuntu 16.04 LTS 32-bit,here is a video: http://screencast.com/t/3QbgwyDsED 

This issue is verified as fixed on Firefox 53.0a1 (20161123030208) and Firefox 52.0a2 (20161123004021) under Windows 7 64-bit and Ubuntu 16.04 LTS 32-bit, there is no WebRequest error in the Browser Console. Here is a video: http://screencast.com/t/IFHOL3TC0EAa
Status: RESOLVED → VERIFIED
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: