Skip to content

test: rely on the ESLint rule instead of the browser import test - #3561

Merged
Lightning00Blade merged 1 commit into
chore/eslint-no-browser-importsfrom
chore/remove-browser-imports-test
Nov 23, 2026
Merged

Lightning00Blade merged 1 commit into
chore/eslint-no-browser-importsfrom
chore/remove-browser-imports-test

Conversation

@yulunz

@yulunz yulunz commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Refs #3427

Follow-up to #3558. Stacked on #3558 in stack #3530.

What

#3558 adds an ESLint rule (@typescript-eslint/no-restricted-imports) that rejects value imports from third_party/browser.js in src/tools/, src/config/ and src/telemetry/. This PR relies on that rule instead of the import-graph test:

  • Removes tests/browser-imports.test.ts and its tests/BUILD.gn entry.
  • Removes the shared tests/importGraph.ts helper. tests/cli-imports.test.ts was its only other user, so the graph walk goes back inline there. That file is now identical to its version before refactor(telemetry): import flagUtils without the browser bundle #3518, so the CLI check behaves exactly as before.
  • AGENTS.md: the "Third-party bundles" section now describes only the lint rule: it rejects direct value imports from browser.js in src/tools/, src/config/ and src/telemetry/.

Known limitation

ESLint checks one file at a time and only sees direct imports. An indirect import through another module is no longer caught, for example tools/memory.ts → formatters/HeapSnapshotFormatter.ts → third_party/browser.js. The removed test used to catch that case by walking the built import graph.

Test plan

  • npm run format.
  • npm run test tests/cli-imports.test.ts and the full npm run test pass.

@Lightning00Blade
Lightning00Blade force-pushed the chore/remove-browser-imports-test branch from ffb2b9a to 0a9903d Compare November 23, 2026 12:36
@Lightning00Blade
Lightning00Blade enabled stacked auto-merge November 23, 2026 12:40
@Lightning00Blade
Lightning00Blade added this pull request to the merge queue Nov 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue because a pull request earlier in the stack was removed Nov 23, 2026
The @typescript-eslint/no-restricted-imports rule from the previous
commit rejects value imports from third_party/browser.js in tool, config
and telemetry modules. Remove tests/browser-imports.test.ts and fold the
import graph walk back into cli-imports.test.ts, its only other user.
Indirect imports through other modules are no longer checked.

Refs #3427
@Lightning00Blade
Lightning00Blade force-pushed the chore/remove-browser-imports-test branch from 0a9903d to 3194163 Compare November 23, 2026 13:23
@Lightning00Blade
Lightning00Blade added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit 5b849fa Nov 23, 2026
17 checks passed
@Lightning00Blade
Lightning00Blade deleted the chore/remove-browser-imports-test branch November 23, 2026 13:49
OrKoN pushed a commit to JasonOA888/chrome-devtools-mcp that referenced this pull request Nov 23, 2026
…evTools#3566)

Refs ChromeDevTools#3427

Stacked on ChromeDevTools#3561. Splits the `Mutex` bundle move out of ChromeDevTools#3563 so
`BrowserManager` can drop value imports from `third_party/browser.js` in
its own PR. Behavior doesn't change.

## What moved

- **`Mutex`**:
- Now re-exported from the light `src/third_party/index.ts` by its
direct path (`puppeteer-core/internal/util/Mutex.js`) instead of
`src/third_party/browser.ts`. `BrowserManager` uses `Mutex` in a field
initializer.
- `src/BrowserManager.ts`, `src/McpContext.ts`, and
`src/NetworkOverrideManager.ts` import `Mutex` from
`./third_party/index.js`, so it's exported in one place.

## Modules now in both bundles

New with this PR, compared from the two metafiles (debug build):

| Module | Size in index.js | Why it's safe |
|---|---|---|
| `puppeteer-core/…/util/Mutex.js` | 0.8 KiB | Each user creates its own
`Mutex` instance. Nothing checks `instanceof Mutex`, and no instance is
passed into Puppeteer. |
| `puppeteer-core/…/util/Deferred.js` | 2.0 KiB | Imported by
`Mutex.js`. `Mutex` only calls `Deferred.create()` without a timeout, so
this copy never creates a `TimeoutError`. `Deferred` isn't exported from
`index.ts`. |
| `puppeteer-core/…/common/Errors.js` (tree-shaken part) | 0.3 KiB |
Imported by `Deferred.js` for its timeout path, which `Mutex` doesn't
use. `TimeoutError` is still exported only from `browser.ts`, so
`instanceof` checks in tools keep using Puppeteer's class. |

Already in both bundles from earlier PRs: `disposable.js`,
`PredefinedNetworkConditions.js`, `StringUtilities.ts`, `Debouncer.ts`.

## Test plan

- `npm run test tests/browser.test.ts tests/McpContext.test.ts
tests/NetworkOverrideManager.test.ts tests/network_overrides.test.ts
tests/third_party_notices.test.ts`.
- `npm run format` and `npm run build`.
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