webRequest.onBeforeRequest listener is called twice if the request is canceled

RESOLVED DUPLICATE of bug 1272199

Status

RESOLVED DUPLICATE of bug 1272199
3 years ago
8 months ago

People

(Reporter: umbecono, Unassigned)

Tracking

46 Branch

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

826 bytes, application/x-xpinstall
Details
(Reporter)

Description

3 years ago
Created attachment 8751580 [details]
bug_cancel_request.xpi

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:46.0) Gecko/20100101 Firefox/46.0
Build ID: 20160425115337

Steps to reproduce:

Return {cancel: true} from a `webRequest.onBeforeRequest` listener which logs each call to it in the console. (In Firefox 46 on Ubuntu 14.04.)


Actual results:

Two messages are logged from the `onBeforeRequest` listener if it returns {cancel: true} to block the load, and one is logged otherwise. That indicates that the listener is called a second time when it cancels a request. If the request is canceled, an error follows the two messages, but the load is terminated.

The console output:

onBeforeRequest: blocking bug 1271553 background.js:9:3
>>>twice; this is my extension reporting. Then,<<<
[Exception... "Component returned failure code: 0x805e0006 [nsIWebNavigation.loadURIWithOptions]"  nsresult: "0x805e0006 (<unknown>)"  location: "JS frame :: chrome://browser/content/browser.js :: _loadURIWithFlags :: line 839"  data: no] browser.js:860:0


Expected results:

The `webRequest.onBeforeRequest` listener should have been called just once, and the load terminated without error.

The attached WebExtension demonstrates the problem. `onBeforeRequest` listens for Bugzilla bug report URLs, blocks odd-numbered bugs, and logs whether it blocked or passed each page. In Chrome, one message is logged from `onBeforeRequest` for each URL, and URLs are blocked without error. In Firefox, two messages are logged if a URL is blocked but one message if it isn't, and an error follows the two messages when a URL is blocked.
I think this is the same issue as bug 1272199. Please reopen if you can still reproduce on Firefox 48.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1272199

Updated

8 months ago
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.