[DesignTheme] Tolerate blocked localStorage during startup#4857
Merged
Conversation
Agent-Logs-Url: https://github.com/microsoft/fluentui-blazor/sessions/cb041476-1c5d-4a67-a06e-46d15d131caa Co-authored-by: vnbaaij <1761079+vnbaaij@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/fluentui-blazor/sessions/cb041476-1c5d-4a67-a06e-46d15d131caa Co-authored-by: vnbaaij <1761079+vnbaaij@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/fluentui-blazor/sessions/cb041476-1c5d-4a67-a06e-46d15d131caa Co-authored-by: vnbaaij <1761079+vnbaaij@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/fluentui-blazor/sessions/cb041476-1c5d-4a67-a06e-46d15d131caa Co-authored-by: vnbaaij <1761079+vnbaaij@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/fluentui-blazor/sessions/cb041476-1c5d-4a67-a06e-46d15d131caa Co-authored-by: vnbaaij <1761079+vnbaaij@users.noreply.github.com>
|
✅ All tests passed successfully Details on your Workflow / Core Tests page. |
Summary - Unit Tests Code CoverageSummary
CoverageMicrosoft.FluentUI.AspNetCore.Components - 61.2%
|
Copilot
AI
changed the title
[WIP] Fix localStorage SecurityError during script init for FluentUI elements
[DesignTheme] Tolerate blocked localStorage during startup
May 12, 2026
vnbaaij
approved these changes
May 12, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Hardens DesignTheme startup and persistence so that browser SecurityErrors (or blocked/unavailable localStorage) don’t abort theme initialization early enough to prevent Fluent custom element registration.
Changes:
- Adds a guarded storage accessor with an in-memory fallback, and treats storage read/write/remove failures as non-fatal.
- Routes persisted theme reads in
loading-theme.jsthrough safe parsing/clearing logic rather than directlocalStorage.getItem(...)+JSON.parse(...).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Core/wwwroot/js/loading-theme.js | Replaces direct localStorage reads during bootstrap with guarded storage access and safe theme parsing/clearing. |
| src/Core.Assets/src/Design/ThemeStorage.ts | Centralizes theme persistence behind a safe getStorage() accessor and makes storage failures non-fatal (with in-memory fallback). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dvoituron
approved these changes
May 13, 2026
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.
Pull Request
📖 Description
A
SecurityErrorfromlocalStorageduring FluentUI startup could abort theme initialization early enough to prevent Fluent custom element registration. This change makes storage access non-fatal so blocked persistence degrades gracefully instead of breaking all Fluent web components on the page.Theme storage hardening
ThemeStoragewindow.localStorageis unavailable or throwsBootstrap path hardening
localStorage.getItem(...)usage inloading-theme.jswith safe storage readsResulting behavior
fluent-design-themeregistration and downstream Fluent element registration continue even when browser privacy settings block storage🎫 Issues
SecurityErrorfromlocalStorageduring FluentUI startup/theme initialization.👩💻 Reviewer Notes
src/Core.Assets/src/Design/ThemeStorage.tssrc/Core/wwwroot/js/loading-theme.jswindow.localStoragecustomElements.get("fluent-design-theme")is defined📑 Test Plan
window.localStorageforced to throwSecurityErrorduring startup✅ Checklist
General
Component-specific
⏭ Next Steps
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
accounts.google.com/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --use-angle=swiftshader-webgl --crashpad-handler-pid=6562 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/com.google.Chrome.scoped_dir.Fpqg3l --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,7650420327376008183,8944856811589620878,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,9974608442809264542,17704172690964978898,4 --trace-process-track-uuid=3190708989122997041(dns block)/opt/google/chrome/chrome /usr/bin/google-chrome --headless --disable-gpu --no-sandbox --virtual-time-budget=5000 --dump-dom REDACTED(dns block)/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --use-angle=swiftshader-webgl --crashpad-handler-pid=6715 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/com.google.Chrome.scoped_dir.V7svss --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,6199369688436918274,3489501208979327526,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,2236751553720916477,7698183581020163837,4 --trace-process-track-uuid=3190708989122997041(dns block)clients2.google.com/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --use-angle=swiftshader-webgl --crashpad-handler-pid=6562 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/com.google.Chrome.scoped_dir.Fpqg3l --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,7650420327376008183,8944856811589620878,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,9974608442809264542,17704172690964978898,4 --trace-process-track-uuid=3190708989122997041(dns block)/opt/google/chrome/chrome /usr/bin/google-chrome --headless --disable-gpu --no-sandbox --virtual-time-budget=5000 --dump-dom REDACTED(dns block)/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --use-angle=swiftshader-webgl --crashpad-handler-pid=6715 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/com.google.Chrome.scoped_dir.V7svss --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,6199369688436918274,3489501208979327526,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,2236751553720916477,7698183581020163837,4 --trace-process-track-uuid=3190708989122997041(dns block)clientservices.googleapis.com/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --use-angle=swiftshader-webgl --crashpad-handler-pid=6562 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/com.google.Chrome.scoped_dir.Fpqg3l --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,7650420327376008183,8944856811589620878,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,9974608442809264542,17704172690964978898,4 --trace-process-track-uuid=3190708989122997041(dns block)/opt/google/chrome/chrome /usr/bin/google-chrome --headless --disable-gpu --no-sandbox --virtual-time-budget=5000 --dump-dom REDACTED(dns block)/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --use-angle=swiftshader-webgl --crashpad-handler-pid=6715 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/com.google.Chrome.scoped_dir.V7svss --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,6199369688436918274,3489501208979327526,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,2236751553720916477,7698183581020163837,4 --trace-process-track-uuid=3190708989122997041(dns block)redirector.gvt1.com/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --use-angle=swiftshader-webgl --crashpad-handler-pid=6562 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/com.google.Chrome.scoped_dir.Fpqg3l --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,7650420327376008183,8944856811589620878,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,9974608442809264542,17704172690964978898,4 --trace-process-track-uuid=3190708989122997041(dns block)/opt/google/chrome/chrome /usr/bin/google-chrome --headless --disable-gpu --no-sandbox --virtual-time-budget=5000 --dump-dom REDACTED(dns block)/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --use-angle=swiftshader-webgl --crashpad-handler-pid=6715 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/com.google.Chrome.scoped_dir.V7svss --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,6199369688436918274,3489501208979327526,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,2236751553720916477,7698183581020163837,4 --trace-process-track-uuid=3190708989122997041(dns block)safebrowsingohttpgateway.googleapis.com/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --use-angle=swiftshader-webgl --crashpad-handler-pid=6562 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/com.google.Chrome.scoped_dir.Fpqg3l --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,7650420327376008183,8944856811589620878,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,9974608442809264542,17704172690964978898,4 --trace-process-track-uuid=3190708989122997041(dns block)/opt/google/chrome/chrome /usr/bin/google-chrome --headless --disable-gpu --no-sandbox --virtual-time-budget=5000 --dump-dom REDACTED(dns block)/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --use-angle=swiftshader-webgl --crashpad-handler-pid=6715 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/com.google.Chrome.scoped_dir.V7svss --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,6199369688436918274,3489501208979327526,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,2236751553720916477,7698183581020163837,4 --trace-process-track-uuid=3190708989122997041(dns block)www.google.com/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --use-angle=swiftshader-webgl --crashpad-handler-pid=6562 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/com.google.Chrome.scoped_dir.Fpqg3l --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,7650420327376008183,8944856811589620878,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,9974608442809264542,17704172690964978898,4 --trace-process-track-uuid=3190708989122997041(dns block)/opt/google/chrome/chrome /usr/bin/google-chrome --headless --disable-gpu --no-sandbox --virtual-time-budget=5000 --dump-dom REDACTED(dns block)/proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --use-angle=swiftshader-webgl --crashpad-handler-pid=6715 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/com.google.Chrome.scoped_dir.V7svss --change-stack-guard-on-fork=enable --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,6199369688436918274,3489501208979327526,262144 --disable-features=PaintHolding --variations-seed-version --pseudonymization-salt-handle=7,i,2236751553720916477,7698183581020163837,4 --trace-process-track-uuid=3190708989122997041(dns block)If you need me to access, download, or install something from one of these locations, you can either: