npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@playwright-repl/playwright-crx

v1.23.0

Published

> **Fork notice:** This is a fork of [ruifigueira/playwright-crx](https://github.com/ruifigueira/playwright-crx) by Rui Figueira, published as [`@playwright-repl/playwright-crx`](https://www.npmjs.com/package/@playwright-repl/playwright-crx) for use with

Readme

Playwright CRX

Fork notice: This is a fork of ruifigueira/playwright-crx by Rui Figueira, published as @playwright-repl/playwright-crx for use with playwright-repl. It follows newer Playwright releases than upstream and carries the patches listed under Fork patches. See CHANGELOG.md for details.

This package contains the Chrome Extensions flavor of the Playwright library.

For that, it relies on chrome.debugger to implement playwright's ConnectionTransport interface.

NOTE: If you want to write end-to-end tests, you should use @playwright/test instead.

Requirements

  • Node.js 20+
  • Bundles Playwright 1.65.0 (Chromium-based browsers only)

Install

npm install @playwright-repl/playwright-crx

The package is ESM only.

API

It's possible to use playwright-crx as a library to create new chrome extensions.

Here's a simple example of a background service worker for a chrome extension using playwright-crx:

import { crx, expect } from '@playwright-repl/playwright-crx/test';

// if you don't need assertions, you can reduce the bundle size by importing crx from the main entry
// import { crx } from '@playwright-repl/playwright-crx';

chrome.action.onClicked.addListener(async ({ id: tabId }) => {
  const crxApp = await crx.start({ slowMo: 500 });

  try {
    // tries to connect to the active tab, or creates a new one
    const page = await crxApp.attach(tabId!).catch(() => crxApp.newPage());

    await page.goto('https://demo.playwright.dev/todomvc/#/');
    await page.getByPlaceholder('What needs to be done?').click();
    await page.getByPlaceholder('What needs to be done?').fill('Hello World!');
    await page.getByPlaceholder('What needs to be done?').press('Enter');

    // assertions work too
    await expect(page.getByTestId('todo-title')).toHaveText('Hello World!');
  } finally {
    // page stays open, but no longer controlled by playwright
    await crxApp.detach(page);
    // releases chrome.debugger
    await crxApp.close();
  }
});

A more complete example can be found in examples/todomvc-crx.

Tracing

Playwright CRX also supports tracing, compatible with Playwright Trace Viewer.

Here's an example on how to run it:

await page.context().tracing.start({ screenshots: true, snapshots: true });

await page.goto('https://demo.playwright.dev/todomvc');
const newTodo = page.getByPlaceholder('What needs to be done?');
await newTodo.fill('buy some cheese');
await newTodo.press('Enter');
await expect(page.getByTestId('todo-title')).toHaveText('buy some cheese');

// stores in memfs and then reads its data
await page.context().tracing.stop({ path: '/tmp/trace.zip' });
const data = crx.fs.readFileSync('/tmp/trace.zip');

// opens playwright traceviewer
const tracePage = await crxApp.newPage();
await tracePage.goto('https://trace.playwright.dev');
const [filechooser] = await Promise.all([
  tracePage.waitForEvent('filechooser'),
  tracePage.getByRole('button', { name: 'Select file(s)' }).click(),
]);

// uploads the trace data buffer (file paths from memfs are not supported)
await filechooser.setFiles({
  name: 'trace.zip',
  mimeType: 'application/zip',
  buffer: Buffer.from(data),
});

You can give it a try with examples/todomvc-crx.

Recorder

Upstream also ships a recorder / player Chrome extension built on this library. This fork doesn't include it; see ruifigueira/playwright-crx if you need it.

Fork patches

Changes to the vendored Playwright source in playwright/, which must be re-checked after every Playwright upgrade:

  • CSP unsafe-eval guard (packages/playwright-core/src/server/javascript.ts): skips the function serialization check when CSP blocks unsafe-eval, as it does in MV3 extension service workers.
  • CrxApplication metainfo (packages/isomorphic/protocolMetainfo.ts): marks attach, attachAll, detach and detachAll as internal, so they don't show up as failed actions in the Trace Viewer.
  • Screencast frame-size rounding (packages/playwright-core/src/server/chromium/crPage.ts, #36): rounds fractional viewport sizes so screencast frames aren't dropped at non-integer display scaling.
  • Main frame session fallback (packages/playwright-core/src/server/chromium/crPage.ts): when attaching to an existing tab with chrome.debugger.attach, the main frame id can differ from the target id. _sessionForFrame falls back to the session stored under the target id instead of throwing Frame has been detached.

npm run check:patches (also run by npm run build) fails if any of these is missing. Add new vendored patches to utils/check_vendor_patches.cjs.

Changes in this package's own source (src/):

  • Graceful detach: detaching a page whose initialization failed no longer throws, so close() still releases chrome.debugger.
  • Restart after close: crx.start() works again after crxApp.close().

Build

To build playwright-crx:

npm ci
npm run build

Tests

npm run test:install
npm test

Tests run in a headed Chromium with the tests/test-extension extension loaded. Set HEADLESS=1 to run headless. To debug the extension's service worker, see CONTRIBUTING.md.

Updating Playwright

Playwright is vendored as a git subtree in playwright/. Upgrade one minor version at a time, on its own branch (replace v1.65.0 with the desired release tag):

git subtree pull --prefix=playwright https://github.com/microsoft/playwright.git v1.65.0 --squash

Then:

  1. Check the vendored patches. The squashed commit message ends with git-subtree-split: <sha>, the upstream commit that was pulled. Compare it with the vendored tree:

    git diff <split sha> HEAD:playwright --stat

    The only files listed should be the ones under Fork patches, and npm run check:patches must pass. If a patch is missing, the pull dropped it: re-apply it.

  2. Bump the test harness. Set @playwright/test in tests/package.json to the same version, so the tests run against the same Chromium.

  3. Merge the PR with a merge commit. Never squash or rebase a subtree PR. git subtree finds the base for the next pull by looking for the last commit with a git-subtree-split line. If the PR is squashed, that commit becomes the squash commit, which also contains our patches. The next pull then treats the patches as changes upstream reverted, and drops them without a conflict. That is how the main frame session fallback was lost in the 1.55 upgrade.

Release

Releases are published by hand:

  1. Bump version in package.json (and package-lock.json, e.g. with npm version <x.y.z> --no-git-tag-version).

  2. Add a section for the version to CHANGELOG.md.

  3. Merge to main, then tag it: git tag v<x.y.z> && git push origin v<x.y.z>.

  4. Create a GitHub release for the tag, using the CHANGELOG section as notes.

  5. Publish to npm from a clean build:

    npm ci
    npm run build
    npm publish