summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/resources/optimize_webui.py
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/chrome/browser/resources/optimize_webui.py
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/chrome/browser/resources/optimize_webui.py')
-rwxr-xr-xchromium/chrome/browser/resources/optimize_webui.py59
1 files changed, 34 insertions, 25 deletions
diff --git a/chromium/chrome/browser/resources/optimize_webui.py b/chromium/chrome/browser/resources/optimize_webui.py
index 388cb640460..30ffbf7f343 100755
--- a/chromium/chrome/browser/resources/optimize_webui.py
+++ b/chromium/chrome/browser/resources/optimize_webui.py
@@ -58,25 +58,29 @@ _POLYMER_PATH = os.path.join(
# These files are already combined and minified.
_BASE_EXCLUDES = [
- # Common excludes for both Polymer 2 and 3.
- 'chrome://resources/polymer/v1_0/web-animations-js/' +
- 'web-animations-next-lite.min.js',
- 'chrome://resources/css/roboto.css',
- 'chrome://resources/css/text_defaults.css',
- 'chrome://resources/css/text_defaults_md.css',
- 'chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.html',
-
# Excludes applying only to Polymer 2.
'chrome://resources/html/polymer.html',
'chrome://resources/polymer/v1_0/polymer/polymer.html',
'chrome://resources/polymer/v1_0/polymer/polymer-micro.html',
'chrome://resources/polymer/v1_0/polymer/polymer-mini.html',
- 'chrome://resources/js/load_time_data.js',
+ 'chrome://resources/js/load_time_data.js'
+]
+for excluded_file in [
+ # Common excludes for both Polymer 2 and 3.
+ 'resources/polymer/v1_0/web-animations-js/web-animations-next-lite.min.js',
+ 'resources/css/roboto.css',
+ 'resources/css/text_defaults.css',
+ 'resources/css/text_defaults_md.css',
+ 'resources/mojo/mojo/public/js/mojo_bindings_lite.html',
# Excludes applying only to Polymer 3.
- 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js',
- 'chrome://resources/js/load_time_data.m.js',
-]
+ 'resources/polymer/v3_0/polymer/polymer_bundled.min.js',
+ 'resources/js/load_time_data.m.js',
+]:
+ # Exclude both the chrome://resources form and the scheme-relative form for
+ # files used in Polymer 3.
+ _BASE_EXCLUDES.append("chrome://" + excluded_file)
+ _BASE_EXCLUDES.append("//" + excluded_file)
_VULCANIZE_BASE_ARGS = [
'--inline-css',
@@ -85,15 +89,19 @@ _VULCANIZE_BASE_ARGS = [
'--strip-comments',
]
-_URL_MAPPINGS = [
- ('chrome://resources/cr_components/', _CR_COMPONENTS_PATH),
- ('chrome://resources/cr_elements/', _CR_ELEMENTS_PATH),
- ('chrome://resources/css/', _CSS_RESOURCES_PATH),
- ('chrome://resources/html/', _HTML_RESOURCES_PATH),
- ('chrome://resources/js/', _JS_RESOURCES_PATH),
- ('chrome://resources/polymer/v1_0/', _POLYMER_PATH),
- ('chrome://resources/images/', _IMAGES_RESOURCES_PATH)
-]
+_URL_MAPPINGS = []
+for (redirect_url, file_path) in [
+ ('resources/cr_components/', _CR_COMPONENTS_PATH),
+ ('resources/cr_elements/', _CR_ELEMENTS_PATH),
+ ('resources/css/', _CSS_RESOURCES_PATH),
+ ('resources/html/', _HTML_RESOURCES_PATH),
+ ('resources/js/', _JS_RESOURCES_PATH),
+ ('resources/polymer/v1_0/', _POLYMER_PATH),
+ ('resources/images/', _IMAGES_RESOURCES_PATH),
+]:
+ # Redirect both the chrome://resources form and the scheme-relative form.
+ _URL_MAPPINGS.append(('chrome://' + redirect_url, file_path))
+ _URL_MAPPINGS.append(('//' + redirect_url, file_path))
_VULCANIZE_REDIRECT_ARGS = list(itertools.chain.from_iterable(map(
@@ -123,7 +131,7 @@ def _update_dep_file(in_folder, args, manifest):
# Add a slash in front of every dependency that is not a chrome:// URL, so
# that we can map it to the correct source file path below.
request_list = map(
- lambda dep: '/' + dep if not dep.startswith('chrome://') else dep,
+ lambda dep: '/' + dep if not (dep.startswith('chrome://') or dep.startswith('//')) else dep,
request_list)
# Undo the URL mappings applied by vulcanize to get file paths relative to
@@ -138,7 +146,7 @@ def _update_dep_file(in_folder, args, manifest):
# If the input was a folder holding an unpacked .pak file, the generated
# depfile should not list files already in the .pak file.
- if args.input.endswith('.unpak'):
+ if args.input.endswith('unpak'):
filter_url = args.input
deps = [d for d in deps if not d.startswith(filter_url)]
@@ -210,9 +218,10 @@ def _bundle_v3(tmp_out_dir, in_path, out_path, manifest_out_path, args,
# arbitrary names?
bundled_paths = []
for index, js_file in enumerate(args.js_module_in_files):
- expected_name = '%s.rollup.js' % js_file[:-len('.js')]
+ base_file_name = os.path.basename(js_file)
+ expected_name = '%s.rollup.js' % base_file_name[:-len('.js')]
assert args.js_out_files[index] == expected_name, \
- 'Output file corresponding to %s should be named %s.rollup.js' % \
+ 'Output file corresponding to %s should be named %s' % \
(js_file, expected_name)
bundled_paths.append(os.path.join(tmp_out_dir, expected_name))