0
Commit Graph

22 Commits

Author SHA1 Message Date
Tim Judkins
1e3d052650 Enable python formatting in //tools/json_schema_compiler/
Python formatting using `git cl format` has been enabled in the codebase
for a while now by including a .style.yapf file in your folder
hierarchy. However back in 2020 an exception was added to ignore the
json schema compiler folder, as the code in there uses a lot of chained
function calls that are split across lines for readability and the
formatter was condensing them into a much less readable state.

This CL resolves this by using the line continuation character `\` for
these chained function lines, allowing us to retain the more readable
indentation and also enable the formatter by default. It also runs a
full format over all the files in the directory, to get them into a
consistent state where we can have the formatter enabled by default
going forward with low impact.

No behavior change is expected.

Bug: 40711753
Change-Id: I6e10dc5af022ce0e3557099a84773aa9cc92d2e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5804254
Commit-Queue: Tim <tjudkins@chromium.org>
Reviewed-by: Devlin Cronin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1345613}
2024-08-22 20:16:07 +00:00
Alison Gale
4d9c23185a Migrate TODOs referencing old crbug IDs to the new issue tracker IDs
The canonical bug format is TODO(crbug.com/<id>). TODOs of the
following forms will all be migrated to the new format:

- TODO(crbug.com/<old id>)
- TODO(https://crbug.com/<old id>)
- TODO(crbug/<old id>)
- TODO(crbug/monorail/<old id>)
- TODO(<old id>)
- TODO(issues.chromium.org/<old id>)
- TODO(https://issues.chromium.org/<old id>)
- TODO(https://issues.chromium.org/u/1/issues/<old id>)
- TODO(bugs.chromium.org/<old id>)

Bug id mapping is sourced from go/chrome-on-buganizer-prod-issues.
See go/crbug-todo-migration for details.

#crbug-todo-migration

Bug: b/321899722
Change-Id: Ib4e61022cc4ca4f0a6563a63fb5d2f582ef930c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5494425
Auto-Submit: Alison Gale <agale@chromium.org>
Owners-Override: Alison Gale <agale@chromium.org>
Reviewed-by: Peter Boström <pbos@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1293183}
2024-04-26 19:15:24 +00:00
Jacob Francis
ee33ea7f51 Added script to generate TypeScript definition files
for chrome extension APIs.

This generator works well with many of the idls and json files that were tested.

It reuses the same data objects that the js_externs generator did, however instead of outputting that data into jsdoc and javascript, it is instead output as typescript definitions.

Note:

Imports are not resolvable, so they will need to be added manually
after generation if any are required.

Bug: 1203307
Change-Id: I62440c9707bc233580123feda46dad130a44446a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4679213
Reviewed-by: Devlin Cronin <rdevlin.cronin@chromium.org>
Commit-Queue: Jacob Francis <francisjp@google.com>
Reviewed-by: Demetrios Papadopoulos <dpapad@chromium.org>
Auto-Submit: Jacob Francis <francisjp@google.com>
Cr-Commit-Position: refs/heads/main@{#1183462}
2023-08-15 01:47:41 +00:00
Mike Frysinger
aa837e6eae json_schema_compiler: rename code module to avoid shadowing Python stdlib
Python's stdlib includes a "code" module already.  Rename the local
code module to avoid namespace collisions with it.

Change-Id: I651e572e01509a54897b13bc06570b167a220c64
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4092431
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1081737}
2022-12-12 16:04:31 +00:00
Avi Drissman
dfd8808526 Update copyright headers in testing/, tools/
The methodology used to generate this CL is documented in
https://crbug.com/1098010#c95.

No-Try: true
No-Presubmit: true
Bug: 1098010
Change-Id: I3a8a7b150e7bd64690534727150646081df50439
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3900697
Reviewed-by: Mark Mentovai <mark@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Owners-Override: Avi Drissman <avi@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1047644}
2022-09-15 20:11:09 +00:00
Bruce Dawson
5030b25aef Fix json_schema_compiler test failures on Windows
While uploading crrev.com/c/3579801 I hit some irrelevant presubmit
warnings from js_interface_generator_test.py that hid important and
relevant warnings. These were Windows-only warnings caused by the
different os path separators on Windows and Linux. The fix is to
normalize paths to Linux-style path separators.

Bug: 1309977
Change-Id: I1b4b92b2cbd352a755e31c4485e06f2eab2c9ab7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3582791
Auto-Submit: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Devlin Cronin <rdevlin.cronin@chromium.org>
Commit-Queue: Devlin Cronin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#992614}
2022-04-14 17:47:31 +00:00
Tim Judkins
6a8c35314c [Extensions Bindings] Support returns_async in extension schemas
(Based on previous work from https://crrev.com/c/2144684 )
This CL is a starting point for supporting a returns_async parameter in
Extension schemas, which is a step in supporting promise-based APIs. It
adds a new property to the Model in json_schema_compiler, returns_async,
which contains information about what the API function is expected to
return.

returns_async is used instead of Model.callback, and can be created
either from a callback specification or a specific "returns_async"
entry in the schema.

It also modifies the doc generation code to handle this new property,
displaying it as a callback at the end of the schema. This should
result in there being no visible difference to the docs when an API is
rolled over to using returns_async, other than previously required
callbacks being displayed as optional.

In order to do end-to-end tests, this CL also moves over tabs.create,
tabs.duplicate and tabs.query to use the new schema format, thereby
enabling promise support on them.


Bug: 978538
Change-Id: I43f5965eb8973f0d9fd25d46f1f1ae7ffa346357
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2430291
Reviewed-by: Karan Bhatia <karandeepb@chromium.org>
Reviewed-by: Devlin <rdevlin.cronin@chromium.org>
Commit-Queue: Tim Judkins <tjudkins@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824488}
2020-11-05 18:02:56 +00:00
David Tseng
f0457f0450 Support instanceof with declared types in js externs generation
Test: tools/json_schema_compiler/compiler.py -g externs extensions/common/api/automation.idl > third_party/closure_compiler/externs/automation.js
results in no diffs. automation.js was hand edited previously.
Run
tools/json_schema_compiler/js_externs_generator_test.py

Change-Id: I949530eecb24e5a26bc2f5bff13c831bdad3dbbf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2314016
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791533}
2020-07-25 21:17:46 +00:00
Julian Watson
6b50987e19 tools: use instanceOf property from idl files in jsdocs
Bug: None
Change-Id: I2e5615ac4888d53a555e890f97e965592d7ce052
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2210601
Commit-Queue: Julian Watson <juwa@google.com>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Devlin <rdevlin.cronin@chromium.org>
Auto-Submit: Julian Watson <juwa@google.com>
Cr-Commit-Position: refs/heads/master@{#775005}
2020-06-04 07:28:55 +00:00
Mike Frysinger
65cdca0e93 externs generator: add space before function return
The style guide says to put spaces after colons in JSDoc types:
https://google.github.io/styleguide/jsguide.html#jsdoc-whitespace

Bug: 469920
Change-Id: I579fd028bd5b55419ae82adcb9de633967a6f911
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2209535
Reviewed-by: dpapad <dpapad@chromium.org>
Reviewed-by: Devlin <rdevlin.cronin@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772391}
2020-05-27 21:02:41 +00:00
dpapad
4a0a3f8680 Extensions JS externs: Handle "!" when converting to nullable type.
When creating externs for an optional non-final parameter, to appear
as a nullable required parameter, handle the case where it is
explicitly non-nullable indicated by the "!" operator.

Otherwise an invalid JS type is created as
?!chrome.fakeApi.Baz|undefined
instead of
?chrome.fakeApi.Baz|undefined

Bug: 469920
Change-Id: I93ce8952586aa92e8ad3f1176643677ec4d6525b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2208185
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Devlin <rdevlin.cronin@chromium.org>
Commit-Queue: dpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#770145}
2020-05-19 16:57:17 +00:00
dpapad
549d31b75a Extensions: Modify JS externs generator optional parameter logic.
Closure compiler disallows optional parameters appearing before required
parameters, by throwing JSC_OPTIONAL_ARG_AT_END.

With this modification the auto-generated JS externs files are compliant
with Closure Compiler, by being stricter compared to what is actually
allowed at runtime by those APIs.

Bug: 469920
Change-Id: I348e1465e66c05cdd827d9bdb39cf883b8f3ddbb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2203708
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Devlin <rdevlin.cronin@chromium.org>
Commit-Queue: dpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#769528}
2020-05-16 03:05:44 +00:00
James Hawkins
08d77f2bf2 Extensions: Remove screenlockPrivate API.
This is no longer used.

R=tbarzic@chromium.org

Bug: 904892
Test: none
Change-Id: Iac3088bdc2b198d0d5b37ab9cf18fba5c4c704c8
Reviewed-on: https://chromium-review.googlesource.com/c/1334331
Reviewed-by: Devlin <rdevlin.cronin@chromium.org>
Reviewed-by: Toni Baržić <tbarzic@chromium.org>
Commit-Queue: James Hawkins <jhawkins@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608821}
2018-11-16 17:16:51 +00:00
Nigel Tao
63b704430b Don't generate @see links for private externs
See https://bugs.chromium.org/p/chromium/issues/detail?id=613096#c5 for
rationale

These two files:
third_party/closure_compiler/externs/accessibility_private.js
third_party/closure_compiler/externs/autofill_private.js
were updated in this commit, as an example of the change.

A follow-up commit will update other *_private.js files.

Bug: 613096
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: Ica4ab471956052b37c8bb6a9aabe4a7502408cfb
Reviewed-on: https://chromium-review.googlesource.com/1090425
Commit-Queue: Nigel Tao <nigeltao@chromium.org>
Reviewed-by: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568702}
2018-06-20 02:41:57 +00:00
rdevlin.cronin
38727920b3 [Closure Externs] Add wrapping parens on optional params
crrev.com/f9c093e54e11cb41c6f3402997a97be16568865f fixed optional
params in callbacks, but forgot to wrap the type in params.
function(!Foo|undefined) -> function((!Foo|undefined))

BUG=704242

Review-Url: https://codereview.chromium.org/2768213002
Cr-Commit-Position: refs/heads/master@{#458958}
2017-03-23 00:42:18 +00:00
rdevlin.cronin
f9c093e54e [Closure Externs] Handle optional params sent to an API callback
An API might conditionally send a response parameter to a caller.
e.g., envision an API:
doStuff({includeResult: true})
which responds with a Result iff includeResult was present and true.

Currently, closure extern generation doesn't handle this case well,
and for a callback like:

callback FooCallback = void(optional FooResponse response);
static void doStuff(DoStuffParams params, FooCallback callback);

generates:

/**
 * @param {DoStuffParams} params
 * @param {function(!FooResponse):void} callback
 */

But this is incorrect, since it indicates that the response would
never be null.

Properly handle these optional responses, and update the test.

BUG=704242

Review-Url: https://codereview.chromium.org/2766363002
Cr-Commit-Position: refs/heads/master@{#458876}
2017-03-22 21:13:23 +00:00
dmazzoni
5964242ae4 Re-land: Update json_schema_compiler to handle the Automation extension API
Originally landed as r445146: https://codereview.chromium.org/2601333002
Reverted as r445428.

Fixed by deferring the initialization of DesktopAutomationHandler
to match the previous behavior that was significant when tests are
run in debug mode.

This allows the automation externs file to be fully autogenerated.

Lots of tweaks to ChromeVox were required since we've been working with a
hand-tweaked externs file for a while.

BUG=683915
TBR=dtseng@chromium.org,rdevlin.cronin@chromium.org,dbeam@chromium.org

Committed: f1cbfff18b
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2649373002
Cr-Commit-Position: refs/heads/master@{#446160}
2017-01-25 23:17:46 +00:00
sebsg
8f4bf2e0d5 Revert of Update json_schema_compiler to handle the Automation extension API (patchset id:220001 of https://codereview.chromium.org/2601333002/ )
Reason for revert:
interactive_uitests failing for 50 times in a row

https://uberchromegw.corp.google.com/i/chromium.chromiumos/builders/Linux%20ChromiumOS%20Tests%20%28dbg%29%281%29?numbuilds=100

see crbug.com/683915

Original issue's description:
> Update json_schema_compiler to handle the Automation extension API
>
> This allows the automation externs file to be fully autogenerated.
>
> Lots of tweaks to ChromeVox were required since we've been working with a
> hand-tweaked externs file for a while.
>
> BUG=none
> CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation
>
> Review-Url: https://codereview.chromium.org/2601333002
> Cr-Commit-Position: refs/heads/master@{#445146}
> Committed: f1cbfff18b

TBR=dbeam@chromium.org,dtseng@chromium.org,rdevlin.cronin@chromium.org,dmazzoni@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=683915

Review-Url: https://codereview.chromium.org/2650733002
Cr-Commit-Position: refs/heads/master@{#445428}
2017-01-23 19:12:32 +00:00
dmazzoni
f1cbfff18b Update json_schema_compiler to handle the Automation extension API
This allows the automation externs file to be fully autogenerated.

Lots of tweaks to ChromeVox were required since we've been working with a
hand-tweaked externs file for a while.

BUG=none
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2601333002
Cr-Commit-Position: refs/heads/master@{#445146}
2017-01-20 20:14:43 +00:00
rdevlin.cronin
3291fa8bb6 [Externs] Support binary/ArrayBuffer type
The binary/ArrayBuffer type corresponds to the js ArrayBuffer type
(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
Add support for this in the auto-generated externs and add tests for same.

BUG=588993

Review URL: https://codereview.chromium.org/1731733003

Cr-Commit-Position: refs/heads/master@{#377439}
2016-02-25 00:41:36 +00:00
stevenjb
74d53a0ec7 Fix line wrapping in json_schema_compiler
BUG=563744

Review URL: https://codereview.chromium.org/1513573012

Cr-Commit-Position: refs/heads/master@{#370540}
2016-01-21 00:13:08 +00:00
stevenjb
f0e8cce513 Add js_interface_generator for generating extensions interfaces
BUG=563744

Review URL: https://codereview.chromium.org/1488773003

Cr-Commit-Position: refs/heads/master@{#364423}
2015-12-10 19:28:26 +00:00