0

WebUI: Disallow JS files in build_webui()'s static_files field.

build_webui() already provides a proper way to allow JS for targets that
are still in the process of migrating, via an allowlist in
tools/typescript/validate_tsconfig.py. Using `static_files` bypassed
this mechanism and allowed having folders that use JS and are not
tracked in the allowlist.

Fixed: 379076355
Change-Id: Ia864c2e36085deb5f55da5cceddb50ad22b291c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6023810
Reviewed-by: Rebekah Potter <rbpotter@chromium.org>
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1383742}
This commit is contained in:
dpapad
2024-11-15 19:04:48 +00:00
committed by Chromium LUCI CQ
parent 3d7301a42b
commit bf630aa975
2 changed files with 10 additions and 0 deletions

@ -552,6 +552,11 @@ static_files: Optional parameter. List of
|css_files| below). These are passed to preprocess_if_expr()
2) JPG/PNG/SVG files. These are included in the build verbatim
without any preprocessing.
Note: JS files are not allowed in this list and will result in
an assertion error. Instead such files should be passed as
|web_component_files| or |non_web_component_files|, assuming the
target is allowlisted to use JS instead of TS in
tools/typescript/validate_tsconfig.py validateJavaScriptAllowed().
web_component_files: List of TS files that hold Web Component definitions with
equivalent HTML template files. These can be either native

@ -151,6 +151,11 @@ template("build_webui") {
filter_include(invoker.static_files, non_preprocessed_files_filter)
static_preprocessed_files =
filter_exclude(invoker.static_files, non_preprocessed_files_filter)
static_js_files = filter_include(invoker.static_files, [ "*.js" ])
assert(static_js_files == [],
"JS files not allowed in static_files, found: " +
string_join(", ", static_js_files))
}
preprocessor_defines = []