@abide/harness 0.4.1 → 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
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.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// 43.36 — happy-dom gives an element its `popover` attribute and none of the methods that open one,
|
|
2
|
+
// and its selector engine matches no `:popover-open`. These are the methods, holding the open state
|
|
3
|
+
// beside the element, and `matches(':popover-open')` reading it — the selector a component asks
|
|
4
|
+
// whether its popover is showing with. A selector that only CONTAINS `:popover-open` still goes to
|
|
5
|
+
// happy-dom and matches nothing. `toggle` fires synchronously where a browser queues it, so a test
|
|
6
|
+
// sees it without waiting a task. Nothing here lays a popover out in a top layer.
|
|
7
|
+
|
|
8
|
+
export function installPopover(): void {
|
|
9
|
+
const prototype = HTMLElement.prototype
|
|
10
|
+
if (typeof prototype.showPopover === 'function') return
|
|
11
|
+
const open = new WeakSet<Element>()
|
|
12
|
+
const flip = (element: HTMLElement, opening: boolean): void => {
|
|
13
|
+
if (!element.hasAttribute('popover')) {
|
|
14
|
+
throw new DOMException(
|
|
15
|
+
'Not supported on elements that do not have a valid value for the popover attribute',
|
|
16
|
+
'NotSupportedError',
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
if (open.has(element) === opening) return
|
|
20
|
+
if (opening) open.add(element)
|
|
21
|
+
else open.delete(element)
|
|
22
|
+
const toggle = new Event('toggle')
|
|
23
|
+
Object.assign(toggle, {
|
|
24
|
+
oldState: opening ? 'closed' : 'open',
|
|
25
|
+
newState: opening ? 'open' : 'closed',
|
|
26
|
+
})
|
|
27
|
+
element.dispatchEvent(toggle)
|
|
28
|
+
}
|
|
29
|
+
prototype.showPopover = function (this: HTMLElement) {
|
|
30
|
+
flip(this, true)
|
|
31
|
+
}
|
|
32
|
+
prototype.hidePopover = function (this: HTMLElement) {
|
|
33
|
+
flip(this, false)
|
|
34
|
+
}
|
|
35
|
+
prototype.togglePopover = function (
|
|
36
|
+
this: HTMLElement,
|
|
37
|
+
force?: boolean | object,
|
|
38
|
+
) {
|
|
39
|
+
const opening = typeof force === 'boolean' ? force : !open.has(this)
|
|
40
|
+
flip(this, opening)
|
|
41
|
+
return opening
|
|
42
|
+
}
|
|
43
|
+
const matches = Element.prototype.matches
|
|
44
|
+
Element.prototype.matches = function (this: Element, selector: string) {
|
|
45
|
+
return selector.trim() === ':popover-open'
|
|
46
|
+
? open.has(this)
|
|
47
|
+
: matches.call(this, selector)
|
|
48
|
+
} as Element['matches']
|
|
49
|
+
}
|
package/src/measure/preload.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { GlobalRegistrator } from '@happy-dom/global-registrator'
|
|
5
5
|
|
|
6
6
|
import { install } from './install.ts'
|
|
7
|
+
import { installPopover } from './installPopover.ts'
|
|
7
8
|
|
|
8
9
|
// A child spawned with this env would paint its output in ANSI off a pipe (bun's console, and
|
|
9
10
|
// abide's own log under RULEBOOK 36.9), and the suites compare that output as text. A terminal
|
|
@@ -42,3 +43,4 @@ GlobalRegistrator.register({
|
|
|
42
43
|
})
|
|
43
44
|
for (const name of WIRE) Object.assign(globalThis, { [name]: native[name] })
|
|
44
45
|
install()
|
|
46
|
+
installPopover()
|