@orkestrel/test 0.0.30 → 0.0.31
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/README.md +5 -5
- package/dist/src/browser/index.d.ts +68 -4
- package/dist/src/browser/index.js +405 -347
- package/dist/src/browser/index.js.map +1 -1
- package/dist/src/core/index.cjs +156 -80
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +43 -0
- package/dist/src/core/index.d.ts +43 -0
- package/dist/src/core/index.js +154 -81
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +70 -22
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +32 -0
- package/dist/src/server/index.d.ts +32 -0
- package/dist/src/server/index.js +69 -23
- package/dist/src/server/index.js.map +1 -1
- package/package.json +13 -13
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { STATECHART_ATTRIBUTES, STATECHART_STATUSES, buildRefusal, checkBounds, collectSelectorClasses, executeScenario, invokeUnchecked, readProperty, requireValue, waitForAbort, waitForCondition, waitForDelay } from "../core/index.js";
|
|
1
|
+
import { STATECHART_ATTRIBUTES, STATECHART_STATUSES, buildRefusal, captureProduction, checkBounds, collectSelectorClasses, executeScenario, invokeUnchecked, readProperty, requireValue, waitForAbort, waitForCondition, waitForDelay } from "../core/index.js";
|
|
2
2
|
import { cdp, commands, page, server, userEvent } from "vitest/browser";
|
|
3
|
-
import { isArray, isError, isNumber, isRecord, isString, resolveField } from "@orkestrel/contract";
|
|
4
|
-
|
|
3
|
+
import { attempt, isArray, isError, isNumber, isRecord, isString, resolveField } from "@orkestrel/contract";
|
|
4
|
+
// src/browser/helpers.ts
|
|
5
5
|
/**
|
|
6
6
|
* Sends one DevTools protocol command through the browser provider.
|
|
7
7
|
*
|
|
@@ -20,16 +20,26 @@ import { isArray, isError, isNumber, isRecord, isString, resolveField } from "@o
|
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
async function sendProtocol(method, params) {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const [session, send] = readProtocolSession();
|
|
24
|
+
if (typeof send !== "function") throw new Error("Browser provider exposes no DevTools session");
|
|
25
|
+
return await invokeUnchecked(session, send, [method, params]);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Reads the browser provider's DevTools session and its send member.
|
|
29
|
+
*
|
|
30
|
+
* @throws Thrown when the provider or member read fails.
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* const [session, send] = readProtocolSession()
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
function readProtocolSession() {
|
|
25
37
|
try {
|
|
26
|
-
session = cdp();
|
|
27
|
-
|
|
38
|
+
const session = cdp();
|
|
39
|
+
return [session, readProperty(session, "send")];
|
|
28
40
|
} catch (cause) {
|
|
29
41
|
throw new Error("Browser provider exposes no DevTools session", { cause });
|
|
30
42
|
}
|
|
31
|
-
if (typeof send !== "function") throw new Error("Browser provider exposes no DevTools session");
|
|
32
|
-
return await invokeUnchecked(session, send, [method, params]);
|
|
33
43
|
}
|
|
34
44
|
/**
|
|
35
45
|
* Waits for one animation frame to settle pending browser paint work.
|
|
@@ -128,8 +138,7 @@ function readStyle(element, property, pseudo) {
|
|
|
128
138
|
}
|
|
129
139
|
return getComputedStyle(element, pseudo).getPropertyValue(property).trim();
|
|
130
140
|
}
|
|
131
|
-
|
|
132
|
-
//#region src/browser/journeys/constants.ts
|
|
141
|
+
// src/browser/journeys/constants.ts
|
|
133
142
|
/**
|
|
134
143
|
* Names the interactive ARIA roles a bare accessible name is searched across.
|
|
135
144
|
*
|
|
@@ -303,8 +312,7 @@ var IMPLICIT_ROLES = Object.freeze({
|
|
|
303
312
|
* so a rejected send keeps the marker for a retry.
|
|
304
313
|
*/
|
|
305
314
|
var POINTER_HOLD = "data-pointer-hold";
|
|
306
|
-
|
|
307
|
-
//#region src/browser/captures/constants.ts
|
|
315
|
+
// src/browser/captures/constants.ts
|
|
308
316
|
/**
|
|
309
317
|
* Names the attribute marking the runner's tester pane, and the rule that sizes it, while a frame
|
|
310
318
|
* is staged.
|
|
@@ -343,8 +351,7 @@ var CAPTURE_STAGE_LIMIT = 4;
|
|
|
343
351
|
* the marker stays four bits and release leaves touch emulation alone.
|
|
344
352
|
*/
|
|
345
353
|
var MEDIA_STAGE = "data-media-stage";
|
|
346
|
-
|
|
347
|
-
//#region src/browser/captures/helpers.ts
|
|
354
|
+
// src/browser/captures/helpers.ts
|
|
348
355
|
/**
|
|
349
356
|
* Reads one resolved CSS length as a number of pixels.
|
|
350
357
|
*
|
|
@@ -573,15 +580,14 @@ function clipsOverflow(element) {
|
|
|
573
580
|
* ```
|
|
574
581
|
*/
|
|
575
582
|
function measureContent() {
|
|
576
|
-
|
|
577
|
-
for (const element of document.body.querySelectorAll("*")) {
|
|
583
|
+
const edge = Array.from(document.body.querySelectorAll("*")).reduce((greatest, element) => {
|
|
578
584
|
const limits = collectClippingAncestors(element).filter((frame) => frame !== document.body && frame !== document.documentElement).flatMap((frame) => {
|
|
579
585
|
const limit = readClipEdge(frame);
|
|
580
586
|
return limit === void 0 ? [] : [limit];
|
|
581
587
|
});
|
|
582
588
|
const bottom = Math.min(element.getBoundingClientRect().bottom + window.scrollY + readPixels(element, "margin-bottom"), ...limits);
|
|
583
|
-
|
|
584
|
-
}
|
|
589
|
+
return bottom > greatest ? bottom : greatest;
|
|
590
|
+
}, 0);
|
|
585
591
|
return Math.ceil(edge + readPixels(document.body, "padding-bottom") + readPixels(document.body, "margin-bottom") + readPixels(document.documentElement, "padding-bottom") + readPixels(document.documentElement, "margin-bottom"));
|
|
586
592
|
}
|
|
587
593
|
/**
|
|
@@ -1067,120 +1073,8 @@ async function captureFrame(options) {
|
|
|
1067
1073
|
const prepared = window.innerWidth === options.width && window.innerHeight === options.height;
|
|
1068
1074
|
try {
|
|
1069
1075
|
if (!prepared) await stagePane(options.width, options.height);
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
let growth = 0;
|
|
1073
|
-
for (let stage = 0;; stage += 1) {
|
|
1074
|
-
let height = element?.getBoundingClientRect().height;
|
|
1075
|
-
if (element !== void 0 && height !== void 0 && height > options.height) {
|
|
1076
|
-
element.scrollIntoView({
|
|
1077
|
-
block: "start",
|
|
1078
|
-
inline: "nearest",
|
|
1079
|
-
behavior: "instant"
|
|
1080
|
-
});
|
|
1081
|
-
const aligned = element.getBoundingClientRect();
|
|
1082
|
-
height = aligned.height + Math.max(0, aligned.top);
|
|
1083
|
-
} else if (element !== void 0 && height !== void 0) {
|
|
1084
|
-
const padding = readStyle(document.documentElement, "scroll-padding-top");
|
|
1085
|
-
const margin = readStyle(element, "scroll-margin-top");
|
|
1086
|
-
if (padding !== "auto" && padding !== "0px" || margin !== "0px") {
|
|
1087
|
-
element.scrollIntoView({
|
|
1088
|
-
block: "nearest",
|
|
1089
|
-
inline: "nearest",
|
|
1090
|
-
behavior: "instant"
|
|
1091
|
-
});
|
|
1092
|
-
if (element.getBoundingClientRect().bottom >= options.height) {
|
|
1093
|
-
let placement = {
|
|
1094
|
-
left: window.scrollX,
|
|
1095
|
-
top: window.scrollY
|
|
1096
|
-
};
|
|
1097
|
-
element.scrollIntoView({
|
|
1098
|
-
block: "start",
|
|
1099
|
-
inline: "nearest",
|
|
1100
|
-
behavior: "instant"
|
|
1101
|
-
});
|
|
1102
|
-
const aligned = element.getBoundingClientRect();
|
|
1103
|
-
if (aligned.bottom > options.height) {
|
|
1104
|
-
element.scrollIntoView({
|
|
1105
|
-
block: "end",
|
|
1106
|
-
inline: "nearest",
|
|
1107
|
-
behavior: "instant"
|
|
1108
|
-
});
|
|
1109
|
-
const end = element.getBoundingClientRect();
|
|
1110
|
-
const sticky = readStyle(element, "position") === "sticky" && readStyle(element, "top") !== "auto" && end.top >= 0 && end.bottom <= pane;
|
|
1111
|
-
if (sticky) placement = {
|
|
1112
|
-
left: window.scrollX,
|
|
1113
|
-
top: window.scrollY
|
|
1114
|
-
};
|
|
1115
|
-
if (!sticky && (pane > options.height || end.top !== aligned.top)) {
|
|
1116
|
-
height = aligned.height + Math.max(0, aligned.top);
|
|
1117
|
-
element.scrollIntoView({
|
|
1118
|
-
block: "start",
|
|
1119
|
-
inline: "nearest",
|
|
1120
|
-
behavior: "instant"
|
|
1121
|
-
});
|
|
1122
|
-
}
|
|
1123
|
-
}
|
|
1124
|
-
if (height <= options.height) window.scrollTo({
|
|
1125
|
-
...placement,
|
|
1126
|
-
behavior: "instant"
|
|
1127
|
-
});
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
const extent = Math.max(height === void 0 ? measureContent() : Math.ceil(height), options.height);
|
|
1132
|
-
if (covered !== void 0) growth = Math.max(0, extent - covered);
|
|
1133
|
-
covered = extent;
|
|
1134
|
-
if (pane === covered) {
|
|
1135
|
-
if (prepared && stage === 0) {
|
|
1136
|
-
await stagePane(options.width, pane);
|
|
1137
|
-
continue;
|
|
1138
|
-
}
|
|
1139
|
-
break;
|
|
1140
|
-
}
|
|
1141
|
-
if (stage === 4) throw new Error(`Capture frame at ${options.path} never settled after ${String(4)} restagings: ${String(covered)} over a ${String(pane)} pane`);
|
|
1142
|
-
pane = covered + growth;
|
|
1143
|
-
await stagePane(options.width, pane);
|
|
1144
|
-
}
|
|
1145
|
-
let shot;
|
|
1146
|
-
if (element === void 0) shot = await page.screenshot({
|
|
1147
|
-
path: options.path,
|
|
1148
|
-
base64: true
|
|
1149
|
-
});
|
|
1150
|
-
else {
|
|
1151
|
-
const box = element.getBoundingClientRect();
|
|
1152
|
-
const down = box.top < 0 ? box.top : Math.max(0, box.bottom - window.innerHeight);
|
|
1153
|
-
const across = box.left < 0 ? box.left : Math.max(0, box.right - window.innerWidth);
|
|
1154
|
-
if (down !== 0 || across !== 0) window.scrollBy({
|
|
1155
|
-
top: down,
|
|
1156
|
-
left: across,
|
|
1157
|
-
behavior: "instant"
|
|
1158
|
-
});
|
|
1159
|
-
const frame = window.frameElement;
|
|
1160
|
-
const view = window.top;
|
|
1161
|
-
const placed = element.getBoundingClientRect();
|
|
1162
|
-
const move = view === null ? {
|
|
1163
|
-
top: 0,
|
|
1164
|
-
left: 0
|
|
1165
|
-
} : computeOffset(placed, view.innerWidth, view.innerHeight);
|
|
1166
|
-
const style = frame?.getAttribute("style") ?? null;
|
|
1167
|
-
const offset = frame !== null && (move.top !== 0 || move.left !== 0);
|
|
1168
|
-
try {
|
|
1169
|
-
if (offset) {
|
|
1170
|
-
frame.setAttribute("style", `${style ?? ""};top:${String(move.top)}px !important;left:${String(move.left)}px !important;will-change:transform`);
|
|
1171
|
-
await waitForFrame();
|
|
1172
|
-
await waitForFrame();
|
|
1173
|
-
}
|
|
1174
|
-
shot = await page.screenshot({
|
|
1175
|
-
element,
|
|
1176
|
-
path: options.path,
|
|
1177
|
-
base64: true
|
|
1178
|
-
});
|
|
1179
|
-
} finally {
|
|
1180
|
-
if (offset && style === null) frame.removeAttribute("style");
|
|
1181
|
-
else if (offset && style !== null) frame.setAttribute("style", style);
|
|
1182
|
-
}
|
|
1183
|
-
}
|
|
1076
|
+
await settleFrame(options, element, prepared);
|
|
1077
|
+
const shot = await takeFrameShot(options, element);
|
|
1184
1078
|
await verifyFrame(shot, options.path, readCaptureReader());
|
|
1185
1079
|
return shot.path;
|
|
1186
1080
|
} finally {
|
|
@@ -1314,13 +1208,10 @@ async function readFrame(path) {
|
|
|
1314
1208
|
const red = row[0];
|
|
1315
1209
|
const green = row[1];
|
|
1316
1210
|
const blue = row[2];
|
|
1317
|
-
const alpha = row[3];
|
|
1318
|
-
let single = red !== void 0 && green !== void 0 && blue !== void 0;
|
|
1319
|
-
for (let pixel = 4; single && pixel < row.length; pixel += 4) single = row[pixel] === red && row[pixel + 1] === green && row[pixel + 2] === blue && row[pixel + 3] === alpha;
|
|
1320
1211
|
return {
|
|
1321
1212
|
width,
|
|
1322
1213
|
height,
|
|
1323
|
-
floor:
|
|
1214
|
+
floor: red !== void 0 && green !== void 0 && blue !== void 0 && row.subarray(4).every((channel, index) => channel === row[index % 4]) ? `rgb(${String(red)}, ${String(green)}, ${String(blue)})` : void 0
|
|
1324
1215
|
};
|
|
1325
1216
|
}
|
|
1326
1217
|
/**
|
|
@@ -1390,8 +1281,155 @@ function expandCaptures(states, variants) {
|
|
|
1390
1281
|
for (const state of states) for (const variant of variants) files.push(`${state}--${variant.name}.png`);
|
|
1391
1282
|
return files;
|
|
1392
1283
|
}
|
|
1393
|
-
|
|
1394
|
-
|
|
1284
|
+
/**
|
|
1285
|
+
* Restages a capture until its content extent equals the pane height.
|
|
1286
|
+
*
|
|
1287
|
+
* @remarks The stage limit bounds the recursion; a prepared pane is staged before accepting it.
|
|
1288
|
+
* @example
|
|
1289
|
+
* ```ts
|
|
1290
|
+
* await settleFrame({ path: 'frame.png', width: 390, height: 844 }, undefined, false)
|
|
1291
|
+
* ```
|
|
1292
|
+
*/
|
|
1293
|
+
async function settleFrame(options, element, prepared, pane = options.height, covered, stage = 0) {
|
|
1294
|
+
const height = readFrameHeight(options, element, pane);
|
|
1295
|
+
const measured = height === void 0 ? measureContent() : Math.ceil(height);
|
|
1296
|
+
const extent = Math.max(measured, options.height);
|
|
1297
|
+
const growth = covered === void 0 ? 0 : Math.max(0, extent - covered);
|
|
1298
|
+
if (pane === extent) {
|
|
1299
|
+
if (prepared && stage === 0) {
|
|
1300
|
+
await stagePane(options.width, pane);
|
|
1301
|
+
return settleFrame(options, element, prepared, pane, extent, stage + 1);
|
|
1302
|
+
}
|
|
1303
|
+
return;
|
|
1304
|
+
}
|
|
1305
|
+
if (stage === 4) throw new Error(`Capture frame at ${options.path} never settled after ${String(4)} restagings: ${String(extent)} over a ${String(pane)} pane`);
|
|
1306
|
+
const next = extent + growth;
|
|
1307
|
+
await stagePane(options.width, next);
|
|
1308
|
+
return settleFrame(options, element, prepared, next, extent, stage + 1);
|
|
1309
|
+
}
|
|
1310
|
+
/**
|
|
1311
|
+
* Reads a capture subject's height after applying its native scroll clearance.
|
|
1312
|
+
*
|
|
1313
|
+
* @example
|
|
1314
|
+
* ```ts
|
|
1315
|
+
* readFrameHeight({ path: 'frame.png', width: 390, height: 844 }, undefined, 844)
|
|
1316
|
+
* ```
|
|
1317
|
+
*/
|
|
1318
|
+
function readFrameHeight(options, element, pane) {
|
|
1319
|
+
const height = element?.getBoundingClientRect().height;
|
|
1320
|
+
if (element === void 0 || height === void 0) return height;
|
|
1321
|
+
if (height > options.height) {
|
|
1322
|
+
element.scrollIntoView({
|
|
1323
|
+
block: "start",
|
|
1324
|
+
inline: "nearest",
|
|
1325
|
+
behavior: "instant"
|
|
1326
|
+
});
|
|
1327
|
+
const aligned = element.getBoundingClientRect();
|
|
1328
|
+
return aligned.height + Math.max(0, aligned.top);
|
|
1329
|
+
}
|
|
1330
|
+
const padding = readStyle(document.documentElement, "scroll-padding-top");
|
|
1331
|
+
const margin = readStyle(element, "scroll-margin-top");
|
|
1332
|
+
if ((padding === "auto" || padding === "0px") && margin === "0px") return height;
|
|
1333
|
+
element.scrollIntoView({
|
|
1334
|
+
block: "nearest",
|
|
1335
|
+
inline: "nearest",
|
|
1336
|
+
behavior: "instant"
|
|
1337
|
+
});
|
|
1338
|
+
if (!(element.getBoundingClientRect().bottom >= options.height)) return height;
|
|
1339
|
+
const placement = {
|
|
1340
|
+
left: window.scrollX,
|
|
1341
|
+
top: window.scrollY
|
|
1342
|
+
};
|
|
1343
|
+
element.scrollIntoView({
|
|
1344
|
+
block: "start",
|
|
1345
|
+
inline: "nearest",
|
|
1346
|
+
behavior: "instant"
|
|
1347
|
+
});
|
|
1348
|
+
const aligned = element.getBoundingClientRect();
|
|
1349
|
+
if (aligned.bottom > options.height) {
|
|
1350
|
+
element.scrollIntoView({
|
|
1351
|
+
block: "end",
|
|
1352
|
+
inline: "nearest",
|
|
1353
|
+
behavior: "instant"
|
|
1354
|
+
});
|
|
1355
|
+
const end = element.getBoundingClientRect();
|
|
1356
|
+
if (readStyle(element, "position") === "sticky" && readStyle(element, "top") !== "auto" && end.top >= 0 && end.bottom <= pane) {
|
|
1357
|
+
if (height <= options.height) window.scrollTo({
|
|
1358
|
+
left: window.scrollX,
|
|
1359
|
+
top: window.scrollY,
|
|
1360
|
+
behavior: "instant"
|
|
1361
|
+
});
|
|
1362
|
+
return height;
|
|
1363
|
+
}
|
|
1364
|
+
if (pane > options.height || end.top !== aligned.top) {
|
|
1365
|
+
const extended = aligned.height + Math.max(0, aligned.top);
|
|
1366
|
+
element.scrollIntoView({
|
|
1367
|
+
block: "start",
|
|
1368
|
+
inline: "nearest",
|
|
1369
|
+
behavior: "instant"
|
|
1370
|
+
});
|
|
1371
|
+
if (extended <= options.height) window.scrollTo({
|
|
1372
|
+
...placement,
|
|
1373
|
+
behavior: "instant"
|
|
1374
|
+
});
|
|
1375
|
+
return extended;
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
if (height <= options.height) window.scrollTo({
|
|
1379
|
+
...placement,
|
|
1380
|
+
behavior: "instant"
|
|
1381
|
+
});
|
|
1382
|
+
return height;
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* Takes a screenshot while temporarily positioning the runner frame around its subject.
|
|
1386
|
+
*
|
|
1387
|
+
* @example
|
|
1388
|
+
* ```ts
|
|
1389
|
+
* const shot = await takeFrameShot({ path: 'frame.png', width: 390, height: 844 }, undefined)
|
|
1390
|
+
* ```
|
|
1391
|
+
*/
|
|
1392
|
+
async function takeFrameShot(options, element) {
|
|
1393
|
+
if (element === void 0) return await page.screenshot({
|
|
1394
|
+
path: options.path,
|
|
1395
|
+
base64: true
|
|
1396
|
+
});
|
|
1397
|
+
else {
|
|
1398
|
+
const box = element.getBoundingClientRect();
|
|
1399
|
+
const down = box.top < 0 ? box.top : Math.max(0, box.bottom - window.innerHeight);
|
|
1400
|
+
const across = box.left < 0 ? box.left : Math.max(0, box.right - window.innerWidth);
|
|
1401
|
+
if (down !== 0 || across !== 0) window.scrollBy({
|
|
1402
|
+
top: down,
|
|
1403
|
+
left: across,
|
|
1404
|
+
behavior: "instant"
|
|
1405
|
+
});
|
|
1406
|
+
const frame = window.frameElement;
|
|
1407
|
+
const view = window.top;
|
|
1408
|
+
const placed = element.getBoundingClientRect();
|
|
1409
|
+
const move = view === null ? {
|
|
1410
|
+
top: 0,
|
|
1411
|
+
left: 0
|
|
1412
|
+
} : computeOffset(placed, view.innerWidth, view.innerHeight);
|
|
1413
|
+
const style = frame?.getAttribute("style") ?? null;
|
|
1414
|
+
const offset = frame !== null && (move.top !== 0 || move.left !== 0);
|
|
1415
|
+
try {
|
|
1416
|
+
if (offset) {
|
|
1417
|
+
frame.setAttribute("style", `${style ?? ""};top:${String(move.top)}px !important;left:${String(move.left)}px !important;will-change:transform`);
|
|
1418
|
+
await waitForFrame();
|
|
1419
|
+
await waitForFrame();
|
|
1420
|
+
}
|
|
1421
|
+
return await page.screenshot({
|
|
1422
|
+
element,
|
|
1423
|
+
path: options.path,
|
|
1424
|
+
base64: true
|
|
1425
|
+
});
|
|
1426
|
+
} finally {
|
|
1427
|
+
if (offset && style === null) frame.removeAttribute("style");
|
|
1428
|
+
else if (offset && style !== null) frame.setAttribute("style", style);
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
// src/browser/journeys/helpers.ts
|
|
1395
1433
|
/**
|
|
1396
1434
|
* Sends one emulated touch event through the browser protocol.
|
|
1397
1435
|
*
|
|
@@ -1618,12 +1656,7 @@ function isOutsideViewport(rectangle) {
|
|
|
1618
1656
|
*/
|
|
1619
1657
|
function isReachable(element) {
|
|
1620
1658
|
if (!(element instanceof HTMLElement) && !(element instanceof SVGElement)) return false;
|
|
1621
|
-
const chain =
|
|
1622
|
-
let root = element.getRootNode();
|
|
1623
|
-
while (root instanceof ShadowRoot) {
|
|
1624
|
-
chain.push(root.host);
|
|
1625
|
-
root = root.host.getRootNode();
|
|
1626
|
-
}
|
|
1659
|
+
const chain = collectShadowHosts(element);
|
|
1627
1660
|
const rectangle = element.getBoundingClientRect();
|
|
1628
1661
|
return element.isConnected && element.checkVisibility({
|
|
1629
1662
|
checkOpacity: true,
|
|
@@ -1631,6 +1664,21 @@ function isReachable(element) {
|
|
|
1631
1664
|
}) && rectangle.width > 0 && rectangle.height > 0 && element.tabIndex >= 0 && !element.matches(":disabled, [aria-disabled=\"true\"]") && element.closest("[inert]") === null && [...element.ownerDocument.querySelectorAll("[aria-modal=\"true\"]")].every((dialog) => !isRendered(dialog) || chain.some((node) => dialog.contains(node)));
|
|
1632
1665
|
}
|
|
1633
1666
|
/**
|
|
1667
|
+
* Collects an element and the successive hosts of its containing shadow roots.
|
|
1668
|
+
*
|
|
1669
|
+
* @param element - The element that opens the collected chain.
|
|
1670
|
+
* @param root - The root already read by an outer traversal step, or the element's current root.
|
|
1671
|
+
* @example
|
|
1672
|
+
* ```ts
|
|
1673
|
+
* collectShadowHosts(document.body) // [document.body]
|
|
1674
|
+
* ```
|
|
1675
|
+
*/
|
|
1676
|
+
function collectShadowHosts(element, root = element.getRootNode()) {
|
|
1677
|
+
if (!(root instanceof ShadowRoot)) return [element];
|
|
1678
|
+
const host = root.host;
|
|
1679
|
+
return [element, ...collectShadowHosts(host, root.host.getRootNode())];
|
|
1680
|
+
}
|
|
1681
|
+
/**
|
|
1634
1682
|
* Determines whether the accessibility tree presents one element at all.
|
|
1635
1683
|
*
|
|
1636
1684
|
* @param element - The element to judge.
|
|
@@ -1814,15 +1862,13 @@ function resolveRendered(first, second) {
|
|
|
1814
1862
|
}
|
|
1815
1863
|
function resolveAccessible(first, second) {
|
|
1816
1864
|
const target = resolveRendered(first, second);
|
|
1817
|
-
|
|
1818
|
-
if (isOutsideViewport(rectangle)) {
|
|
1865
|
+
if (isOutsideViewport(target.getBoundingClientRect())) {
|
|
1819
1866
|
target.scrollIntoView({
|
|
1820
1867
|
block: "nearest",
|
|
1821
1868
|
behavior: "instant"
|
|
1822
1869
|
});
|
|
1823
|
-
|
|
1870
|
+
if (isOutsideViewport(target.getBoundingClientRect())) throw new Error(`Interactive target "${second ?? first}" is unreachable after scrolling`);
|
|
1824
1871
|
}
|
|
1825
|
-
if (isOutsideViewport(rectangle)) throw new Error(`Interactive target "${second ?? first}" is unreachable after scrolling`);
|
|
1826
1872
|
return target;
|
|
1827
1873
|
}
|
|
1828
1874
|
async function clickAccessible(first, second) {
|
|
@@ -1908,10 +1954,10 @@ async function clickAccessibleWithin(region, role, name) {
|
|
|
1908
1954
|
* @throws When the named control is absent, unreachable, or ambiguous inside the region.
|
|
1909
1955
|
*
|
|
1910
1956
|
* @remarks
|
|
1911
|
-
* The region's name is matched exactly
|
|
1912
|
-
*
|
|
1913
|
-
*
|
|
1914
|
-
*
|
|
1957
|
+
* The region's name is matched exactly. The control first matches the case-sensitive pattern
|
|
1958
|
+
* from `computeNamePattern`, with hidden subtrees included. Any exact candidates own the result,
|
|
1959
|
+
* including unreachable or ambiguous candidates. Only an empty exact tier selects the loose query.
|
|
1960
|
+
* Both tiers refuse zero reachable candidates and several reachable candidates.
|
|
1915
1961
|
*
|
|
1916
1962
|
* @example
|
|
1917
1963
|
* ```ts
|
|
@@ -1919,14 +1965,20 @@ async function clickAccessibleWithin(region, role, name) {
|
|
|
1919
1965
|
* ```
|
|
1920
1966
|
*/
|
|
1921
1967
|
function resolveAccessibleWithin(region, role, name) {
|
|
1922
|
-
const
|
|
1968
|
+
const scope = page.getByRole("region", {
|
|
1923
1969
|
name: region,
|
|
1924
1970
|
exact: true
|
|
1925
|
-
})
|
|
1971
|
+
});
|
|
1972
|
+
const exact = scope.getByRole(role, {
|
|
1973
|
+
name: computeNamePattern(name),
|
|
1974
|
+
exact: true,
|
|
1975
|
+
includeHidden: true
|
|
1976
|
+
}).elements();
|
|
1977
|
+
const reachable = (exact.length > 0 ? exact : scope.getByRole(role, {
|
|
1926
1978
|
name,
|
|
1927
1979
|
exact: false,
|
|
1928
1980
|
includeHidden: true
|
|
1929
|
-
}).elements().filter((element) => element instanceof HTMLElement && isReachable(element));
|
|
1981
|
+
}).elements()).filter((element) => element instanceof HTMLElement && isReachable(element));
|
|
1930
1982
|
if (reachable.length === 0) throw new Error(`Interactive target "${name}" is not reachable inside "${region}"`);
|
|
1931
1983
|
if (reachable.length > 1) throw new Error(`Interactive target "${name}" is ambiguous across ${reachable.length} elements inside "${region}"`);
|
|
1932
1984
|
const [target] = reachable;
|
|
@@ -2106,24 +2158,18 @@ async function parkPointer() {
|
|
|
2106
2158
|
*/
|
|
2107
2159
|
async function releasePointer() {
|
|
2108
2160
|
const held = document.documentElement.getAttribute(POINTER_HOLD);
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
});
|
|
2122
|
-
released = true;
|
|
2123
|
-
}
|
|
2124
|
-
} catch (cause) {
|
|
2125
|
-
rejection = cause;
|
|
2126
|
-
}
|
|
2161
|
+
const [x, y] = held === null ? [] : held.split("x").map(Number);
|
|
2162
|
+
const request = {
|
|
2163
|
+
type: "mouseReleased",
|
|
2164
|
+
x,
|
|
2165
|
+
y,
|
|
2166
|
+
button: "left",
|
|
2167
|
+
buttons: 0,
|
|
2168
|
+
clickCount: 1
|
|
2169
|
+
};
|
|
2170
|
+
const release = held === null ? void 0 : await captureProduction(() => sendProtocol("Input.dispatchMouseEvent", request));
|
|
2171
|
+
const released = release === void 0 || release.status === "fulfilled";
|
|
2172
|
+
const rejection = release?.status === "rejected" ? release.reason : void 0;
|
|
2127
2173
|
if (released) document.documentElement.removeAttribute(POINTER_HOLD);
|
|
2128
2174
|
try {
|
|
2129
2175
|
await parkPointer();
|
|
@@ -2840,7 +2886,9 @@ function readRefusal(first, second) {
|
|
|
2840
2886
|
function readText(element) {
|
|
2841
2887
|
const parts = [];
|
|
2842
2888
|
const walker = element.ownerDocument.createTreeWalker(element, NodeFilter.SHOW_TEXT);
|
|
2843
|
-
|
|
2889
|
+
while (true) {
|
|
2890
|
+
const node = walker.nextNode();
|
|
2891
|
+
if (node === null) break;
|
|
2844
2892
|
const owner = node.parentElement;
|
|
2845
2893
|
if (owner === null || owner.closest("[aria-hidden=\"true\"]") !== null) continue;
|
|
2846
2894
|
parts.push(node.textContent ?? "");
|
|
@@ -3007,14 +3055,14 @@ function describeTree(element) {
|
|
|
3007
3055
|
if (entry === void 0) break;
|
|
3008
3056
|
if (!isRendered(entry.node)) continue;
|
|
3009
3057
|
const role = readRole(entry.node);
|
|
3010
|
-
let depth = entry.depth;
|
|
3011
3058
|
if (role !== void 0) {
|
|
3012
3059
|
const name = readName(entry.node);
|
|
3013
3060
|
const states = readStates(entry.node);
|
|
3014
|
-
lines.push(`${" ".repeat(depth)}${role}${name.length > 0 ? ` "${name}"` : ""}${states.length > 0 ? ` [${states.join(", ")}]` : ""}`);
|
|
3015
|
-
depth += 1;
|
|
3061
|
+
lines.push(`${" ".repeat(entry.depth)}${role}${name.length > 0 ? ` "${name}"` : ""}${states.length > 0 ? ` [${states.join(", ")}]` : ""}`);
|
|
3016
3062
|
}
|
|
3017
|
-
|
|
3063
|
+
const depth = entry.depth + (role === void 0 ? 0 : 1);
|
|
3064
|
+
const length = entry.node.children.length;
|
|
3065
|
+
for (const index of Array.from({ length }, (_, offset) => length - offset - 1)) {
|
|
3018
3066
|
const child = entry.node.children[index];
|
|
3019
3067
|
if (child !== void 0) pending.push({
|
|
3020
3068
|
node: child,
|
|
@@ -3066,24 +3114,22 @@ async function waitForState(first, second, third, fourth) {
|
|
|
3066
3114
|
const options = keyed ? fourth : third;
|
|
3067
3115
|
const absent = options?.absent ?? false;
|
|
3068
3116
|
const description = `"${name}" to ${absent ? "stop announcing" : "announce"} "${state}"`;
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
let refused;
|
|
3072
|
-
try {
|
|
3117
|
+
const observations = [];
|
|
3118
|
+
const waited = await captureProduction(async () => {
|
|
3073
3119
|
await waitForCondition(description, () => {
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
refused = { thrown };
|
|
3079
|
-
throw thrown;
|
|
3080
|
-
}
|
|
3081
|
-
return observed.includes(state) !== absent;
|
|
3120
|
+
const observation = attempt(() => readStates(role === void 0 ? resolveRendered(name) : resolveRendered(role, name)));
|
|
3121
|
+
observations.push(observation);
|
|
3122
|
+
if (!observation.success) throw observation.error;
|
|
3123
|
+
return observation.value.includes(state) !== absent;
|
|
3082
3124
|
}, options);
|
|
3083
|
-
}
|
|
3084
|
-
|
|
3125
|
+
});
|
|
3126
|
+
const observed = observations.reduce((states, observation) => observation.success ? observation.value : states, []);
|
|
3127
|
+
const refused = observations.find((observation) => !observation.success);
|
|
3128
|
+
if (waited.status === "rejected") {
|
|
3129
|
+
const cause = waited.reason;
|
|
3130
|
+
if (refused?.success === false && cause === refused.error) throw cause;
|
|
3085
3131
|
if (cause === options?.signal?.reason) throw cause;
|
|
3086
|
-
if (
|
|
3132
|
+
if (observations.length === 0) throw cause;
|
|
3087
3133
|
if (!isError(cause)) throw cause;
|
|
3088
3134
|
throw new Error(`${cause.message} (last states: ${JSON.stringify(observed)})`, { cause });
|
|
3089
3135
|
}
|
|
@@ -3133,22 +3179,20 @@ async function waitForAnimations(element, options) {
|
|
|
3133
3179
|
const label = readName(element);
|
|
3134
3180
|
const subject = `${readRole(element) ?? element.localName}${label.length > 0 ? ` "${label}"` : ""}`;
|
|
3135
3181
|
const start = performance.now();
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
const
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
}, budget);
|
|
3144
|
-
});
|
|
3182
|
+
const deadline = new AbortController();
|
|
3183
|
+
const aborts = /* @__PURE__ */ new Map();
|
|
3184
|
+
const expiry = Promise.withResolvers();
|
|
3185
|
+
const timer = setTimeout(() => {
|
|
3186
|
+
deadline.abort();
|
|
3187
|
+
expiry.resolve();
|
|
3188
|
+
}, budget);
|
|
3145
3189
|
try {
|
|
3146
3190
|
while (true) {
|
|
3147
3191
|
signal?.throwIfAborted();
|
|
3148
3192
|
const running = readAnimations(element).finite;
|
|
3149
3193
|
if (running.length === 0) return;
|
|
3150
3194
|
const elapsed = performance.now() - start;
|
|
3151
|
-
if (
|
|
3195
|
+
if (deadline.signal.aborted || elapsed >= budget) {
|
|
3152
3196
|
const names = running.map((animation) => {
|
|
3153
3197
|
if (animation instanceof CSSAnimation) return animation.animationName;
|
|
3154
3198
|
if (animation instanceof CSSTransition) return animation.transitionProperty;
|
|
@@ -3157,15 +3201,16 @@ async function waitForAnimations(element, options) {
|
|
|
3157
3201
|
throw new Error(`Animation "${subject}" did not settle within ${budget}ms (waited ${elapsed}ms): ${names.join(", ")}`);
|
|
3158
3202
|
}
|
|
3159
3203
|
const pending = running.map((animation) => animation.finished.catch(() => void 0));
|
|
3160
|
-
pending.push(expiry);
|
|
3204
|
+
pending.push(expiry.promise);
|
|
3161
3205
|
if (signal !== void 0) {
|
|
3162
|
-
aborted
|
|
3206
|
+
const aborted = aborts.get(signal) ?? waitForAbort(signal);
|
|
3207
|
+
if (!aborts.has(signal)) aborts.set(signal, aborted);
|
|
3163
3208
|
pending.push(aborted);
|
|
3164
3209
|
}
|
|
3165
3210
|
await Promise.race(pending);
|
|
3166
3211
|
}
|
|
3167
3212
|
} finally {
|
|
3168
|
-
|
|
3213
|
+
clearTimeout(timer);
|
|
3169
3214
|
}
|
|
3170
3215
|
}
|
|
3171
3216
|
/**
|
|
@@ -3453,8 +3498,110 @@ function readRows(root, selector) {
|
|
|
3453
3498
|
function buildDenial(operation, key) {
|
|
3454
3499
|
return new DOMException(`Access is denied for ${operation}${key === void 0 ? "" : ` "${key}"`}`, "SecurityError");
|
|
3455
3500
|
}
|
|
3456
|
-
|
|
3457
|
-
|
|
3501
|
+
// src/browser/journeys/Journal.ts
|
|
3502
|
+
/** Owns the state and console subscriptions behind a journal projection. */
|
|
3503
|
+
var Journal = class {
|
|
3504
|
+
#steps = [];
|
|
3505
|
+
#output = [];
|
|
3506
|
+
#intercepted;
|
|
3507
|
+
#listeners;
|
|
3508
|
+
get steps() {
|
|
3509
|
+
return [...this.#steps];
|
|
3510
|
+
}
|
|
3511
|
+
get output() {
|
|
3512
|
+
return [...this.#output];
|
|
3513
|
+
}
|
|
3514
|
+
start() {
|
|
3515
|
+
this.#steps.length = 0;
|
|
3516
|
+
this.#output.length = 0;
|
|
3517
|
+
if (this.#intercepted !== void 0) return;
|
|
3518
|
+
const forwarded = {
|
|
3519
|
+
debug: console.debug,
|
|
3520
|
+
error: console.error,
|
|
3521
|
+
info: console.info,
|
|
3522
|
+
log: console.log,
|
|
3523
|
+
warn: console.warn
|
|
3524
|
+
};
|
|
3525
|
+
this.#intercepted = forwarded;
|
|
3526
|
+
for (const channel of [
|
|
3527
|
+
"debug",
|
|
3528
|
+
"error",
|
|
3529
|
+
"info",
|
|
3530
|
+
"log",
|
|
3531
|
+
"warn"
|
|
3532
|
+
]) console[channel] = createChannel(channel, this.#output, forwarded[channel]);
|
|
3533
|
+
const dropped = new AbortController();
|
|
3534
|
+
this.#listeners = dropped;
|
|
3535
|
+
window.addEventListener("error", (event) => {
|
|
3536
|
+
this.#output.push(`error: ${event.message}`);
|
|
3537
|
+
}, { signal: dropped.signal });
|
|
3538
|
+
window.addEventListener("unhandledrejection", (event) => {
|
|
3539
|
+
this.#output.push(`rejection: ${String(event.reason)}`);
|
|
3540
|
+
}, { signal: dropped.signal });
|
|
3541
|
+
}
|
|
3542
|
+
stop() {
|
|
3543
|
+
if (this.#intercepted === void 0) return;
|
|
3544
|
+
Object.assign(console, this.#intercepted);
|
|
3545
|
+
this.#intercepted = void 0;
|
|
3546
|
+
this.#listeners?.abort();
|
|
3547
|
+
this.#listeners = void 0;
|
|
3548
|
+
}
|
|
3549
|
+
record(action, trigger, result) {
|
|
3550
|
+
if (this.#intercepted === void 0) return;
|
|
3551
|
+
this.#steps.push(Object.freeze({
|
|
3552
|
+
action,
|
|
3553
|
+
trigger,
|
|
3554
|
+
result
|
|
3555
|
+
}));
|
|
3556
|
+
}
|
|
3557
|
+
};
|
|
3558
|
+
// src/browser/journeys/WebStorage.ts
|
|
3559
|
+
/** Owns permissions, values, and quota behind a Web Storage projection. */
|
|
3560
|
+
var WebStorage = class {
|
|
3561
|
+
#values;
|
|
3562
|
+
#reads;
|
|
3563
|
+
#writes;
|
|
3564
|
+
#room;
|
|
3565
|
+
constructor(options, quota) {
|
|
3566
|
+
this.#values = new Map(Object.entries(options?.values ?? {}));
|
|
3567
|
+
this.#reads = options?.reads ?? true;
|
|
3568
|
+
this.#writes = options?.writes ?? true;
|
|
3569
|
+
this.#room = quota;
|
|
3570
|
+
}
|
|
3571
|
+
get length() {
|
|
3572
|
+
if (!this.#reads) throw buildDenial("length");
|
|
3573
|
+
return this.#values.size;
|
|
3574
|
+
}
|
|
3575
|
+
permit() {
|
|
3576
|
+
this.#reads = true;
|
|
3577
|
+
this.#writes = true;
|
|
3578
|
+
}
|
|
3579
|
+
clear() {
|
|
3580
|
+
if (!this.#writes) throw buildDenial("clear");
|
|
3581
|
+
this.#values.clear();
|
|
3582
|
+
}
|
|
3583
|
+
getItem(key) {
|
|
3584
|
+
if (!this.#reads) throw buildDenial("getItem", key);
|
|
3585
|
+
return this.#values.get(key) ?? null;
|
|
3586
|
+
}
|
|
3587
|
+
key(index) {
|
|
3588
|
+
if (!this.#reads) throw buildDenial("key");
|
|
3589
|
+
return [...this.#values.keys()][index] ?? null;
|
|
3590
|
+
}
|
|
3591
|
+
removeItem(key) {
|
|
3592
|
+
if (!this.#writes) throw buildDenial("removeItem", key);
|
|
3593
|
+
this.#values.delete(key);
|
|
3594
|
+
}
|
|
3595
|
+
setItem(key, value) {
|
|
3596
|
+
if (!this.#writes) throw buildDenial("setItem", key);
|
|
3597
|
+
if (this.#room !== void 0) {
|
|
3598
|
+
if (this.#room === 0) throw new DOMException(`No room is left for ${key}`, "QuotaExceededError");
|
|
3599
|
+
this.#room -= 1;
|
|
3600
|
+
}
|
|
3601
|
+
this.#values.set(key, value);
|
|
3602
|
+
}
|
|
3603
|
+
};
|
|
3604
|
+
// src/browser/journeys/factories.ts
|
|
3458
3605
|
/**
|
|
3459
3606
|
* Creates one console channel that records every call it receives and hands that call on unchanged.
|
|
3460
3607
|
*
|
|
@@ -3510,60 +3657,17 @@ function createChannel(name, output, forward) {
|
|
|
3510
3657
|
* ```
|
|
3511
3658
|
*/
|
|
3512
3659
|
function createJournal() {
|
|
3513
|
-
const
|
|
3514
|
-
const output = [];
|
|
3515
|
-
let intercepted;
|
|
3516
|
-
let listeners;
|
|
3660
|
+
const journal = new Journal();
|
|
3517
3661
|
return {
|
|
3518
3662
|
get steps() {
|
|
3519
|
-
return
|
|
3663
|
+
return journal.steps;
|
|
3520
3664
|
},
|
|
3521
3665
|
get output() {
|
|
3522
|
-
return
|
|
3523
|
-
},
|
|
3524
|
-
start() {
|
|
3525
|
-
steps.length = 0;
|
|
3526
|
-
output.length = 0;
|
|
3527
|
-
if (intercepted !== void 0) return;
|
|
3528
|
-
const forwarded = {
|
|
3529
|
-
debug: console.debug,
|
|
3530
|
-
error: console.error,
|
|
3531
|
-
info: console.info,
|
|
3532
|
-
log: console.log,
|
|
3533
|
-
warn: console.warn
|
|
3534
|
-
};
|
|
3535
|
-
intercepted = forwarded;
|
|
3536
|
-
for (const channel of [
|
|
3537
|
-
"debug",
|
|
3538
|
-
"error",
|
|
3539
|
-
"info",
|
|
3540
|
-
"log",
|
|
3541
|
-
"warn"
|
|
3542
|
-
]) console[channel] = createChannel(channel, output, forwarded[channel]);
|
|
3543
|
-
const dropped = new AbortController();
|
|
3544
|
-
listeners = dropped;
|
|
3545
|
-
window.addEventListener("error", (event) => {
|
|
3546
|
-
output.push(`error: ${event.message}`);
|
|
3547
|
-
}, { signal: dropped.signal });
|
|
3548
|
-
window.addEventListener("unhandledrejection", (event) => {
|
|
3549
|
-
output.push(`rejection: ${String(event.reason)}`);
|
|
3550
|
-
}, { signal: dropped.signal });
|
|
3551
|
-
},
|
|
3552
|
-
stop() {
|
|
3553
|
-
if (intercepted === void 0) return;
|
|
3554
|
-
Object.assign(console, intercepted);
|
|
3555
|
-
intercepted = void 0;
|
|
3556
|
-
listeners?.abort();
|
|
3557
|
-
listeners = void 0;
|
|
3666
|
+
return journal.output;
|
|
3558
3667
|
},
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
action,
|
|
3563
|
-
trigger,
|
|
3564
|
-
result
|
|
3565
|
-
}));
|
|
3566
|
-
}
|
|
3668
|
+
start: journal.start.bind(journal),
|
|
3669
|
+
stop: journal.stop.bind(journal),
|
|
3670
|
+
record: journal.record.bind(journal)
|
|
3567
3671
|
};
|
|
3568
3672
|
}
|
|
3569
3673
|
/**
|
|
@@ -3611,43 +3715,17 @@ function createJournal() {
|
|
|
3611
3715
|
function createStorage(options) {
|
|
3612
3716
|
const quota = options?.quota;
|
|
3613
3717
|
if (quota !== void 0 && (!Number.isSafeInteger(quota) || quota < 0)) throw new Error("Storage quota must be a non-negative integer");
|
|
3614
|
-
const
|
|
3615
|
-
let reads = options?.reads ?? true;
|
|
3616
|
-
let writes = options?.writes ?? true;
|
|
3617
|
-
let room = quota;
|
|
3718
|
+
const storage = new WebStorage(options, quota);
|
|
3618
3719
|
return {
|
|
3619
3720
|
get length() {
|
|
3620
|
-
|
|
3621
|
-
return values.size;
|
|
3622
|
-
},
|
|
3623
|
-
permit() {
|
|
3624
|
-
reads = true;
|
|
3625
|
-
writes = true;
|
|
3626
|
-
},
|
|
3627
|
-
clear() {
|
|
3628
|
-
if (!writes) throw buildDenial("clear");
|
|
3629
|
-
values.clear();
|
|
3630
|
-
},
|
|
3631
|
-
getItem(key) {
|
|
3632
|
-
if (!reads) throw buildDenial("getItem", key);
|
|
3633
|
-
return values.get(key) ?? null;
|
|
3634
|
-
},
|
|
3635
|
-
key(index) {
|
|
3636
|
-
if (!reads) throw buildDenial("key");
|
|
3637
|
-
return [...values.keys()][index] ?? null;
|
|
3638
|
-
},
|
|
3639
|
-
removeItem(key) {
|
|
3640
|
-
if (!writes) throw buildDenial("removeItem", key);
|
|
3641
|
-
values.delete(key);
|
|
3721
|
+
return storage.length;
|
|
3642
3722
|
},
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
values.set(key, value);
|
|
3650
|
-
}
|
|
3723
|
+
permit: storage.permit.bind(storage),
|
|
3724
|
+
clear: storage.clear.bind(storage),
|
|
3725
|
+
getItem: storage.getItem.bind(storage),
|
|
3726
|
+
key: storage.key.bind(storage),
|
|
3727
|
+
removeItem: storage.removeItem.bind(storage),
|
|
3728
|
+
setItem: storage.setItem.bind(storage)
|
|
3651
3729
|
};
|
|
3652
3730
|
}
|
|
3653
3731
|
/**
|
|
@@ -3750,34 +3828,25 @@ function createHarness(options) {
|
|
|
3750
3828
|
for (const row of table) row.element.removeAttribute(STATECHART_ATTRIBUTES.result);
|
|
3751
3829
|
state.removeAttribute(STATECHART_ATTRIBUTES.state);
|
|
3752
3830
|
state.textContent = "";
|
|
3753
|
-
|
|
3754
|
-
let failed = 0;
|
|
3831
|
+
const outcomes = [];
|
|
3755
3832
|
root.setAttribute(STATECHART_ATTRIBUTES.passed, "0");
|
|
3756
3833
|
root.setAttribute(STATECHART_ATTRIBUTES.failed, "0");
|
|
3757
3834
|
root.setAttribute(STATECHART_ATTRIBUTES.status, "running");
|
|
3758
3835
|
announcer.textContent = `Statechart harness is running, 0 passed and 0 failed of ${table.length}.`;
|
|
3759
3836
|
try {
|
|
3760
3837
|
for (const [index, row] of table.entries()) {
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
}
|
|
3768
|
-
if (built !== void 0) {
|
|
3769
|
-
try {
|
|
3770
|
-
await executeScenario(row.scenario, built.context);
|
|
3771
|
-
} catch (cause) {
|
|
3772
|
-
if (!isError(cause)) throw cause;
|
|
3773
|
-
refusal = cause.message;
|
|
3774
|
-
}
|
|
3775
|
-
const current = options.state(built.context);
|
|
3838
|
+
const built = await captureProduction(() => options.build(row.scenario));
|
|
3839
|
+
const executed = built.status === "fulfilled" ? await captureProduction(() => executeScenario(row.scenario, built.value)) : void 0;
|
|
3840
|
+
if (executed?.status === "rejected" && !isError(executed.reason)) throw executed.reason;
|
|
3841
|
+
const refusal = built.status === "rejected" ? buildRefusal(row.scenario.transition.name, built.reason).message : executed?.status === "rejected" && isError(executed.reason) ? executed.reason.message : void 0;
|
|
3842
|
+
if (built.status === "fulfilled") {
|
|
3843
|
+
const current = options.state(built.value);
|
|
3776
3844
|
state.setAttribute(STATECHART_ATTRIBUTES.state, current);
|
|
3777
3845
|
state.textContent = current;
|
|
3778
3846
|
}
|
|
3779
|
-
|
|
3780
|
-
|
|
3847
|
+
outcomes.push(refusal === void 0);
|
|
3848
|
+
const passed = outcomes.filter((outcome) => outcome).length;
|
|
3849
|
+
const failed = outcomes.length - passed;
|
|
3781
3850
|
row.element.setAttribute(STATECHART_ATTRIBUTES.result, refusal === void 0 ? "passed" : "failed");
|
|
3782
3851
|
root.setAttribute(STATECHART_ATTRIBUTES.passed, String(passed));
|
|
3783
3852
|
root.setAttribute(STATECHART_ATTRIBUTES.failed, String(failed));
|
|
@@ -3785,10 +3854,14 @@ function createHarness(options) {
|
|
|
3785
3854
|
if (options.pause !== void 0 && index < table.length - 1) await waitForDelay(options.pause);
|
|
3786
3855
|
}
|
|
3787
3856
|
} catch (cause) {
|
|
3857
|
+
const passed = outcomes.filter((outcome) => outcome).length;
|
|
3858
|
+
const failed = outcomes.length - passed;
|
|
3788
3859
|
root.setAttribute(STATECHART_ATTRIBUTES.status, "failed");
|
|
3789
3860
|
announcer.textContent = `Statechart harness failed, ${passed} passed and ${failed} failed of ${table.length}.`;
|
|
3790
3861
|
throw cause;
|
|
3791
3862
|
}
|
|
3863
|
+
const passed = outcomes.filter((result) => result).length;
|
|
3864
|
+
const failed = outcomes.length - passed;
|
|
3792
3865
|
const outcome = failed === 0 ? "passed" : "failed";
|
|
3793
3866
|
root.setAttribute(STATECHART_ATTRIBUTES.status, outcome);
|
|
3794
3867
|
announcer.textContent = `Statechart harness ${outcome}, ${passed} passed and ${failed} failed of ${table.length}.`;
|
|
@@ -3905,8 +3978,7 @@ function createKeyboardEvent(name, options) {
|
|
|
3905
3978
|
...options
|
|
3906
3979
|
});
|
|
3907
3980
|
}
|
|
3908
|
-
|
|
3909
|
-
//#region src/browser/captures/factories.ts
|
|
3981
|
+
// src/browser/captures/factories.ts
|
|
3910
3982
|
/**
|
|
3911
3983
|
* Creates the capture portfolio one run places its screenshots through; a disabled run still refuses.
|
|
3912
3984
|
*
|
|
@@ -3977,8 +4049,7 @@ function createPortfolio(options) {
|
|
|
3977
4049
|
}
|
|
3978
4050
|
};
|
|
3979
4051
|
}
|
|
3980
|
-
|
|
3981
|
-
//#region src/browser/colors/constants.ts
|
|
4052
|
+
// src/browser/colors/constants.ts
|
|
3982
4053
|
/**
|
|
3983
4054
|
* Names the color a browser paints an unstyled document with: opaque white.
|
|
3984
4055
|
*
|
|
@@ -3993,8 +4064,7 @@ var CANVAS_COLOR = Object.freeze([
|
|
|
3993
4064
|
255,
|
|
3994
4065
|
1
|
|
3995
4066
|
]);
|
|
3996
|
-
|
|
3997
|
-
//#region src/browser/colors/helpers.ts
|
|
4067
|
+
// src/browser/colors/helpers.ts
|
|
3998
4068
|
/**
|
|
3999
4069
|
* Converts normalized encoded sRGB channels to the clipped paint scale.
|
|
4000
4070
|
*
|
|
@@ -4507,20 +4577,12 @@ function measureContrast(front, back) {
|
|
|
4507
4577
|
* ```
|
|
4508
4578
|
*/
|
|
4509
4579
|
function readLayers(element) {
|
|
4510
|
-
const
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
if (/\/\s*(?:0(?:\.0*)?|none)\s*\)$/u.test(computed)) continue;
|
|
4517
|
-
throw new Error(`Computed background color is unreadable on ${node.localName}${node.id === "" ? "" : `#${node.id}`}: ${computed}`);
|
|
4518
|
-
}
|
|
4519
|
-
if (layer[3] === 0) continue;
|
|
4520
|
-
layers.push(layer);
|
|
4521
|
-
if (layer[3] >= 1) break;
|
|
4522
|
-
}
|
|
4523
|
-
return Object.freeze(layers);
|
|
4580
|
+
const computed = getComputedStyle(element).backgroundColor;
|
|
4581
|
+
const layer = computed === "" ? void 0 : parseColor(computed);
|
|
4582
|
+
if (layer === void 0 && computed !== "" && !/\/\s*(?:0(?:\.0*)?|none)\s*\)$/u.test(computed)) throw new Error(`Computed background color is unreadable on ${element.localName}${element.id === "" ? "" : `#${element.id}`}: ${computed}`);
|
|
4583
|
+
if (layer !== void 0 && layer[3] >= 1) return Object.freeze([layer]);
|
|
4584
|
+
const parent = element.parentElement;
|
|
4585
|
+
return Object.freeze([...layer === void 0 || layer[3] === 0 ? [] : [layer], ...parent === null ? [] : readLayers(parent)]);
|
|
4524
4586
|
}
|
|
4525
4587
|
/**
|
|
4526
4588
|
* Resolves the opaque color standing behind one element.
|
|
@@ -4760,20 +4822,21 @@ function buildContrast(bar) {
|
|
|
4760
4822
|
tint[2],
|
|
4761
4823
|
1
|
|
4762
4824
|
];
|
|
4763
|
-
|
|
4764
|
-
let acceptedChannel;
|
|
4765
|
-
for (let channel = 0; channel <= 255; channel += 1) {
|
|
4825
|
+
const channels = Array.from({ length: 256 }, (_, channel) => {
|
|
4766
4826
|
const front = [
|
|
4767
4827
|
channel,
|
|
4768
4828
|
channel,
|
|
4769
4829
|
channel,
|
|
4770
4830
|
1
|
|
4771
4831
|
];
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4832
|
+
return {
|
|
4833
|
+
channel,
|
|
4834
|
+
composited: measureContrast(front, backdrop),
|
|
4835
|
+
flat: measureContrast(front, flattened)
|
|
4836
|
+
};
|
|
4837
|
+
});
|
|
4838
|
+
const refusedChannel = channels.find(({ composited, flat }) => composited < bar && flat >= bar)?.channel;
|
|
4839
|
+
const acceptedChannel = channels.find(({ composited, flat }) => composited >= bar && flat < bar)?.channel;
|
|
4777
4840
|
if (refusedChannel === void 0 || acceptedChannel === void 0) throw new Error(`Contrast control cannot straddle the bar ${bar}`);
|
|
4778
4841
|
const root = build("div", { attributes: { style: `background-color: rgb(${CANVAS_COLOR[0]}, ${CANVAS_COLOR[1]}, ${CANVAS_COLOR[2]})` } });
|
|
4779
4842
|
const tinted = build("div", { attributes: { style: `background-color: rgba(${tint[0]}, ${tint[1]}, ${tint[2]}, ${tint[3]})` } });
|
|
@@ -4793,8 +4856,7 @@ function buildContrast(bar) {
|
|
|
4793
4856
|
accepted
|
|
4794
4857
|
});
|
|
4795
4858
|
}
|
|
4796
|
-
|
|
4797
|
-
//#region src/browser/sheets/helpers.ts
|
|
4859
|
+
// src/browser/sheets/helpers.ts
|
|
4798
4860
|
/**
|
|
4799
4861
|
* Adopts CSS text into the document with an idempotent release operation.
|
|
4800
4862
|
*
|
|
@@ -4976,10 +5038,7 @@ function readRules() {
|
|
|
4976
5038
|
} catch {
|
|
4977
5039
|
continue;
|
|
4978
5040
|
}
|
|
4979
|
-
for (
|
|
4980
|
-
const rule = rules[index];
|
|
4981
|
-
if (rule instanceof CSSGroupingRule) rules.push(...rule.cssRules);
|
|
4982
|
-
}
|
|
5041
|
+
for (const rule of rules) if (rule instanceof CSSGroupingRule) rules.push(...rule.cssRules);
|
|
4983
5042
|
return rules;
|
|
4984
5043
|
}
|
|
4985
5044
|
/**
|
|
@@ -5219,7 +5278,6 @@ function buildCensus() {
|
|
|
5219
5278
|
mark
|
|
5220
5279
|
});
|
|
5221
5280
|
}
|
|
5222
|
-
|
|
5223
|
-
export { ACCESSIBLE_ROLES, CANVAS_COLOR, CAPTURE_PANE, CAPTURE_STAGE_LIMIT, CONTENT_ROLES, FIELD_ROLES, FOCUSABLE_SELECTOR, FOCUS_SEGMENT_LIMIT, HEADER_ROLES, IMPLICIT_ROLES, MEDIA_STAGE, POINTER_HOLD, SEGMENTED_INPUT_TYPES, adoptSheet, blendColor, build, buildCensus, buildContrast, buildDenial, buildEscapes, captureFrame, chooseAccessible, clearStorage, clickAccessible, clickAccessibleWithin, clickDisclosure, clipsOverflow, collectClippingAncestors, collectScrollRegions, collectTabStops, commitInput, computeNamePattern, computeOffset, containsNode, convertA98RGB, convertDisplayP3, convertLab, convertLinearSRGB, convertOKLab, convertProPhotoRGB, convertRec2020, convertSRGB, convertXYZD50, convertXYZD65, countElements, createChannel, createDragEvent, createHarness, createJournal, createKeyboardEvent, createPointerEvent, createPortfolio, createStorage, describeFocus, describeScrollRegions, describeTree, driveHold, driveTraversal, expandCaptures, extractOrphans, extractStyles, fillAccessible, findKeyframes, findRule, holdAccessible, holdAccessibleWithin, hoverAccessible, isOutsideViewport, isReachable, isRendered, matchesColor, matchesTraversalName, measureContent, measureContrast, measureLuminance, mount, paintImage, parkPointer, parseCSSColor, parseColor, pressKeys, readAccessibilityNode, readActiveElement, readAnimations, readBackdrop, readCaptureReader, readCascade, readCensus, readClasses, readClipEdge, readClipMargin, readClippedBlock, readColorContrast, readContrast, readFocus, readFrame, readHit, readLayerNames, readLayers, readName, readPage, readPerception, readPixels, readProtocolNode, readProtocolPoint, readRefusal, readRing, readRole, readRootToken, readRows, readRules, readShotPixel, readStates, readStyle, readText, readToken, readValue, releaseMedia, releasePane, releasePointer, releaseTouch, removeDatabase, render, resolveAccessible, resolveAccessibleWithin, resolveFileInput, resolveRendered, sendFileDrag, sendProtocol, sendTouch, settleCapture, stageMedia, stagePane, stepFocus, supportsSegmentedFocus, tapTouch, traverseAccessible, traverseAccessibleWithin, typeAccessible, typeInput, verifyFrame, waitForAnimations, waitForFrame, waitForStability, waitForState, walkFocus };
|
|
5281
|
+
export { ACCESSIBLE_ROLES, CANVAS_COLOR, CAPTURE_PANE, CAPTURE_STAGE_LIMIT, CONTENT_ROLES, FIELD_ROLES, FOCUSABLE_SELECTOR, FOCUS_SEGMENT_LIMIT, HEADER_ROLES, IMPLICIT_ROLES, MEDIA_STAGE, POINTER_HOLD, SEGMENTED_INPUT_TYPES, adoptSheet, blendColor, build, buildCensus, buildContrast, buildDenial, buildEscapes, captureFrame, chooseAccessible, clearStorage, clickAccessible, clickAccessibleWithin, clickDisclosure, clipsOverflow, collectClippingAncestors, collectScrollRegions, collectShadowHosts, collectTabStops, commitInput, computeNamePattern, computeOffset, containsNode, convertA98RGB, convertDisplayP3, convertLab, convertLinearSRGB, convertOKLab, convertProPhotoRGB, convertRec2020, convertSRGB, convertXYZD50, convertXYZD65, countElements, createChannel, createDragEvent, createHarness, createJournal, createKeyboardEvent, createPointerEvent, createPortfolio, createStorage, describeFocus, describeScrollRegions, describeTree, driveHold, driveTraversal, expandCaptures, extractOrphans, extractStyles, fillAccessible, findKeyframes, findRule, holdAccessible, holdAccessibleWithin, hoverAccessible, isOutsideViewport, isReachable, isRendered, matchesColor, matchesTraversalName, measureContent, measureContrast, measureLuminance, mount, paintImage, parkPointer, parseCSSColor, parseColor, pressKeys, readAccessibilityNode, readActiveElement, readAnimations, readBackdrop, readCaptureReader, readCascade, readCensus, readClasses, readClipEdge, readClipMargin, readClippedBlock, readColorContrast, readContrast, readFocus, readFrame, readFrameHeight, readHit, readLayerNames, readLayers, readName, readPage, readPerception, readPixels, readProtocolNode, readProtocolPoint, readProtocolSession, readRefusal, readRing, readRole, readRootToken, readRows, readRules, readShotPixel, readStates, readStyle, readText, readToken, readValue, releaseMedia, releasePane, releasePointer, releaseTouch, removeDatabase, render, resolveAccessible, resolveAccessibleWithin, resolveFileInput, resolveRendered, sendFileDrag, sendProtocol, sendTouch, settleCapture, settleFrame, stageMedia, stagePane, stepFocus, supportsSegmentedFocus, takeFrameShot, tapTouch, traverseAccessible, traverseAccessibleWithin, typeAccessible, typeInput, verifyFrame, waitForAnimations, waitForFrame, waitForStability, waitForState, walkFocus };
|
|
5224
5282
|
|
|
5225
5283
|
//# sourceMappingURL=index.js.map
|