| Index: headless/lib/browser/devtools_api/domain_js.template
|
| diff --git a/headless/lib/browser/devtools_api/domain_js.template b/headless/lib/browser/devtools_api/domain_js.template
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..5ac1e1e2b320f25cf742f29bbae92a23f3870ec1
|
| --- /dev/null
|
| +++ b/headless/lib/browser/devtools_api/domain_js.template
|
| @@ -0,0 +1,136 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +/**
|
| + * @fileoverview Generated DevTools bindings for the {{domain.domain}} Domain.
|
| + * Note bindings are not generated for experimental commands and events, if you
|
| + * need to use one of those you must use the
|
| + * <code>goog.DevTools.Connection</code> class directly.
|
| + */
|
| +'use strict';
|
| +
|
| +goog.require('goog.DevTools.Connection');
|
| +{% for domain_name in domain.js_dependencies %}
|
| +goog.require('goog.DevTools.{{domain_name}}')
|
| +{% endfor %}
|
| +goog.provide('goog.DevTools.{{domain.domain}}');
|
| +
|
| +/**
|
| + * @class Bindings for the {{domain.domain}} DevTools Domain.
|
| + * @param {!goog.DevTools.Connection} connection The DevTools connection.
|
| + * @constructor
|
| + */
|
| +goog.DevTools.{{domain.domain}} = function(connection) {
|
| + /**
|
| + * The DevTools connection.
|
| + *
|
| + * @private {!goog.DevTools.Connection}
|
| + */
|
| + this.connection_ = connection;
|
| +};
|
| +
|
| +goog.scope(function () {
|
| +
|
| +var {{domain.domain}} = goog.DevTools.{{domain.domain}};
|
| +
|
| +{# Generate enums. #}
|
| +{% for type in domain.types %}
|
| +{% if not "enum" in type %}{% continue %}{% endif %}
|
| +/**
|
| +{% if type.description %}
|
| + * {{type.description}}
|
| + *
|
| +{% endif %}
|
| + * @enum {string}
|
| + */
|
| +{{domain.domain}}.{{type.id}} = {
|
| +{% for literal in type.enum %}
|
| + {{ literal | sanitize_literal | dash_to_camelcase | camelcase_to_hacker_style | upper }}: "{{ literal }}"{{',' if not loop.last}}
|
| +{% endfor %}
|
| +};
|
| +
|
| +{% endfor %}
|
| +
|
| +{# Generate types. #}
|
| +{% for type in domain.types %}
|
| +{% if not (type.type == "object") or not ("properties" in type) %}{% continue %}{% endif %}
|
| +/**
|
| +{% if type.description %}
|
| + * {{type.description}}
|
| + *
|
| +{% endif %}
|
| +{% for property in type.properties %}
|
| +{% if property.description %}
|
| + * {{property.name}}: {{property.description}}
|
| +{% endif %}
|
| +{% endfor %}
|
| + *
|
| +{% if type.properties %}
|
| + * @typedef {{ '{{' }}
|
| +{% for property in type.properties %}
|
| +{% if property.optional %}
|
| + * {{property.name}}: ({{ resolve_type(property).js_type }}|undefined){% if not loop.last %},{% endif %}
|
| +
|
| +{% else %}
|
| + * {{property.name}}: {{ resolve_type(property).js_type }}{% if not loop.last %}, {% endif %}
|
| +
|
| +{% endif %}
|
| +{% endfor %}
|
| + * {{ '}}' }}
|
| +{% else %}
|
| + * @typedef {undefined}
|
| +{% endif %}
|
| + */
|
| +{{domain.domain}}.{{type.id}};
|
| +
|
| +
|
| +{% endfor %}
|
| +
|
| +{# Generate non-experimental commands. #}
|
| +{% for command in domain.commands %}
|
| +{% if command.experimental %}{% continue %}{% endif %}
|
| +{% set method_name = command.name | sanitize_literal | to_title_case %}
|
| +{% if command.parameters|length > 0 %}
|
| +{% set param_name = 'params' %}
|
| +{% set param_type = '{' + domain.domain + '.' + method_name + 'Params}' %}
|
| +{% else %}
|
| +{% set param_name = 'opt_params' %}
|
| +{% set param_type = '{' + domain.domain + '.' + method_name + 'Params=}' %}
|
| +{% endif %}
|
| +{% set result_type = '{Promise<' + domain.domain + '.' + method_name + 'Result>}' %}
|
| +
|
| +/**
|
| +{% if command.description %}
|
| + * {{ command.description }}
|
| +{% endif %}
|
| + * @param {{param_type}} {{param_name}}
|
| + * @return {{result_type}}
|
| + */
|
| +{{domain.domain}}.prototype.{{method_name}} = function({{param_name}}) {
|
| + return /** @type {{result_type}} **/(
|
| + this.connection_.sendDevToolsMessage('{{domain.domain}}.{{command.name}}',
|
| + {{param_name}}));
|
| +};
|
| +
|
| +{% endfor %}
|
| +
|
| +
|
| +{# Generate non-experimental events. #}
|
| +{% for event in domain.events %}
|
| +{% if event.experimental %}{% continue %}{% endif %}
|
| +{% set param_type = '{!function(!' + domain.domain + '.' + event.name | to_title_case + 'Params)}' %}
|
| +
|
| +/**
|
| +{% if event.description %}
|
| + * {{ event.description }}
|
| +{% endif %}
|
| + * @param {{param_type}} listener
|
| + */
|
| +{{domain.domain}}.prototype.On{{event.name | to_title_case}} = function(listener) {
|
| + this.connection_.addEventListener('{{domain.domain}}.{{event.name}}',
|
| + /** @type {!function(!Object)} */ (listener));
|
| +};
|
| +{% endfor %}
|
| +
|
| +}); // goog.scope
|
|
|