testsurfer 0.1.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +52 -149
  2. package/dist/browser.d.ts +135 -1
  3. package/dist/browser.js +378 -2
  4. package/dist/browser.js.map +1 -1
  5. package/dist/cli.d.ts +16 -0
  6. package/dist/cli.js +140 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/client.d.ts +12 -2
  9. package/dist/client.js +73 -4
  10. package/dist/client.js.map +1 -1
  11. package/dist/diff.d.ts +19 -0
  12. package/dist/diff.js +116 -0
  13. package/dist/diff.js.map +1 -0
  14. package/dist/events.d.ts +386 -0
  15. package/dist/events.js +1035 -0
  16. package/dist/events.js.map +1 -0
  17. package/dist/expect.d.ts +135 -26
  18. package/dist/expect.js +634 -130
  19. package/dist/expect.js.map +1 -1
  20. package/dist/frame.d.ts +88 -0
  21. package/dist/frame.js +194 -0
  22. package/dist/frame.js.map +1 -0
  23. package/dist/global.d.ts +12 -0
  24. package/dist/global.js +136 -0
  25. package/dist/global.js.map +1 -0
  26. package/dist/hooks.d.ts +28 -0
  27. package/dist/hooks.js +48 -0
  28. package/dist/hooks.js.map +1 -0
  29. package/dist/index.d.ts +22 -3
  30. package/dist/index.js +21 -3
  31. package/dist/index.js.map +1 -1
  32. package/dist/injected.d.ts +15 -0
  33. package/dist/injected.js +2025 -0
  34. package/dist/injected.js.map +1 -0
  35. package/dist/locator.d.ts +374 -86
  36. package/dist/locator.js +845 -244
  37. package/dist/locator.js.map +1 -1
  38. package/dist/media.d.ts +15 -0
  39. package/dist/media.js +83 -0
  40. package/dist/media.js.map +1 -0
  41. package/dist/net.d.ts +110 -0
  42. package/dist/net.js +498 -0
  43. package/dist/net.js.map +1 -0
  44. package/dist/page.d.ts +448 -5
  45. package/dist/page.js +1187 -31
  46. package/dist/page.js.map +1 -1
  47. package/dist/png.d.ts +28 -0
  48. package/dist/png.js +197 -0
  49. package/dist/png.js.map +1 -0
  50. package/dist/pwconfig.d.ts +66 -0
  51. package/dist/pwconfig.js +77 -0
  52. package/dist/pwconfig.js.map +1 -0
  53. package/dist/register.d.ts +6 -0
  54. package/dist/register.js +9 -0
  55. package/dist/register.js.map +1 -0
  56. package/dist/request.d.ts +29 -0
  57. package/dist/request.js +75 -0
  58. package/dist/request.js.map +1 -0
  59. package/dist/runner.d.ts +99 -15
  60. package/dist/runner.js +354 -58
  61. package/dist/runner.js.map +1 -1
  62. package/dist/screenshot.d.ts +35 -0
  63. package/dist/screenshot.js +171 -0
  64. package/dist/screenshot.js.map +1 -0
  65. package/dist/selector.d.ts +55 -0
  66. package/dist/selector.js +208 -0
  67. package/dist/selector.js.map +1 -0
  68. package/dist/selectors.d.ts +13 -0
  69. package/dist/selectors.js +16 -0
  70. package/dist/selectors.js.map +1 -0
  71. package/dist/serialize.d.ts +17 -0
  72. package/dist/serialize.js +149 -0
  73. package/dist/serialize.js.map +1 -0
  74. package/dist/shim.d.ts +15 -0
  75. package/dist/shim.js +211 -0
  76. package/dist/shim.js.map +1 -0
  77. package/dist/testinfo.d.ts +62 -0
  78. package/dist/testinfo.js +23 -0
  79. package/dist/testinfo.js.map +1 -0
  80. package/dist/values.d.ts +67 -0
  81. package/dist/values.js +293 -0
  82. package/dist/values.js.map +1 -0
  83. package/package.json +10 -3
  84. package/skills/testsurfer/SKILL.md +55 -0
package/README.md CHANGED
@@ -1,177 +1,80 @@
1
1
  # testsurfer
2
2
 
3
- End-to-end testing for the web, driven by [vibesurfer](https://github.com/frane/vibesurfer).
3
+ **Your Playwright tests on a 10 MB install instead of 300 MB.**
4
4
 
5
- testsurfer is lightweight. It drives the browser engine already on your machine through vibesurfer, a small native binary. Nothing bundles Chromium or Firefox or WebKit; you add one small dependency and get a real WebKit engine with fast cold starts and cheap CI.
6
-
7
- Tests address the page through its accessibility tree. You assert on roles and labels instead of CSS selectors, so tests survive DOM and styling churn. And because the engine is a plain OS webview, no automation protocol is attached to the page: no WebDriver, no CDP, and `navigator.webdriver` is `undefined`.
8
-
9
- ```ts
10
- import { test, expect } from 'testsurfer';
11
-
12
- test('login', async ({ page }) => {
13
- await page.goto('https://example.com/login');
14
- await page.getByRole('textbox', { name: 'Email' }).fill('a@b.com');
15
- await page.getByRole('button', { name: 'Sign in' }).click();
16
- await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible();
17
- });
18
- ```
19
-
20
- Install it and run with node's built-in test runner:
5
+ testsurfer runs end-to-end tests with Playwright's API on the WebKit engine your OS already ships. There is no browser download: `npm install` and you are testing.
21
6
 
22
7
  ```sh
23
8
  npm install -D testsurfer
24
- node --test tests/
25
- ```
26
-
27
- Node 22.18 or newer runs the `.ts` test files directly.
28
-
29
- ## How it works
30
-
31
- vibesurfer is a daemon that owns one real WebKit engine and speaks a line protocol over a Unix socket. testsurfer is a TypeScript client for that protocol. It opens a session, resolves your locators against the live accessibility tree, and handles the daemon's optimistic-concurrency tokens internally. You never see a token, a ref, or a retry.
32
-
33
- The daemon is fetched automatically. If `vs` is not on your PATH, testsurfer runs `npx vibesurfer@0.2.14` (pinned, checksum-verified) to download and start it. Set `TESTSURFER_VS` to point at a specific binary. testsurfer reads the daemon's protocol version and feature flags at launch and uses what it offers, so a newer `vs` on your PATH works too.
34
-
35
- ## CI
36
-
37
- testsurfer runs on macOS and Linux GitHub runners. On Linux it needs WebKitGTK 6 and an X display; the action in this repo installs both and starts the pinned vibesurfer daemon:
38
-
39
- ```yaml
40
- jobs:
41
- test:
42
- runs-on: ubuntu-24.04 # or macos-15
43
- steps:
44
- - uses: actions/checkout@v4
45
- - uses: actions/setup-node@v4
46
- with:
47
- node-version: 24
48
- - run: npm ci
49
- - uses: frane/testsurfer@v0
50
- - run: node --test tests/
51
- ```
52
-
53
- `vibesurfer-version` overrides the pinned daemon. This repo's own CI runs the same action on both runners. Windows (WebView2) is supported by vibesurfer but not yet tested here.
54
-
55
- ## API
56
-
57
- Locators resolve lazily at action time, against a fresh view:
58
-
59
- - `page.getByRole(role, { name, exact, level })` matches ARIA roles (`button`, `textbox`, `heading`, `link`, ...). Name matching is whole-string and case-insensitive by default; `exact: true` makes it case-sensitive. RegExp names are supported.
60
- - `page.getByText(text, { exact })` matches visible text, substring and case-insensitive by default.
61
- - `page.getByLabel(text, { exact })` matches form fields by their `<label>` (for, wrapping, or `aria-labelledby`) or `aria-label`.
62
- - `.first()` and `.nth(i)` pick one match when several qualify. Otherwise a locator that matches more than one element fails the action, like Playwright's strict mode.
63
-
64
- Actions auto-wait for their element and retry when the page changes underneath them: `click()`, `fill(value)`, `type(text)` (trusted native keystrokes, for rich-text editors), `press(key)`, `hover()`, `focus()`, `check()`, `uncheck()`, `dragTo(locator)`. Reads: `textContent()`, `inputValue()`, `isChecked()`, `isVisible()`, `boundingBox()`, `count()`, `ariaSnapshot()`.
65
-
66
- Clicks and keystrokes dispatch as native OS input. The cadence is configurable per browser: the default `inputMode: 'robotic'` is instant, which is what tests want; `'human'` moves the cursor along a humanized path with realistic timing for flows that score input behavior.
67
-
68
- Assertions poll until they pass or time out:
69
-
70
- - `expect(locator).toBeVisible()` / `.toBeHidden()`
71
- - `expect(locator).toHaveText(value)` / `.toContainText(value)` (string or RegExp)
72
- - `expect(locator).toHaveValue(value)` / `.toBeChecked()`
73
- - `expect(locator).toHaveCount(n)`
74
- - `expect(locator).toMatchAriaSnapshot(template)` / `expect(page).toMatchAriaSnapshot(template)`
75
- - `expect(page).toHaveTitle(value)` / `.toHaveURL(value)`
76
- - every matcher takes `{ timeout }` and negates with `.not`
77
-
78
- ## Tree snapshots
79
-
80
- `toMatchAriaSnapshot` compares part of the page against a template of roles and names:
81
-
82
- ```ts
83
- await expect(page.getByRole('main')).toMatchAriaSnapshot(`
84
- - heading "Settings" [level=1]
85
- - textbox "Work email"
86
- - checkbox "Send me news" [checked]
87
- - list:
88
- - listitem "Alpha"
89
- - listitem /bravo/i
90
- `);
9
+ npx testsurfer test
91
10
  ```
92
11
 
93
- Template siblings must appear in that order, and a child can sit at any depth under its parent, so wrapper elements do not break a template. Nodes the template does not mention are ignored. A name in quotes matches the whole name; `/regex/flags` is tested as written; no name matches any. `[level=N]` and `[checked]` constrain headings and checkboxes. A form field is printed under its `<label>` text when it has one; in a template, either that text or the field's current value names it. `await locator.ariaSnapshot()` (or `page.ariaSnapshot()`) prints the current tree in this format, ready to paste in and trim.
94
-
95
- ## The page
12
+ That command runs an existing Playwright suite as it is. `@playwright/test` imports resolve to testsurfer, and `playwright.config.*` is read, including `webServer`, `globalSetup` and `baseURL`.
96
13
 
97
- - `page.goto(url)` navigates; relative URLs resolve against the `baseURL` option.
98
- - `page.url()`, `page.title()`, and `page.evaluate(expr | fn)` read the page. `evaluate` returns the JSON-serialized result.
99
- - `page.screenshot({ path, fullPage })` saves a PNG and returns its path.
100
- - `page.mouse.move(x, y)`, `page.mouse.click(x, y)` and `page.mouse.drag(x1, y1, x2, y2)` send trusted pointer input at viewport coordinates, for canvas, maps, sliders and other surfaces with no accessibility tree. A drag also fires the HTML5 drag events, so native `draggable` lists see the drop.
101
-
102
- ## Logging in once
103
-
104
- `page.saveAuth(name)` stores the page's cookies, local and session storage, and IndexedDB, encrypted by the daemon. `page.loadAuth(name)` restores them in a later run; `page.clearAuth(name)` deletes them. Storage is per origin, so load on a page of the same site, then navigate:
14
+ ## Write a test
105
15
 
106
16
  ```ts
107
- // once, after logging in through the UI
108
- await page.saveAuth('staging-admin');
17
+ import { test, expect } from 'testsurfer';
109
18
 
110
- // every run after that
111
- configure({ auth: { name: 'staging-admin', url: 'https://staging.example.com/' } });
19
+ test('sign in', async ({ page }) => {
20
+ await page.goto('https://example.com/login');
21
+ await page.getByLabel('Email').fill('ada@example.com');
22
+ await page.getByRole('button', { name: 'Sign in' }).click();
23
+ await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible();
24
+ });
112
25
  ```
113
26
 
114
- With the `auth` option, every test's `page` starts logged in.
27
+ Locators, auto-waiting, web-first assertions, fixtures, routes, screenshots and aria snapshots all work as you know them from Playwright.
115
28
 
116
- ## Runner
29
+ ## Why testsurfer
117
30
 
118
- The `test` export wraps node:test. Each test gets a fresh `page`; one browser session is shared across the file. `test.describe(name, fn)` groups tests, `test.beforeEach(fn)` and `test.afterEach(fn)` receive the same `{ page }`, and `test.only` / `test.skip` work as in node:test.
31
+ - **Small and fast to install.** One npm package plus a few-MB native daemon, fetched and checksum-verified on first run. CI caches stay small and cold starts take milliseconds.
32
+ - **The engine your users have.** Pages render in the OS web view: WKWebView (Safari's engine) on macOS, WebKitGTK on Linux, WebView2 on Windows.
33
+ - **Real input.** Clicks and keystrokes are native OS events, so `isTrusted` is true and rich-text editors, canvas apps and drag-and-drop behave as they do for users.
34
+ - **No automation protocol.** No WebDriver, no DevTools protocol, and `navigator.webdriver` is `undefined`, so flows behind bot checks stay testable.
119
35
 
120
- `configure(options)` sets the shared browser up before the first test runs:
36
+ ## Use cases
121
37
 
122
- - `baseURL`: resolve relative `goto` URLs against it.
123
- - `auth: { name, url }`: start every page logged in (see above).
124
- - `screenshot: 'only-on-failure'` with `outputDir` (default `test-results`): save a PNG when a test fails and add its path to the error.
125
- - `timeouts: { action, expect, navigation }`, in milliseconds.
126
- - `inputMode`: `robotic` (default, instant), `careful`, or `human` (a humanized cursor path for flows that score input behavior).
38
+ - Run your Playwright suite in CI without downloading browsers.
39
+ - Add end-to-end tests to a project that never had room for 300 MB of browsers.
40
+ - Test sign-up, checkout and login flows that block automated browsers.
41
+ - Check your app in Safari's engine on a Mac without extra setup.
127
42
 
128
- ```ts
129
- import { test, expect, configure } from 'testsurfer';
130
-
131
- configure({ baseURL: 'http://localhost:3000', screenshot: 'only-on-failure' });
43
+ ## Compared to Playwright
132
44
 
133
- test.describe('todos', () => {
134
- test.beforeEach(async ({ page }) => {
135
- await page.goto('/');
136
- });
45
+ | | testsurfer | Playwright |
46
+ |---|---|---|
47
+ | Install | ~10 MB | ~300 MB per browser |
48
+ | Browser download | none | required |
49
+ | Launch | 3-11 ms | 0.4-1.3 s |
50
+ | Engines | the OS web view | bundled Chromium, Firefox, WebKit |
51
+ | Input | native OS events | events sent over a browser protocol |
52
+ | `navigator.webdriver` | `undefined` | `true` |
53
+ | API | Playwright's | Playwright's |
54
+ | Bench suite (CI runners) | 364-405 ms | 576-600 ms |
137
55
 
138
- test('adds one', async ({ page }) => {
139
- await page.getByLabel('New todo').fill('Buy milk');
140
- await page.getByLabel('New todo').press('Enter');
141
- await expect(page.getByRole('listitem')).toHaveCount(1);
142
- });
143
- });
144
- ```
56
+ Playwright's own page specs pass 488 of 488 on testsurfer. An unedited open-source suite (docsify, 105 tests) passes 99, where Playwright's WebKit passes 104. Numbers and how to reproduce them: [compatibility and evidence](docs/compatibility.md).
145
57
 
146
- Runner integration is optional. Under vitest or any other runner, use `Browser.launch()` directly:
147
-
148
- ```ts
149
- import { Browser, expect } from 'testsurfer';
58
+ ## CI
150
59
 
151
- const browser = await Browser.launch();
152
- const page = browser.newPage();
153
- await page.goto('https://example.com');
154
- await expect(page.getByRole('heading', { name: 'Example Domain' })).toBeVisible();
155
- await browser.close();
60
+ ```yaml
61
+ - uses: actions/setup-node@v4
62
+ with:
63
+ node-version: 24
64
+ - run: npm ci
65
+ - uses: frane/testsurfer@v0 # installs what the OS lacks, starts the daemon
66
+ - run: npx testsurfer test
156
67
  ```
157
68
 
158
- ## Status
159
-
160
- Version 0.1 pins vibesurfer 0.2.14 and speaks its frozen wire protocol (v1). Older daemons work for everything except `level`, `checked` and `<label>` lookups, which need the tree attributes 0.2.12 added. Known issue: on some macOS 27 machines each WebKit navigation stalls for about ten seconds inside the engine, which makes suites much slower than the benchmark below; it is tracked in the vibesurfer repo.
161
-
162
- ## Benchmark
163
-
164
- [`bench/`](bench) runs identical flows through testsurfer and Playwright (WebKit and Chromium) against the same app and reports the numbers, favorable and not. On GitHub runners with vibesurfer 0.2.14, testsurfer launches in 3-11ms against Playwright's 0.4-1.3s. The four-flow suite takes 702-968ms on macOS against 561-627ms for Playwright-WebKit and 416-483ms for Playwright-Chromium, and 842-873ms on Linux against 549-664ms and 368-408ms. A working install is ~6MB against ~300MB+ per Playwright browser. The full tables, methodology and history are in the bench README; the `bench` workflow reproduces them.
69
+ macOS, Linux and Windows runners are supported.
165
70
 
166
- ## Example
71
+ ## Documentation
167
72
 
168
- [`examples/todo`](examples/todo) is a small todo app with a complete e2e suite: locators by role and label, polling assertions, and the `{ page }` fixture. It installs testsurfer as a package dependency, so it also exercises the published module shape.
73
+ - [Running tests](docs/running.md): the CLI, Playwright configs, the runner, options, CI, how it works
74
+ - [API](docs/api.md): locators, actions, assertions, aria snapshots, the page, saved logins
75
+ - [Network](docs/network.md): routes, events, the proxy mode, popups and dialogs
76
+ - [Compatibility and evidence](docs/compatibility.md): differences from Playwright, test results, benchmarks
77
+ - [Example project](examples/todo): a small app with a complete suite
78
+ - [For AI agents](skills/testsurfer/SKILL.md): a skill file shipped in the package; copy `node_modules/testsurfer/skills/testsurfer` into your agent's skills folder (`.claude/skills/` for Claude Code)
169
79
 
170
- ## Development
171
-
172
- ```sh
173
- npm install
174
- npm run test:unit # protocol and locator tests, no daemon needed
175
- npm run test:e2e # drives a real page through a local daemon
176
- npm run build
177
- ```
80
+ testsurfer is built on [vibesurfer](https://github.com/frane/vibesurfer). Apache-2.0.
package/dist/browser.d.ts CHANGED
@@ -2,7 +2,8 @@
2
2
  * Browser: one vibesurfer session. Owns the wire client, opens pages,
3
3
  * and closes the session on shutdown.
4
4
  */
5
- import { type ClientOptions } from './client.ts';
5
+ import { WireClient, type ClientOptions } from './client.ts';
6
+ import { type RouteHandler, type UrlMatcher } from './events.ts';
6
7
  import { Page, type ClickVia, type InputMode, type ProtocolOptions, type Timeouts } from './page.ts';
7
8
  export interface LaunchOptions extends ClientOptions {
8
9
  timeouts?: Partial<Timeouts>;
@@ -20,6 +21,26 @@ export interface LaunchOptions extends ClientOptions {
20
21
  protocol?: ProtocolOptions;
21
22
  /** Resolve relative goto() URLs against this, e.g. `http://localhost:3000`. */
22
23
  baseURL?: string;
24
+ /** Attribute getByTestId matches. Default `data-testid`. */
25
+ testIdAttribute?: string;
26
+ /** Page size in CSS px. Default 1280x720, as Playwright; null keeps the engine's own size. */
27
+ viewport?: {
28
+ width: number;
29
+ height: number;
30
+ } | null;
31
+ /** Device pixel ratio for screenshots. Default 1. */
32
+ deviceScaleFactor?: number;
33
+ }
34
+ /** A session and blank page opened ahead of the context that will use them. */
35
+ interface Spare {
36
+ sessionId: string;
37
+ pageId: string;
38
+ token: string;
39
+ sized: {
40
+ width: number;
41
+ height: number;
42
+ dpr: number;
43
+ } | null;
23
44
  }
24
45
  export declare class Browser {
25
46
  private readonly client;
@@ -29,6 +50,9 @@ export declare class Browser {
29
50
  private readonly clickVia;
30
51
  private readonly protocol;
31
52
  private readonly baseURL;
53
+ private testIdAttribute;
54
+ private viewport;
55
+ private deviceScaleFactor;
32
56
  private constructor();
33
57
  /**
34
58
  * Connect to the daemon (spawning it if needed) and open a session.
@@ -38,8 +62,118 @@ export declare class Browser {
38
62
  * automatically. Explicit options always win over negotiation.
39
63
  */
40
64
  static launch(options?: LaunchOptions): Promise<Browser>;
65
+ private defaultCtx;
66
+ private readonly openContexts;
67
+ /** The context that browser.newPage() opens pages in. */
68
+ get defaultContext(): BrowserContext;
69
+ /**
70
+ * A new context: its own vibesurfer session, closed with the context.
71
+ * By default the session is isolated (vibesurfer 0.2.16+): its own
72
+ * in-memory cookie and storage jar, discarded on close, as a
73
+ * Playwright context is. `{ isolated: false }` shares the engine's
74
+ * persistent jar (logins survive across runs).
75
+ */
76
+ newContext(options?: {
77
+ isolated?: boolean;
78
+ intercept?: boolean;
79
+ }): Promise<BrowserContext>;
80
+ private spare;
81
+ /** The spare, once it is open. */
82
+ private spareReady;
83
+ private spareKey;
84
+ private warmer;
85
+ /** Open a session with `flags` and a blank, sized page in it, on a connection of its own. */
86
+ private warm;
87
+ /** Close a spare nobody will take (its flags did not match). */
88
+ private dropSpare;
89
+ /** A context over this browser's own session; closing it closes its pages only. */
90
+ sharedContext(): BrowserContext;
91
+ contexts(): BrowserContext[];
92
+ /** @internal Called by a context when it closes. */
93
+ forgetContext(ctx: BrowserContext): void;
94
+ /** @internal Close a context's session. */
95
+ closeSession(sessionId: string): Promise<void>;
96
+ /** @internal A second daemon connection, for a context's event poller. */
97
+ openPoller(): Promise<WireClient>;
98
+ /** @internal One wire call on the browser's own connection. */
99
+ rawCall(prim: string, args: string[], flags?: Record<string, string | true>): Promise<import("./wire.ts").WireResponse>;
41
100
  /** A new page in this session. Call page.goto(url) to load a URL. */
42
101
  newPage(): Page;
102
+ /** @internal A page bound to `sessionId`, with this browser's options. */
103
+ makePage(sessionId: string): Page;
43
104
  /** Close the session and drop the connection. */
44
105
  close(): Promise<void>;
45
106
  }
107
+ /**
108
+ * A group of pages, with routes and init scripts that apply to all of
109
+ * them (Playwright's BrowserContext). See Browser.newContext() for the
110
+ * isolation caveat.
111
+ */
112
+ export declare class BrowserContext {
113
+ private readonly owner;
114
+ readonly sessionId: string;
115
+ private readonly ownsSession;
116
+ private readonly open;
117
+ private readonly routes;
118
+ private readonly scripts;
119
+ /** The session runs through vibesurfer's intercepting proxy. */
120
+ readonly intercept: boolean;
121
+ constructor(owner: Browser, sessionId: string, ownsSession: boolean, intercept?: boolean);
122
+ browser(): Browser;
123
+ /** @internal Track a page created elsewhere as part of this context. */
124
+ adopt(page: Page): void;
125
+ /** @internal A page closed; it is no longer one of the context's pages. */
126
+ forgetPage(page: Page): void;
127
+ private readonly listeners;
128
+ private hub;
129
+ /** Proxy mode: watch the session's event stream for popups and context-level events. */
130
+ private listen;
131
+ private netContext;
132
+ private popupOpened;
133
+ private emit;
134
+ on(event: string, listener: (arg: never) => void): this;
135
+ once(event: string, listener: (arg: never) => void): this;
136
+ off(event: string, listener: (arg: never) => void): this;
137
+ removeListener(event: string, listener: (arg: never) => void): this;
138
+ /** The next `event` that `predicate` accepts. */
139
+ waitForEvent<T = unknown>(event: string, optionsOrPredicate?: ((arg: T) => boolean | Promise<boolean>) | {
140
+ predicate?: (arg: T) => boolean | Promise<boolean>;
141
+ timeout?: number;
142
+ }): Promise<T>;
143
+ /** setExtraHTTPHeaders() for every page of the context. */
144
+ extraHeaders: Record<string, string>;
145
+ setExtraHTTPHeaders(headers: Record<string, string>): Promise<void>;
146
+ private pendingCookies;
147
+ private cookieSeq;
148
+ /**
149
+ * Add cookies to the context's jar: `{ name, value, url }` or
150
+ * `{ name, value, domain, path }`, with optional expires, httpOnly,
151
+ * secure and sameSite. HttpOnly cookies work too: they go in through
152
+ * the engine's cookie store, not document.cookie.
153
+ */
154
+ addCookies(cookies: {
155
+ name: string;
156
+ value: string;
157
+ url?: string;
158
+ domain?: string;
159
+ path?: string;
160
+ expires?: number;
161
+ httpOnly?: boolean;
162
+ secure?: boolean;
163
+ sameSite?: 'Strict' | 'Lax' | 'None';
164
+ }[]): Promise<void>;
165
+ /** @internal A blank page Browser.newContext opened ahead of time; the first newPage() takes it. */
166
+ warmPage: Spare | null;
167
+ newPage(): Promise<Page>;
168
+ pages(): Page[];
169
+ /** Route requests of every page in this context, current and future. */
170
+ route(url: UrlMatcher, handler: RouteHandler, options?: {
171
+ times?: number;
172
+ }): Promise<void>;
173
+ unrouteAll(): Promise<void>;
174
+ /** An init script for every page in this context, current and future. */
175
+ addInitScript(script: Parameters<Page['addInitScript']>[0], arg?: unknown): Promise<void>;
176
+ /** Close every page, and the session when the context opened one. */
177
+ close(): Promise<void>;
178
+ }
179
+ export {};