webRequest.onBeforeRequest blocking doesn't affect redirects from other blocking request handlers

RESOLVED INVALID

Status

()

Toolkit
WebExtensions: Request Handling
RESOLVED INVALID
15 days ago
15 days ago

People

(Reporter: stoically, Unassigned)

Tracking

58 Branch
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

15 days ago
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0
Build ID: 20180131010234

Steps to reproduce:

Loaded a WebExtension with the following code and navigated to any domain.

let redirected = false;
browser.webRequest.onBeforeRequest.addListener((request) => {
  if (!redirected) {
    console.log('redirect', request);
    redirected = true;
    return {redirectUrl: 'http://example.com'};
  }
},  {
  urls: ['<all_urls>'],
  types: ['main_frame']
}, [
  'blocking'
]);

browser.webRequest.onBeforeRequest.addListener((request) => {
  console.log('blocking', request);
  return {cancel: true};
},  {
  urls: ['<all_urls>'],
  types: ['main_frame']
}, [
  'blocking'
]);


Actual results:

The blocking request handler sees the redirect to example.com


Expected results:

Since the blocking request handler blocked the request, the redirect should not happen (and thus not be seen by the blocking handler).

The request that comes in from the redirect has the same requestId as the initial request, indicating that it indeed is the same request that the blocking handler already decided to block.

When the redirect handler has no "blocking" as "extraInfoSpec" this works as expected.

Updated

15 days ago
Component: Untriaged → WebExtensions: Request Handling
Product: Firefox → Toolkit
When multiple blocking handlers modify a request, only one set of modifications take effect. Redirects and cancellations have the same precedence.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 15 days ago
Resolution: --- → INVALID
(Reporter)

Comment 2

15 days ago
Thanks for letting me know. Unfortunately I wasn't able to find that information on https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/webRequest/onBeforeRequest or other pages about webRequest. Did I just miss it? And if not, would it be maybe possible to add it?
(Reporter)

Comment 3

15 days ago
Nevermind, one can just edit pages on MDN and I just did. Thanks again!
You need to log in before you can comment on or make changes to this bug.