Skip to content

feat(storage): add localstorage-* commands#3

Merged
drakulavich merged 1 commit into
mainfrom
feat/localstorage-commands
May 14, 2026
Merged

feat(storage): add localstorage-* commands#3
drakulavich merged 1 commit into
mainfrom
feat/localstorage-commands

Conversation

@drakulavich
Copy link
Copy Markdown
Owner

Summary

First slice of the storage-commands roadmap item. Adds five new commands that read and write the current page's localStorage from the CLI, matching the playwright-cli storage command naming:

  • bowser localstorage-list — key=value lines, or --json object
  • bowser localstorage-get <key> — raw value (empty string if missing)
  • bowser localstorage-set <key> <value>
  • bowser localstorage-delete <key>
  • bowser localstorage-clear

All commands are implemented via the existing evaluate daemon op — no new daemon ops or browser methods. Keys and values are JSON.stringify'd before injection into the page script, following the convention in src/browser.ts and the AGENTS.md "Gotchas" note. Storage errors (e.g. SecurityError on about:blank) are wrapped with a localStorage: prefix so the daemon returns a readable message instead of a bare DOMException.

The remaining storage roadmap subitems — sessionstorage-*, cookie-*, and state-save/state-load — are tracked as nested checkboxes under the storage item in README.md. cookie-* is deferred because reading HttpOnly cookies needs CDP, which would require new daemon ops.

Files

  • src/commands.ts — new cmdLocalStorage* functions plus a shared lsScript helper 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.
  • E2E against a real Chromium (BOWSER_E2E=1 bun test) — not run in this PR; the new commands are pure evaluate shims so they're covered by the unit-level fake daemon, but a follow-up could add an e2e that opens a data: URL, sets a localStorage key, navigates back, and verifies the value survives.

🤖 Generated with Claude Code

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>
@drakulavich drakulavich merged commit e0d26d7 into main May 14, 2026
4 checks passed
@drakulavich drakulavich deleted the feat/localstorage-commands branch May 14, 2026 09:16
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