Repository navigation
Implement CSS module scripts - #74961
Merged
webkit-commit-queue merged 1 commit intoOct 6, 2026
Merged
Conversation
tuankiet65
requested review from
a team,
JonWBedard,
burg,
cdumez,
dcrousso,
gsnedders and
patrickangle
as code owners
September 25, 2026 21:39
Collaborator
|
EWS run on previous version of this PR (hash c03b0b2) Details |
tuankiet65
marked this pull request as draft
September 25, 2026 21:41
rniwa
approved these changes
Sep 25, 2026
tuankiet65
force-pushed
the
eng/Implement-CSS-module-scripts
branch
from
September 28, 2026 09:58
c03b0b2 to
7a7d81e
Compare
Collaborator
|
EWS run on previous version of this PR (hash 7a7d81e) Details |
tuankiet65
marked this pull request as ready for review
September 28, 2026 09:58
heimskr
approved these changes
Sep 28, 2026
Constellation
approved these changes
Sep 28, 2026
tuankiet65
force-pushed
the
eng/Implement-CSS-module-scripts
branch
from
September 29, 2026 03:50
7a7d81e to
f65513b
Compare
Collaborator
|
EWS run on previous version of this PR (hash f65513b) Details |
tuankiet65
force-pushed
the
eng/Implement-CSS-module-scripts
branch
from
October 5, 2026 20:22
f65513b to
cdf904c
Compare
Collaborator
|
EWS run on previous version of this PR (hash cdf904c) Details |
Collaborator
|
Failed mac-safer-cpp, wpe-wk2 checks. Please resolve failures and re-apply Rejecting #74961 from merge queue. |
Collaborator
|
Safe-Merge-Queue: Build #106723. |
tuankiet65
force-pushed
the
eng/Implement-CSS-module-scripts
branch
from
October 6, 2026 05:22
cdf904c to
1052d11
Compare
Collaborator
|
EWS run on current version of this PR (hash 1052d11) Details |
rdar://80917329 https://bugs.webkit.org/show_bug.cgi?id=227967 Reviewed by Ryosuke Niwa and Yusuke Suzuki. This patch implements importing CSS stylesheets as JavaScript modules, using the `import ... with { type: 'css' }` and `import(..., { with: { type: 'css' } })` syntax. On the JSC side, we add support for the `css` module type, and requests the host to fetch it. If the host supports CSS modules (like WebCore), it fetches the stylesheet, constructs a CSSStyleSheet object out of it, wraps it in a JSCSSStyleSheet, and returns it back to JSC as a JSValue. JSC uses this as the default export value of the CSS module. If the host doesn't support CSS modules (like `jsc` command line or workers/worklets), then the import simply fails. To implement this requires some changes in how script modules loading works. For JavaScript/WASM/JSON/text, JSC asks the host (e.g WebCore) to fetch the source code. The host fetches the source code and passes it back to JSC so it can turn it into modules. CSS is a WebCore construct however, so only WebCore can parse and create stylesheets out of it, not JSC. So to support CSS, the host now returns either source code or a JSValue. When it's a source code, JSC will parse and create modules like before. When it's a JSValue, JSC assumes the host has already created a module, and it uses that value as the default module export. This is gated by the CSSModuleScriptsEnabled feature flag, which is disabled by default. There is one failing test only on GTK, which is tracked at webkit.org/b/326330: - imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/credentials.sub.html Tests: imported/w3c/web-platform-tests/content-security-policy/style-src/import-style-allowed.sub.html imported/w3c/web-platform-tests/content-security-policy/style-src/import-style-blocked.sub.html imported/w3c/web-platform-tests/fetch/api/request/destination/fetch-destination.https.html imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/ * LayoutTests/TestExpectations: * LayoutTests/imported/w3c/web-platform-tests/content-security-policy/style-src/import-style-allowed.sub-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/content-security-policy/style-src/import-style-blocked.sub-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/destination/fetch-destination.https-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-style-element/tentative/style-element-basic-import-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-style-element/tentative/style-element-fixed-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/charset-2-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/charset-bom-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/charset-bom.html: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/charset-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/content-type-checking-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/content-type-checking.html: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/cors-crossorigin-requests-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/credentials.sub-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/css-module-parse-error-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-basic-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-dynamic-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/integrity-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/load-error-events-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/redirect-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/referrer-policies.sub-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/relative-urls-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/repeated-import-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/resources/should-not-be-loaded.js: Added. * LayoutTests/imported/w3c/web-platform-tests/shadow-dom/declarative/tentative/shadowrootadoptedstylesheets/shadowrootadoptedstylesheets-fetched-module-expected.txt: * LayoutTests/platform/glib/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/credentials.sub-expected.txt: Copied from LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/credentials.sub-expected.txt. * Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp: (Inspector::scriptTypeForScript): * Source/JavaScriptCore/jsc.cpp: (GlobalObject::moduleLoaderFetch): * Source/JavaScriptCore/parser/NodesAnalyzeModule.cpp: (JSC::tryCreateAttributes): * Source/JavaScriptCore/parser/SourceProvider.h: (JSC::SourceProvider::isModuleType const): * Source/JavaScriptCore/runtime/AbstractModuleRecord.cpp: (JSC::AbstractModuleRecord::moduleType const): * Source/JavaScriptCore/runtime/Completion.cpp: (JSC::getSourceType): (JSC::retrieveTypeImportAttribute): * Source/JavaScriptCore/runtime/JSMicrotask.cpp: (JSC::moduleRegistryFetchSettled): (JSC::moduleLoadTopSettled): * Source/JavaScriptCore/runtime/JSModuleLoader.cpp: (JSC::JSModuleLoader::provideFetch): (JSC::JSModuleLoader::hostLoadImportedModule): (JSC::JSModuleLoader::makeModule): * Source/JavaScriptCore/runtime/JSModuleLoader.h: * Source/JavaScriptCore/runtime/ModuleRegistryEntry.cpp: (JSC::ModuleRegistryEntry::provideFetch): * Source/JavaScriptCore/runtime/ModuleRegistryEntry.h: * Source/JavaScriptCore/runtime/ScriptFetchParameters.h: (JSC::ScriptFetchParameters::parseType): * Source/JavaScriptCore/runtime/SyntheticModuleRecord.h: * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/bindings/js/CachedModuleScriptLoader.cpp: (WebCore::CachedModuleScriptLoader::load): (WebCore::CachedModuleScriptLoader::notifyFinished): (WebCore::CachedModuleScriptLoader::setCSSStyleSheet): (WebCore::CachedModuleScriptLoader::notifyFinishedInternal): * Source/WebCore/bindings/js/CachedModuleScriptLoader.h: * Source/WebCore/bindings/js/CachedScriptFetcher.cpp: (WebCore::CachedScriptFetcher::requestResourceWithCache const): * Source/WebCore/bindings/js/JSDOMGlobalObject.cpp: (WebCore::JSDOMGlobalObject::moduleTypeIsAllowed): * Source/WebCore/bindings/js/JSDOMGlobalObject.h: * Source/WebCore/bindings/js/JSDOMWindowBase.cpp: (WebCore::JSDOMWindowBase::globalObjectMethodTable): * Source/WebCore/bindings/js/ScriptModuleLoader.cpp: (WebCore::ScriptModuleLoader::importModule): (WebCore::createCSSModuleScript): (WebCore::ScriptModuleLoader::notifyFinished): * Source/WebCore/bindings/js/ScriptModuleLoader.h: * Source/WebCore/bindings/js/WorkerModuleScriptLoader.cpp: (WebCore::WorkerModuleScriptLoader::load): * Source/WebCore/css/CSSStyleSheet.cpp: (WebCore::CSSStyleSheet::replaceSync): * Source/WebCore/loader/cache/CachedCSSStyleSheet.cpp: (WebCore::CachedCSSStyleSheet::sheetText const): * Source/WebCore/loader/cache/CachedCSSStyleSheet.h: * Tools/Scripts/webkitpy/style/checkers/cpp.py: Canonical link: https://commits.webkit.org/322887@main
webkit-commit-queue
force-pushed
the
eng/Implement-CSS-module-scripts
branch
from
October 6, 2026 20:39
1052d11 to
b1913f6
Compare
Collaborator
|
Committed 322887@main (b1913f6): https://commits.webkit.org/322887@main Reviewed commits have been landed. Closing PR #74961 and removing active labels. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
b1913f6
1052d11