Skip to content

feat(playwright): add human.emulateMedia - #116

Open
totigm wants to merge 1 commit into
mainfrom
feat/human-emulate-media
Open

totigm wants to merge 1 commit into
mainfrom
feat/human-emulate-media

Conversation

@totigm

@totigm totigm commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Answers one of the open questions from the last batch: human_emulate_media shipped as an MCP tool in #112, but library users had no equivalent. A primitive that agents can reach and library users cannot is a half-feature split across the two adapters, which is exactly what CLAUDE.md asks us to avoid.

await human.emulateMedia({ reducedMotion: 'reduce' });
await human.goto(url); // now renders the reduced-motion path

Covers prefers-reduced-motion, prefers-color-scheme, forced-colors, prefers-contrast and print media. null stops emulating a feature and falls back to the host setting.

Why reduced motion is the case worth naming

It cannot be exercised without changing an OS setting, so it tends to ship unverified even in projects that wrote it deliberately. And it fails quietly: the people who depend on it are the least likely to file a bug about it. One line now checks it.

Placement

Implemented as a straight pass-through alongside setViewportSize, waitForURL and pdf — no plugin events, unaffected by speed. Documented in its own README section rather than the Primitives table, since that table is for humanized actions.

CLAUDE.md's public-API block is deliberately left alone: it lists humanized primitives, and setViewportSize and pdf are absent from it for the same reason.

Follow-up

human_emulate_media in @humanjs/mcp currently calls page.emulateMedia directly, matching the other inspection tools. Once #112 and this both land, it can route through human.emulateMedia instead. Left out here so the two PRs stay independently reviewable and mergeable in either order.

Verification

4 new tests (114 in @humanjs/playwright). lint, typecheck (10/10), test (9/9), build (7/7), check:exports (13/13) all pass.

…g checks

Brings the library to parity with the human_emulate_media MCP tool
added in #112. A primitive available to agents but not to library users
is a half-feature, and this is the direction CLAUDE.md asks the surfaces
to stay aligned in.

The reduced-motion branch is the motivating case: it cannot be exercised
without changing an OS setting, so it ships unverified even where it was
written carefully -- and it fails silently, because the users who depend
on it are the least likely to report it.

Documented under its own README section rather than in the Primitives
table, which covers humanized actions; this is configuration, like
setViewportSize and pdf.
@vercel

vercel Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
humanjs Ready Ready Preview Sep 1, 2026 1:10pm UTC

This branch was successfully deployed

1 active deployment
Preview — 83229711 Deployed Sep 1, 2026 by vercel[bot]
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.

1 participant