Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 64168e4d90c4f106867471495b7842b5995990a6
      
https://github.com/WebKit/WebKit/commit/64168e4d90c4f106867471495b7842b5995990a6
  Author: Kiet Ho <[email protected]>
  Date:   2026-09-04 (Fri, 04 Sep 2026)

  Changed paths:
    M Source/JavaScriptCore/API/JSAPIGlobalObject.cpp
    M Source/JavaScriptCore/API/JSAPIGlobalObject.h
    M Source/JavaScriptCore/API/JSAPIGlobalObject.mm
    M Source/JavaScriptCore/jsc.cpp
    M Source/JavaScriptCore/runtime/GlobalObjectMethodTable.h
    M Source/JavaScriptCore/runtime/JSGlobalObject.cpp
    M Source/JavaScriptCore/runtime/JSModuleLoader.cpp
    M Source/WebCore/bindings/js/JSDOMWindowBase.cpp
    M Source/WebCore/bindings/js/JSShadowRealmGlobalScopeBase.cpp
    M Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp
    M Source/WebCore/bindings/js/JSWorkletGlobalScopeBase.cpp

  Log Message:
  -----------
  [CSS Module Scripts] Verify if a module type is allowed before fetching
rdar://186415342
https://bugs.webkit.org/show_bug.cgi?id=323170

Reviewed by Yusuke Suzuki.

As defined in the HTML spec [1], when loading a module script, there's a check 
to
ensure the module script type is allowed (understood as "supported by the 
environment").
This wasn't needed before, as the available module script types (JS/WASM, JSON, 
text)
are always supported by JSC. But CSS is a DOM concept, so CSS module scripts 
can only
be loaded in DOM environments (not worker/worklets or non-DOM.) Therefore to 
implement
CSS module scripts, the type check must be present to avoid loading CSS modules 
in
unsupported environments.

The check is implemented in both JSC and host. First, JSC checks if it's one of
JS/WASM/JSON/text, which it supports. If it's not, JSC vends it out to the host 
through
the new moduleTypeIsAllowed method in the global object method table. A host 
should
implement this method if it can handle other module types not supported by JSC. 
For
example, a DOM host can indicate it supports CSS module scripts.

This will be tested by CSS module script tests once it's fully implemented.

[1]: https://html.spec.whatwg.org/multipage/webappapis.html#module-type-allowed

* Source/JavaScriptCore/API/JSAPIGlobalObject.cpp:
(JSC::JSAPIGlobalObject::globalObjectMethodTable):
* Source/JavaScriptCore/API/JSAPIGlobalObject.h:
* Source/JavaScriptCore/API/JSAPIGlobalObject.mm:
(JSC::JSAPIGlobalObject::globalObjectMethodTable):
* Source/JavaScriptCore/jsc.cpp:
* Source/JavaScriptCore/runtime/GlobalObjectMethodTable.h:
* Source/JavaScriptCore/runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::baseGlobalObjectMethodTable):
* Source/JavaScriptCore/runtime/JSModuleLoader.cpp:
(JSC::moduleTypeIsAllowed):
(JSC::JSModuleLoader::importModule):
(JSC::JSModuleLoader::fetch):
(JSC::JSModuleLoader::hostLoadImportedModule):
* Source/WebCore/bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::globalObjectMethodTable):
* Source/WebCore/bindings/js/JSShadowRealmGlobalScopeBase.cpp:
(WebCore::JSShadowRealmGlobalScopeBase::globalObjectMethodTable):
* Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp:
(WebCore::JSWorkerGlobalScopeBase::globalObjectMethodTable):
* Source/WebCore/bindings/js/JSWorkletGlobalScopeBase.cpp:
(WebCore::JSWorkletGlobalScopeBase::globalObjectMethodTable):

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



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

Reply via email to