Commit abbb8458 authored by Pavel Feldman's avatar Pavel Feldman Committed by Commit Bot

DevTools: allow application descriptors to be extended.

Change-Id: Ie9e792d2a191aa65c3ff6a0ac49175bc9957fb42
Reviewed-on: https://chromium-review.googlesource.com/894604
Commit-Queue: Pavel Feldman <pfeldman@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533893}
parent e2db7866
...@@ -512,6 +512,7 @@ all_devtools_files = [ ...@@ -512,6 +512,7 @@ all_devtools_files = [
"front_end/resources/ServiceWorkersView.js", "front_end/resources/ServiceWorkersView.js",
"front_end/resources/StorageItemsView.js", "front_end/resources/StorageItemsView.js",
"front_end/Runtime.js", "front_end/Runtime.js",
"front_end/shell.json",
"front_end/screencast/InputModel.js", "front_end/screencast/InputModel.js",
"front_end/screencast/module.json", "front_end/screencast/module.json",
"front_end/screencast/ScreencastApp.js", "front_end/screencast/ScreencastApp.js",
...@@ -932,6 +933,7 @@ generated_scripts = [ ...@@ -932,6 +933,7 @@ generated_scripts = [
] ]
generated_applications = [ generated_applications = [
"$resources_out_dir/shell.js",
"$resources_out_dir/inspector.html", "$resources_out_dir/inspector.html",
"$resources_out_dir/inspector.js", "$resources_out_dir/inspector.js",
"$resources_out_dir/toolbox.html", "$resources_out_dir/toolbox.html",
...@@ -992,6 +994,7 @@ generated_remote_modules = [ ...@@ -992,6 +994,7 @@ generated_remote_modules = [
] ]
devtools_applications = [ devtools_applications = [
"shell",
"inspector", "inspector",
"toolbox", "toolbox",
"integration_test_runner", "integration_test_runner",
......
...@@ -39,11 +39,6 @@ def _CheckBuildGN(input_api, output_api): ...@@ -39,11 +39,6 @@ def _CheckBuildGN(input_api, output_api):
return _checkWithNodeScript(input_api, output_api, script_path) return _checkWithNodeScript(input_api, output_api, script_path)
def _CheckApplicationDescriptors(input_api, output_api):
script_path = input_api.os_path.join(input_api.PresubmitLocalPath(), "scripts", "check_application_descriptors.js")
return _checkWithNodeScript(input_api, output_api, script_path)
def _CheckFormat(input_api, output_api): def _CheckFormat(input_api, output_api):
def popen(args): def popen(args):
...@@ -194,7 +189,6 @@ def _CheckCSSViolations(input_api, output_api): ...@@ -194,7 +189,6 @@ def _CheckCSSViolations(input_api, output_api):
def CheckChangeOnUpload(input_api, output_api): def CheckChangeOnUpload(input_api, output_api):
results = [] results = []
results.extend(_CheckBuildGN(input_api, output_api)) results.extend(_CheckBuildGN(input_api, output_api))
results.extend(_CheckApplicationDescriptors(input_api, output_api))
results.extend(_CheckFormat(input_api, output_api)) results.extend(_CheckFormat(input_api, output_api))
results.extend(_CheckDevtoolsStyle(input_api, output_api)) results.extend(_CheckDevtoolsStyle(input_api, output_api))
results.extend(_CompileDevtoolsFrontend(input_api, output_api)) results.extend(_CompileDevtoolsFrontend(input_api, output_api))
......
...@@ -215,7 +215,7 @@ var Runtime = class { ...@@ -215,7 +215,7 @@ var Runtime = class {
* @param {string} appName * @param {string} appName
* @return {!Promise.<undefined>} * @return {!Promise.<undefined>}
*/ */
static startApplication(appName) { static async startApplication(appName) {
console.timeStamp('Runtime.startApplication'); console.timeStamp('Runtime.startApplication');
var allDescriptorsByName = {}; var allDescriptorsByName = {};
...@@ -224,52 +224,42 @@ var Runtime = class { ...@@ -224,52 +224,42 @@ var Runtime = class {
allDescriptorsByName[d['name']] = d; allDescriptorsByName[d['name']] = d;
} }
var applicationPromise; if (!applicationDescriptor) {
if (applicationDescriptor) var data = await Runtime.loadResourcePromise(appName + '.json');
applicationPromise = Promise.resolve(applicationDescriptor); applicationDescriptor = JSON.parse(data);
else var descriptor = applicationDescriptor;
applicationPromise = Runtime.loadResourcePromise(appName + '.json').then(JSON.parse.bind(JSON)); while (descriptor.extends) {
data = await Runtime.loadResourcePromise(descriptor.extends + '.json');
return applicationPromise.then(parseModuleDescriptors); descriptor = JSON.parse(data);
applicationDescriptor.modules = descriptor.modules.concat(applicationDescriptor.modules);
/**
* @param {!{modules: !Array.<!Object>, has_html: boolean}} appDescriptor
* @return {!Promise.<undefined>}
*/
function parseModuleDescriptors(appDescriptor) {
var configuration = appDescriptor.modules;
var moduleJSONPromises = [];
var coreModuleNames = [];
for (var i = 0; i < configuration.length; ++i) {
var descriptor = configuration[i];
var name = descriptor['name'];
var moduleJSON = allDescriptorsByName[name];
if (moduleJSON)
moduleJSONPromises.push(Promise.resolve(moduleJSON));
else
moduleJSONPromises.push(Runtime.loadResourcePromise(name + '/module.json').then(JSON.parse.bind(JSON)));
if (descriptor['type'] === 'autostart')
coreModuleNames.push(name);
} }
}
return Promise.all(moduleJSONPromises).then(instantiateRuntime); var configuration = applicationDescriptor.modules;
var moduleJSONPromises = [];
var coreModuleNames = [];
for (var i = 0; i < configuration.length; ++i) {
var descriptor = configuration[i];
var name = descriptor['name'];
var moduleJSON = allDescriptorsByName[name];
if (moduleJSON)
moduleJSONPromises.push(Promise.resolve(moduleJSON));
else
moduleJSONPromises.push(Runtime.loadResourcePromise(name + '/module.json').then(JSON.parse.bind(JSON)));
if (descriptor['type'] === 'autostart')
coreModuleNames.push(name);
}
/** var moduleDescriptors = await Promise.all(moduleJSONPromises);
* @param {!Array.<!Object>} moduleDescriptors
* @return {!Promise.<undefined>} for (var i = 0; i < moduleDescriptors.length; ++i) {
*/ moduleDescriptors[i].name = configuration[i]['name'];
function instantiateRuntime(moduleDescriptors) { moduleDescriptors[i].condition = configuration[i]['condition'];
for (var i = 0; i < moduleDescriptors.length; ++i) { moduleDescriptors[i].remote = configuration[i]['type'] === 'remote';
moduleDescriptors[i].name = configuration[i]['name'];
moduleDescriptors[i].condition = configuration[i]['condition'];
moduleDescriptors[i].remote = configuration[i]['type'] === 'remote';
}
self.runtime = new Runtime(moduleDescriptors);
if (coreModuleNames)
return /** @type {!Promise<undefined>} */ (self.runtime._loadAutoStartModules(coreModuleNames));
return Promise.resolve();
}
} }
self.runtime = new Runtime(moduleDescriptors);
if (coreModuleNames)
return /** @type {!Promise<undefined>} */ (self.runtime._loadAutoStartModules(coreModuleNames));
} }
/** /**
......
...@@ -2,7 +2,5 @@ ...@@ -2,7 +2,5 @@
"modules": [ "modules": [
{ "name": "worker_service", "type": "autostart" }, { "name": "worker_service", "type": "autostart" },
{ "name": "audits2_worker", "type": "remote" } { "name": "audits2_worker", "type": "remote" }
], ]
"has_html": false
} }
{ {
"modules": [ "modules": [
{ "name": "platform", "type": "autostart" }, { "name": "platform", "type": "autostart" },
{ "name": "text_utils", "type": "autostart" }, { "name": "text_utils", "type": "autostart" },
{ "name": "cm_headless", "type": "autostart" }, { "name": "cm_headless", "type": "autostart" },
{ "name": "formatter_worker", "type": "autostart" } { "name": "formatter_worker", "type": "autostart" }
], ]
"has_html": false
} }
{ {
"modules": [ "modules": [
{ "name": "heap_snapshot_worker", "type": "autostart" }, { "name": "heap_snapshot_worker", "type": "autostart" },
{ "name": "heap_snapshot_model", "type": "autostart" }, { "name": "heap_snapshot_model", "type": "autostart" },
{ "name": "platform", "type": "autostart" }, { "name": "platform", "type": "autostart" },
{ "name": "text_utils", "type": "autostart" }, { "name": "text_utils", "type": "autostart" },
{ "name": "common", "type": "autostart" } { "name": "common", "type": "autostart" }
], ]
"has_html": false
} }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<html> <html>
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-eval' https://chrome-devtools-frontend.appspot.com"> <meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-eval' 'unsafe-inline' https://chrome-devtools-frontend.appspot.com">
<meta name="referrer" content="no-referrer"> <meta name="referrer" content="no-referrer">
<script type="text/javascript" src="Runtime.js"></script> <script type="text/javascript" src="Runtime.js"></script>
<script type="text/javascript" src="inspector.js"></script> <script type="text/javascript" src="inspector.js"></script>
......
{ {
"modules" : [ "modules" : [
{ "name": "platform", "type": "autostart" }, { "name": "emulation", "type": "autostart" },
{ "name": "dom_extension", "type": "autostart" }, { "name": "mobile_throttling", "type": "autostart" },
{ "name": "main", "type": "autostart" },
{ "name": "components", "type": "autostart"},
{ "name": "ui", "type": "autostart" },
{ "name": "sdk", "type": "autostart" },
{ "name": "protocol", "type": "autostart" },
{ "name": "host", "type": "autostart" },
{ "name": "common", "type": "autostart" },
{ "name": "emulation", "type": "autostart" },
{ "name": "workspace", "type": "autostart" },
{ "name": "bindings", "type": "autostart" },
{ "name": "persistence", "type": "autostart" },
{ "name": "extensions", "type": "autostart" },
{ "name": "services", "type": "autostart" },
{ "name": "elements", "condition": "!v8only" },
{ "name": "network", "condition": "!v8only" },
{ "name": "har_importer", "condition": "!v8only" },
{ "name": "sources" },
{ "name": "timeline", "condition": "!v8only" },
{ "name": "timeline_model", "condition": "!v8only" },
{ "name": "product_registry", "type": "autostart" },
{ "name": "product_registry_impl", "condition": "!v8only", "type": "remote" },
{ "name": "profiler" },
{ "name": "resources", "condition": "!v8only" },
{ "name": "audits2", "condition": "!v8only" },
{ "name": "devices" },
{ "name": "security", "condition": "!v8only" },
{ "name": "console" },
{ "name": "source_frame" },
{ "name": "text_editor" },
{ "name": "cm" },
{ "name": "cm_modes", "type": "remote" },
{ "name": "settings" },
{ "name": "layers", "condition": "!v8only" },
{ "name": "layer_viewer", "condition": "!v8only" },
{ "name": "snippets" },
{ "name": "diff" },
{ "name": "terminal", "type": "remote" },
{ "name": "accessibility", "condition": "!v8only", "type": "remote" },
{ "name": "animation", "condition": "!v8only" },
{ "name": "coverage" },
{ "name": "screencast", "condition": "remoteFrontend", "type": "remote" },
{ "name": "emulated_devices", "condition": "!v8only" , "type": "remote" },
{ "name": "perf_ui" },
{ "name": "quick_open" },
{ "name": "cookie_table" },
{ "name": "inline_editor" },
{ "name": "color_picker" },
{ "name": "data_grid" },
{ "name": "heap_snapshot_model" },
{ "name": "event_listeners" },
{ "name": "object_ui" },
{ "name": "help" },
{ "name": "workspace_diff" },
{ "name": "console_model", "type": "autostart" },
{ "name": "network_log", "type": "autostart" },
{ "name": "text_utils", "type": "autostart" },
{ "name": "changes" },
{ "name": "mobile_throttling", "type": "autostart" },
{ "name": "formatter" },
{ "name": "console_counters", "type": "autostart" }
],
"has_html": true { "name": "accessibility", "condition": "!v8only", "type": "remote" },
{ "name": "animation", "condition": "!v8only" },
{ "name": "audits2", "condition": "!v8only" },
{ "name": "cookie_table" },
{ "name": "devices" },
{ "name": "elements", "condition": "!v8only" },
{ "name": "emulated_devices", "condition": "!v8only" , "type": "remote" },
{ "name": "har_importer", "condition": "!v8only" },
{ "name": "help" },
{ "name": "layers", "condition": "!v8only" },
{ "name": "layer_viewer", "condition": "!v8only" },
{ "name": "network", "condition": "!v8only" },
{ "name": "product_registry_impl", "condition": "!v8only", "type": "remote" },
{ "name": "resources", "condition": "!v8only" },
{ "name": "screencast", "condition": "remoteFrontend", "type": "remote" },
{ "name": "security", "condition": "!v8only" },
{ "name": "timeline", "condition": "!v8only" },
{ "name": "timeline_model", "condition": "!v8only" }
],
"extends": "shell",
"has_html": true
} }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<html> <html>
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-eval' https://chrome-devtools-frontend.appspot.com"> <meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-eval' 'unsafe-inline' https://chrome-devtools-frontend.appspot.com">
<script type="text/javascript" src="Runtime.js"></script> <script type="text/javascript" src="Runtime.js"></script>
<script type="text/javascript" src="integration_test_runner.js"></script> <script type="text/javascript" src="integration_test_runner.js"></script>
</head> </head>
......
{ {
"modules" : [ "modules" : [
{ "name": "test_runner", "type": "autostart" }, { "name": "test_runner", "type": "autostart" },
{ "name": "heap_snapshot_worker" },
{ "name": "accessibility_test_runner" },
{ "name": "application_test_runner" }, { "name": "application_test_runner" },
{ "name": "audits2_test_runner" }, { "name": "audits2_test_runner" },
{ "name": "bindings_test_runner" }, { "name": "bindings_test_runner" },
{ "name": "console_test_runner" },
{ "name": "coverage_test_runner" },
{ "name": "cpu_profiler_test_runner" },
{ "name": "data_grid_test_runner" },
{ "name": "device_mode_test_runner" },
{ "name": "elements_test_runner" },
{ "name": "extensions_test_runner" }, { "name": "extensions_test_runner" },
{ "name": "heap_profiler_test_runner" },
{ "name": "layers_test_runner" }, { "name": "layers_test_runner" },
{ "name": "network_test_runner" }, { "name": "network_test_runner" },
{ "name": "security_test_runner" },
{ "name": "performance_test_runner" }, { "name": "performance_test_runner" },
{ "name": "coverage_test_runner" },
{ "name": "device_mode_test_runner" },
{ "name": "accessibility_test_runner" },
{ "name": "console_test_runner" },
{ "name": "elements_test_runner" },
{ "name": "sources_test_runner" },
{ "name": "data_grid_test_runner" },
{ "name": "sdk_test_runner" }, { "name": "sdk_test_runner" },
{ "name": "cpu_profiler_test_runner" }, { "name": "security_test_runner" },
{ "name": "heap_profiler_test_runner" }, { "name": "sources_test_runner" }
{ "name": "heap_snapshot_worker" },
{ "name": "platform", "type": "autostart" },
{ "name": "dom_extension", "type": "autostart" },
{ "name": "main", "type": "autostart" },
{ "name": "components", "type": "autostart"},
{ "name": "ui", "type": "autostart" },
{ "name": "sdk", "type": "autostart" },
{ "name": "protocol", "type": "autostart" },
{ "name": "host", "type": "autostart" },
{ "name": "common", "type": "autostart" },
{ "name": "emulation", "type": "autostart" },
{ "name": "har_importer", "condition": "!v8only" },
{ "name": "workspace", "type": "autostart" },
{ "name": "bindings", "type": "autostart" },
{ "name": "persistence", "type": "autostart" },
{ "name": "extensions", "type": "autostart" },
{ "name": "services", "type": "autostart" },
{ "name": "elements", "condition": "!v8only" },
{ "name": "network", "condition": "!v8only" },
{ "name": "sources" },
{ "name": "timeline", "condition": "!v8only" },
{ "name": "timeline_model", "condition": "!v8only" },
{ "name": "product_registry", "type": "autostart" },
{ "name": "product_registry_impl", "condition": "!v8only", "type": "remote" },
{ "name": "profiler" },
{ "name": "resources", "condition": "!v8only" },
{ "name": "audits2", "condition": "!v8only" },
{ "name": "devices" },
{ "name": "security", "condition": "!v8only" },
{ "name": "console" },
{ "name": "source_frame" },
{ "name": "text_editor" },
{ "name": "cm" },
{ "name": "cm_modes", "type": "remote" },
{ "name": "settings" },
{ "name": "layers", "condition": "!v8only" },
{ "name": "layer_viewer", "condition": "!v8only" },
{ "name": "snippets" },
{ "name": "diff" },
{ "name": "terminal", "type": "remote" },
{ "name": "accessibility", "condition": "!v8only", "type": "remote" },
{ "name": "animation", "condition": "!v8only" },
{ "name": "coverage" },
{ "name": "screencast", "condition": "remoteFrontend", "type": "remote" },
{ "name": "emulated_devices", "condition": "!v8only" , "type": "remote" },
{ "name": "perf_ui" },
{ "name": "quick_open" },
{ "name": "cookie_table" },
{ "name": "inline_editor" },
{ "name": "color_picker" },
{ "name": "data_grid" },
{ "name": "heap_snapshot_model" },
{ "name": "event_listeners" },
{ "name": "object_ui" },
{ "name": "help" },
{ "name": "workspace_diff" },
{ "name": "console_model", "type": "autostart" },
{ "name": "network_log", "type": "autostart" },
{ "name": "text_utils", "type": "autostart" },
{ "name": "changes" },
{ "name": "mobile_throttling", "type": "autostart" },
{ "name": "formatter" },
{ "name": "console_counters", "type": "autostart" }
], ],
"extends": "inspector",
"has_html": true "has_html": true
} }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<html> <html>
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-eval' https://chrome-devtools-frontend.appspot.com"> <meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-eval' 'unsafe-inline' https://chrome-devtools-frontend.appspot.com">
<meta name="referrer" content="no-referrer"> <meta name="referrer" content="no-referrer">
<script type="text/javascript" src="Runtime.js"></script> <script type="text/javascript" src="Runtime.js"></script>
<script type="text/javascript" src="ndb.js"></script> <script type="text/javascript" src="ndb.js"></script>
......
{ {
"modules" : [ "modules" : [
{ "name": "platform", "type": "autostart" }, ],
{ "name": "dom_extension", "type": "autostart" }, "extends": "shell",
{ "name": "main", "type": "autostart" }, "has_html": true
{ "name": "components", "type": "autostart"},
{ "name": "ui", "type": "autostart" },
{ "name": "sdk", "type": "autostart" },
{ "name": "protocol", "type": "autostart" },
{ "name": "host", "type": "autostart" },
{ "name": "common", "type": "autostart" },
{ "name": "workspace", "type": "autostart" },
{ "name": "bindings", "type": "autostart" },
{ "name": "persistence", "type": "autostart" },
{ "name": "extensions", "type": "autostart" },
{ "name": "services", "type": "autostart" },
{ "name": "sources" },
{ "name": "product_registry", "type": "autostart" },
{ "name": "profiler" },
{ "name": "console" },
{ "name": "source_frame" },
{ "name": "text_editor" },
{ "name": "cm" },
{ "name": "cm_modes", "type": "remote" },
{ "name": "settings" },
{ "name": "snippets" },
{ "name": "diff" },
{ "name": "terminal", "type": "remote" },
{ "name": "coverage" },
{ "name": "perf_ui" },
{ "name": "quick_open" },
{ "name": "inline_editor" },
{ "name": "color_picker" },
{ "name": "data_grid" },
{ "name": "heap_snapshot_model" },
{ "name": "event_listeners" },
{ "name": "object_ui" },
{ "name": "workspace_diff" },
{ "name": "console_model", "type": "autostart" },
{ "name": "network_log", "type": "autostart" },
{ "name": "text_utils", "type": "autostart" },
{ "name": "changes" },
{ "name": "formatter" }
],
"has_html": true
} }
{
"modules" : [
{ "name": "bindings", "type": "autostart" },
{ "name": "common", "type": "autostart" },
{ "name": "components", "type": "autostart"},
{ "name": "console_counters", "type": "autostart" },
{ "name": "console_model", "type": "autostart" },
{ "name": "dom_extension", "type": "autostart" },
{ "name": "extensions", "type": "autostart" },
{ "name": "host", "type": "autostart" },
{ "name": "main", "type": "autostart" },
{ "name": "network_log", "type": "autostart" },
{ "name": "persistence", "type": "autostart" },
{ "name": "platform", "type": "autostart" },
{ "name": "product_registry", "type": "autostart" },
{ "name": "protocol", "type": "autostart" },
{ "name": "sdk", "type": "autostart" },
{ "name": "services", "type": "autostart" },
{ "name": "text_utils", "type": "autostart" },
{ "name": "ui", "type": "autostart" },
{ "name": "workspace", "type": "autostart" },
{ "name": "changes" },
{ "name": "cm" },
{ "name": "cm_modes", "type": "remote" },
{ "name": "color_picker" },
{ "name": "console" },
{ "name": "coverage" },
{ "name": "data_grid" },
{ "name": "diff" },
{ "name": "event_listeners" },
{ "name": "formatter" },
{ "name": "heap_snapshot_model" },
{ "name": "inline_editor" },
{ "name": "object_ui" },
{ "name": "perf_ui" },
{ "name": "profiler" },
{ "name": "quick_open" },
{ "name": "settings" },
{ "name": "snippets" },
{ "name": "source_frame" },
{ "name": "sources" },
{ "name": "terminal", "type": "remote" },
{ "name": "text_editor" },
{ "name": "workspace_diff" }
]
}
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<html> <html>
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-eval'"> <meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-eval' 'unsafe-inline' ">
<script type="text/javascript" src="Runtime.js"></script> <script type="text/javascript" src="Runtime.js"></script>
<script type="text/javascript" src="toolbox.js"></script> <script type="text/javascript" src="toolbox.js"></script>
</head> </head>
......
{ {
"modules": [ "modules": [
{ { "name": "platform", "type": "autostart" },
"name": "platform", { "name": "dom_extension","type": "autostart" },
"type": "autostart" { "name": "toolbox_bootstrap", "type": "autostart" }
}, ],
{ "has_html": true
"name": "dom_extension",
"type": "autostart"
},
{
"name": "toolbox_bootstrap",
"type": "autostart"
}
],
"has_html": true
} }
...@@ -13,8 +13,7 @@ ...@@ -13,8 +13,7 @@
"format-py": "yapf --exclude scripts/build/rjsmin.py -i --recursive scripts PRESUBMIT.py", "format-py": "yapf --exclude scripts/build/rjsmin.py -i --recursive scripts PRESUBMIT.py",
"extract": "node scripts/extract_module/extract_module.js", "extract": "node scripts/extract_module/extract_module.js",
"check-gn": "node scripts/check_gn.js", "check-gn": "node scripts/check_gn.js",
"check-json": "node scripts/json_validator/validate_module_json.js", "check-json": "node scripts/json_validator/validate_module_json.js"
"check-descriptors": "node scripts/check_application_descriptors.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
......
...@@ -32,7 +32,7 @@ def main(argv): ...@@ -32,7 +32,7 @@ def main(argv):
loader = modular_build.DescriptorLoader(input_path) loader = modular_build.DescriptorLoader(input_path)
for app in application_names: for app in application_names:
descriptors = loader.load_application(app + '.json') descriptors = loader.load_application(app)
builder = DebugBuilder(app, descriptors, input_path, output_path) builder = DebugBuilder(app, descriptors, input_path, output_path)
builder.build_app() builder.build_app()
......
...@@ -45,7 +45,7 @@ def main(argv): ...@@ -45,7 +45,7 @@ def main(argv):
loader = modular_build.DescriptorLoader(input_path) loader = modular_build.DescriptorLoader(input_path)
for app in application_names: for app in application_names:
descriptors = loader.load_application(app + '.json') descriptors = loader.load_application(app)
builder = ReleaseBuilder(app, descriptors, input_path, output_path) builder = ReleaseBuilder(app, descriptors, input_path, output_path)
builder.build_app() builder.build_app()
...@@ -101,7 +101,7 @@ class ReleaseBuilder(object): ...@@ -101,7 +101,7 @@ class ReleaseBuilder(object):
def app_file(self, extension): def app_file(self, extension):
return self.application_name + '.' + extension return self.application_name + '.' + extension
def core_resource_names(self): def autorun_resource_names(self):
result = [] result = []
for module in self.descriptors.sorted_modules(): for module in self.descriptors.sorted_modules():
if self.descriptors.application[module].get('type') != 'autostart': if self.descriptors.application[module].get('type') != 'autostart':
...@@ -122,6 +122,12 @@ class ReleaseBuilder(object): ...@@ -122,6 +122,12 @@ class ReleaseBuilder(object):
self.descriptors.application.values()): self.descriptors.application.values()):
self._concatenate_dynamic_module(module['name']) self._concatenate_dynamic_module(module['name'])
def _write_include_tags(self, descriptors, output):
if descriptors.extends:
self._write_include_tags(descriptors.extends, output)
output.write(self._generate_include_tag(descriptors.application_name + '.js'))
def _build_html(self): def _build_html(self):
html_name = self.app_file('html') html_name = self.app_file('html')
output = StringIO() output = StringIO()
...@@ -130,7 +136,10 @@ class ReleaseBuilder(object): ...@@ -130,7 +136,10 @@ class ReleaseBuilder(object):
if '<script ' in line or '<link ' in line: if '<script ' in line or '<link ' in line:
continue continue
if '</head>' in line: if '</head>' in line:
output.write(self._generate_include_tag(self.app_file('js'))) self._write_include_tags(self.descriptors, output)
js_file = join(self.application_dir, self.app_file('js'))
if path.exists(js_file):
output.write(' <script>%s</script>\n' % minify_js(read_file(js_file)))
output.write(line) output.write(line)
write_file(join(self.output_dir, html_name), output.getvalue()) write_file(join(self.output_dir, html_name), output.getvalue())
...@@ -207,21 +216,31 @@ class ReleaseBuilder(object): ...@@ -207,21 +216,31 @@ class ReleaseBuilder(object):
return self._special_case_namespaces.get(module, camel_case_namespace) return self._special_case_namespaces.get(module, camel_case_namespace)
def _concatenate_application_script(self, output): def _concatenate_application_script(self, output):
runtime_contents = read_file(join(self.application_dir, 'Runtime.js')) if not self.descriptors.extends:
runtime_contents = re.sub('var allDescriptors = \[\];', runtime_contents = read_file(join(self.application_dir, 'Runtime.js'))
'var allDescriptors = %s;' % self._release_module_descriptors().replace('\\', '\\\\'), runtime_contents = re.sub('var allDescriptors = \[\];',
runtime_contents, 1) 'var allDescriptors = %s;' % self._release_module_descriptors().replace('\\', '\\\\'),
output.write('/* Runtime.js */\n') runtime_contents, 1)
output.write(runtime_contents) output.write('/* Runtime.js */\n')
output.write(runtime_contents)
output.write('/* Application descriptor %s */\n' % self.app_file('json'))
output.write('applicationDescriptor = ')
output.write(self.descriptors.application_json())
else:
output.write('/* Additional descriptors */\n')
output.write('allDescriptors.push(...%s);' % self._release_module_descriptors())
output.write('/* Additional descriptors %s */\n' % self.app_file('json'))
output.write('applicationDescriptor.modules.push(...%s)' % json.dumps(self.descriptors.application.values()))
output.write('\n/* Autostart modules */\n') output.write('\n/* Autostart modules */\n')
self._concatenate_autostart_modules(output) self._concatenate_autostart_modules(output)
output.write('/* Application descriptor %s */\n' % self.app_file('json')) output.write(';\n/* Autostart resources */\n')
output.write('applicationDescriptor = ') self._write_module_resources(self.autorun_resource_names(), output)
output.write(self.descriptors.application_json()) if not self.descriptors.has_html:
output.write(';\n/* Core resources */\n') js_file = join(self.application_dir, self.app_file('js'))
self._write_module_resources(self.core_resource_names(), output) if path.exists(js_file):
output.write('\n/* Application loader */\n') output.write(';\n/* Autostart script for worker */\n')
output.write(read_file(join(self.application_dir, self.app_file('js')))) output.write(read_file(js_file))
def _concatenate_dynamic_module(self, module_name): def _concatenate_dynamic_module(self, module_name):
module = self.descriptors.modules[module_name] module = self.descriptors.modules[module_name]
......
...@@ -56,11 +56,13 @@ def concatenate_scripts(file_names, module_dir, output_dir, output): ...@@ -56,11 +56,13 @@ def concatenate_scripts(file_names, module_dir, output_dir, output):
class Descriptors: class Descriptors:
def __init__(self, application_dir, application_descriptor, module_descriptors, has_html): def __init__(self, application_name, application_dir, application_descriptor, module_descriptors, extends, has_html):
self.application_name = application_name
self.application_dir = application_dir self.application_dir = application_dir
self.application = application_descriptor self.application = application_descriptor
self.modules = module_descriptors
self._cached_sorted_modules = None self._cached_sorted_modules = None
self.modules = module_descriptors
self.extends = extends
self.has_html = has_html self.has_html = has_html
def application_json(self): def application_json(self):
...@@ -152,37 +154,46 @@ class DescriptorLoader: ...@@ -152,37 +154,46 @@ class DescriptorLoader:
self.application_dir = application_dir self.application_dir = application_dir
def load_application(self, application_descriptor_name): def load_application(self, application_descriptor_name):
return self.load_applications([application_descriptor_name]) all_module_descriptors = {}
result = self._load_application(application_descriptor_name, all_module_descriptors)
return result
def load_applications(self, application_descriptor_names): def load_applications(self, application_descriptor_names):
merged_application_descriptor = {}
all_module_descriptors = {} all_module_descriptors = {}
has_html = False all_application_descriptors = {}
for application_descriptor_name in application_descriptor_names: for application_descriptor_name in application_descriptor_names:
module_descriptors = {} descriptors = {}
application_descriptor_filename = path.join(self.application_dir, application_descriptor_name) result = self._load_application(application_descriptor_name, descriptors)
descriptor_json = load_and_parse_json(application_descriptor_filename) for name in descriptors:
application_descriptor = {desc['name']: desc for desc in descriptor_json['modules']} all_module_descriptors[name] = descriptors[name]
has_html = descriptor_json['has_html'] for name in result.application:
all_application_descriptors[name] = result.application[name]
for name in application_descriptor: return Descriptors('all', self.application_dir, all_application_descriptors, all_module_descriptors, None, False)
merged_application_descriptor[name] = application_descriptor[name]
def _load_application(self, application_descriptor_name, all_module_descriptors):
for (module_name, module) in application_descriptor.items(): module_descriptors = {}
if module_descriptors.get(module_name): application_descriptor_filename = path.join(self.application_dir, application_descriptor_name + '.json')
bail_error('Duplicate definition of module "%s" in %s' % (module_name, application_descriptor_filename)) descriptor_json = load_and_parse_json(application_descriptor_filename)
if not all_module_descriptors.get(module_name): application_descriptor = {desc['name']: desc for desc in descriptor_json['modules']}
module_descriptors[module_name] = self._read_module_descriptor(module_name, application_descriptor_filename) extends = descriptor_json['extends'] if 'extends' in descriptor_json else None
all_module_descriptors[module_name] = module_descriptors[module_name] if extends:
extends = self._load_application(extends, all_module_descriptors)
for module in module_descriptors.values(): has_html = True if 'has_html' in descriptor_json and descriptor_json['has_html'] else False
deps = module.get('dependencies', [])
for dep in deps: for (module_name, module) in application_descriptor.items():
if dep not in application_descriptor: if all_module_descriptors.get(module_name):
bail_error('Module "%s" (dependency of "%s") not listed in application descriptor %s' % bail_error('Duplicate definition of module "%s" in %s' % (module_name, application_descriptor_filename))
(dep, module['name'], application_descriptor_filename)) module_descriptors[module_name] = self._read_module_descriptor(module_name, application_descriptor_filename)
all_module_descriptors[module_name] = module_descriptors[module_name]
return Descriptors(self.application_dir, merged_application_descriptor, all_module_descriptors, has_html)
for module in module_descriptors.values():
for dep in module.get('dependencies', []):
if dep not in all_module_descriptors:
bail_error('Module "%s" (dependency of "%s") not listed in application descriptor %s' %
(dep, module['name'], application_descriptor_filename))
return Descriptors(
application_descriptor_name, self.application_dir, application_descriptor, module_descriptors, extends, has_html)
def _read_module_descriptor(self, module_name, application_descriptor_filename): def _read_module_descriptor(self, module_name, application_descriptor_filename):
json_filename = path.join(self.application_dir, module_name, 'module.json') json_filename = path.join(self.application_dir, module_name, 'module.json')
......
// 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.
'use strict';
/**
* This is used by PRESUBMIT.py to ensure that integration_test_runner.json
* is a superset of inspector.json.
*/
const inspectorManifest = require('../front_end/inspector.json');
const testManifest = require('../front_end/integration_test_runner.json');
function main() {
const testModules = new Set();
for (const module of testManifest.modules) {
testModules.add(serialize(module));
}
const missingModules = [];
for (const module of inspectorManifest.modules) {
if (!testModules.has(serialize(module))) {
missingModules.push(JSON.stringify(module));
}
}
if (missingModules.length) {
console.log('DevTools application descriptor checker found an error!');
console.log('integration_test_runner.json is missing the following modules:');
console.log(missingModules.join('\n'));
process.exit(1);
}
console.log('DevTools application descriptor checker passed');
}
main();
// Only works for shallow objects
// See: https://stackoverflow.com/questions/16167581/sort-object-properties-and-json-stringify
function serialize(object) {
return JSON.stringify(object, Object.keys(object).sort())
}
...@@ -8,6 +8,7 @@ const path = require('path'); ...@@ -8,6 +8,7 @@ const path = require('path');
const FRONTEND_PATH = path.resolve(__dirname, '..', 'front_end'); const FRONTEND_PATH = path.resolve(__dirname, '..', 'front_end');
const inspectorManifest = require(path.resolve(FRONTEND_PATH, 'inspector.json')); const inspectorManifest = require(path.resolve(FRONTEND_PATH, 'inspector.json'));
const shellManifest = require(path.resolve(FRONTEND_PATH, 'shell.json'));
const utils = require('./utils'); const utils = require('./utils');
const gnPath = path.resolve(__dirname, '..', 'BUILD.gn'); const gnPath = path.resolve(__dirname, '..', 'BUILD.gn');
...@@ -45,7 +46,7 @@ function checkNonAutostartNonRemoteModules() { ...@@ -45,7 +46,7 @@ function checkNonAutostartNonRemoteModules() {
]; ];
} }
const text = lines.join('\n'); const text = lines.join('\n');
const modules = inspectorManifest.modules.filter(m => m.type !== 'autostart' && m.type !== 'remote').map(m => m.name); const modules = inspectorManifest.modules.concat(shellManifest.modules).filter(m => m.type !== 'autostart' && m.type !== 'remote').map(m => m.name);
const missingModules = modules.filter(m => !utils.includes(text, `${m}/${m}_module.js`)); const missingModules = modules.filter(m => !utils.includes(text, `${m}/${m}_module.js`));
if (missingModules.length) if (missingModules.length)
......
...@@ -108,11 +108,11 @@ def error_excepthook(exctype, value, traceback): ...@@ -108,11 +108,11 @@ def error_excepthook(exctype, value, traceback):
sys.excepthook = error_excepthook sys.excepthook = error_excepthook
application_descriptors = [ application_descriptors = [
'inspector.json', 'inspector',
'toolbox.json', 'toolbox',
'integration_test_runner.json', 'integration_test_runner',
'formatter_worker.json', 'formatter_worker',
'heap_snapshot_worker.json', 'heap_snapshot_worker',
] ]
skipped_namespaces = { skipped_namespaces = {
......
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