@botiverse/porthole 0.9.0 → 0.10.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/dist/annotate/types.d.ts +3 -1
- package/dist/annotate/validate.d.ts +7 -2
- package/dist/annotate/validate.js +11 -4
- package/dist/bridge/bridge.js +1 -51
- package/dist/bridge/unseen.d.ts +18 -0
- package/dist/bridge/unseen.js +71 -0
- package/dist/check/page-source.js +1 -1
- package/dist/conformance/behavior.js +107 -68
- package/dist/conformance/clipboard.js +16 -14
- package/dist/conformance/harness-source.js +1 -1
- package/dist/conformance/limits.js +117 -64
- package/dist/conformance/probes.js +66 -49
- package/dist/conformance/served.js +66 -63
- package/dist/host/create-host.js +44 -2
- package/dist/platform/types.d.ts +4 -2
- package/dist/shell/annotate.d.ts +5 -3
- package/dist/shell/annotate.js +453 -100
- package/docs/ADOPTING.md +76 -0
- package/docs/DECISIONS.md +374 -13
- package/docs/DESIGN.md +166 -38
- package/docs/THREAT_MODEL.md +72 -25
- package/package.json +1 -1
- package/src/annotate/types.ts +3 -1
- package/src/annotate/validate.ts +12 -5
- package/src/bridge/bridge.ts +1 -60
- package/src/bridge/unseen.ts +82 -0
- package/src/conformance/behavior.ts +221 -69
- package/src/conformance/clipboard.ts +44 -14
- package/src/conformance/limits.ts +169 -76
- package/src/conformance/probes.ts +97 -49
- package/src/conformance/served.ts +112 -63
- package/src/host/create-host.ts +42 -2
- package/src/platform/types.ts +4 -2
- package/src/shell/annotate.ts +453 -100
|
@@ -14,10 +14,16 @@ const variable = (frame, name) => frame.evaluate((each) => getComputedStyle(docu
|
|
|
14
14
|
/** Polls the frame element's height until it is `px` (± 1). */
|
|
15
15
|
async function expectHeight(display, px, message) {
|
|
16
16
|
await expect
|
|
17
|
-
.poll(async () => Math.round((await display.box()).height), {
|
|
17
|
+
.poll(async () => Math.round((await display.box()).height), {
|
|
18
|
+
message: `probe: ${message}`,
|
|
19
|
+
timeout: 5_000,
|
|
20
|
+
})
|
|
18
21
|
.toBeGreaterThanOrEqual(px - 1);
|
|
19
22
|
await expect
|
|
20
|
-
.poll(async () => Math.round((await display.box()).height), {
|
|
23
|
+
.poll(async () => Math.round((await display.box()).height), {
|
|
24
|
+
message: `probe: ${message}`,
|
|
25
|
+
timeout: 5_000,
|
|
26
|
+
})
|
|
21
27
|
.toBeLessThanOrEqual(px + 1);
|
|
22
28
|
}
|
|
23
29
|
/** The refusals the display reported, by capability. */
|
|
@@ -44,14 +50,30 @@ async function clickAfterLapse(context, display, selector) {
|
|
|
44
50
|
await context.page.waitForTimeout(ACTIVATION_LAPSE_MS);
|
|
45
51
|
await context.page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
|
|
46
52
|
}
|
|
47
|
-
/**
|
|
48
|
-
|
|
53
|
+
/**
|
|
54
|
+
* The attribute `name` of the frame's body, once set. Where it is a gate's answer to the content,
|
|
55
|
+
* `verdict` is the probe's: an answer that never comes (a call left waiting on a gate that should
|
|
56
|
+
* have refused it) fails the probe's verdict, not its setup (P096).
|
|
57
|
+
*/
|
|
58
|
+
async function bodyData(display, name, verdict, timeout = 5_000) {
|
|
49
59
|
const frame = await display.frame();
|
|
50
60
|
await expect
|
|
51
|
-
.poll(() => frame.locator("body").getAttribute(`data-${name}`), {
|
|
61
|
+
.poll(() => frame.locator("body").getAttribute(`data-${name}`), {
|
|
62
|
+
timeout,
|
|
63
|
+
...(verdict === undefined ? {} : { message: verdict }),
|
|
64
|
+
})
|
|
52
65
|
.not.toBeNull();
|
|
53
66
|
return (await frame.locator("body").getAttribute(`data-${name}`)) ?? "";
|
|
54
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* The next confirmation, answered, where the gate must ask one now: none coming
|
|
70
|
+
* (`answerNextConfirmation` rejects) is the probe's verdict failing, `verdict` (P096).
|
|
71
|
+
*/
|
|
72
|
+
async function answered(display, accept, verdict) {
|
|
73
|
+
const request = await display.answerNextConfirmation(accept).catch(() => undefined);
|
|
74
|
+
expect(request, verdict).toBeDefined();
|
|
75
|
+
return request;
|
|
76
|
+
}
|
|
55
77
|
/** A model context update (P100): what the view says the person is looking at. */
|
|
56
78
|
const CONTEXT_UPDATE = {
|
|
57
79
|
content: [{ type: "text", text: "The person is looking at March's signups." }],
|
|
@@ -101,7 +123,7 @@ export const BEHAVIOR_PROBES = [
|
|
|
101
123
|
1;
|
|
102
124
|
});
|
|
103
125
|
await display.setContent(step2, { partial: true });
|
|
104
|
-
await expect(frame.locator("#r2")).toHaveText("two");
|
|
126
|
+
await expect(frame.locator("#r2"), "probe: the next draft is drawn").toHaveText("two");
|
|
105
127
|
expect(await read(frame, () => ({
|
|
106
128
|
kept: document.getElementById("img")
|
|
107
129
|
.portholeMark,
|
|
@@ -109,16 +131,16 @@ export const BEHAVIOR_PROBES = [
|
|
|
109
131
|
href: document.getElementById("js")?.getAttribute("href") ?? null,
|
|
110
132
|
handler: document.getElementById("b")?.getAttribute("onclick") ?? null,
|
|
111
133
|
scripts: document.querySelectorAll("#porthole-root script").length,
|
|
112
|
-
}))).toEqual({ kept: 1, ran: null, href: null, handler: null, scripts: 0 });
|
|
134
|
+
})), "probe: a draft keeps what was drawn and is inert").toEqual({ kept: 1, ran: null, href: null, handler: null, scripts: 0 });
|
|
113
135
|
await display.setContent(whole);
|
|
114
|
-
await expect(frame.locator("body")).toHaveAttribute("data-ran", "1");
|
|
115
|
-
expect(await frame.locator("#b").getAttribute("onclick")).not.toBeNull();
|
|
136
|
+
await expect(frame.locator("body"), "probe: the whole ran once").toHaveAttribute("data-ran", "1");
|
|
137
|
+
expect(await frame.locator("#b").getAttribute("onclick"), "probe: the whole keeps its handlers").not.toBeNull();
|
|
116
138
|
// The whole goes once: sending it again, or a late draft, changes nothing.
|
|
117
139
|
await display.setContent(whole);
|
|
118
140
|
await display.setContent(head, { partial: true });
|
|
119
141
|
await settle(400);
|
|
120
|
-
await expect(frame.locator("body")).toHaveAttribute("data-ran", "1");
|
|
121
|
-
await expect(frame.locator("#r2")).toHaveText("two");
|
|
142
|
+
await expect(frame.locator("body"), "probe: the whole ran only once").toHaveAttribute("data-ran", "1");
|
|
143
|
+
await expect(frame.locator("#r2"), "probe: a late draft changed what was drawn").toHaveText("two");
|
|
122
144
|
},
|
|
123
145
|
},
|
|
124
146
|
// ── 11: sizing ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -138,15 +160,15 @@ export const BEHAVIOR_PROBES = [
|
|
|
138
160
|
await expectHeight(display, 300, "grows with it");
|
|
139
161
|
await frame.evaluate(() => window.setBox(1_000));
|
|
140
162
|
await expectHeight(display, 400, "stops at maxHeightPx");
|
|
141
|
-
expect(await read(frame, () => document.documentElement.scrollHeight > document.documentElement.clientHeight), "past its height, the content scrolls inside").toBe(true);
|
|
163
|
+
expect(await read(frame, () => document.documentElement.scrollHeight > document.documentElement.clientHeight), "probe: past its height, the content scrolls inside").toBe(true);
|
|
142
164
|
await frame.evaluate(() => window.setBox(5));
|
|
143
165
|
await expectHeight(display, 30, "shrinks to minHeightPx");
|
|
144
166
|
const sizes = (await display.events()).flatMap((event) => event.type === "resize" ? [event.detail.height] : []);
|
|
145
167
|
// The first size is the content's: an empty shell reports none (it would make the host
|
|
146
168
|
// forget the height it remembered, and the frame jump).
|
|
147
|
-
expect(sizes[0]).toBe(150);
|
|
148
|
-
expect(sizes).toEqual(expect.arrayContaining([150, 300, 400, 30]));
|
|
149
|
-
expect(Math.max(...sizes)).toBe(400);
|
|
169
|
+
expect(sizes[0], "probe: the first size reported is the content's").toBe(150);
|
|
170
|
+
expect(sizes, "probe: each size was reported").toEqual(expect.arrayContaining([150, 300, 400, 30]));
|
|
171
|
+
expect(Math.max(...sizes), "probe: no size past maxHeightPx was reported").toBe(400);
|
|
150
172
|
},
|
|
151
173
|
},
|
|
152
174
|
{
|
|
@@ -161,8 +183,8 @@ export const BEHAVIOR_PROBES = [
|
|
|
161
183
|
await expectHeight(display, 500, "follows the page");
|
|
162
184
|
const frame = await display.frame();
|
|
163
185
|
await expect(frame.locator("#page")).toHaveText("page");
|
|
164
|
-
await expect(frame.locator("body"), "the page's own load event fires").toHaveAttribute("data-loaded", "1");
|
|
165
|
-
expect(await read(frame, () => document.title)).toBe("Report");
|
|
186
|
+
await expect(frame.locator("body"), "probe: the page's own load event fires").toHaveAttribute("data-loaded", "1");
|
|
187
|
+
expect(await read(frame, () => document.title), "probe: the page keeps its own title").toBe("Report");
|
|
166
188
|
},
|
|
167
189
|
},
|
|
168
190
|
// ── 11: theming ────────────────────────────────────────────────────────────────────────────
|
|
@@ -181,35 +203,36 @@ export const BEHAVIOR_PROBES = [
|
|
|
181
203
|
});
|
|
182
204
|
const frame = await display.frame();
|
|
183
205
|
await expect(frame.locator("p")).toHaveText("themed");
|
|
184
|
-
expect(await variable(frame, "--color-text-primary")).toBe(light["--color-text-primary"]);
|
|
206
|
+
expect(await variable(frame, "--color-text-primary"), "probe: the content takes the light theme").toBe(light["--color-text-primary"]);
|
|
185
207
|
const flips = () => read(frame, () => window.flips);
|
|
186
208
|
// Mounting, and a host telling it the scheme it already has, are no flip: no event (#3).
|
|
187
209
|
await settle(400);
|
|
188
|
-
expect(await flips(), "no theme event at mount").toEqual([]);
|
|
210
|
+
expect(await flips(), "probe: no theme event at mount").toEqual([]);
|
|
189
211
|
await display.setTheme("light");
|
|
190
212
|
await settle(400);
|
|
191
|
-
expect(await flips(), "no theme event for the scheme it has").toEqual([]);
|
|
213
|
+
expect(await flips(), "probe: no theme event for the scheme it has").toEqual([]);
|
|
192
214
|
await display.setTheme("dark");
|
|
193
215
|
await expect
|
|
194
|
-
.poll(() => variable(frame, "--color-text-primary")
|
|
216
|
+
.poll(() => variable(frame, "--color-text-primary"), {
|
|
217
|
+
message: "probe: the content is re-themed dark",
|
|
218
|
+
})
|
|
195
219
|
.toBe(dark["--color-text-primary"]);
|
|
196
|
-
expect(await variable(frame, "--color-chart-1")).toBe(dark["--color-chart-1"]);
|
|
220
|
+
expect(await variable(frame, "--color-chart-1"), "probe: the chart colors are re-themed dark").toBe(dark["--color-chart-1"]);
|
|
197
221
|
expect(await read(frame, () => ({
|
|
198
222
|
kept: window.kept,
|
|
199
223
|
flips: window.flips,
|
|
200
224
|
theme: document.documentElement.dataset.theme,
|
|
201
225
|
scheme: document.documentElement.style.colorScheme,
|
|
202
|
-
}))).toEqual({ kept: "yes", flips: ["dark"], theme: "dark", scheme: "dark" });
|
|
226
|
+
})), "probe: the running content is re-themed in place and told once").toEqual({ kept: "yes", flips: ["dark"], theme: "dark", scheme: "dark" });
|
|
203
227
|
const element = await frame.frameElement();
|
|
204
|
-
expect(await element.evaluate((node) => node.style.colorScheme)).toBe("dark");
|
|
228
|
+
expect(await element.evaluate((node) => node.style.colorScheme), "probe: the frame element takes the dark scheme").toBe("dark");
|
|
205
229
|
await display.setTheme("light");
|
|
206
230
|
await expect
|
|
207
|
-
.poll(() => variable(frame, "--color-text-primary")
|
|
231
|
+
.poll(() => variable(frame, "--color-text-primary"), {
|
|
232
|
+
message: "probe: the content is re-themed light",
|
|
233
|
+
})
|
|
208
234
|
.toBe(light["--color-text-primary"]);
|
|
209
|
-
expect(await read(frame, () => window.flips)).toEqual([
|
|
210
|
-
"dark",
|
|
211
|
-
"light",
|
|
212
|
-
]);
|
|
235
|
+
expect(await read(frame, () => window.flips), "probe: each flip is told once").toEqual(["dark", "light"]);
|
|
213
236
|
},
|
|
214
237
|
},
|
|
215
238
|
{
|
|
@@ -231,9 +254,13 @@ export const BEHAVIOR_PROBES = [
|
|
|
231
254
|
});
|
|
232
255
|
const frame = await display.frame();
|
|
233
256
|
await expect(frame.locator("p")).toHaveText("live");
|
|
234
|
-
await expect
|
|
235
|
-
|
|
236
|
-
|
|
257
|
+
await expect
|
|
258
|
+
.poll(() => variable(frame, "--color-text-primary"), {
|
|
259
|
+
message: "probe: the host's spec value reached the frame",
|
|
260
|
+
})
|
|
261
|
+
.toBe("rgb(1, 2, 3)");
|
|
262
|
+
expect(await variable(frame, "--color-chart-1"), "probe: the host's Porthole value reached the frame").toBe("rgb(4, 5, 6)");
|
|
263
|
+
expect(await variable(frame, "--not-declared"), "probe: an undeclared host value reached the frame").toBe("");
|
|
237
264
|
},
|
|
238
265
|
},
|
|
239
266
|
{
|
|
@@ -258,14 +285,14 @@ export const BEHAVIOR_PROBES = [
|
|
|
258
285
|
input: of("i").borderTopLeftRadius,
|
|
259
286
|
};
|
|
260
287
|
});
|
|
261
|
-
expect(styles).toEqual({
|
|
288
|
+
expect(styles, "probe: native controls take the theme, and content's CSS overrides it").toEqual({
|
|
262
289
|
radius: resolveTheme(config.theme, "light")["--border-radius-md"],
|
|
263
290
|
font: true,
|
|
264
291
|
height: expect.any(Number),
|
|
265
292
|
overridden: "0px",
|
|
266
293
|
input: resolveTheme(config.theme, "light")["--border-radius-md"],
|
|
267
294
|
});
|
|
268
|
-
expect(styles.height, "a control is tall enough to tap").toBeGreaterThanOrEqual(44);
|
|
295
|
+
expect(styles.height, "probe: a control is tall enough to tap").toBeGreaterThanOrEqual(44);
|
|
269
296
|
},
|
|
270
297
|
},
|
|
271
298
|
{
|
|
@@ -290,7 +317,7 @@ export const BEHAVIOR_PROBES = [
|
|
|
290
317
|
content: page("", "plain"),
|
|
291
318
|
});
|
|
292
319
|
// An author's own page, declaring nothing: shown as styled, in light; the variables are there.
|
|
293
|
-
expect(await scheme(plain, "plain")).toEqual({
|
|
320
|
+
expect(await scheme(plain, "plain"), "probe: a page declaring nothing stays as styled").toEqual({
|
|
294
321
|
scheme: "normal",
|
|
295
322
|
theme: null,
|
|
296
323
|
variable: true,
|
|
@@ -298,7 +325,7 @@ export const BEHAVIOR_PROBES = [
|
|
|
298
325
|
await plain.setTheme("light");
|
|
299
326
|
await plain.setTheme("dark");
|
|
300
327
|
await settle(300);
|
|
301
|
-
expect(await scheme(plain, "plain")).toEqual({
|
|
328
|
+
expect(await scheme(plain, "plain"), "probe: a page declaring nothing stays as styled after a flip").toEqual({
|
|
302
329
|
scheme: "normal",
|
|
303
330
|
theme: null,
|
|
304
331
|
variable: true,
|
|
@@ -308,14 +335,22 @@ export const BEHAVIOR_PROBES = [
|
|
|
308
335
|
scheme: "dark",
|
|
309
336
|
content: page('<meta name="color-scheme" content="light dark">', "declared"),
|
|
310
337
|
});
|
|
311
|
-
await expect
|
|
312
|
-
|
|
338
|
+
await expect
|
|
339
|
+
.poll(async () => (await scheme(declared, "declared")).theme, {
|
|
340
|
+
message: "probe: a page declaring its schemes takes the person's",
|
|
341
|
+
})
|
|
342
|
+
.toBe("dark");
|
|
343
|
+
expect((await scheme(declared, "declared")).scheme, "probe: a page declaring its schemes takes the person's color scheme").toBe("dark");
|
|
313
344
|
const always = await context.launch({
|
|
314
345
|
config: presets.artifact({ theme: { documents: "always" } }),
|
|
315
346
|
scheme: "dark",
|
|
316
347
|
content: page("", "always"),
|
|
317
348
|
});
|
|
318
|
-
await expect
|
|
349
|
+
await expect
|
|
350
|
+
.poll(async () => (await scheme(always, "always")).theme, {
|
|
351
|
+
message: "probe: a page the host always themes takes the person's scheme",
|
|
352
|
+
})
|
|
353
|
+
.toBe("dark");
|
|
319
354
|
},
|
|
320
355
|
},
|
|
321
356
|
// ── 12: the host-function gates ────────────────────────────────────────────────────────────
|
|
@@ -325,8 +360,8 @@ export const BEHAVIOR_PROBES = [
|
|
|
325
360
|
title: "sendPrompt needs a click and the person's yes; a no sends nothing",
|
|
326
361
|
async run(context) {
|
|
327
362
|
const display = await context.launch({ config: prompts(), content: PROMPT_CONTENT });
|
|
328
|
-
expect(await bodyData(display, "onload"), "a call made on load is refused by the shell").toContain("needs a click");
|
|
329
|
-
expect(await display.calls()).toEqual([]);
|
|
363
|
+
expect(await bodyData(display, "onload", "probe: a call made on load is refused by the shell"), "probe: a call made on load is refused by the shell").toContain("needs a click");
|
|
364
|
+
expect(await display.calls(), "probe: a call made on load reached the host's handler").toEqual([]);
|
|
330
365
|
// The host's own check needs the frame's click to reach the host page (activation
|
|
331
366
|
// propagates to ancestors): measured with raw input, after the harness's activation lapsed.
|
|
332
367
|
await clickAfterLapse(context, display, "#ask");
|
|
@@ -334,14 +369,14 @@ export const BEHAVIOR_PROBES = [
|
|
|
334
369
|
const refused = await refusals(display);
|
|
335
370
|
context.measured(`${context.engine}: a click in the frame ${refused.includes("sendPrompt:no-user-activation") ? "does not reach" : "reaches"} the host page's user activation`);
|
|
336
371
|
expect(refused, "the frame's click didn't count as a gesture on the host page").toEqual([]);
|
|
337
|
-
const declined = await display
|
|
338
|
-
expect(declined).toMatchObject({
|
|
372
|
+
const declined = await answered(display, false, "probe: the person was asked about the prompt");
|
|
373
|
+
expect(declined, "probe: the person was asked about the whole prompt").toMatchObject({
|
|
339
374
|
capability: "sendPrompt",
|
|
340
375
|
args: { text: "Explain why signups doubled in March" },
|
|
341
376
|
display: { title: "Probe" },
|
|
342
377
|
});
|
|
343
|
-
expect(await bodyData(display, "result")).toBe("false");
|
|
344
|
-
expect(await display.calls(), "a declined prompt reached the host's handler").toEqual([]);
|
|
378
|
+
expect(await bodyData(display, "result", "probe: the content is told a declined prompt wasn't sent"), "probe: the content is told a declined prompt wasn't sent").toBe("false");
|
|
379
|
+
expect(await display.calls(), "probe: a declined prompt reached the host's handler").toEqual([]);
|
|
345
380
|
await click(display, "#ask");
|
|
346
381
|
await display.answerNextConfirmation(true);
|
|
347
382
|
expect(await bodyData(display, "result")).toBe("true");
|
|
@@ -367,9 +402,11 @@ export const BEHAVIOR_PROBES = [
|
|
|
367
402
|
});
|
|
368
403
|
// Nothing is evaluated in the page until the message has been answered.
|
|
369
404
|
await context.page.waitForTimeout(ACTIVATION_LAPSE_MS + 1_500);
|
|
370
|
-
expect(await bodyData(display, "answer")).toBe(JSON.stringify({ isError: true }));
|
|
371
|
-
expect(await display.calls()).toEqual([]);
|
|
372
|
-
expect(await refusals(display)
|
|
405
|
+
expect(await bodyData(display, "answer", "probe: a raw ui/message without a click is refused"), "probe: a raw ui/message without a click is refused").toBe(JSON.stringify({ isError: true }));
|
|
406
|
+
expect(await display.calls(), "probe: a raw ui/message reached the host's handler").toEqual([]);
|
|
407
|
+
expect(await refusals(display), "probe: the host refused it for no user activation").toEqual([
|
|
408
|
+
"sendPrompt:no-user-activation",
|
|
409
|
+
]);
|
|
373
410
|
},
|
|
374
411
|
},
|
|
375
412
|
{
|
|
@@ -387,8 +424,8 @@ export const BEHAVIOR_PROBES = [
|
|
|
387
424
|
</script>`,
|
|
388
425
|
});
|
|
389
426
|
await click(display, "#web");
|
|
390
|
-
const asked = await display
|
|
391
|
-
expect(asked).toMatchObject({
|
|
427
|
+
const asked = await answered(display, true, "probe: the person was asked about the link");
|
|
428
|
+
expect(asked, "probe: the person was asked about the link").toMatchObject({
|
|
392
429
|
capability: "openLink",
|
|
393
430
|
args: { url: "https://example.com/report?q=1" },
|
|
394
431
|
});
|
|
@@ -397,11 +434,11 @@ export const BEHAVIOR_PROBES = [
|
|
|
397
434
|
.toEqual([{ capability: "openLink", args: { url: "https://example.com/report?q=1" } }]);
|
|
398
435
|
await click(display, "#js");
|
|
399
436
|
await click(display, "#raw");
|
|
400
|
-
expect(await bodyData(display, "raw")).toBe("false");
|
|
437
|
+
expect(await bodyData(display, "raw", "probe: openLink of a javascript: URL is refused"), "probe: openLink of a javascript: URL is refused").toBe("false");
|
|
401
438
|
await settle(300);
|
|
402
|
-
expect(await (await display.frame()).locator("body").getAttribute("data-ran")).toBeNull();
|
|
403
|
-
expect(await refusals(display)).toContain("openLink:invalid");
|
|
404
|
-
expect(await display.calls()).toHaveLength(1);
|
|
439
|
+
expect(await (await display.frame()).locator("body").getAttribute("data-ran"), "probe: a javascript: link ran").toBeNull();
|
|
440
|
+
expect(await refusals(display), "probe: the host refused the javascript: URL as invalid").toContain("openLink:invalid");
|
|
441
|
+
expect(await display.calls(), "probe: a non-http(s) link reached the host's handler").toHaveLength(1);
|
|
405
442
|
},
|
|
406
443
|
},
|
|
407
444
|
{
|
|
@@ -415,16 +452,18 @@ export const BEHAVIOR_PROBES = [
|
|
|
415
452
|
});
|
|
416
453
|
for (let index = 0; index < 2; index += 1) {
|
|
417
454
|
await click(display, "#ask");
|
|
418
|
-
await display
|
|
419
|
-
expect(await bodyData(display, "result")).toBe("false");
|
|
455
|
+
await answered(display, false, "probe: the display asked before it muted");
|
|
456
|
+
expect(await bodyData(display, "result", "probe: the content is told a declined prompt wasn't sent"), "probe: the content is told a declined prompt wasn't sent").toBe("false");
|
|
420
457
|
}
|
|
421
458
|
await expect
|
|
422
|
-
.poll(async () => (await display.events()).some((event) => event.type === "muted")
|
|
459
|
+
.poll(async () => (await display.events()).some((event) => event.type === "muted"), {
|
|
460
|
+
message: "probe: the display muted after the declines",
|
|
461
|
+
})
|
|
423
462
|
.toBe(true);
|
|
424
463
|
await click(display, "#ask");
|
|
425
|
-
expect(await bodyData(display, "result")).toBe("false");
|
|
426
|
-
expect(await refusals(display)).toContain("sendPrompt:muted");
|
|
427
|
-
expect(await display.calls()).toEqual([]);
|
|
464
|
+
expect(await bodyData(display, "result", "probe: a muted display's prompt is refused"), "probe: a muted display's prompt is refused").toBe("false");
|
|
465
|
+
expect(await refusals(display), "probe: the prompt was refused as muted").toContain("sendPrompt:muted");
|
|
466
|
+
expect(await display.calls(), "probe: a prompt reached the host's handler").toEqual([]);
|
|
428
467
|
},
|
|
429
468
|
},
|
|
430
469
|
{
|
|
@@ -444,9 +483,9 @@ export const BEHAVIOR_PROBES = [
|
|
|
444
483
|
if (asked) {
|
|
445
484
|
context.inapplicable("this host always has a confirm function (a default dialog), so a display without one can't be shown; it asked the person instead");
|
|
446
485
|
}
|
|
447
|
-
expect(await bodyData(display, "result")).toBe("false");
|
|
448
|
-
expect(await refusals(display)).toContain("sendPrompt:no-confirm");
|
|
449
|
-
expect(await display.calls()).toEqual([]);
|
|
486
|
+
expect(await bodyData(display, "result", "probe: a prompt with no one to confirm it is refused"), "probe: a prompt with no one to confirm it is refused").toBe("false");
|
|
487
|
+
expect(await refusals(display), "probe: the prompt was refused for no confirm").toContain("sendPrompt:no-confirm");
|
|
488
|
+
expect(await display.calls(), "probe: an unconfirmed prompt reached the host's handler").toEqual([]);
|
|
450
489
|
},
|
|
451
490
|
},
|
|
452
491
|
{
|
|
@@ -462,8 +501,8 @@ export const BEHAVIOR_PROBES = [
|
|
|
462
501
|
}
|
|
463
502
|
expect(await bodyData(display, "answer")).toBe("{}");
|
|
464
503
|
const shown = await said();
|
|
465
|
-
expect(shown, "the update reached the model unseen").toHaveLength(1);
|
|
466
|
-
expect(shown[0]).toMatchObject({
|
|
504
|
+
expect(shown, "probe: the update reached the model unseen").toHaveLength(1);
|
|
505
|
+
expect(shown[0], "probe: the person was shown the whole update").toMatchObject({
|
|
467
506
|
capability: "setModelContext",
|
|
468
507
|
args: CONTEXT_UPDATE,
|
|
469
508
|
display: { title: "Probe" },
|
|
@@ -476,9 +515,9 @@ export const BEHAVIOR_PROBES = [
|
|
|
476
515
|
if (answer.code === undefined && ((await unseen.shown?.()) ?? []).length > 0) {
|
|
477
516
|
return context.inapplicable("this host always has a show function (a default surface), so a display without one can't be shown; it showed the person instead");
|
|
478
517
|
}
|
|
479
|
-
expect(answer.code, "an update nobody could see was taken").toBe("not_allowed");
|
|
480
|
-
expect(await refusals(unseen)).toContain("setModelContext:no-show");
|
|
481
|
-
expect(await unseen.calls()).toEqual([]);
|
|
518
|
+
expect(answer.code, "probe: an update nobody could see was taken").toBe("not_allowed");
|
|
519
|
+
expect(await refusals(unseen), "probe: the update was refused for no show").toContain("setModelContext:no-show");
|
|
520
|
+
expect(await unseen.calls(), "probe: an unseen update reached the host's handler").toEqual([]);
|
|
482
521
|
},
|
|
483
522
|
},
|
|
484
523
|
];
|
|
@@ -47,10 +47,14 @@ async function pasted(page) {
|
|
|
47
47
|
async function click(display, selector) {
|
|
48
48
|
await (await display.frame()).locator(selector).click();
|
|
49
49
|
}
|
|
50
|
-
async function bodyData(display, name) {
|
|
50
|
+
async function bodyData(display, name, verdict) {
|
|
51
51
|
const frame = await display.frame();
|
|
52
|
+
// A probe's verdict where the answer is a wall's (P096): none coming fails it, not its setup.
|
|
52
53
|
await expect
|
|
53
|
-
.poll(() => frame.locator("body").getAttribute(`data-${name}`), {
|
|
54
|
+
.poll(() => frame.locator("body").getAttribute(`data-${name}`), {
|
|
55
|
+
timeout: 5_000,
|
|
56
|
+
...(verdict === undefined ? {} : { message: verdict }),
|
|
57
|
+
})
|
|
54
58
|
.not.toBeNull();
|
|
55
59
|
return (await frame.locator("body").getAttribute(`data-${name}`)) ?? "";
|
|
56
60
|
}
|
|
@@ -78,10 +82,10 @@ export const CLIPBOARD_PROBES = [
|
|
|
78
82
|
});
|
|
79
83
|
await seed(context.page, SEED);
|
|
80
84
|
await click(display, "#go");
|
|
81
|
-
expect(await bodyData(display, "text")).toMatch(/^refused/u);
|
|
82
|
-
expect(await bodyData(display, "item")).toMatch(/^refused/u);
|
|
83
|
-
expect(await bodyData(display, "read")).toMatch(/^refused/u);
|
|
84
|
-
expect(await pasted(context.page), "the clipboard still holds the person's own").toBe(SEED);
|
|
85
|
+
expect(await bodyData(display, "text", "probe: writeText is refused"), "probe: writeText is refused").toMatch(/^refused/u);
|
|
86
|
+
expect(await bodyData(display, "item", "probe: write is refused"), "probe: write is refused").toMatch(/^refused/u);
|
|
87
|
+
expect(await bodyData(display, "read", "probe: readText is refused"), "probe: readText is refused").toMatch(/^refused/u);
|
|
88
|
+
expect(await pasted(context.page), "probe: the clipboard still holds the person's own").toBe(SEED);
|
|
85
89
|
},
|
|
86
90
|
},
|
|
87
91
|
{
|
|
@@ -110,8 +114,8 @@ export const CLIPBOARD_PROBES = [
|
|
|
110
114
|
});
|
|
111
115
|
await seed(context.page, SEED);
|
|
112
116
|
await click(display, "#go");
|
|
113
|
-
expect(await bodyData(display, "copied")).not.toContain("true");
|
|
114
|
-
expect(await pasted(context.page), "the clipboard still holds the person's own").toBe(SEED);
|
|
117
|
+
expect(await bodyData(display, "copied", "probe: execCommand copied or cut"), "probe: execCommand copied or cut").not.toContain("true");
|
|
118
|
+
expect(await pasted(context.page), "probe: the clipboard still holds the person's own").toBe(SEED);
|
|
115
119
|
},
|
|
116
120
|
},
|
|
117
121
|
{
|
|
@@ -140,8 +144,8 @@ export const CLIPBOARD_PROBES = [
|
|
|
140
144
|
await context.page.keyboard.press("ControlOrMeta+C");
|
|
141
145
|
await settle(200);
|
|
142
146
|
// The positive control: the person's own copy works, and copies what they selected.
|
|
143
|
-
expect((await pasted(context.page)).trim()).toBe("porthole-selected-text");
|
|
144
|
-
expect(await frame.locator("body").getAttribute("data-ran")).toBeNull();
|
|
147
|
+
expect((await pasted(context.page)).trim(), "probe: the clipboard holds what the person selected").toBe("porthole-selected-text");
|
|
148
|
+
expect(await frame.locator("body").getAttribute("data-ran"), "probe: a copy listener of the content's ran").toBeNull();
|
|
145
149
|
},
|
|
146
150
|
},
|
|
147
151
|
{
|
|
@@ -159,12 +163,10 @@ export const CLIPBOARD_PROBES = [
|
|
|
159
163
|
copyText("copied on load").then(${settled("onload")});
|
|
160
164
|
</script>`,
|
|
161
165
|
});
|
|
162
|
-
expect(await bodyData(display, "onload")).toMatch(/^refused/u);
|
|
166
|
+
expect(await bodyData(display, "onload", "probe: copyText without a click is refused"), "probe: copyText without a click is refused").toMatch(/^refused/u);
|
|
163
167
|
await click(display, "#copy");
|
|
164
168
|
expect(await bodyData(display, "result")).toBe("true");
|
|
165
|
-
expect(await display.calls()).toEqual([
|
|
166
|
-
{ capability: "copyText", args: { text: "npm test -- --run" } },
|
|
167
|
-
]);
|
|
169
|
+
expect(await display.calls(), "probe: only the click's whole text reached the host's handler").toEqual([{ capability: "copyText", args: { text: "npm test -- --run" } }]);
|
|
168
170
|
},
|
|
169
171
|
},
|
|
170
172
|
];
|