Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Tool to automatically collect API information from Chrome #122

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Rob--W
Copy link
Member

@Rob--W Rob--W commented Jun 1, 2018

This tool automatically generates metadata from Chrome's runtime, by walking the API namespace, calling the methods with invalid parameters and catching the error. The error message includes a useful method signature.

This PR contains two test extensions, because the page_action and browser_action manifest keys are mutually exclusive. I have added a Node.js server to collect and merge the results from separate runs.

The permissions to unlock the APIs are based on:

I double-checked with:

Alternatives that I have considered and rejected:

  • Parsing the schemas directly from the source code. Chromium's API definitions are scattered over JSON and IDL files (for schemas) and also some other files for permissions and availability (JSON). I didn't want to write a new parser for it. The source also contains Python scripts that parse everything, but re-using to get our desired information takes some efforts (and a multi-GB Chromium checkout).
  • Scraping the schemas from Chrome's documentation: Rejected because the documentation is not consistently updated: https://bugs.chromium.org/p/chromium/issues/detail?id=513780#c23

@Rob--W
Copy link
Member Author

Rob--W commented Jun 1, 2018

For reference, the tool output is:

API subset from Chromium 54, 67, 67 with NativeCrxBindings: https://pastebin.com/raw/JdSTEN8S
The full file (including the omited namespaces) is: https://pastebin.com/raw/Sn7ctsUi

The following namespaces are excluded from the subset because they do not appear in the current namespace:

  • browsingData
  • debugger
  • desktopCapture
  • fontSettings
  • gcm
  • instanceID
  • pageCapture
  • permissions
  • sessions
  • system
  • tabCapture
  • topSites
  • tts

Note that browsingData, permissions and topSites should have been included because Firefox supports them...

Also note that my tool does not generate anything in the devtools namespace because the devtools API is special in Chrome (implemented in JavaScript without wrappers for extension APIs).

Finally, my tool excludes the APIs in the privacy and contentSettings namespaces because these are basically copy & paste APIs, and we should do something special for them instead of duplicating exactly the same schema a zillion times for every subkey of privacy.

@Rob--W
Copy link
Member Author

Rob--W commented Jun 5, 2018

I have updated the commit to include the "downloads.open" and "downloads.shelf" permission. The output is not different, because these functions don't take any callbacks.

@brit878

This comment has been minimized.

@infokiller
Copy link
Contributor

This looks great. Any reason it's not merged?

@Rob--W
Copy link
Member Author

Rob--W commented Oct 15, 2020

This looks great. Any reason it's not merged?

The tool was used once and kept here for reference. It is not actively maintained: if new APIs are added to Chrome, then the changes won't be reflected here because the permission needs to be added to the manifest file of the tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants