Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 5955a87e92059dd7205d0ce1b0b17257f4815838
https://github.com/WebKit/WebKit/commit/5955a87e92059dd7205d0ce1b0b17257f4815838
Author: Ahmad Saleem <[email protected]>
Date: 2026-10-08 (Thu, 08 Oct 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/content-security-policy/script-src/script-src-strict_dynamic_parser_inserted_error_event-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/content-security-policy/script-src/script-src-strict_dynamic_parser_inserted_error_event.html
A
LayoutTests/imported/w3c/web-platform-tests/content-security-policy/script-src/script-src-strict_dynamic_parser_inserted_error_event.html.headers
M Source/WebCore/dom/ScriptElement.cpp
Log Message:
-----------
External scripts blocked by 'strict-dynamic' do not fire an error event
https://bugs.webkit.org/show_bug.cgi?id=326655
rdar://189386852
Reviewed by Chris Dumez.
This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.
When a CSP policy contains 'strict-dynamic', WebKit checks external scripts
early via ContentSecurityPolicy::allowScriptForStrictDynamic(). If that check
failed, requestClassicScript() and requestModuleScript() returned without
firing an error event at the script element.
Per "prepare the script element" [1], a script blocked by CSP is a network
error, so el's result is null and "execute the script element" says:
"If el's result is null, then fire an event named error at el, and
return."
This is also what WebKit already does when CSP blocks a script without
'strict-dynamic', since the fetch is refused in the loader. For classic
scripts, fall through to the existing queued error event; for module
scripts, queue one on the DOM manipulation task source. Blocked inline
scripts are unchanged, as the spec returns without firing an error event
for those.
[1]
https://html.spec.whatwg.org/multipage/scripting.html#prepare-the-script-element
Test:
imported/w3c/web-platform-tests/content-security-policy/script-src/script-src-strict_dynamic_parser_inserted_error_event.html
*
LayoutTests/imported/w3c/web-platform-tests/content-security-policy/script-src/script-src-strict_dynamic_parser_inserted_error_event-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/content-security-policy/script-src/script-src-strict_dynamic_parser_inserted_error_event.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/content-security-policy/script-src/script-src-strict_dynamic_parser_inserted_error_event.html.headers:
Added.
* Source/WebCore/dom/ScriptElement.cpp:
(WebCore::ScriptElement::requestClassicScript):
(WebCore::ScriptElement::requestModuleScript):
Canonical link: https://commits.webkit.org/323191@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications