Repository navigation
Conversation
Covers length, key order after an add and a remove, key past the end and getItem of a missing key reading null, String coercion on setItem, and the storage-set/storage-remove messages relayed to the page. The test cuts workerCode out of the embedded lg-host-core.js, so it exercises the shipped source; it skips when node is missing. Follow-up to #1080. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Self-check: No actionable findings.
The test exercises the shipped worker source rather than a duplicate shim, initializes the storage snapshot through the real init handler, and verifies key order/cache invalidation, missing-key nulls, value string coercion, and the relayed write/remove messages. Source extraction has explicit failure checks, and the Node subprocess is time-bounded. The PR changes no production behavior.
Validation at 90468cd: TestWorkerStorageShim ran under Node and passed (not skipped). I also temporarily removed the add-path key-cache invalidation in lg-host-core.js; the test failed on the after-add and after-overwrite key lists as expected. Restored the original source and confirmed no diff remained. Existing CI is green.
Follow-up to #1080, whose review asked for a test of the
_lgStorageshim.TestWorkerStorageShimcutsworkerCodeout of the embeddedlg-host-core.jsand runs it under node withpostMessagestubbed. It sends the worker aninitcarrying a two-key storage snapshot and awasmExecJSthat throws, so the worker stops after building_lgStorageand before any wasm loads. The test then checks:lengthandkey(i)order, including after an add, an overwrite, and a remove;keypast the end andgetItemof a missing or removed key read null;setItemstoresString(v);storage-setandstorage-removemessages relayed to the page, in order.Since the test runs the shipped source, a change to the shim needs no matching change to a fixture. It skips when node is not on PATH.
Verification
go test ./pkg/rt/wasm/passes.keys = nullreset on add removed from the shim, the test fails on the key order after the add.GOOS=js GOARCH=wasm,linux, andplan9builds pass.🤖 Generated with Claude Code