@a11y-pulse/browser-adaptor 0.2.2 → 0.4.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.
- package/LICENSE.md +21 -166
- package/README.md +40 -6
- package/dist/adaptor.d.ts +7 -2
- package/dist/adaptors/playwright.d.ts +23 -0
- package/dist/adaptors/playwright.js +103 -0
- package/dist/adaptors/playwright.js.map +1 -0
- package/dist/adaptors/puppeteer.d.ts +13 -2
- package/dist/adaptors/puppeteer.js +12 -3
- package/dist/adaptors/puppeteer.js.map +1 -1
- package/package.json +15 -4
package/LICENSE.md
CHANGED
|
@@ -1,166 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
to
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
License](#changes-and-new-works-license).
|
|
23
|
-
|
|
24
|
-
## Distribution License
|
|
25
|
-
|
|
26
|
-
The licensor grants you an additional copyright license
|
|
27
|
-
to distribute copies of the software. Your license
|
|
28
|
-
to distribute covers distributing the software with
|
|
29
|
-
changes and new works permitted by [Changes and New Works
|
|
30
|
-
License](#changes-and-new-works-license).
|
|
31
|
-
|
|
32
|
-
## Notices
|
|
33
|
-
|
|
34
|
-
You must ensure that anyone who gets a copy of any part of
|
|
35
|
-
the software from you also gets a copy of these terms or the
|
|
36
|
-
URL for them above, as well as copies of any plain-text lines
|
|
37
|
-
beginning with `Required Notice:` that the licensor provided
|
|
38
|
-
with the software. For example:
|
|
39
|
-
|
|
40
|
-
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
|
|
41
|
-
|
|
42
|
-
## Changes and New Works License
|
|
43
|
-
|
|
44
|
-
The licensor grants you an additional copyright license to
|
|
45
|
-
make changes and new works based on the software for any
|
|
46
|
-
permitted purpose.
|
|
47
|
-
|
|
48
|
-
## Patent License
|
|
49
|
-
|
|
50
|
-
The licensor grants you a patent license for the software that
|
|
51
|
-
covers patent claims the licensor can license, or becomes able
|
|
52
|
-
to license, that you would infringe by using the software.
|
|
53
|
-
|
|
54
|
-
## Noncompete
|
|
55
|
-
|
|
56
|
-
Any purpose is a permitted purpose, except for providing any
|
|
57
|
-
product that competes with the software or any product the
|
|
58
|
-
licensor or any of its affiliates provides using the software.
|
|
59
|
-
|
|
60
|
-
## Competition
|
|
61
|
-
|
|
62
|
-
Goods and services compete even when they provide functionality
|
|
63
|
-
through different kinds of interfaces or for different technical
|
|
64
|
-
platforms. Applications can compete with services, libraries
|
|
65
|
-
with plugins, frameworks with development tools, and so on,
|
|
66
|
-
even if they're written in different programming languages
|
|
67
|
-
or for different computer architectures. Goods and services
|
|
68
|
-
compete even when provided free of charge. If you market a
|
|
69
|
-
product as a practical substitute for the software or another
|
|
70
|
-
product, it definitely competes.
|
|
71
|
-
|
|
72
|
-
## New Products
|
|
73
|
-
|
|
74
|
-
If you are using the software to provide a product that does
|
|
75
|
-
not compete, but the licensor or any of its affiliates brings
|
|
76
|
-
your product into competition by providing a new version of
|
|
77
|
-
the software or another product using the software, you may
|
|
78
|
-
continue using versions of the software available under these
|
|
79
|
-
terms beforehand to provide your competing product, but not
|
|
80
|
-
any later versions.
|
|
81
|
-
|
|
82
|
-
## Discontinued Products
|
|
83
|
-
|
|
84
|
-
You may begin using the software to compete with a product
|
|
85
|
-
or service that the licensor or any of its affiliates has
|
|
86
|
-
stopped providing, unless the licensor includes a plain-text
|
|
87
|
-
line beginning with `Licensor Line of Business:` with the
|
|
88
|
-
software that mentions that line of business. For example:
|
|
89
|
-
|
|
90
|
-
> Licensor Line of Business: YoyodyneCMS Content Management
|
|
91
|
-
System (http://example.com/cms)
|
|
92
|
-
|
|
93
|
-
## Sales of Business
|
|
94
|
-
|
|
95
|
-
If the licensor or any of its affiliates sells a line of
|
|
96
|
-
business developing the software or using the software
|
|
97
|
-
to provide a product, the buyer can also enforce
|
|
98
|
-
[Noncompete](#noncompete) for that product.
|
|
99
|
-
|
|
100
|
-
## Fair Use
|
|
101
|
-
|
|
102
|
-
You may have "fair use" rights for the software under the
|
|
103
|
-
law. These terms do not limit them.
|
|
104
|
-
|
|
105
|
-
## No Other Rights
|
|
106
|
-
|
|
107
|
-
These terms do not allow you to sublicense or transfer any of
|
|
108
|
-
your licenses to anyone else, or prevent the licensor from
|
|
109
|
-
granting licenses to anyone else. These terms do not imply
|
|
110
|
-
any other licenses.
|
|
111
|
-
|
|
112
|
-
## Patent Defense
|
|
113
|
-
|
|
114
|
-
If you make any written claim that the software infringes or
|
|
115
|
-
contributes to infringement of any patent, your patent license
|
|
116
|
-
for the software granted under these terms ends immediately. If
|
|
117
|
-
your company makes such a claim, your patent license ends
|
|
118
|
-
immediately for work on behalf of your company.
|
|
119
|
-
|
|
120
|
-
## Violations
|
|
121
|
-
|
|
122
|
-
The first time you are notified in writing that you have
|
|
123
|
-
violated any of these terms, or done anything with the software
|
|
124
|
-
not covered by your licenses, your licenses can nonetheless
|
|
125
|
-
continue if you come into full compliance with these terms,
|
|
126
|
-
and take practical steps to correct past violations, within
|
|
127
|
-
32 days of receiving notice. Otherwise, all your licenses
|
|
128
|
-
end immediately.
|
|
129
|
-
|
|
130
|
-
## No Liability
|
|
131
|
-
|
|
132
|
-
***As far as the law allows, the software comes as is, without
|
|
133
|
-
any warranty or condition, and the licensor will not be liable
|
|
134
|
-
to you for any damages arising out of these terms or the use
|
|
135
|
-
or nature of the software, under any kind of legal claim.***
|
|
136
|
-
|
|
137
|
-
## Definitions
|
|
138
|
-
|
|
139
|
-
The **licensor** is the individual or entity offering these
|
|
140
|
-
terms, and the **software** is the software the licensor makes
|
|
141
|
-
available under these terms.
|
|
142
|
-
|
|
143
|
-
A **product** can be a good or service, or a combination
|
|
144
|
-
of them.
|
|
145
|
-
|
|
146
|
-
**You** refers to the individual or entity agreeing to these
|
|
147
|
-
terms.
|
|
148
|
-
|
|
149
|
-
**Your company** is any legal entity, sole proprietorship,
|
|
150
|
-
or other kind of organization that you work for, plus all
|
|
151
|
-
its affiliates.
|
|
152
|
-
|
|
153
|
-
**Affiliates** means the other organizations than an
|
|
154
|
-
organization has control over, is under the control of, or is
|
|
155
|
-
under common control with.
|
|
156
|
-
|
|
157
|
-
**Control** means ownership of substantially all the assets of
|
|
158
|
-
an entity, or the power to direct its management and policies
|
|
159
|
-
by vote, contract, or otherwise. Control can be direct or
|
|
160
|
-
indirect.
|
|
161
|
-
|
|
162
|
-
**Your licenses** are all the licenses granted to you for the
|
|
163
|
-
software under these terms.
|
|
164
|
-
|
|
165
|
-
**Use** means anything you do with the software requiring one
|
|
166
|
-
of your licenses.
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026-present, A11y Pulse (https://www.a11ypulse.com/)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@a11y-pulse/browser-adaptor)
|
|
4
4
|
[](https://github.com/A11y-Pulse/audits/actions/workflows/ci.yml)
|
|
5
|
-
[](./LICENSE.md)
|
|
6
6
|
|
|
7
7
|
Shared browser adaptor primitives and DOM helpers used by [A11y Pulse](https://www.a11ypulse.com/) accessibility audits. Audit packages drive a page through a `BrowserAdaptor` without depending on a specific automation library. This package also exports `getSelector` and `truncateHtml` for building result metadata.
|
|
8
8
|
|
|
9
|
-
Released
|
|
9
|
+
Released under the [MIT License](#license).
|
|
10
10
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
@@ -14,7 +14,7 @@ Released as source-available under the [PolyForm Shield License 1.0.0](#license)
|
|
|
14
14
|
npm install @a11y-pulse/browser-adaptor
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
`puppeteer`
|
|
17
|
+
`puppeteer` and `playwright-core` are optional peer dependencies. Each is only required if you use the matching bundled adaptor ([Puppeteer](#puppeteer-adaptor), [Playwright](#playwright-adaptor)).
|
|
18
18
|
|
|
19
19
|
## Exports
|
|
20
20
|
|
|
@@ -22,6 +22,7 @@ npm install @a11y-pulse/browser-adaptor
|
|
|
22
22
|
| --- | --- |
|
|
23
23
|
| `@a11y-pulse/browser-adaptor` | `BrowserAdaptor`, `ElementRef`, `Rect` |
|
|
24
24
|
| `@a11y-pulse/browser-adaptor/puppeteer` | `PuppeteerAdaptor` |
|
|
25
|
+
| `@a11y-pulse/browser-adaptor/playwright` | `PlaywrightAdaptor` |
|
|
25
26
|
| `@a11y-pulse/browser-adaptor/dom` | `getSelector`, `truncateHtml` |
|
|
26
27
|
|
|
27
28
|
## Quickstart
|
|
@@ -52,7 +53,8 @@ interface BrowserAdaptor {
|
|
|
52
53
|
disposeRef(ref: ElementRef): Promise<void>;
|
|
53
54
|
pressTab(): Promise<void>;
|
|
54
55
|
pressEnter(): Promise<void>;
|
|
55
|
-
screenshotClip(clip: Rect): Promise<Uint8Array>;
|
|
56
|
+
screenshotClip(clip: Rect, scale?: number): Promise<Uint8Array>;
|
|
57
|
+
readonly screenshotClipScale?: number;
|
|
56
58
|
ensureFocusReporting(): Promise<void>; // must not throw
|
|
57
59
|
}
|
|
58
60
|
```
|
|
@@ -61,7 +63,36 @@ Consumers may ignore methods they do not need. `ensureFocusReporting` is best-ef
|
|
|
61
63
|
|
|
62
64
|
## Puppeteer adaptor
|
|
63
65
|
|
|
64
|
-
`PuppeteerAdaptor` wraps a Puppeteer `Page`.
|
|
66
|
+
`PuppeteerAdaptor` wraps a Puppeteer `Page`. Its CDP session is cached per page, so reusing a page across audit runs does not open extra sessions.
|
|
67
|
+
|
|
68
|
+
## Playwright adaptor
|
|
69
|
+
|
|
70
|
+
`PlaywrightAdaptor` wraps a Playwright `Page`, and works with either `playwright` or `playwright-core`.
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
import { PlaywrightAdaptor } from "@a11y-pulse/browser-adaptor/playwright";
|
|
74
|
+
import { chromium } from "playwright";
|
|
75
|
+
|
|
76
|
+
const browser = await chromium.launch();
|
|
77
|
+
const page = await browser.newPage({ deviceScaleFactor: 2 });
|
|
78
|
+
await page.goto("https://example.com/");
|
|
79
|
+
|
|
80
|
+
const adaptor = new PlaywrightAdaptor(page);
|
|
81
|
+
await adaptor.ensureFocusReporting();
|
|
82
|
+
await adaptor.pressTab();
|
|
83
|
+
|
|
84
|
+
await browser.close();
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Two differences from the Puppeteer adaptor are worth knowing about.
|
|
88
|
+
|
|
89
|
+
**`evaluate` needs `unsafe-eval`.** Playwright's `evaluate` takes a single argument, so the adaptor packs the page function's source and its arguments into one tuple and rebuilds the function in the page with `new Function`. A page whose Content-Security-Policy omits `unsafe-eval` from `script-src` will reject that; the adaptor throws a message naming CSP as the cause rather than letting it read as a page failure. Puppeteer is unaffected, because CDP serialises the function itself.
|
|
90
|
+
|
|
91
|
+
**Screenshot scale depends on the engine.** On Chromium the adaptor screenshots over CDP, which honours `screenshotClipScale` per capture and captures clips that lie outside the viewport, so evidence images match Puppeteer's. Firefox and WebKit expose no CDP, so the adaptor falls back to a full-page capture at the context's own `deviceScaleFactor`. There, create the context with a `deviceScaleFactor` matching `screenshotClipScale` (2 by default), or pass the scale you want:
|
|
92
|
+
|
|
93
|
+
```js
|
|
94
|
+
new PlaywrightAdaptor(page, { screenshotClipScale: 1 });
|
|
95
|
+
```
|
|
65
96
|
|
|
66
97
|
## DOM helpers
|
|
67
98
|
|
|
@@ -73,4 +104,7 @@ import { getSelector, truncateHtml } from "@a11y-pulse/browser-adaptor/dom";
|
|
|
73
104
|
|
|
74
105
|
## License
|
|
75
106
|
|
|
76
|
-
[
|
|
107
|
+
[MIT](./LICENSE.md). Use it however you like, including in commercial and competing products.
|
|
108
|
+
|
|
109
|
+
The audit packages in this repository are licensed separately, under the
|
|
110
|
+
[PolyForm Shield License 1.0.0](../../LICENSE.md).
|
package/dist/adaptor.d.ts
CHANGED
|
@@ -35,9 +35,14 @@ export interface BrowserAdaptor {
|
|
|
35
35
|
*/
|
|
36
36
|
pressEnter(): Promise<void>;
|
|
37
37
|
/**
|
|
38
|
-
* Screenshot a clipped region of the page defined by `clip`.
|
|
38
|
+
* Screenshot a clipped region of the page defined by `clip`. `scale` is the device scale factor
|
|
39
|
+
* (bitmap pixels per CSS pixel), multiplied against whatever deviceScaleFactor the page itself
|
|
40
|
+
* currently has. The caller is responsible for the page being at a known deviceScaleFactor before
|
|
41
|
+
* invoking this. This function must return PNG bytes.
|
|
39
42
|
*/
|
|
40
|
-
screenshotClip(clip: Rect): Promise<Uint8Array>;
|
|
43
|
+
screenshotClip(clip: Rect, scale?: number): Promise<Uint8Array>;
|
|
44
|
+
/** Device scale factor for evidence screenshots stored on failure. */
|
|
45
|
+
readonly screenshotClipScale?: number;
|
|
41
46
|
/**
|
|
42
47
|
* Ensure the page reports focus for its lifetime. In particular, `document.hasFocus()` must
|
|
43
48
|
* function correctly and :focus styles must be applied, even when the page is not the foreground.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Page } from "playwright-core";
|
|
2
|
+
import type { BrowserAdaptor, ElementRef, Rect } from "../adaptor";
|
|
3
|
+
export type PlaywrightAdaptorOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Device scale factor for evidence screenshots. Defaults to 2. On Chromium any value is honoured
|
|
6
|
+
* per capture. Elsewhere this must match the `deviceScaleFactor` the browser context was created
|
|
7
|
+
* with, because Playwright's public screenshot API cannot rescale a single capture.
|
|
8
|
+
*/
|
|
9
|
+
screenshotClipScale?: number;
|
|
10
|
+
};
|
|
11
|
+
/** A BrowserAdaptor backed by a Playwright Page. */
|
|
12
|
+
export declare class PlaywrightAdaptor implements BrowserAdaptor {
|
|
13
|
+
private readonly page;
|
|
14
|
+
readonly screenshotClipScale: number;
|
|
15
|
+
constructor(page: Page, options?: PlaywrightAdaptorOptions);
|
|
16
|
+
evaluate<T>(fn: (...args: any[]) => T | Promise<T>, ...args: unknown[]): Promise<T>;
|
|
17
|
+
evaluateHandle(fn: () => Element | null): Promise<ElementRef>;
|
|
18
|
+
disposeRef(ref: ElementRef): Promise<void>;
|
|
19
|
+
pressTab(): Promise<void>;
|
|
20
|
+
pressEnter(): Promise<void>;
|
|
21
|
+
screenshotClip(clip: Rect, scale?: number): Promise<Uint8Array>;
|
|
22
|
+
ensureFocusReporting(): Promise<void>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// src/adaptors/playwright.ts
|
|
2
|
+
var cdpSessions = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
var focusEmulatedPages = /* @__PURE__ */ new WeakSet();
|
|
4
|
+
var DEFAULT_SCREENSHOT_CLIP_SCALE = 2;
|
|
5
|
+
var EVAL_BLOCKED = /EvalError|unsafe-eval|Content Security Policy/i;
|
|
6
|
+
function cdpSession(page) {
|
|
7
|
+
const existing = cdpSessions.get(page);
|
|
8
|
+
if (existing) {
|
|
9
|
+
return existing;
|
|
10
|
+
}
|
|
11
|
+
const session = page.context().newCDPSession(page).catch(() => null);
|
|
12
|
+
cdpSessions.set(page, session);
|
|
13
|
+
return session;
|
|
14
|
+
}
|
|
15
|
+
function isChromium(page) {
|
|
16
|
+
try {
|
|
17
|
+
return page.context().browser()?.browserType().name() === "chromium";
|
|
18
|
+
} catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
var PlaywrightAdaptor = class {
|
|
23
|
+
constructor(page, options = {}) {
|
|
24
|
+
this.page = page;
|
|
25
|
+
this.screenshotClipScale = options.screenshotClipScale ?? DEFAULT_SCREENSHOT_CLIP_SCALE;
|
|
26
|
+
}
|
|
27
|
+
page;
|
|
28
|
+
screenshotClipScale;
|
|
29
|
+
async evaluate(fn, ...args) {
|
|
30
|
+
try {
|
|
31
|
+
return await this.page.evaluate(
|
|
32
|
+
([source, packed]) => new Function(`return (${source})`)()(...packed),
|
|
33
|
+
[fn.toString(), args]
|
|
34
|
+
);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
37
|
+
if (EVAL_BLOCKED.test(message)) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
"The Playwright adaptor rebuilds page functions with new Function(), which this page's Content-Security-Policy blocks. Allow 'unsafe-eval' in script-src, or use the Puppeteer adaptor.",
|
|
40
|
+
{ cause: error }
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
evaluateHandle(fn) {
|
|
47
|
+
return this.page.evaluateHandle(fn);
|
|
48
|
+
}
|
|
49
|
+
async disposeRef(ref) {
|
|
50
|
+
await ref.dispose();
|
|
51
|
+
}
|
|
52
|
+
async pressTab() {
|
|
53
|
+
await this.page.keyboard.press("Tab");
|
|
54
|
+
}
|
|
55
|
+
async pressEnter() {
|
|
56
|
+
await this.page.keyboard.press("Enter");
|
|
57
|
+
}
|
|
58
|
+
async screenshotClip(clip, scale = 1) {
|
|
59
|
+
const session = await cdpSession(this.page);
|
|
60
|
+
if (session) {
|
|
61
|
+
const { data } = await session.send("Page.captureScreenshot", {
|
|
62
|
+
format: "png",
|
|
63
|
+
captureBeyondViewport: true,
|
|
64
|
+
clip: { ...clip, scale }
|
|
65
|
+
});
|
|
66
|
+
return Buffer.from(data, "base64");
|
|
67
|
+
}
|
|
68
|
+
return await this.page.screenshot({
|
|
69
|
+
type: "png",
|
|
70
|
+
fullPage: true,
|
|
71
|
+
clip,
|
|
72
|
+
scale: "device"
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
async ensureFocusReporting() {
|
|
76
|
+
const session = await cdpSession(this.page);
|
|
77
|
+
if (!session) {
|
|
78
|
+
if (isChromium(this.page)) {
|
|
79
|
+
console.warn("Could not open a CDP session for the browser adaptor");
|
|
80
|
+
}
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
if (focusEmulatedPages.has(this.page)) {
|
|
85
|
+
await session.send("Emulation.setFocusEmulationEnabled", {
|
|
86
|
+
enabled: false
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
await session.send("Emulation.setFocusEmulationEnabled", {
|
|
90
|
+
enabled: true
|
|
91
|
+
});
|
|
92
|
+
focusEmulatedPages.add(this.page);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
console.warn("Could not enable focus emulation for the browser adaptor", {
|
|
95
|
+
error
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
export {
|
|
101
|
+
PlaywrightAdaptor
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=playwright.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/adaptors/playwright.ts"],"sourcesContent":["import type { CDPSession, JSHandle, Page } from \"playwright-core\";\nimport type { BrowserAdaptor, ElementRef, Rect } from \"../adaptor\";\n\n// The CDP session for each page, shared by focus emulation and clipped screenshots. A fresh adaptor\n// is created per audit run, but a page often outlives one run, so without this each run would open\n// another session that is never detached. The session is kept attached for the page's lifetime:\n// Chrome clears focus emulation when the CDP client disconnects. Resolves to null on Firefox and\n// WebKit, where Playwright offers no CDP.\nconst cdpSessions = new WeakMap<Page, Promise<CDPSession | null>>();\n\n// Pages that have had focus emulation enabled at least once.\nconst focusEmulatedPages = new WeakSet<Page>();\n\nconst DEFAULT_SCREENSHOT_CLIP_SCALE = 2;\n\nconst EVAL_BLOCKED = /EvalError|unsafe-eval|Content Security Policy/i;\n\nfunction cdpSession(page: Page): Promise<CDPSession | null> {\n\tconst existing = cdpSessions.get(page);\n\n\tif (existing) {\n\t\treturn existing;\n\t}\n\n\tconst session = page\n\t\t.context()\n\t\t.newCDPSession(page)\n\t\t.catch(() => null);\n\tcdpSessions.set(page, session);\n\n\treturn session;\n}\n\nfunction isChromium(page: Page): boolean {\n\ttry {\n\t\treturn page.context().browser()?.browserType().name() === \"chromium\";\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport type PlaywrightAdaptorOptions = {\n\t/**\n\t * Device scale factor for evidence screenshots. Defaults to 2. On Chromium any value is honoured\n\t * per capture. Elsewhere this must match the `deviceScaleFactor` the browser context was created\n\t * with, because Playwright's public screenshot API cannot rescale a single capture.\n\t */\n\tscreenshotClipScale?: number;\n};\n\n/** A BrowserAdaptor backed by a Playwright Page. */\nexport class PlaywrightAdaptor implements BrowserAdaptor {\n\treadonly screenshotClipScale: number;\n\n\tconstructor(\n\t\tprivate readonly page: Page,\n\t\toptions: PlaywrightAdaptorOptions = {},\n\t) {\n\t\tthis.screenshotClipScale = options.screenshotClipScale ?? DEFAULT_SCREENSHOT_CLIP_SCALE;\n\t}\n\n\tasync evaluate<T>(\n\t\t// biome-ignore lint/suspicious/noExplicitAny: the page-evaluated fn accepts arbitrary serialised args and element handles.\n\t\tfn: (...args: any[]) => T | Promise<T>,\n\t\t...args: unknown[]\n\t): Promise<T> {\n\t\ttry {\n\t\t\t// Playwright takes a single argument, so the function source and its args travel packed\n\t\t\t// into one tuple. Handles nested in that tuple are still resolved to live elements.\n\t\t\treturn (await this.page.evaluate(\n\t\t\t\t([source, packed]) => new Function(`return (${source})`)()(...(packed as unknown[])),\n\t\t\t\t[fn.toString(), args] as [string, unknown[]],\n\t\t\t)) as T;\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\n\t\t\tif (EVAL_BLOCKED.test(message)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"The Playwright adaptor rebuilds page functions with new Function(), which this page's Content-Security-Policy blocks. Allow 'unsafe-eval' in script-src, or use the Puppeteer adaptor.\",\n\t\t\t\t\t{ cause: error },\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tevaluateHandle(fn: () => Element | null): Promise<ElementRef> {\n\t\treturn this.page.evaluateHandle(fn);\n\t}\n\n\tasync disposeRef(ref: ElementRef): Promise<void> {\n\t\tawait (ref as JSHandle).dispose();\n\t}\n\n\tasync pressTab(): Promise<void> {\n\t\tawait this.page.keyboard.press(\"Tab\");\n\t}\n\n\tasync pressEnter(): Promise<void> {\n\t\tawait this.page.keyboard.press(\"Enter\");\n\t}\n\n\tasync screenshotClip(clip: Rect, scale = 1): Promise<Uint8Array> {\n\t\tconst session = await cdpSession(this.page);\n\n\t\tif (session) {\n\t\t\t// The public API cannot scale one capture, and its `clip` is only honoured inside the\n\t\t\t// viewport. CDP is what Puppeteer drives too, so evidence images stay pixel-comparable.\n\t\t\tconst { data } = await session.send(\"Page.captureScreenshot\", {\n\t\t\t\tformat: \"png\",\n\t\t\t\tcaptureBeyondViewport: true,\n\t\t\t\tclip: { ...clip, scale },\n\t\t\t});\n\n\t\t\treturn Buffer.from(data, \"base64\");\n\t\t}\n\n\t\t// Clips are document coordinates, and Playwright renders anything outside the viewport blank\n\t\t// unless the capture is full-page.\n\t\treturn (await this.page.screenshot({\n\t\t\ttype: \"png\",\n\t\t\tfullPage: true,\n\t\t\tclip,\n\t\t\tscale: \"device\",\n\t\t})) as Uint8Array;\n\t}\n\n\tasync ensureFocusReporting(): Promise<void> {\n\t\t// Pages only report focus while they are the foreground tab. Since this browser instance is\n\t\t// likely running in the background, we need to enable focus emulation to get accurate results.\n\t\t//\n\t\t// Note this function does not throw if enabling emulation fails; it is a best-effort.\n\t\tconst session = await cdpSession(this.page);\n\n\t\tif (!session) {\n\t\t\t// Playwright emulates focus on Firefox and WebKit itself, so there is nothing to assert\n\t\t\t// and nothing worth warning about.\n\t\t\tif (isChromium(this.page)) {\n\t\t\t\tconsole.warn(\"Could not open a CDP session for the browser adaptor\");\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tif (focusEmulatedPages.has(this.page)) {\n\t\t\t\t// Chromium ignores a redundant enable, so re-asserting has to toggle.\n\t\t\t\tawait session.send(\"Emulation.setFocusEmulationEnabled\", {\n\t\t\t\t\tenabled: false,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tawait session.send(\"Emulation.setFocusEmulationEnabled\", {\n\t\t\t\tenabled: true,\n\t\t\t});\n\t\t\tfocusEmulatedPages.add(this.page);\n\t\t} catch (error) {\n\t\t\tconsole.warn(\"Could not enable focus emulation for the browser adaptor\", {\n\t\t\t\terror,\n\t\t\t});\n\t\t}\n\t}\n}\n"],"mappings":"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","names":[]}
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import type { Page } from "puppeteer";
|
|
2
2
|
import type { BrowserAdaptor, ElementRef, Rect } from "../adaptor";
|
|
3
|
+
export type PuppeteerAdaptorOptions = {
|
|
4
|
+
/** Device scale factor for evidence screenshots. Defaults to 2, applied per capture. */
|
|
5
|
+
screenshotClipScale?: number;
|
|
6
|
+
/**
|
|
7
|
+
* Trade PNG compression for capture speed. Defaults to true, which roughly doubles the encoded
|
|
8
|
+
* size of each capture without changing a single pixel.
|
|
9
|
+
*/
|
|
10
|
+
optimizeForSpeed?: boolean;
|
|
11
|
+
};
|
|
3
12
|
/** A BrowserAdaptor backed by a Puppeteer Page. */
|
|
4
13
|
export declare class PuppeteerAdaptor implements BrowserAdaptor {
|
|
5
14
|
private readonly page;
|
|
6
|
-
|
|
15
|
+
readonly screenshotClipScale: number;
|
|
16
|
+
private readonly optimizeForSpeed;
|
|
17
|
+
constructor(page: Page, options?: PuppeteerAdaptorOptions);
|
|
7
18
|
evaluate<T>(fn: (...args: any[]) => T | Promise<T>, ...args: unknown[]): Promise<T>;
|
|
8
19
|
evaluateHandle(fn: () => Element | null): Promise<ElementRef>;
|
|
9
20
|
disposeRef(ref: ElementRef): Promise<void>;
|
|
10
21
|
pressTab(): Promise<void>;
|
|
11
22
|
pressEnter(): Promise<void>;
|
|
12
|
-
screenshotClip(clip: Rect): Promise<Uint8Array>;
|
|
23
|
+
screenshotClip(clip: Rect, scale?: number): Promise<Uint8Array>;
|
|
13
24
|
ensureFocusReporting(): Promise<void>;
|
|
14
25
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
// src/adaptors/puppeteer.ts
|
|
2
2
|
var focusEmulationSessions = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
var DEFAULT_SCREENSHOT_CLIP_SCALE = 2;
|
|
3
4
|
var PuppeteerAdaptor = class {
|
|
4
|
-
constructor(page) {
|
|
5
|
+
constructor(page, options = {}) {
|
|
5
6
|
this.page = page;
|
|
7
|
+
this.screenshotClipScale = options.screenshotClipScale ?? DEFAULT_SCREENSHOT_CLIP_SCALE;
|
|
8
|
+
this.optimizeForSpeed = options.optimizeForSpeed ?? true;
|
|
6
9
|
}
|
|
7
10
|
page;
|
|
11
|
+
screenshotClipScale;
|
|
12
|
+
optimizeForSpeed;
|
|
8
13
|
evaluate(fn, ...args) {
|
|
9
14
|
return this.page.evaluate(fn, ...args);
|
|
10
15
|
}
|
|
@@ -20,8 +25,12 @@ var PuppeteerAdaptor = class {
|
|
|
20
25
|
async pressEnter() {
|
|
21
26
|
await this.page.keyboard.press("Enter");
|
|
22
27
|
}
|
|
23
|
-
async screenshotClip(clip) {
|
|
24
|
-
return await this.page.screenshot({
|
|
28
|
+
async screenshotClip(clip, scale = 1) {
|
|
29
|
+
return await this.page.screenshot({
|
|
30
|
+
type: "png",
|
|
31
|
+
optimizeForSpeed: this.optimizeForSpeed,
|
|
32
|
+
clip: { ...clip, scale }
|
|
33
|
+
});
|
|
25
34
|
}
|
|
26
35
|
async ensureFocusReporting() {
|
|
27
36
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/adaptors/puppeteer.ts"],"sourcesContent":["import type { CDPSession, JSHandle, Page } from \"puppeteer\";\nimport type { BrowserAdaptor, ElementRef, Rect } from \"../adaptor\";\n\n// The CDP session holding focus emulation for each page. A fresh adaptor is created per audit run,\n// but a page often outlives one run, so without this each run would open another CDP session that\n// is never detached. The session is kept attached for the page's lifetime: Chrome clears the\n// emulation when the CDP client disconnects.\nconst focusEmulationSessions = new WeakMap<Page, CDPSession>();\n\n/** A BrowserAdaptor backed by a Puppeteer Page. */\nexport class PuppeteerAdaptor implements BrowserAdaptor {\n\tconstructor(
|
|
1
|
+
{"version":3,"sources":["../../src/adaptors/puppeteer.ts"],"sourcesContent":["import type { CDPSession, JSHandle, Page } from \"puppeteer\";\nimport type { BrowserAdaptor, ElementRef, Rect } from \"../adaptor\";\n\n// The CDP session holding focus emulation for each page. A fresh adaptor is created per audit run,\n// but a page often outlives one run, so without this each run would open another CDP session that\n// is never detached. The session is kept attached for the page's lifetime: Chrome clears the\n// emulation when the CDP client disconnects.\nconst focusEmulationSessions = new WeakMap<Page, CDPSession>();\n\nconst DEFAULT_SCREENSHOT_CLIP_SCALE = 2;\n\nexport type PuppeteerAdaptorOptions = {\n\t/** Device scale factor for evidence screenshots. Defaults to 2, applied per capture. */\n\tscreenshotClipScale?: number;\n\n\t/**\n\t * Trade PNG compression for capture speed. Defaults to true, which roughly doubles the encoded\n\t * size of each capture without changing a single pixel.\n\t */\n\toptimizeForSpeed?: boolean;\n};\n\n/** A BrowserAdaptor backed by a Puppeteer Page. */\nexport class PuppeteerAdaptor implements BrowserAdaptor {\n\treadonly screenshotClipScale: number;\n\n\tprivate readonly optimizeForSpeed: boolean;\n\n\tconstructor(\n\t\tprivate readonly page: Page,\n\t\toptions: PuppeteerAdaptorOptions = {},\n\t) {\n\t\tthis.screenshotClipScale = options.screenshotClipScale ?? DEFAULT_SCREENSHOT_CLIP_SCALE;\n\t\tthis.optimizeForSpeed = options.optimizeForSpeed ?? true;\n\t}\n\n\tevaluate<T>(\n\t\t// biome-ignore lint/suspicious/noExplicitAny: the page-evaluated fn accepts arbitrary serialised args and element handles.\n\t\tfn: (...args: any[]) => T | Promise<T>,\n\t\t...args: unknown[]\n\t): Promise<T> {\n\t\t// Puppeteer resolves any JSHandle passed as an arg to the live element.\n\t\treturn this.page.evaluate(fn as never, ...(args as never[])) as Promise<T>;\n\t}\n\n\tevaluateHandle(fn: () => Element | null): Promise<ElementRef> {\n\t\treturn this.page.evaluateHandle(fn);\n\t}\n\n\tasync disposeRef(ref: ElementRef): Promise<void> {\n\t\tawait (ref as JSHandle).dispose();\n\t}\n\n\tasync pressTab(): Promise<void> {\n\t\tawait this.page.keyboard.press(\"Tab\");\n\t}\n\n\tasync pressEnter(): Promise<void> {\n\t\tawait this.page.keyboard.press(\"Enter\");\n\t}\n\n\tasync screenshotClip(clip: Rect, scale = 1): Promise<Uint8Array> {\n\t\treturn (await this.page.screenshot({\n\t\t\ttype: \"png\",\n\t\t\toptimizeForSpeed: this.optimizeForSpeed,\n\t\t\tclip: { ...clip, scale },\n\t\t})) as Uint8Array;\n\t}\n\n\tasync ensureFocusReporting(): Promise<void> {\n\t\t// Pages only report focus while they are the foreground tab. Since this browser instance is\n\t\t// likely running in the background, we need to enable focus emulation to get accurate results.\n\t\t//\n\t\t// Note this function does not throw if enabling emulation fails; it is a best-effort.\n\t\ttry {\n\t\t\tconst existing = focusEmulationSessions.get(this.page);\n\n\t\t\tif (existing) {\n\t\t\t\t// Chromium ignores a redundant enable, so re-asserting has to toggle.\n\t\t\t\tawait existing.send(\"Emulation.setFocusEmulationEnabled\", {\n\t\t\t\t\tenabled: false,\n\t\t\t\t});\n\t\t\t\tawait existing.send(\"Emulation.setFocusEmulationEnabled\", {\n\t\t\t\t\tenabled: true,\n\t\t\t\t});\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst client = await this.page.createCDPSession();\n\t\t\tawait client.send(\"Emulation.setFocusEmulationEnabled\", {\n\t\t\t\tenabled: true,\n\t\t\t});\n\t\t\tfocusEmulationSessions.set(this.page, client);\n\t\t} catch (error) {\n\t\t\tconsole.warn(\"Could not enable focus emulation for the browser adaptor\", {\n\t\t\t\terror,\n\t\t\t});\n\t\t}\n\t}\n}\n"],"mappings":";AAOA,IAAM,yBAAyB,oBAAI,QAA0B;AAE7D,IAAM,gCAAgC;AAc/B,IAAM,mBAAN,MAAiD;AAAA,EAKvD,YACkB,MACjB,UAAmC,CAAC,GACnC;AAFgB;AAGjB,SAAK,sBAAsB,QAAQ,uBAAuB;AAC1D,SAAK,mBAAmB,QAAQ,oBAAoB;AAAA,EACrD;AAAA,EALkB;AAAA,EALT;AAAA,EAEQ;AAAA,EAUjB,SAEC,OACG,MACU;AAEb,WAAO,KAAK,KAAK,SAAS,IAAa,GAAI,IAAgB;AAAA,EAC5D;AAAA,EAEA,eAAe,IAA+C;AAC7D,WAAO,KAAK,KAAK,eAAe,EAAE;AAAA,EACnC;AAAA,EAEA,MAAM,WAAW,KAAgC;AAChD,UAAO,IAAiB,QAAQ;AAAA,EACjC;AAAA,EAEA,MAAM,WAA0B;AAC/B,UAAM,KAAK,KAAK,SAAS,MAAM,KAAK;AAAA,EACrC;AAAA,EAEA,MAAM,aAA4B;AACjC,UAAM,KAAK,KAAK,SAAS,MAAM,OAAO;AAAA,EACvC;AAAA,EAEA,MAAM,eAAe,MAAY,QAAQ,GAAwB;AAChE,WAAQ,MAAM,KAAK,KAAK,WAAW;AAAA,MAClC,MAAM;AAAA,MACN,kBAAkB,KAAK;AAAA,MACvB,MAAM,EAAE,GAAG,MAAM,MAAM;AAAA,IACxB,CAAC;AAAA,EACF;AAAA,EAEA,MAAM,uBAAsC;AAK3C,QAAI;AACH,YAAM,WAAW,uBAAuB,IAAI,KAAK,IAAI;AAErD,UAAI,UAAU;AAEb,cAAM,SAAS,KAAK,sCAAsC;AAAA,UACzD,SAAS;AAAA,QACV,CAAC;AACD,cAAM,SAAS,KAAK,sCAAsC;AAAA,UACzD,SAAS;AAAA,QACV,CAAC;AAED;AAAA,MACD;AAEA,YAAM,SAAS,MAAM,KAAK,KAAK,iBAAiB;AAChD,YAAM,OAAO,KAAK,sCAAsC;AAAA,QACvD,SAAS;AAAA,MACV,CAAC;AACD,6BAAuB,IAAI,KAAK,MAAM,MAAM;AAAA,IAC7C,SAAS,OAAO;AACf,cAAQ,KAAK,4DAA4D;AAAA,QACxE;AAAA,MACD,CAAC;AAAA,IACF;AAAA,EACD;AACD;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a11y-pulse/browser-adaptor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Shared browser adaptor primitives and DOM helpers for A11y Pulse accessibility audits.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"license": "
|
|
6
|
+
"license": "MIT",
|
|
7
7
|
"author": "A11y Pulse",
|
|
8
8
|
"homepage": "https://github.com/A11y-Pulse/audits/tree/main/packages/browser-adaptor#readme",
|
|
9
9
|
"repository": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"accessibility",
|
|
19
19
|
"a11y",
|
|
20
20
|
"puppeteer",
|
|
21
|
+
"playwright",
|
|
21
22
|
"browser-adaptor",
|
|
22
23
|
"audit"
|
|
23
24
|
],
|
|
@@ -35,6 +36,11 @@
|
|
|
35
36
|
"types": "./dist/adaptors/puppeteer.d.ts",
|
|
36
37
|
"import": "./dist/adaptors/puppeteer.js"
|
|
37
38
|
},
|
|
39
|
+
"./playwright": {
|
|
40
|
+
"source": "./src/adaptors/playwright.ts",
|
|
41
|
+
"types": "./dist/adaptors/playwright.d.ts",
|
|
42
|
+
"import": "./dist/adaptors/playwright.js"
|
|
43
|
+
},
|
|
38
44
|
"./dom": {
|
|
39
45
|
"source": "./src/dom.ts",
|
|
40
46
|
"types": "./dist/dom.d.ts",
|
|
@@ -59,15 +65,20 @@
|
|
|
59
65
|
"access": "public"
|
|
60
66
|
},
|
|
61
67
|
"peerDependencies": {
|
|
62
|
-
"
|
|
68
|
+
"playwright-core": ">=1.40",
|
|
69
|
+
"puppeteer": "^25.10.0"
|
|
63
70
|
},
|
|
64
71
|
"peerDependenciesMeta": {
|
|
72
|
+
"playwright-core": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
65
75
|
"puppeteer": {
|
|
66
76
|
"optional": true
|
|
67
77
|
}
|
|
68
78
|
},
|
|
69
79
|
"devDependencies": {
|
|
70
80
|
"happy-dom": "^20.12.0",
|
|
71
|
-
"
|
|
81
|
+
"playwright-core": "^1.63.0",
|
|
82
|
+
"puppeteer": "^25.10.0"
|
|
72
83
|
}
|
|
73
84
|
}
|