commit 7d8a26e79f98723c28a487d702f92d0fe9247d95
parent 5656250560142b1a1eea88bdb5dd42eb4e9b9cbc
Author: Kurt Catti-Schmidt <kschmi@microsoft.com>
Date: Mon, 8 Dec 2025 12:27:45 +0000
Bug 2004091 [wpt PR 56492] - [CSS Modules] Fix crash in GetFetchedStyleSheetFromModuleMap, a=testonly
Automatic update from web-platform-tests
[CSS Modules] Fix crash in GetFetchedStyleSheetFromModuleMap
Document::DOMWindow is not always available, for example when parsing
via Document.parseHTMLUnsafe. This change adds an early return to
prevent crashing. This means declarative modules won't work via
Document.parseHTMLUnsafe, but that matches the behavior of imperative
modules. I added a TODO to follow up with the WHATWG about this.
A test was added that crashes without the fix.
Bug: 448174611
Change-Id: I471d397fd730385d16eaef231c3cb8c369230597
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7214509
Reviewed-by: Mason Freed <masonf@chromium.org>
Commit-Queue: Kurt Catti-Schmidt <kschmi@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1554428}
--
wpt-commits: 00fbedbc68e032e822d36c28324d3546b4c963b1
wpt-pr: 56492
Diffstat:
1 file changed, 21 insertions(+), 0 deletions(-)
diff --git a/testing/web-platform/tests/shadow-dom/declarative/tentative/shadowrootadoptedstylesheets/shadowrootadoptedstylesheets-document-parse-crash.html b/testing/web-platform/tests/shadow-dom/declarative/tentative/shadowrootadoptedstylesheets/shadowrootadoptedstylesheets-document-parse-crash.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>shadowrootadoptedstylesheets does not crash in Document.parseHTMLUnsafe</title>
+<meta name="author" title="Kurt Catti-Schmidt" href="mailto:kschmi@microsoft.com" />
+<link rel='help' href='https://github.com/whatwg/html/pull/11687'>
+</head>
+<body>
+<script>
+ const new_document = Document.parseHTMLUnsafe(
+ "<div id='host'>" +
+ "<template shadowrootmode='open' shadowrootadoptedstylesheets='foo'>" +
+ "<span id='test_element'>Test content</span>" +
+ "</template>" +
+ "</div>"
+ );
+</script>
+<p>Test passes if there is no crash.</p>
+</body>
+</html>
+\ No newline at end of file