Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Unified Diff: headless/lib/browser/client_api_generator.py

Issue 2278123002: headless: Ensure all commands have parameters and return types (Closed)
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | headless/lib/browser/client_api_generator_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/lib/browser/client_api_generator.py
diff --git a/headless/lib/browser/client_api_generator.py b/headless/lib/browser/client_api_generator.py
index a264b32c9fff5d880dfbbe522ec041e4f8c3af75..bb93ede97aa557fde61a8ead59480db0b88f9abd 100644
--- a/headless/lib/browser/client_api_generator.py
+++ b/headless/lib/browser/client_api_generator.py
@@ -373,16 +373,21 @@ def PatchExperimentalCommandsAndEvents(json_api):
command['experimental'] = True
for event in domain.get('events', []):
event['experimental'] = True
+
+
+def EnsureCommandsHaveParametersAndReturnTypes(json_api):
+ """
+ Make sure all commands have at least empty parameters and return values. This
+ guarantees API compatibility if a previously experimental command is made
+ stable.
+ """
+ for domain in json_api['domains']:
for command in domain.get('commands', []):
- if not command.get('experimental', False):
- continue
if not 'parameters' in command:
command['parameters'] = []
if not 'returns' in command:
command['returns'] = []
for event in domain.get('events', []):
- if not event.get('experimental', False):
- continue
if not 'parameters' in event:
event['parameters'] = []
@@ -422,6 +427,7 @@ if __name__ == '__main__':
json_api, output_dirname = ParseArguments(sys.argv[1:])
jinja_env = InitializeJinjaEnv(output_dirname)
PatchExperimentalCommandsAndEvents(json_api)
+ EnsureCommandsHaveParametersAndReturnTypes(json_api)
SynthesizeCommandTypes(json_api)
SynthesizeEventTypes(json_api)
PatchFullQualifiedRefs(json_api)
« no previous file with comments | « no previous file | headless/lib/browser/client_api_generator_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698