New issue
Advanced search Search tips

Issue 760589 link

Starred by 1 user

Issue metadata

Status: Untriaged
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

"binary" type in extension schemas is unclear and used incorrectly

Project Member Reported by rob@robwu.nl, Aug 30 2017

Issue description

The JSON schema for extensions has a type "binary". This is supposedly an ArrayBuffer or view (e.g. typed array), but it has also been "abused" to refer to other types.

Here is what I have found in a search for "type": "binary": https://cs.chromium.org/search/?q=%22%5C%22type%5C%22:+%5C%22binary%22&sq=package:chromium&type=cs

ArrayBuffer
https://chromium.googlesource.com/chromium/src/+/052e98539f9979950099934c56589149b2487874/chrome/common/extensions/api/wallpaper.json#23
https://chromium.googlesource.com/chromium/src/+/f8e512c973f7a8d9c6c5ea5127654d6d7d4b720a/chrome/common/extensions/api/wallpaper_private.json#85
https://chromium.googlesource.com/chromium/src/+/f8e512c973f7a8d9c6c5ea5127654d6d7d4b720a/chrome/common/extensions/api/wallpaper_private.json#117
https://chromium.googlesource.com/chromium/src/+/f8e512c973f7a8d9c6c5ea5127654d6d7d4b720a/chrome/common/extensions/api/wallpaper_private.json#214
https://chromium.googlesource.com/chromium/src/+/f8e512c973f7a8d9c6c5ea5127654d6d7d4b720a/chrome/common/extensions/api/wallpaper_private.json#273

Blob
https://chromium.googlesource.com/chromium/src/+/d7834ed41b46c358c51feadf0bfe8ac941a7b617/chrome/common/extensions/api/page_capture.json#11

ImageData
https://chromium.googlesource.com/chromium/src/+/052e98539f9979950099934c56589149b2487874/chrome/common/extensions/api/declarative_content.json#11


pageCapture: a callback parameter is declarared as a "binary" type. I think that the callback parameter is not validated against the schema, so the incorrect type did not raise flags.
 
declarativeContent: The type is changed with "isInstanceOf" in the JSON schema. This seems to be supported here:
https://chromium.googlesource.com/chromium/src/+/e86b68d914f37845d5193099d83aafd1b4788496/extensions/renderer/bindings/argument_spec.cc#201


I was also expecting to find the webRequest API in the results, since its UploadData type can also have a property of type Buffer. But for some reason this is typed "any".
https://chromium.googlesource.com/chromium/src/+/e86b68d914f37845d5193099d83aafd1b4788496/extensions/common/api/web_request.json#138


The effect of this is:
- The API is confusing (and by extension the documentation is confusing) (it is not obvious what "binary" means). In most cases the docs say ArrayBuffer, but it is not obvious at all that typed arrays are also supported.


To fix:
- Change the type in pageCapture to "object" and add "isInstanceOf": "Blob".
- Change the type in declarativeContent to "object".
- Remove support for isInstanceOf with the "binary" type.
- Change the type in webRequest (UploadType.bytes) from "any" to "binary"
- Optional: Rename "binary" to "ArrayBufferOrView" for clarity.
 

Comment 1 by rob@robwu.nl, Aug 30 2017

FWIW, the extension APIs that are defined by an IDL use ArrayBuffer (and do not support typed arrays).

The only occurrence of ArrayBufferView is in a unit test:

https://cs.chromium.org/search/?q=file:extensions+file:idl+ArrayBufferView&sq=package:chromium&type=cs

Sign in to add a comment