New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 696494 link

Starred by 6 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

Unable to capture error when adding chrome.webRequest.* listener for invalid URL pattern

Reported by tamer.zo...@blazemeter.com, Feb 27 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36

Steps to reproduce the problem:
1. Register one of chrome.webRequest.* listeners
for example:

 chrome.webRequest.onBeforeRequest.addListener( blockSites, { urls:  ["<bad_url>"] }, ['blocking'] );

with bad url which doesn't pass Chrome Match patterns validation (https://developer.chrome.com/extensions/match_patterns)

2. In console we will get syntax error:

Unchecked runtime.lastError while running webRequestInternal.addEventListener: '<bad url>' is not a valid URL pattern.

What is the expected behavior?
We tried to use onErrorOccurred but it never gets called for this specific error.
Also checking for chrome.runtime.lastError inside WebRequest callback doesn't supress the error (it even doesn't reach the callback since error happens before).

We expect to be able to catch this error using chrome.runtime.lastError similar to the rest of the extension system.

What went wrong?
In our use case we allow users to enter list of URLs in our extension, however if user enters wrong URL pattern we have no way of reporting this error to the user.

Did this work before? No 

Does this work in other browsers? Yes

Chrome version: 56.0.2924.87  Channel: stable
OS Version: OS X 10.12.3
Flash Version: Shockwave Flash 24.0 r0

 

Comment 1 by woxxom@gmail.com, Feb 27 2017

And what's worse the listener is attached anyway so we can't test the failure by using a temporary dummy function and checking it in chrome.webRequest.onBeforeRequest.hasListener.

Comment 2 by rbyers@chromium.org, Feb 27 2017

Components: -Blink>Network Platform>Extensions>API
Labels: -Hotlist-Interop
Labels: Needs-Triage-M56
Cc: kavvaru@chromium.org
Labels: Needs-Feedback
tamer.zoubi@ Thanks for the issue.

Could you please provide us any sample URL to triage the issue from test team end.

Thanks,

Comment 5 by woxxom@gmail.com, Mar 1 2017

kavvaru@, this bug report is about the extension API itself, not about a web page. Simplified repro if you really need it:

1. Unpack the attached extension zip
2. Open chrome://extensions and enable [x] Developer mode
3. Drag'n'drop the unpacked folder onto the page or use "Load unpacked extension"
4. Click "Inspect views: background page" of the installed extension
5. Observe the Console panel in the devtools that just appeared

EXPECTED output:
	Error successfully caught

OBSERVED output:
	Detecting via exception: FAILED, none thrown
	Detecting via runtime.lastError: FAILED, not set
	Detecting via webRequest.hasListener: FAILED, the nonfunctional listener is attached
	Unchecked runtime.lastError while running webRequestInternal.addEventListener: '<bad_url>' is not a valid URL pattern.

onBeforeRequest-bad-URL.zip
927 bytes Download

Comment 6 by woxxom@gmail.com, Mar 10 2017

Seems to be blocked on issue 366282.
Owner: rdevlin....@chromium.org
Status: Assigned (was: Unconfirmed)
Mac triage: Assigning to rdevlin.cronin@ for further triage or routing, since they own issue 366282.
This is also happening on Windows 10 machines.

User-agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
Cc: rdevlin....@chromium.org
Owner: karandeepb@chromium.org
Triage! -> karandeepb@, who has been doing webRequest work lately.

Sign in to add a comment