@abide/harness 0.7.0 → 0.7.2
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 +3 -4
- package/src/engine/traceOp.ts +3 -1
- package/src/gate/index.ts +1 -1
- package/src/gate/spawned.ts +3 -3
- package/src/measure/injectable.ts +6 -4
- package/src/measure/install.ts +5 -2
- package/src/measure/installFormReset.ts +15 -0
- package/src/measure/installLeadingNewline.ts +47 -0
- package/src/measure/installSelect.ts +88 -0
- package/src/measure/preload.ts +6 -0
- package/src/report/batch.ts +12 -7
- package/src/report/environment.ts +1 -1
- package/src/report/ratio.ts +1 -1
- package/src/runner/runBenches.ts +1 -1
- package/src/runner/runSuite.ts +2 -2
- package/src/runner/testRows.ts +7 -2
- package/scripts/buildInjectable.ts +0 -44
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abide/harness",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
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",
|
|
@@ -30,8 +30,7 @@
|
|
|
30
30
|
"provenance": true
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
|
-
"src"
|
|
34
|
-
"scripts/buildInjectable.ts"
|
|
33
|
+
"src"
|
|
35
34
|
],
|
|
36
35
|
"bin": {
|
|
37
36
|
"harness-bench": "./src/runner/harnessBench.ts"
|
|
@@ -57,7 +56,7 @@
|
|
|
57
56
|
},
|
|
58
57
|
"peerDependencies": {
|
|
59
58
|
"@playwright/test": "^1.64.0",
|
|
60
|
-
"@abide/abide": ">=0.
|
|
59
|
+
"@abide/abide": ">=0.145.0"
|
|
61
60
|
},
|
|
62
61
|
"peerDependenciesMeta": {
|
|
63
62
|
"@playwright/test": {
|
package/src/engine/traceOp.ts
CHANGED
|
@@ -21,7 +21,9 @@ const TRACE_CATEGORIES = [
|
|
|
21
21
|
|
|
22
22
|
type TraceEvent = {
|
|
23
23
|
name: string
|
|
24
|
-
args?:
|
|
24
|
+
args?:
|
|
25
|
+
| { beginData?: { stackTrace?: unknown } | undefined; data?: unknown }
|
|
26
|
+
| undefined
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
type Metrics = Record<string, number>
|
package/src/gate/index.ts
CHANGED
|
@@ -84,7 +84,7 @@ export function gate(
|
|
|
84
84
|
`gate("${name}") passed with the mechanism out. A case reporting the same number either way distinguishes nothing, and this gate is worth nothing.`,
|
|
85
85
|
)
|
|
86
86
|
const reported = String(
|
|
87
|
-
(failure as { message?: string }).message ?? failure,
|
|
87
|
+
(failure as { message?: string | undefined }).message ?? failure,
|
|
88
88
|
)
|
|
89
89
|
for (const [counter, value] of Object.entries(spec.worth)) {
|
|
90
90
|
if (reported.includes(String(value))) continue
|
package/src/gate/spawned.ts
CHANGED
|
@@ -12,9 +12,9 @@ const DEFAULT_DEADLINE_MILLISECONDS = 60_000
|
|
|
12
12
|
export async function spawned(
|
|
13
13
|
command: string[],
|
|
14
14
|
options: {
|
|
15
|
-
cwd?: string
|
|
16
|
-
env?: Record<string, string | undefined>
|
|
17
|
-
deadline?: number
|
|
15
|
+
cwd?: string | undefined
|
|
16
|
+
env?: Record<string, string | undefined> | undefined
|
|
17
|
+
deadline?: number | undefined
|
|
18
18
|
} = {},
|
|
19
19
|
): Promise<{ exitCode: number; stdout: string; stderr: string }> {
|
|
20
20
|
const child = Bun.spawn(command, {
|
|
@@ -13,9 +13,11 @@ import { measure } from './measure.ts'
|
|
|
13
13
|
install()
|
|
14
14
|
;(
|
|
15
15
|
globalThis as {
|
|
16
|
-
__HARNESS_MEASURE__?:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
__HARNESS_MEASURE__?:
|
|
17
|
+
| {
|
|
18
|
+
measure: typeof measure
|
|
19
|
+
patchSet: typeof patchSet
|
|
20
|
+
}
|
|
21
|
+
| undefined
|
|
20
22
|
}
|
|
21
23
|
).__HARNESS_MEASURE__ = { measure, patchSet }
|
package/src/measure/install.ts
CHANGED
|
@@ -450,8 +450,11 @@ function prototypeNamed(
|
|
|
450
450
|
let proto: object | null = Object.getPrototypeOf(instance)
|
|
451
451
|
while (proto) {
|
|
452
452
|
if (
|
|
453
|
-
(
|
|
454
|
-
|
|
453
|
+
(
|
|
454
|
+
proto as {
|
|
455
|
+
constructor?: { name?: string | undefined } | undefined
|
|
456
|
+
}
|
|
457
|
+
).constructor?.name === interfaceName
|
|
455
458
|
)
|
|
456
459
|
return proto
|
|
457
460
|
proto = Object.getPrototypeOf(proto)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// 43.48 — happy-dom's form reset puts back every field but a file input, which keeps the files picked:
|
|
2
|
+
// the HTML reset algorithm empties a file input's list of selected files. A form that starts over
|
|
3
|
+
// after a call (56.34) left the picked file standing under `bun test`, where a browser clears it.
|
|
4
|
+
// Setting `value` to `''` is the one write a file input takes, and happy-dom empties its files on it.
|
|
5
|
+
|
|
6
|
+
export function installFormReset(): void {
|
|
7
|
+
const prototype = HTMLFormElement.prototype
|
|
8
|
+
const reset = prototype.reset
|
|
9
|
+
prototype.reset = function (this: HTMLFormElement): void {
|
|
10
|
+
for (const element of this.elements)
|
|
11
|
+
if (element instanceof HTMLInputElement && element.type === 'file')
|
|
12
|
+
element.value = ''
|
|
13
|
+
reset.call(this)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// 43.49 — the HTML parser drops the one newline that follows a `<textarea>`, `<pre>` or `<listing>`
|
|
2
|
+
// start tag, so a writer leads such an element's text with a newline wherever that text may itself
|
|
3
|
+
// open with one. happy-dom keeps it, and a textarea abide wrote read `"\n"` for its empty value —
|
|
4
|
+
// what a form reset to, and what a test read back. This drops it where the spec does: the first text
|
|
5
|
+
// the parser hands such an element, before anything else is in it.
|
|
6
|
+
//
|
|
7
|
+
// happy-dom's parser is no export of the global registrator, so it is resolved beside the copy of
|
|
8
|
+
// happy-dom the registrator itself loads, and patched there.
|
|
9
|
+
|
|
10
|
+
const LEADING_NEWLINE_ELEMENTS = new Set(['TEXTAREA', 'PRE', 'LISTING'])
|
|
11
|
+
|
|
12
|
+
type Parser = {
|
|
13
|
+
currentNode:
|
|
14
|
+
{ tagName?: string | undefined; firstChild: unknown } | undefined
|
|
15
|
+
parsePlainText(text: string): void
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function installLeadingNewline(): Promise<void> {
|
|
19
|
+
const registrator = Bun.resolveSync(
|
|
20
|
+
'@happy-dom/global-registrator',
|
|
21
|
+
import.meta.dir,
|
|
22
|
+
)
|
|
23
|
+
const parserPath = Bun.resolveSync(
|
|
24
|
+
'happy-dom/lib/html-parser/HTMLParser.js',
|
|
25
|
+
registrator.slice(0, registrator.lastIndexOf('/')),
|
|
26
|
+
)
|
|
27
|
+
const { default: HTMLParser } = (await import(parserPath)) as {
|
|
28
|
+
default: { prototype: Parser }
|
|
29
|
+
}
|
|
30
|
+
const prototype = HTMLParser.prototype
|
|
31
|
+
const parsePlainText = prototype.parsePlainText
|
|
32
|
+
if (typeof parsePlainText !== 'function')
|
|
33
|
+
throw new Error(
|
|
34
|
+
"@abide/harness: happy-dom's parser no longer reads text where installLeadingNewline patches it. RULEBOOK 43.49.",
|
|
35
|
+
)
|
|
36
|
+
prototype.parsePlainText = function (this: Parser, text: string): void {
|
|
37
|
+
const node = this.currentNode
|
|
38
|
+
parsePlainText.call(
|
|
39
|
+
this,
|
|
40
|
+
node !== undefined &&
|
|
41
|
+
node.firstChild === null &&
|
|
42
|
+
LEADING_NEWLINE_ELEMENTS.has(node.tagName ?? '')
|
|
43
|
+
? text.replace(/^\r?\n/, '')
|
|
44
|
+
: text,
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// 43.47 — happy-dom's `<option>` has no `defaultSelected`, and its select lands on the wrong option
|
|
2
|
+
// when one is built from markup: its parser connects the first option before the marked one, the
|
|
3
|
+
// first is chosen as the default, and of the two then selected it keeps the one AT THE INDEX of the
|
|
4
|
+
// count less one rather than the last of them (a mark on the third option of four lands on the
|
|
5
|
+
// second). A select cloned out of a `<template>` keeps the index it never computed, -1. A form reads
|
|
6
|
+
// its baseline off `defaultSelected` (56.14), so under it every select read as edited at the first
|
|
7
|
+
// keystroke. This is the selectedness algorithm as the spec writes it, run where happy-dom runs its
|
|
8
|
+
// own, and `selectedIndex` read off the options rather than off a copy that can go stale.
|
|
9
|
+
//
|
|
10
|
+
// happy-dom keeps selectedness under its own symbols, which no export names; they are found by their
|
|
11
|
+
// descriptions, as `bridgeFiles` finds the one a `Blob` keeps its bytes under.
|
|
12
|
+
|
|
13
|
+
export function installSelect(): void {
|
|
14
|
+
const optionPrototype = HTMLOptionElement.prototype
|
|
15
|
+
if (Object.getOwnPropertyDescriptor(optionPrototype, 'defaultSelected'))
|
|
16
|
+
return
|
|
17
|
+
Object.defineProperty(optionPrototype, 'defaultSelected', {
|
|
18
|
+
configurable: true,
|
|
19
|
+
get(this: HTMLOptionElement) {
|
|
20
|
+
return this.hasAttribute('selected')
|
|
21
|
+
},
|
|
22
|
+
set(this: HTMLOptionElement, selected: boolean) {
|
|
23
|
+
this.toggleAttribute('selected', Boolean(selected))
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
const symbolNamed = (holder: object, description: string): symbol => {
|
|
27
|
+
const found = Object.getOwnPropertySymbols(holder).find(
|
|
28
|
+
(symbol) => symbol.description === description,
|
|
29
|
+
)
|
|
30
|
+
if (found === undefined)
|
|
31
|
+
throw new Error(
|
|
32
|
+
`@abide/harness: happy-dom no longer keeps a select's '${description}' where installSelect reads it. RULEBOOK 43.47.`,
|
|
33
|
+
)
|
|
34
|
+
return found
|
|
35
|
+
}
|
|
36
|
+
const selectPrototype = HTMLSelectElement.prototype
|
|
37
|
+
const UPDATE = symbolNamed(selectPrototype, 'updateSelectedness')
|
|
38
|
+
const SELECTEDNESS = symbolNamed(
|
|
39
|
+
document.createElement('option'),
|
|
40
|
+
'selectedness',
|
|
41
|
+
)
|
|
42
|
+
type Held = HTMLOptionElement & Record<symbol, boolean>
|
|
43
|
+
const optionsOf = (select: HTMLSelectElement): Held[] =>
|
|
44
|
+
[...select.querySelectorAll('option')] as Held[]
|
|
45
|
+
const disabled = (option: HTMLOptionElement): boolean =>
|
|
46
|
+
option.disabled ||
|
|
47
|
+
(option.parentElement instanceof HTMLOptGroupElement &&
|
|
48
|
+
option.parentElement.disabled)
|
|
49
|
+
// https://html.spec.whatwg.org/multipage/form-elements.html#selectedness-setting-algorithm
|
|
50
|
+
Object.defineProperty(selectPrototype, UPDATE, {
|
|
51
|
+
configurable: true,
|
|
52
|
+
value(this: HTMLSelectElement, chosen?: HTMLOptionElement | null) {
|
|
53
|
+
// A multiple select keeps every option picked: one picked leaves the others be.
|
|
54
|
+
if (this.multiple) return
|
|
55
|
+
const options = optionsOf(this)
|
|
56
|
+
if (chosen)
|
|
57
|
+
for (const option of options)
|
|
58
|
+
option[SELECTEDNESS] = option === chosen
|
|
59
|
+
let last: Held | undefined
|
|
60
|
+
for (const option of options)
|
|
61
|
+
if (option[SELECTEDNESS]) last = option
|
|
62
|
+
if (last !== undefined) {
|
|
63
|
+
for (const option of options)
|
|
64
|
+
option[SELECTEDNESS] = option === last
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
if (this.size > 1) return
|
|
68
|
+
for (const option of options)
|
|
69
|
+
if (!disabled(option)) {
|
|
70
|
+
option[SELECTEDNESS] = true
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
})
|
|
75
|
+
const selectedIndex = Object.getOwnPropertyDescriptor(
|
|
76
|
+
selectPrototype,
|
|
77
|
+
'selectedIndex',
|
|
78
|
+
)
|
|
79
|
+
Object.defineProperty(selectPrototype, 'selectedIndex', {
|
|
80
|
+
...selectedIndex,
|
|
81
|
+
get(this: HTMLSelectElement) {
|
|
82
|
+
const options = optionsOf(this)
|
|
83
|
+
for (let index = 0; index < options.length; index++)
|
|
84
|
+
if (options[index]?.[SELECTEDNESS]) return index
|
|
85
|
+
return -1
|
|
86
|
+
},
|
|
87
|
+
})
|
|
88
|
+
}
|
package/src/measure/preload.ts
CHANGED
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
import { GlobalRegistrator } from '@happy-dom/global-registrator'
|
|
5
5
|
|
|
6
6
|
import { install } from './install.ts'
|
|
7
|
+
import { installFormReset } from './installFormReset.ts'
|
|
8
|
+
import { installLeadingNewline } from './installLeadingNewline.ts'
|
|
7
9
|
import { installPopover } from './installPopover.ts'
|
|
10
|
+
import { installSelect } from './installSelect.ts'
|
|
8
11
|
|
|
9
12
|
// A child spawned with this env would paint its output in ANSI off a pipe (bun's console, and
|
|
10
13
|
// abide's own log under RULEBOOK 36.9), and the suites compare that output as text. A terminal
|
|
@@ -57,6 +60,9 @@ for (const name of WIRE) Object.assign(globalThis, { [name]: native[name] })
|
|
|
57
60
|
bridgeFiles()
|
|
58
61
|
install()
|
|
59
62
|
installPopover()
|
|
63
|
+
installSelect()
|
|
64
|
+
installFormReset()
|
|
65
|
+
await installLeadingNewline()
|
|
60
66
|
|
|
61
67
|
/**
|
|
62
68
|
* 43.37, 43.38 — ONE `File` FOR BOTH HALVES. The wire's are bun's (43.28), and happy-dom takes only
|
package/src/report/batch.ts
CHANGED
|
@@ -62,11 +62,15 @@ const DEFAULT_BUDGET_NANOSECONDS = 2_000_000_000
|
|
|
62
62
|
// `bun:jsc` is a specifier a browser bundler must resolve and nothing stands in for it.
|
|
63
63
|
// Read by the MEMBER, so a browser — which has no `Bun` — gets `undefined` here and
|
|
64
64
|
// `collectGarbage` does nothing, rather than a TypeError in the middle of a timing run.
|
|
65
|
-
const BUN_GC = (
|
|
65
|
+
const BUN_GC = (
|
|
66
|
+
globalThis as { Bun?: { gc?(sync: boolean): void } | undefined }
|
|
67
|
+
).Bun?.gc
|
|
66
68
|
|
|
67
69
|
// `bun run test` is `--parallel`, and bun marks a worker process with this.
|
|
68
70
|
const WORKER_ID = (
|
|
69
|
-
globalThis as {
|
|
71
|
+
globalThis as {
|
|
72
|
+
process?: { env: Record<string, string | undefined> } | undefined
|
|
73
|
+
}
|
|
70
74
|
).process?.env?.BUN_TEST_WORKER_ID
|
|
71
75
|
|
|
72
76
|
/** What `batch()` returns: one `Sample` per arm, and the A/A floor they were measured against. */
|
|
@@ -108,17 +112,18 @@ export type BatchSpec = {
|
|
|
108
112
|
* Counting and timing are mutually exclusive passes over the same body — the counter runs
|
|
109
113
|
* inside the path it counts — so the work cannot come off this run and is handed in.
|
|
110
114
|
*/
|
|
111
|
-
work?:
|
|
115
|
+
work?:
|
|
116
|
+
Readonly<Record<string, Readonly<Record<string, number>>>> | undefined
|
|
112
117
|
/**
|
|
113
118
|
* Fixed batch size, when a second `batch()` call has to match a first.
|
|
114
119
|
*
|
|
115
120
|
* Left out, it grows until the sample clears the bar.
|
|
116
121
|
*/
|
|
117
|
-
n?: number
|
|
118
|
-
reps?: number
|
|
119
|
-
warmup?: number
|
|
122
|
+
n?: number | undefined
|
|
123
|
+
reps?: number | undefined
|
|
124
|
+
warmup?: number | undefined
|
|
120
125
|
/** Wall clock for the whole call. A page has a reader waiting on it. */
|
|
121
|
-
budgetNanoseconds?: number
|
|
126
|
+
budgetNanoseconds?: number | undefined
|
|
122
127
|
}
|
|
123
128
|
|
|
124
129
|
function collectGarbage(): void {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// than the name of a global anything could define.
|
|
5
5
|
|
|
6
6
|
const UNDER_BUN =
|
|
7
|
-
typeof (globalThis as { Bun?: { nanoseconds?: unknown } }).Bun
|
|
7
|
+
typeof (globalThis as { Bun?: { nanoseconds?: unknown } | undefined }).Bun
|
|
8
8
|
?.nanoseconds === 'function'
|
|
9
9
|
|
|
10
10
|
/** Whether this is bun, rather than a browser. */
|
package/src/report/ratio.ts
CHANGED
|
@@ -48,7 +48,7 @@ export type RatioSpec = {
|
|
|
48
48
|
* Byte-identical page source ran 4.5x apart because one arm shipped a stylesheet and the
|
|
49
49
|
* other was therefore not doing the work at all.
|
|
50
50
|
*/
|
|
51
|
-
workFactor?: number
|
|
51
|
+
workFactor?: number | undefined
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
const DEFAULT_WORK_FACTOR = 1.05
|
package/src/runner/runBenches.ts
CHANGED
|
@@ -39,7 +39,7 @@ export async function runBenches(
|
|
|
39
39
|
const { CEILINGS = {}, ...exported } = (await import(
|
|
40
40
|
Bun.pathToFileURL(`${base}${file}`).href
|
|
41
41
|
)) as {
|
|
42
|
-
CEILINGS?: Record<string, Record<string, number>>
|
|
42
|
+
CEILINGS?: Record<string, Record<string, number>> | undefined
|
|
43
43
|
} & Record<string, unknown>
|
|
44
44
|
for (const [name, priced] of Object.entries(exported)) {
|
|
45
45
|
if (typeof priced !== 'function') continue
|
package/src/runner/runSuite.ts
CHANGED
|
@@ -156,8 +156,8 @@ export async function runSuite(spec: {
|
|
|
156
156
|
command: string[]
|
|
157
157
|
reportTo: ReportTo
|
|
158
158
|
cwd: string
|
|
159
|
-
environment?: Record<string, string>
|
|
160
|
-
deadline?: number
|
|
159
|
+
environment?: Record<string, string> | undefined
|
|
160
|
+
deadline?: number | undefined
|
|
161
161
|
}): Promise<{ suites: Suite[]; milliseconds: number }> {
|
|
162
162
|
const deadline = spec.deadline ?? SUITE_DEADLINE_MILLISECONDS
|
|
163
163
|
const report = `${tmpdir()}/abide-suite-${crypto.randomUUID()}.xml`
|
package/src/runner/testRows.ts
CHANGED
|
@@ -22,13 +22,18 @@ const BUN_WIDTH = 8
|
|
|
22
22
|
* replaces either glob, relative to `root`.
|
|
23
23
|
*/
|
|
24
24
|
export type TestSuite =
|
|
25
|
-
| {
|
|
25
|
+
| {
|
|
26
|
+
section: string
|
|
27
|
+
root: string
|
|
28
|
+
runner: 'bun'
|
|
29
|
+
pattern?: string | undefined
|
|
30
|
+
}
|
|
26
31
|
| {
|
|
27
32
|
section: string
|
|
28
33
|
root: string
|
|
29
34
|
runner: 'playwright'
|
|
30
35
|
projects: string[]
|
|
31
|
-
pattern?: string
|
|
36
|
+
pattern?: string | undefined
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
type TestItem = RowItem & { command: string[]; browser: boolean }
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// Builds the measure lane into ONE IIFE the browser arm is injected with. The bytes
|
|
2
|
-
// playwright injects and the bytes `bun test` imports have to be the same code, or
|
|
3
|
-
// the lane's one claim — the only lane in both substrates — is a claim about two
|
|
4
|
-
// different instruments.
|
|
5
|
-
//
|
|
6
|
-
// A spec injects the source with `addInitScript({ content })` and reads
|
|
7
|
-
// `__HARNESS_MEASURE__` off the page. Built in memory rather than into `dist/`: every
|
|
8
|
-
// spec loads in both engine projects at once, and two workers writing one file is a
|
|
9
|
-
// reader that can catch it half-written.
|
|
10
|
-
//
|
|
11
|
-
// A SCRIPT, NOT AN ENTRY: abide's browser specs import it by path, and it stays out of `exports`
|
|
12
|
-
// because no app measuring itself injects a lane by hand — `@abide/harness/abide`'s preload does
|
|
13
|
-
// that for one — so an entry would be public surface, with its clauses and its pages, for this
|
|
14
|
-
// repo's specs alone.
|
|
15
|
-
|
|
16
|
-
import type { Page } from '@playwright/test'
|
|
17
|
-
|
|
18
|
-
const ENTRY = new URL('../src/measure/injectable.ts', import.meta.url).pathname
|
|
19
|
-
|
|
20
|
-
/** Builds the measure lane's injectable — or another entry's, the same way — and returns its source. */
|
|
21
|
-
export async function buildInjectable(entry = ENTRY): Promise<string> {
|
|
22
|
-
const built = await Bun.build({
|
|
23
|
-
entrypoints: [entry],
|
|
24
|
-
format: 'iife',
|
|
25
|
-
target: 'browser',
|
|
26
|
-
minify: false,
|
|
27
|
-
})
|
|
28
|
-
if (!built.success)
|
|
29
|
-
throw new AggregateError(built.logs, `${entry} did not build`)
|
|
30
|
-
return (built.outputs[0] as Blob).text()
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Opens a blank page `page` runs `source` in first.
|
|
35
|
-
*
|
|
36
|
-
* NAVIGATED, NOT JUST SET: `setContent` on a page still on its initial `about:blank` reruns no init
|
|
37
|
-
* script — nothing navigated — so the injection would be silently absent, and every counter read
|
|
38
|
-
* undefined: the gate failing on the instrument rather than on the claim.
|
|
39
|
-
*/
|
|
40
|
-
export async function openInjected(page: Page, source: string): Promise<void> {
|
|
41
|
-
await page.addInitScript({ content: source })
|
|
42
|
-
await page.goto('about:blank')
|
|
43
|
-
await page.setContent('<!doctype html><html><body></body></html>')
|
|
44
|
-
}
|