feat(storage): add localstorage-* commands#3
Merged
Conversation
First slice of the storage-commands roadmap item. Implemented purely via `evaluate` against the live page — no new daemon ops. Selectors and values are JSON-escaped before injection to avoid quoting issues. Errors during storage access (SecurityError, etc.) are wrapped with a `localStorage:` prefix so the daemon returns a readable message. Remaining storage roadmap subitems (sessionstorage-*, cookie-*, state-save/load) are tracked as nested checkboxes in the README. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
First slice of the storage-commands roadmap item. Adds five new commands that read and write the current page's
localStoragefrom the CLI, matching theplaywright-clistorage command naming:bowser localstorage-list— key=value lines, or--jsonobjectbowser localstorage-get <key>— raw value (empty string if missing)bowser localstorage-set <key> <value>bowser localstorage-delete <key>bowser localstorage-clearAll commands are implemented via the existing
evaluatedaemon op — no new daemon ops or browser methods. Keys and values areJSON.stringify'd before injection into the page script, following the convention insrc/browser.tsand the AGENTS.md "Gotchas" note. Storage errors (e.g.SecurityErroronabout:blank) are wrapped with alocalStorage:prefix so the daemon returns a readable message instead of a bare DOMException.The remaining storage roadmap subitems —
sessionstorage-*,cookie-*, andstate-save/state-load— are tracked as nested checkboxes under the storage item inREADME.md.cookie-*is deferred because reading HttpOnly cookies needs CDP, which would require new daemon ops.Files
src/commands.ts— newcmdLocalStorage*functions plus a sharedlsScripthelper for error wrapping.src/cli.ts,src/cli/schemas.ts— schema entries and dispatch.tests/commands.test.ts— 12 new cases covering list/get/set/delete/clear, empty result,--json, JSON-escaping of values containing quotes, and usage errors.tests/compat.test.ts— 5 new parse table rows.README.md,CHANGELOG.md,skills/bowser/SKILL.md— command-reference and changelog updates.Test plan
bun test— 94 pass, 0 fail (10 skipped are the gated e2e suites).bun build src/cli.ts --compile --outfile dist/bowser— clean build../dist/bowser --help— new commands appear in the help text.BOWSER_E2E=1 bun test) — not run in this PR; the new commands are pureevaluateshims so they're covered by the unit-level fake daemon, but a follow-up could add an e2e that opens adata:URL, sets a localStorage key, navigates back, and verifies the value survives.🤖 Generated with Claude Code