Meta: Import a WPT resource for both the test and its reference page

Downloads were de-duplicated by source URL, so a reference page sharing
a relative resource with its test, such as css-pseudo's selection helper
script, never got its own copy under the expected directory.
This commit is contained in:
Luke Wilde authored and Andreas Kling committed 2026-09-11 15:58:13 +02:00
1 parent b7025c2c39
commit b52a795407
2 files changed
+12 -14
Notes: github-actions[bot] 2026-09-11 14:01:44 +00:00

No files matched your search

+1
View File
@@ -5,5 +5,6 @@ Tests/LibJS/Runtime/unicode-identifier-escape.js
Tests/LibJS/Runtime/modules/failing.mjs
Tests/LibWeb/Crash/wpt-import/
Tests/LibWeb/Ref/expected/wpt-import
Tests/LibWeb/Ref/input/wpt-import
Tests/LibWeb/Text/input/wpt-import
+11 -14
View File
@@ -29,7 +29,7 @@ download_exclude_list = {
# Modified to use a relative path, which the importer can't rewrite.
"/fonts/ahem.css",
}
visited_paths = set()
visited_destinations = set()
class TestType(Enum):
@@ -259,23 +259,23 @@ def download_files(filepaths, wpt_base_url, skip_existing):
for file in filepaths:
normalized_path = remove_repeated_url_slashes(file.source)
print(f"Source {normalized_path}, Destination {file.destination}")
if normalized_path in visited_paths:
continue
if normalized_path in download_exclude_list:
print(f"Skipping {file.source} as it is in the exclude list")
visited_paths.add(normalized_path)
continue
source = urljoin(wpt_base_url, normalized_path)
destination = Path(os.path.normpath(file.destination))
# A test and its reference page can share a relative resource, which then has to exist next to each of
# them, so what has been downloaded is tracked by destination rather than by source.
if destination in visited_destinations:
continue
visited_destinations.add(destination)
if skip_existing and destination.exists():
print(f"Skipping {destination} as it already exists")
visited_paths.add(normalized_path)
continue
visited_paths.add(normalized_path)
print(f"Downloading {source} to {destination}")
connection = urlopen(source)
@@ -297,20 +297,17 @@ def download_headers_files(filepaths, wpt_base_url, skip_existing):
for file in filepaths:
normalized_path = remove_repeated_url_slashes(file.source)
headers_path = normalized_path + ".headers"
if headers_path in visited_paths:
continue
source = urljoin(wpt_base_url, headers_path)
destination = Path(os.path.normpath(str(file.destination) + ".headers"))
if destination in visited_destinations:
continue
visited_destinations.add(destination)
if skip_existing and destination.exists():
print(f"Skipping {destination} as it already exists")
visited_paths.add(headers_path)
continue
visited_paths.add(headers_path)
try:
connection = urlopen(source)
except HTTPError: