You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 64168e4
Browse filesBrowse the repository at this point in the historyBrowse files
[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
0 commit comments