Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 8029659c55d4f5f2551ea702d8dbbb979a686543
      
https://github.com/WebKit/WebKit/commit/8029659c55d4f5f2551ea702d8dbbb979a686543
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-10-09 (Fri, 09 Oct 2026)

  Changed paths:
    A 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/fetch-src/whitespace-with-base-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/fetch-src/whitespace-with-base-module-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/fetch-src/whitespace-with-base-module.html
    A 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/fetch-src/whitespace-with-base.html
    A 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/fetch-src/whitespace.js
    M Source/WebCore/dom/ScriptElement.cpp

  Log Message:
  -----------
  Script elements with an ASCII-whitespace-only src are treated as having an 
empty src
https://bugs.webkit.org/show_bug.cgi?id=326654
rdar://189386063

Reviewed by Anne van Kesteren and Chris Dumez.

This patch aligns WebKit with Gecko / Firefox.

"Prepare the script element" [1] only special-cases the exact empty string:

    "If src is the empty string, then queue an element task on the DOM
    manipulation task source given el to fire an event named error at el,
    and return."

Any other value, including one made up only of ASCII whitespace, is
encoding-parsed as a URL. The URL parser strips leading and trailing C0
control or space and removes tabs and newlines, so a whitespace-only src
resolves to the document's base URL and is fetched.

requestClassicScript() and requestModuleScript() treated a whitespace-only
src as empty and fired an error event instead. Check isEmpty() in both to
match the spec.

[1] 
https://html.spec.whatwg.org/multipage/scripting.html#prepare-the-script-element

Tests: 
imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/fetch-src/whitespace-with-base-module.html
       
imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/fetch-src/whitespace-with-base.html

* 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/fetch-src/whitespace-with-base-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/fetch-src/whitespace-with-base-module-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/fetch-src/whitespace-with-base-module.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/fetch-src/whitespace-with-base.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/fetch-src/whitespace.js:
 Added.
* Source/WebCore/dom/ScriptElement.cpp:
(WebCore::ScriptElement::requestClassicScript):
(WebCore::ScriptElement::requestModuleScript):

Canonical link: https://commits.webkit.org/323236@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to