@abide/harness 0.4.2 → 0.4.3
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/package.json +2 -2
- package/scripts/buildInjectable.ts +19 -4
- package/src/measure/install.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abide/harness",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Ratios against hand-written code, counts of the work an op did, and gates whose revert can be run — three measurement lanes for anything that renders, on bun",
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@playwright/test": "^1.64.0",
|
|
60
|
-
"@abide/abide": ">=0.
|
|
60
|
+
"@abide/abide": ">=0.136.1"
|
|
61
61
|
},
|
|
62
62
|
"peerDependenciesMeta": {
|
|
63
63
|
"@playwright/test": {
|
|
@@ -8,17 +8,32 @@
|
|
|
8
8
|
// spec loads in both engine projects at once, and two workers writing one file is a
|
|
9
9
|
// reader that can catch it half-written.
|
|
10
10
|
|
|
11
|
+
import type { Page } from '@playwright/test'
|
|
12
|
+
|
|
11
13
|
const ENTRY = new URL('../src/measure/injectable.ts', import.meta.url).pathname
|
|
12
14
|
|
|
13
|
-
/** Builds the measure lane's injectable and returns its source. */
|
|
14
|
-
export async function buildInjectable(): Promise<string> {
|
|
15
|
+
/** Builds the measure lane's injectable — or another entry's, the same way — and returns its source. */
|
|
16
|
+
export async function buildInjectable(entry = ENTRY): Promise<string> {
|
|
15
17
|
const built = await Bun.build({
|
|
16
|
-
entrypoints: [
|
|
18
|
+
entrypoints: [entry],
|
|
17
19
|
format: 'iife',
|
|
18
20
|
target: 'browser',
|
|
19
21
|
minify: false,
|
|
20
22
|
})
|
|
21
23
|
if (!built.success)
|
|
22
|
-
throw new AggregateError(built.logs,
|
|
24
|
+
throw new AggregateError(built.logs, `${entry} did not build`)
|
|
23
25
|
return (built.outputs[0] as Blob).text()
|
|
24
26
|
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Opens a blank page `page` runs `source` in first.
|
|
30
|
+
*
|
|
31
|
+
* NAVIGATED, NOT JUST SET: `setContent` on a page still on its initial `about:blank` reruns no init
|
|
32
|
+
* script — nothing navigated — so the injection would be silently absent, and every counter read
|
|
33
|
+
* undefined: the gate failing on the instrument rather than on the claim.
|
|
34
|
+
*/
|
|
35
|
+
export async function openInjected(page: Page, source: string): Promise<void> {
|
|
36
|
+
await page.addInitScript({ content: source })
|
|
37
|
+
await page.goto('about:blank')
|
|
38
|
+
await page.setContent('<!doctype html><html><body></body></html>')
|
|
39
|
+
}
|
package/src/measure/install.ts
CHANGED
|
@@ -140,7 +140,7 @@ const DECLARED: [interfaceName: string, member: string, role: Role][] = [
|
|
|
140
140
|
['Document', 'write', 'refused'],
|
|
141
141
|
]
|
|
142
142
|
|
|
143
|
-
/** A fresh `Work` with every counted row at 0 and
|
|
143
|
+
/** A fresh `Work` with every counted row at 0 and nothing published. */
|
|
144
144
|
export function blankWork(): Work {
|
|
145
145
|
// Fixed shape at construction — every field initialized, `undefined` included —
|
|
146
146
|
// because this object is read on every counted call.
|