Commit 01369246 authored by Tim van der Lippe's avatar Tim van der Lippe Committed by Commit Bot

Migrate protocol/ to ESM

- InspectorBackendCommands is now loaded via ES Modules

Bug: 1006759
Change-Id: I2826518a55e1f4fd7704cfb04120885f9aa9b604
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1837772Reviewed-by: default avatarYang Guo <yangguo@chromium.org>
Reviewed-by: default avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Tim Van der Lippe <tvanderlippe@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702821}
parent 4b5a5b9f
...@@ -528,8 +528,6 @@ all_devtools_files = [ ...@@ -528,8 +528,6 @@ all_devtools_files = [
"front_end/profiler/ProfileTypeRegistry.js", "front_end/profiler/ProfileTypeRegistry.js",
"front_end/profiler/ProfileView.js", "front_end/profiler/ProfileView.js",
"front_end/profiler/TopDownProfileDataGrid.js", "front_end/profiler/TopDownProfileDataGrid.js",
"front_end/protocol/NodeURL.js",
"front_end/protocol/InspectorBackend.js",
"front_end/protocol/module.json", "front_end/protocol/module.json",
"front_end/quick_open/CommandMenu.js", "front_end/quick_open/CommandMenu.js",
"front_end/quick_open/filteredListWidget.css", "front_end/quick_open/filteredListWidget.css",
...@@ -899,7 +897,9 @@ lighthouse_locale_files = [ ...@@ -899,7 +897,9 @@ lighthouse_locale_files = [
all_devtools_files += lighthouse_locale_files all_devtools_files += lighthouse_locale_files
all_devtools_modules = [ all_devtools_modules = [
"front_end/root.js", "front_end/protocol/protocol.js",
"front_end/protocol/NodeURL.js",
"front_end/protocol/InspectorBackend.js",
"front_end/host/host.js", "front_end/host/host.js",
"front_end/host/UserMetrics.js", "front_end/host/UserMetrics.js",
"front_end/host/ResourceLoader.js", "front_end/host/ResourceLoader.js",
...@@ -1191,6 +1191,9 @@ application_templates = [ ...@@ -1191,6 +1191,9 @@ application_templates = [
] ]
copied_devtools_modules = [ copied_devtools_modules = [
"$resources_out_dir/protocol/protocol.js",
"$resources_out_dir/protocol/NodeURL.js",
"$resources_out_dir/protocol/InspectorBackend.js",
"$resources_out_dir/host/host.js", "$resources_out_dir/host/host.js",
"$resources_out_dir/host/UserMetrics.js", "$resources_out_dir/host/UserMetrics.js",
"$resources_out_dir/host/ResourceLoader.js", "$resources_out_dir/host/ResourceLoader.js",
...@@ -1492,7 +1495,10 @@ action("generate_devtools_grd") { ...@@ -1492,7 +1495,10 @@ action("generate_devtools_grd") {
grd_files = grd_files =
copied_devtools_modules + generated_applications + copied_devtools_modules + generated_applications +
generated_non_autostart_non_remote_modules + devtools_embedder_scripts + generated_non_autostart_non_remote_modules + devtools_embedder_scripts +
[ "$resources_out_dir/devtools_extension_api.js" ] [
"$resources_out_dir/devtools_extension_api.js",
"$resources_out_dir/InspectorBackendCommands.js",
]
# Bundle remote modules in ChromeOS. # Bundle remote modules in ChromeOS.
if (is_chromeos) { if (is_chromeos) {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
Protocol.NodeURL = class { export default class NodeURL {
/** /**
* @param {!Object} object * @param {!Object} object
*/ */
...@@ -14,7 +14,7 @@ Protocol.NodeURL = class { ...@@ -14,7 +14,7 @@ Protocol.NodeURL = class {
* @param {string} path * @param {string} path
*/ */
function process(object, path) { function process(object, path) {
if (object.url && Protocol.NodeURL._isPlatformPath(object.url, Host.isWin())) { if (object.url && NodeURL._isPlatformPath(object.url, Host.isWin())) {
object.url = Common.ParsedURL.platformPathToURL(object.url); object.url = Common.ParsedURL.platformPathToURL(object.url);
} }
for (const entry of Object.entries(object)) { for (const entry of Object.entries(object)) {
...@@ -41,4 +41,13 @@ Protocol.NodeURL = class { ...@@ -41,4 +41,13 @@ Protocol.NodeURL = class {
return fileSystemPath.length ? fileSystemPath[0] === '/' : false; return fileSystemPath.length ? fileSystemPath[0] === '/' : false;
} }
} }
}; }
/* Legacy exported object */
self.Protocol = self.Protocol || {};
/* Legacy exported object */
Protocol = Protocol || {};
/** @constructor */
Protocol.NodeURL = NodeURL;
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
"common", "common",
"host" "host"
], ],
"scripts": [ "scripts": [],
"modules": [
"protocol.js",
"NodeURL.js", "NodeURL.js",
"InspectorBackend.js", "InspectorBackend.js",
"../InspectorBackendCommands.js" "../InspectorBackendCommands.js"
......
// Copyright 2019 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.
import './InspectorBackend.js';
import './NodeURL.js';
import '../InspectorBackendCommands.js';
import * as InspectorBackend from './InspectorBackend.js';
import * as NodeURL from './NodeURL.js';
export {
InspectorBackend,
NodeURL,
};
...@@ -7,4 +7,5 @@ import './platform/utilities.js'; ...@@ -7,4 +7,5 @@ import './platform/utilities.js';
import './dom_extension/DOMExtension.js'; import './dom_extension/DOMExtension.js';
import './common/common.js'; import './common/common.js';
import './host/host.js'; import './host/host.js';
import './protocol/protocol.js';
import './ui/ui.js'; import './ui/ui.js';
...@@ -48,13 +48,13 @@ SDKTestRunner.PageMock = class { ...@@ -48,13 +48,13 @@ SDKTestRunner.PageMock = class {
this._enabledDomains.clear(); this._enabledDomains.clear();
SDK.targetManager._targets = []; SDK.targetManager._targets = [];
const oldFactory = Protocol.Connection._factory; const oldFactory = Protocol.Connection.getFactory();
Protocol.Connection._factory = () => { Protocol.Connection.setFactory(() => {
this._connection = new MockPageConnection(this); this._connection = new MockPageConnection(this);
return this._connection; return this._connection;
}; });
const target = SDK.targetManager.createTarget(nextId('mock-target-'), targetName, this._type, null); const target = SDK.targetManager.createTarget(nextId('mock-target-'), targetName, this._type, null);
Protocol.Connection._factory = oldFactory; Protocol.Connection.setFactory(oldFactory);
this._target = target; this._target = target;
return target; return target;
......
...@@ -290,6 +290,12 @@ def prepare_closure_frontend_compile(temp_devtools_path, descriptors, namespace_ ...@@ -290,6 +290,12 @@ def prepare_closure_frontend_compile(temp_devtools_path, descriptors, namespace_
args.extend(['--js', file]) args.extend(['--js', file])
if "InspectorBackend.js" in file: if "InspectorBackend.js" in file:
args.extend(['--js', protocol_externs_file]) args.extend(['--js', protocol_externs_file])
# Write a dummy file for InspectorBackendCommands. We don't type-check this file, but we
# import it from protocol/protocol.js
inspector_backends_commands_file = path.join(temp_frontend_path, 'InspectorBackendCommands.js')
modular_build.write_file(inspector_backends_commands_file, '')
args.extend(['--js', inspector_backends_commands_file])
command += args command += args
command = [arg.replace(DEVTOOLS_FRONTEND_PATH, temp_frontend_path) for arg in command] command = [arg.replace(DEVTOOLS_FRONTEND_PATH, temp_frontend_path) for arg in command]
compiler_args_file = tempfile.NamedTemporaryFile(mode='wt', delete=False) compiler_args_file = tempfile.NamedTemporaryFile(mode='wt', delete=False)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment