Skip to content

Studio: a blocked or disabled site storage no longer stops the whole page - #8568

Open
Crxckyi wants to merge 1 commit into
ItsNotRexed:mainfrom
Crxckyi:studio-storage
Open

Crxckyi wants to merge 1 commit into
ItsNotRexed:mainfrom
Crxckyi:studio-storage

Conversation

@Crxckyi

@Crxckyi Crxckyi commented Nov 23, 2026

Copy link
Copy Markdown

Claimed in the coordination issue as: #8344 (comment)

Depends on: none. Several open Studio PRs (#7287, #6786, #5780, #6704, #6731, #5017, #6821) touch the localStorage stub in tests/test_viewer_studio.cjs. None changes the page's own read at viewer/studio.html:458; a textual conflict in the test's context object is possible and trivial.

What and why

The Studio's inline script read localStorage.getItem('leonida_lang') at top level, and setLanguage wrote it unguarded. When the browser blocks site data, the localStorage getter throws SecurityError (Chrome with the site not allowed to save data). When storage is disabled, localStorage is null (Firefox dom.storage.enabled=false). In both cases the script stopped at line 458, before window.onload was set, so the page stayed empty: no model, no texture, no button. The language preference is a convenience; it shouldn't take the whole page down.

The language is now read and saved through two small try/catch helpers, loadLanguage() (falls back to 'ru') and saveLanguage() (ignores a failure). Nothing else changes.

New test "blocked or disabled site storage still starts the Studio in Russian" in tests/test_viewer_studio.cjs covers a getter that throws SecurityError and localStorage: null. In both, window.onload is a function, the language is 'ru', and setLanguage('eu') doesn't throw. node:vm doesn't call a getter set on the context object, so the test defines it on globalThis from inside the context, and a counter checks that the throwing getter is really reached. With the old studio.html both cases fail (SecurityError: storage is blocked, TypeError: Cannot read properties of null (reading 'getItem')).

Tested

Windows 11, Node 24.19.0, CPU only (no GPU or driver involved), on main 867d922f0:

AI-assisted: yes

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

…page

The inline script read localStorage.getItem('leonida_lang') at top level.
With site data blocked the localStorage getter throws SecurityError, and
with storage disabled it is null; either way the script stopped before
window.onload was set and nothing in the Studio worked. The language is now
read and saved through try/catch helpers that fall back to 'ru'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 0b981e3cb0c1552eb4e6220ac18bbe8fbe50314c)
@matheusfermiano-source

Copy link
Copy Markdown

Independent real-browser check of 39a72d2e6e72bfc1f2c283e3255a152c893ceaea vs 867d922f on CachyOS. I served both pages on loopback with the same local Three.js r128 scripts and an empty synthetic models response. An added observer recorded the real storage state, startup handler, renderer and language button. No storage APIs were replaced or mocked.

Browser setting Base PR
Chromium 156, site data blocked in a fresh profile Reading window.localStorage raised SecurityError; startup handler was absent. Storage still raised SecurityError; handler registered, WebGL initialized through SwiftShader, and clicking EU switched the UI from ru to eu without script errors.
Chromium 156, site data allowed Handler and renderer initialized; clicking EU activated it and saved eu. Same result.
Firefox 160, dom.storage.enabled=false localStorage was actually null; initial script threw and did not register the startup handler. Storage remained null; handler registered and clicking EU switched the language. Headless Firefox could not create a WebGL context, so this row verifies only the storage and language behavior.

node --test tests/test_viewer_studio.cjs passed 11/11. No game assets or data were served. AI-assisted (Codex).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants