New issue
Advanced search Search tips

Issue 733764 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Chrome , Mac
Pri: 3
Type: Bug



Sign in to add a comment

Calling event.getRules(function() {}) fails

Project Member Reported by rdevlin....@chromium.org, Jun 15 2017

Issue description

What steps will reproduce the problem?
1. Add some rules to a declarative event (e.g., declarativeWebRequest.onRequest).
2. Call getRules(function() {...})

What is the expected result?
The callback should be invoked with all the rules.

What happens instead of that?
An error is thrown for an invalid invocation.

Please provide any additional information below. Attach a screenshot if
possible.

In extension API calls, we allow optional parameters to be omitted, and the filter list is defined as optional in the spec/documentation (and we allow it to be null or undefined).  The reason this fails is because the get/removeRules functions are defined in event.js as taking two parameters, and validate against those rather than against `arguments`.  This means that the validation sees the callback as the filter argument, and throws an error.

Native bindings do the right thing here, so when those go out, this will be fixed.  Filing this for documentation (and reminding) purposes.
 
Project Member

Comment 1 by bugdroid1@chromium.org, Jun 15 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/df6434db4fb6f58af26c25696f19332853938288

commit df6434db4fb6f58af26c25696f19332853938288
Author: rdevlin.cronin <rdevlin.cronin@chromium.org>
Date: Thu Jun 15 21:35:09 2017

[Extensions] Update DeclarativeApiTest.DeclarativeApi

The DeclarativeApiTest.DeclarativeApi test exercises calling invalid
invocations of [declarativeEvent].getRules() and removeRules(). However,
the "invalid" invocations they have been using simply omit the first
parameter, which is a filter. In the documentation and the schema, this
first parameter is listed as *optional*, and in extension APIs, omitted
optional parameters are allowed. Thus, this is contradictory.

This happens because the get/removeRules functions are defined in
event.js and take two named parameters, using those for validation,
rather than validating on the `arguments` property. Native bindings
actually do the right thing here, and allow the invocation.

Update the test to use truly invalid invocations for the invalid
invocations tests, and add a (disabled) test for using getRules with an
omitted filter.

BUG=733764
BUG= 653596 

Review-Url: https://codereview.chromium.org/2940133002
Cr-Commit-Position: refs/heads/master@{#479846}

[modify] https://crrev.com/df6434db4fb6f58af26c25696f19332853938288/chrome/test/data/extensions/api_test/declarative/api/background.js

Status: Assigned (was: ass)

Sign in to add a comment