@parcha/agentrun-computer 0.1.0-beta.36 → 0.1.0-beta.38
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/NOTICE +2 -0
- package/README.md +547 -478
- package/box/Dockerfile +18 -1
- package/box/README.md +13 -0
- package/box/build-agent37.mjs +158 -0
- package/box/build-daytona.py +2 -2
- package/box/build-e2b.mjs +41 -18
- package/box/recipe.mjs +43 -0
- package/dist/agent37-ssh.d.ts +89 -0
- package/dist/agent37-ssh.js +445 -0
- package/dist/agent37.d.ts +104 -0
- package/dist/agent37.js +402 -0
- package/dist/attach.d.ts +146 -0
- package/dist/attach.js +469 -0
- package/dist/browserbase.d.ts +2 -10
- package/dist/browserbase.js +3 -6
- package/dist/client.d.ts +45 -4
- package/dist/client.js +92 -4
- package/dist/computerd-linux-amd64 +0 -0
- package/dist/computerd-linux-arm64 +0 -0
- package/dist/computerd.json +4 -0
- package/dist/conformance/agent37.d.ts +96 -0
- package/dist/conformance/agent37.js +154 -0
- package/dist/conformance/cases/apps.d.ts +11 -0
- package/dist/conformance/cases/apps.js +173 -73
- package/dist/conformance/cases/health.js +14 -0
- package/dist/conformance/cases/index.js +2 -0
- package/dist/conformance/cases/isolation.d.ts +7 -5
- package/dist/conformance/cases/isolation.js +44 -14
- package/dist/conformance/cases/mount.js +1 -1
- package/dist/conformance/cases/provider.js +27 -1
- package/dist/conformance/cases/screen.d.ts +3 -0
- package/dist/conformance/cases/screen.js +18 -0
- package/dist/conformance/cases/settings.d.ts +29 -23
- package/dist/conformance/cases/settings.js +76 -58
- package/dist/conformance/cases/touch.js +19 -17
- package/dist/conformance/cases/ui.d.ts +2 -0
- package/dist/conformance/cases/ui.js +475 -0
- package/dist/conformance/cli.d.ts +9 -0
- package/dist/conformance/cli.js +94 -9
- package/dist/conformance/daytona.d.ts +9 -20
- package/dist/conformance/daytona.js +12 -21
- package/dist/conformance/e2b.d.ts +6 -0
- package/dist/conformance/e2b.js +9 -2
- package/dist/conformance/exec-stream.d.ts +45 -0
- package/dist/conformance/exec-stream.js +486 -0
- package/dist/conformance/fixture.d.ts +1 -1
- package/dist/conformance/fixture.js +25 -1
- package/dist/conformance/modal.d.ts +17 -13
- package/dist/conformance/modal.js +18 -9
- package/dist/conformance/orgo.d.ts +3 -3
- package/dist/conformance/orgo.js +6 -8
- package/dist/conformance/phone-harness.d.ts +6 -2
- package/dist/conformance/phone-harness.js +21 -4
- package/dist/conformance/report.js +1 -1
- package/dist/conformance/runner.js +23 -4
- package/dist/conformance/sweep.d.ts +50 -0
- package/dist/conformance/sweep.js +187 -0
- package/dist/conformance/types.d.ts +13 -5
- package/dist/conformance/ui-fixture.d.ts +56 -0
- package/dist/conformance/ui-fixture.js +43 -0
- package/dist/create-requests.d.ts +51 -0
- package/dist/create-requests.js +121 -0
- package/dist/daytona.d.ts +20 -133
- package/dist/daytona.js +405 -1449
- package/dist/descriptor.d.ts +11 -1
- package/dist/descriptor.js +9 -0
- package/dist/descriptors/agent37.d.ts +41 -0
- package/dist/descriptors/agent37.js +28 -0
- package/dist/descriptors/daytona.d.ts +6 -5
- package/dist/descriptors/daytona.js +9 -5
- package/dist/descriptors/index.d.ts +42 -7
- package/dist/descriptors/index.js +4 -2
- package/dist/descriptors/orgo.d.ts +2 -1
- package/dist/descriptors/orgo.js +3 -2
- package/dist/descriptors/phone-harness.d.ts +1 -1
- package/dist/descriptors/phone-harness.js +2 -2
- package/dist/descriptors/shared.d.ts +1 -1
- package/dist/descriptors/shared.js +2 -2
- package/dist/desktop.d.ts +18 -4
- package/dist/desktop.js +89 -9
- package/dist/docker.d.ts +7 -10
- package/dist/docker.js +272 -34
- package/dist/drift.js +4 -4
- package/dist/e2b.d.ts +16 -290
- package/dist/e2b.js +230 -1393
- package/dist/fake-ui-driver.d.ts +97 -0
- package/dist/fake-ui-driver.js +717 -0
- package/dist/host.d.ts +201 -0
- package/dist/host.js +8 -0
- package/dist/hosted/process.d.ts +81 -0
- package/dist/hosted/process.js +259 -0
- package/dist/hosted/provider.d.ts +160 -0
- package/dist/hosted/provider.js +1415 -0
- package/dist/hosted/rest.d.ts +66 -0
- package/dist/hosted/rest.js +121 -0
- package/dist/hosted/scripts.d.ts +82 -0
- package/dist/{child.js → hosted/scripts.js} +118 -12
- package/dist/hosted/values.d.ts +5 -0
- package/dist/hosted/values.js +8 -0
- package/dist/index.d.ts +7 -3
- package/dist/index.js +7 -4
- package/dist/kernel.d.ts +2 -10
- package/dist/kernel.js +3 -6
- package/dist/kinds.d.ts +11 -2
- package/dist/kinds.js +20 -4
- package/dist/local-chrome.d.ts +2 -10
- package/dist/local-chrome.js +3 -6
- package/dist/modal.d.ts +22 -257
- package/dist/modal.js +183 -1280
- package/dist/mount-archil.d.ts +8 -4
- package/dist/mount-archil.js +22 -11
- package/dist/mount.d.ts +10 -4
- package/dist/mount.js +8 -4
- package/dist/orgo-channel.d.ts +3 -2
- package/dist/orgo-channel.js +5 -2
- package/dist/orgo-desktop.d.ts +9 -4
- package/dist/orgo-desktop.js +33 -13
- package/dist/orgo-workspaces.d.ts +47 -0
- package/dist/orgo-workspaces.js +94 -0
- package/dist/orgo.d.ts +10 -13
- package/dist/orgo.js +32 -21
- package/dist/phone-harness.d.ts +31 -28
- package/dist/phone-harness.js +510 -702
- package/dist/png.d.ts +4 -0
- package/dist/png.js +27 -0
- package/dist/protocol.d.ts +339 -33
- package/dist/protocol.js +97 -3
- package/dist/provider.d.ts +36 -8
- package/dist/provider.js +16 -0
- package/dist/providers.d.ts +11 -12
- package/dist/result.d.ts +1 -1
- package/dist/screen-watch.js +34 -6
- package/dist/surface/api.d.ts +260 -0
- package/dist/surface/api.js +1 -0
- package/dist/surface/core.d.ts +55 -0
- package/dist/surface/core.js +475 -0
- package/dist/surface/index.d.ts +5 -0
- package/dist/surface/index.js +3 -0
- package/dist/surface/outline.d.ts +10 -0
- package/dist/surface/outline.js +51 -0
- package/dist/surface/script.d.ts +10 -0
- package/dist/surface/script.js +94 -0
- package/dist/ui-engine.d.ts +114 -0
- package/dist/ui-engine.js +814 -0
- package/package.json +18 -3
- package/dist/child.d.ts +0 -42
- package/dist/conformance/daytona-sweep.d.ts +0 -18
- package/dist/conformance/daytona-sweep.js +0 -126
- package/dist/conformance/e2b-diagnose.d.ts +0 -16
- package/dist/conformance/e2b-diagnose.js +0 -61
- package/dist/conformance/e2b-sweep.d.ts +0 -18
- package/dist/conformance/e2b-sweep.js +0 -132
- package/dist/conformance/modal-sweep.d.ts +0 -22
- package/dist/conformance/modal-sweep.js +0 -213
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
// Apps: the fixture installs, is listed, comes to the front when launched and leaves it when terminated;
|
|
2
|
-
// the protocol's shape, inside
|
|
3
|
-
// listed, launched and terminated with no install, which needs the apps group alone
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
|
|
1
|
+
// Apps: the fixture installs, is listed, comes to the front when launched and leaves it when terminated; ui.observe has
|
|
2
|
+
// the protocol's shape, inside its window, with the fixture's button found by its id. A phone's stock Settings app is
|
|
3
|
+
// listed, launched and terminated with no install, which needs the apps group alone, and so is a Linux desktop's stock
|
|
4
|
+
// editor or terminal (DESKTOP_APPS), on any vendor: its launch is seen in ui.observe
|
|
5
|
+
// (Settings' list) when the phone has the ui group, else in a screenshot that is not the one before. On a phone that
|
|
6
|
+
// takes no fixture file the observation's shape is checked on Settings, with its rows found (settings.ts).
|
|
7
|
+
import { MAX_UI_NODES, UI_FLAGS, UI_ROLES } from "../../protocol.js";
|
|
7
8
|
import { FIXTURE_BUTTON } from "../fixture.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
9
|
+
import { featureOff } from "../../ui-engine.js";
|
|
10
|
+
import { UI_FIXTURE } from "../ui-fixture.js";
|
|
11
|
+
import { captureOff, shoot } from "./screen.js";
|
|
12
|
+
import { namesOf, observe, openSettings, rowsOf, settingsApp, throughSettings } from "./settings.js";
|
|
10
13
|
/** Whether the provider and the computer both declare group. */
|
|
11
14
|
const declares = (t, group) => t.provider.capabilities().groups.includes(group) && t.hello.groups.includes(group);
|
|
15
|
+
/** Why ui.observe gives no elements here (ui.tree is off), or undefined when it gives them. */
|
|
16
|
+
const treeOff = (t) => featureOff(t.hello.features ?? {}, "ui.tree");
|
|
17
|
+
/** Whether ui.observe shows the screen's elements: the ui group, with ui.tree on. */
|
|
18
|
+
const readsTree = (t) => declares(t, "ui") && treeOff(t) === undefined;
|
|
12
19
|
/** A screenshot's pixels sampled on a 16 x 16 grid, with its size: two different screens differ in it. */
|
|
13
20
|
async function screenPrint(t) {
|
|
14
21
|
const { image } = await shoot(t);
|
|
@@ -20,57 +27,96 @@ async function screenPrint(t) {
|
|
|
20
27
|
return `${image.width}x${image.height}:${samples.join(";")}`;
|
|
21
28
|
}
|
|
22
29
|
/**
|
|
23
|
-
* What the screen shows now, as the case compares it:
|
|
24
|
-
* screenshot's print.
|
|
30
|
+
* What the screen shows now, as the case compares it: ui.observe's names and values when it reads the elements, else a
|
|
31
|
+
* screenshot's print, else (ui.tree off, no screen group or screen.capture off) ui.observe's image. Undefined when the
|
|
32
|
+
* launch cannot be seen.
|
|
25
33
|
*/
|
|
26
34
|
async function shown(t) {
|
|
27
|
-
if (
|
|
28
|
-
return JSON.stringify(
|
|
29
|
-
if (declares(t, "screen"))
|
|
35
|
+
if (readsTree(t))
|
|
36
|
+
return JSON.stringify(namesOf(await observe(t)));
|
|
37
|
+
if (declares(t, "screen") && captureOff(t) === undefined)
|
|
30
38
|
return screenPrint(t);
|
|
39
|
+
if (declares(t, "ui"))
|
|
40
|
+
return (await observe(t)).image?.data;
|
|
31
41
|
return undefined;
|
|
32
42
|
}
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (typeof
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (typeof
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
55
|
-
return
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
for (const [i,
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
return
|
|
43
|
+
const ROLES = new Set(UI_ROLES);
|
|
44
|
+
const FLAGS = new Set(UI_FLAGS);
|
|
45
|
+
const show = (value) => JSON.stringify(value) ?? String(value);
|
|
46
|
+
const isRect = (value) => Array.isArray(value) && value.length === 4 && value.every((v) => typeof v === "number" && Number.isFinite(v)) && value[2] >= 0 && value[3] >= 0;
|
|
47
|
+
const strings = (value) => Array.isArray(value) && value.every((one) => typeof one === "string");
|
|
48
|
+
/**
|
|
49
|
+
* The first way ui.observe's result breaks the protocol, in words, or undefined: its state, app, window and truncated,
|
|
50
|
+
* and each node against UiNode, its bounds inside the window and its parent a node before it.
|
|
51
|
+
*/
|
|
52
|
+
export function observeWrong(result) {
|
|
53
|
+
if (typeof result !== "object" || result === null)
|
|
54
|
+
return "the result is not an object";
|
|
55
|
+
const r = result;
|
|
56
|
+
if (typeof r.state !== "string" || r.state === "")
|
|
57
|
+
return `state is ${show(r.state)}, not a state id`;
|
|
58
|
+
if (typeof r.truncated !== "boolean")
|
|
59
|
+
return `truncated is ${show(r.truncated)}, not a boolean`;
|
|
60
|
+
const app = r.app;
|
|
61
|
+
if (typeof app?.id !== "string" || typeof app.name !== "string")
|
|
62
|
+
return `app is ${show(r.app)}, not { id, name }`;
|
|
63
|
+
const window = r.window;
|
|
64
|
+
if (typeof window?.id !== "string" || !isRect(window.bounds))
|
|
65
|
+
return `window is ${show(r.window)}, not { id, bounds: [x, y, w, h] }`;
|
|
66
|
+
if (window.title !== undefined && typeof window.title !== "string")
|
|
67
|
+
return `window.title is ${show(window.title)}, not a string`;
|
|
68
|
+
if (window.role !== undefined && (typeof window.role !== "string" || !ROLES.has(window.role)))
|
|
69
|
+
return `window.role is ${show(window.role)}, not one of the protocol's roles (UI_ROLES)`;
|
|
70
|
+
const [, , width, height] = window.bounds;
|
|
71
|
+
if (!Array.isArray(r.nodes))
|
|
72
|
+
return `nodes is ${show(r.nodes)}, not a list`;
|
|
73
|
+
if (r.nodes.length > MAX_UI_NODES)
|
|
74
|
+
return `nodes holds ${r.nodes.length}, more than the ${MAX_UI_NODES} one observe gives`;
|
|
75
|
+
const refs = new Set();
|
|
76
|
+
for (const [i, node] of r.nodes.entries()) {
|
|
77
|
+
const at = `nodes[${i}]`;
|
|
78
|
+
if (typeof node !== "object" || node === null)
|
|
79
|
+
return `${at} is not an object`;
|
|
80
|
+
const n = node;
|
|
81
|
+
if (typeof n.ref !== "string" || !n.ref.startsWith("@") || n.ref.length < 2)
|
|
82
|
+
return `${at}.ref is ${show(n.ref)}, not a ref ("@e12")`;
|
|
83
|
+
if (refs.has(n.ref))
|
|
84
|
+
return `${at}.ref ${n.ref} is a ref an earlier node has`;
|
|
85
|
+
if (typeof n.role !== "string" || !ROLES.has(n.role))
|
|
86
|
+
return `${at}.role is ${show(n.role)}, not one of the protocol's roles (UI_ROLES)`;
|
|
87
|
+
for (const field of ["name", "value", "desc", "id"])
|
|
88
|
+
if (n[field] !== undefined && typeof n[field] !== "string")
|
|
89
|
+
return `${at}.${field} is ${show(n[field])}, not a string`;
|
|
90
|
+
if (!isRect(n.bounds))
|
|
91
|
+
return `${at}.bounds is ${show(n.bounds)}, not [x, y, w, h]`;
|
|
92
|
+
const [x, y, w, h] = n.bounds;
|
|
93
|
+
if (x < 0 || y < 0 || x + w > width || y + h > height)
|
|
94
|
+
return `${at}.bounds ${show(n.bounds)} reach outside the window's ${width}x${height} points`;
|
|
95
|
+
if (n.parent !== undefined && (typeof n.parent !== "string" || !refs.has(n.parent)))
|
|
96
|
+
return `${at}.parent is ${show(n.parent)}, not the ref of a node before it`;
|
|
97
|
+
if (n.flags !== undefined && !(strings(n.flags) && n.flags.every((flag) => FLAGS.has(flag))))
|
|
98
|
+
return `${at}.flags is ${show(n.flags)}, not a list of the protocol's flags`;
|
|
99
|
+
if (n.actions !== undefined && !strings(n.actions))
|
|
100
|
+
return `${at}.actions is ${show(n.actions)}, not a list of action names`;
|
|
101
|
+
if (n.flags?.includes("secure") && n.value !== undefined)
|
|
102
|
+
return `${at} is secure and sends its value`;
|
|
103
|
+
refs.add(n.ref);
|
|
70
104
|
}
|
|
71
105
|
return undefined;
|
|
72
106
|
}
|
|
73
107
|
const foreground = async (t) => (await t.call("apps.list", {})).foreground;
|
|
108
|
+
/**
|
|
109
|
+
* The stock apps a Linux desktop may have, by their desktop file ids, any vendor's: the text editor and the terminal of
|
|
110
|
+
* Xfce, which E2B Desktop's template and the box image (box/build-agent37.mjs) both carry, and xterm, which a bare
|
|
111
|
+
* desktop has (the Docker suite's, test/fixtures/desktop).
|
|
112
|
+
*/
|
|
113
|
+
export const DESKTOP_APPS = ["org.xfce.mousepad", "mousepad", "xfce4-terminal", "org.xfce.terminal", "xterm"];
|
|
114
|
+
/** A stock app the computer lists: the first of DESKTOP_APPS on a desktop, a phone's Settings, or the case skips in words. */
|
|
115
|
+
function stockApp(t, listed) {
|
|
116
|
+
if (t.provider.capabilities().kind !== "desktop")
|
|
117
|
+
return settingsApp(t);
|
|
118
|
+
return DESKTOP_APPS.find((id) => listed.some((one) => one.id === id)) ?? t.skip(`this desktop lists none of the stock apps the case knows (${DESKTOP_APPS.join(", ")})`);
|
|
119
|
+
}
|
|
74
120
|
export const appsCases = [
|
|
75
121
|
{
|
|
76
122
|
id: "apps.install-launch",
|
|
@@ -97,27 +143,30 @@ export const appsCases = [
|
|
|
97
143
|
group: "apps",
|
|
98
144
|
needs: ["apps"],
|
|
99
145
|
async run(t) {
|
|
100
|
-
//
|
|
101
|
-
|
|
146
|
+
// An app the computer has: the ui fixture where it is installed, else a stock app (a Linux desktop's editor or
|
|
147
|
+
// terminal, the phone's own Settings app). Listed; launched, in front and shown; terminated, and no longer in front.
|
|
102
148
|
const listed = await t.call("apps.list", {});
|
|
103
149
|
t.assert(Array.isArray(listed.apps) && listed.apps.every((one) => typeof one?.id === "string"), `apps.list gives apps with ids: ${JSON.stringify(listed.apps).slice(0, 300)}`);
|
|
150
|
+
const uiFixture = listed.apps.some((one) => one.id === UI_FIXTURE.id);
|
|
151
|
+
const app = uiFixture ? UI_FIXTURE.id : stockApp(t, listed.apps);
|
|
104
152
|
t.assert(listed.apps.some((one) => one.id === app), `apps.list holds ${app}`);
|
|
105
153
|
t.deepEqual(await t.call("apps.terminate", { id: app }), {}, `apps.terminate ${app}`);
|
|
106
154
|
await t.until(async () => (await foreground(t)) !== app, `${app} not in front after apps.terminate`);
|
|
107
155
|
const before = await shown(t);
|
|
108
156
|
if (before === undefined)
|
|
109
|
-
return t.skip("no way to see a launch: the computer declares neither
|
|
157
|
+
return t.skip("no way to see a launch: the computer declares neither ui nor screen");
|
|
110
158
|
t.deepEqual(await t.call("apps.launch", { id: app }), {}, `apps.launch ${app}`);
|
|
111
159
|
await t.until(async () => (await foreground(t)) === app, `${app} in front after apps.launch`);
|
|
112
160
|
// apps.list's word is not enough: the screen must show it.
|
|
113
|
-
if (
|
|
161
|
+
if (readsTree(t)) {
|
|
114
162
|
await t.until(async () => {
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
163
|
+
const seen = await observe(t);
|
|
164
|
+
const ready = uiFixture ? seen.nodes.some((node) => node.id === "next") : rowsOf(seen).length > 0;
|
|
165
|
+
return ready && JSON.stringify(namesOf(seen)) !== before;
|
|
166
|
+
}, `${app} shown after apps.launch: ${uiFixture ? "the ui fixture's Next button" : "Settings' list"} in ui.observe, not the screen before it`);
|
|
118
167
|
}
|
|
119
168
|
else {
|
|
120
|
-
await t.until(async () => (await
|
|
169
|
+
await t.until(async () => (await shown(t)) !== before, `${app} shown after apps.launch: ${declares(t, "screen") ? "a screenshot" : "ui.observe's image"} other than the one before it`);
|
|
121
170
|
}
|
|
122
171
|
t.deepEqual(await t.call("apps.terminate", { id: app }), {}, `apps.terminate ${app}, launched`);
|
|
123
172
|
await t.until(async () => (await foreground(t)) !== app, `${app} no longer in front after apps.terminate`);
|
|
@@ -126,30 +175,81 @@ export const appsCases = [
|
|
|
126
175
|
},
|
|
127
176
|
},
|
|
128
177
|
{
|
|
129
|
-
|
|
178
|
+
// apps.launch answers once the app has a window (wire.md, apps.launch). A driver that answers when the launch is
|
|
179
|
+
// asked for races every caller: the Mac and the phone both answered not_found to the observe right after it.
|
|
180
|
+
id: "apps.launch-window",
|
|
130
181
|
level: "core",
|
|
131
182
|
group: "apps",
|
|
132
|
-
needs: ["apps
|
|
183
|
+
needs: ["apps", "ui"],
|
|
133
184
|
async run(t) {
|
|
134
|
-
|
|
185
|
+
if (treeOff(t) !== undefined && featureOff(t.hello.features ?? {}, "ui.image") !== undefined)
|
|
186
|
+
return t.skip("ui.observe has nothing to show on this computer: ui.tree and ui.image are both off");
|
|
187
|
+
const listed = await t.call("apps.list", {});
|
|
188
|
+
const app = listed.apps.some((one) => one.id === UI_FIXTURE.id) ? UI_FIXTURE.id : stockApp(t, listed.apps);
|
|
189
|
+
t.assert(listed.apps.some((one) => one.id === app), `apps.list holds ${app}`);
|
|
190
|
+
t.deepEqual(await t.call("apps.terminate", { id: app }), {}, `apps.terminate ${app}`);
|
|
191
|
+
await t.until(async () => (await foreground(t)) !== app, `${app} not in front after apps.terminate`);
|
|
192
|
+
t.deepEqual(await t.call("apps.launch", { id: app }), {}, `apps.launch ${app}`);
|
|
193
|
+
// At once, with no wait of the case's own: launch has answered, so the window is there.
|
|
194
|
+
const seen = await t.client.call("ui.observe", { target: { app } }, { signal: t.signal });
|
|
195
|
+
const window = t.ok(seen, `ui.observe of ${app} right after apps.launch answered: launch answers once the app has a window`);
|
|
196
|
+
t.equal(window.app.id, app, "the app ui.observe saw right after apps.launch");
|
|
197
|
+
t.deepEqual(await t.call("apps.terminate", { id: app }), {}, `apps.terminate ${app}, launched`);
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
id: "ui.observe-shape",
|
|
202
|
+
level: "core",
|
|
203
|
+
group: "ui",
|
|
204
|
+
needs: ["ui"],
|
|
205
|
+
async run(t) {
|
|
206
|
+
// With both off, ui.observe is refused by design (wire.md): there is no shape to read, so the case skips in the
|
|
207
|
+
// words hello gives for each.
|
|
208
|
+
const imageOff = featureOff(t.hello.features ?? {}, "ui.image");
|
|
209
|
+
const bothOff = treeOff(t);
|
|
210
|
+
if (bothOff !== undefined && imageOff !== undefined)
|
|
211
|
+
return t.skip(`ui.observe has nothing to show on this computer: ${bothOff}, and ${imageOff}`);
|
|
212
|
+
// What to observe: the ui fixture where the computer has it installed (it needs no exec, files or processes,
|
|
213
|
+
// which a ui driver need not offer); else Settings on a phone with no fixture file; else the input fixture.
|
|
214
|
+
const listed = t.hello.groups.includes("apps") ? await t.call("apps.list", {}) : undefined;
|
|
215
|
+
const uiFixture = listed?.apps.some((app) => app.id === UI_FIXTURE.id) === true;
|
|
216
|
+
const settings = !uiFixture && throughSettings(t);
|
|
135
217
|
if (settings)
|
|
136
218
|
await openSettings(t);
|
|
219
|
+
else if (uiFixture) {
|
|
220
|
+
t.deepEqual(await t.call("apps.launch", { id: UI_FIXTURE.id }), {}, `apps.launch ${UI_FIXTURE.id}`);
|
|
221
|
+
await t.until(async () => (await t.call("apps.list", {})).foreground === UI_FIXTURE.id, `${UI_FIXTURE.id} in front after apps.launch`);
|
|
222
|
+
}
|
|
137
223
|
else
|
|
138
224
|
await t.fixture();
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
t.
|
|
225
|
+
const off = treeOff(t);
|
|
226
|
+
if (off !== undefined) {
|
|
227
|
+
// With ui.tree off the observation is image-only: no nodes, the reason in empty, and the window's image.
|
|
228
|
+
const seen = await observe(t);
|
|
229
|
+
const wrong = observeWrong(seen);
|
|
230
|
+
t.assert(wrong === undefined, `ui.observe: ${wrong}`);
|
|
231
|
+
t.deepEqual(seen.nodes, [], "with ui.tree off, ui.observe gives no nodes");
|
|
232
|
+
const why = (t.hello.features?.["ui.tree"]).off;
|
|
233
|
+
t.assert(typeof seen.empty === "string" && seen.empty.includes(why), `empty says why with ui.tree's declared sentence "${why}": ${show(seen.empty)}`);
|
|
234
|
+
const image = t.present(seen.image, "with ui.tree off, ui.observe gives the window's image unasked");
|
|
235
|
+
t.assert(image.width > 0 && image.height > 0 && typeof image.data === "string" && image.data !== "", `the image is ${show({ ...image, data: `${image.data?.length} chars` })}, not one with pixels`);
|
|
149
236
|
return;
|
|
150
237
|
}
|
|
151
|
-
|
|
152
|
-
|
|
238
|
+
// Settings comes up, or the fixture's button, before the shape is read: a phone draws its window after the launch.
|
|
239
|
+
const waitedFor = settings ? "Settings' list, with its rows, in ui.observe" : uiFixture ? `the ui fixture's Next button, by its id, in ui.observe` : `the fixture's button, by its id ${FIXTURE_BUTTON.id}, in ui.observe`;
|
|
240
|
+
const seen = await t.until(async () => {
|
|
241
|
+
const one = await observe(t);
|
|
242
|
+
const ready = settings ? rowsOf(one).length > 0 : one.nodes.some((node) => node.id === (uiFixture ? "next" : FIXTURE_BUTTON.id));
|
|
243
|
+
return ready || observeWrong(one) !== undefined ? one : undefined;
|
|
244
|
+
}, waitedFor);
|
|
245
|
+
const wrong = observeWrong(seen);
|
|
246
|
+
t.assert(wrong === undefined, `ui.observe: ${wrong}`);
|
|
247
|
+
if (settings)
|
|
248
|
+
return;
|
|
249
|
+
if (uiFixture)
|
|
250
|
+
return t.equal(seen.app.id, UI_FIXTURE.id, "the observed app");
|
|
251
|
+
const button = t.present(seen.nodes.find((node) => node.id === FIXTURE_BUTTON.id), `the fixture's button, by its id ${FIXTURE_BUTTON.id}, in ui.observe`);
|
|
252
|
+
t.equal(button.name, FIXTURE_BUTTON.text, "the fixture's button's name");
|
|
153
253
|
},
|
|
154
254
|
},
|
|
155
255
|
];
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// says it is; what the provider declares of itself, its capabilities() and each hello agree, at this protocol's
|
|
3
3
|
// version; and no error the provider answers holds a key.
|
|
4
4
|
import { GROUPS, PROTOCOL_VERSION } from "../../protocol.js";
|
|
5
|
+
import { kindServed } from "../../kinds.js";
|
|
5
6
|
import { kindRefusals } from "../../provider.js";
|
|
6
7
|
import { coreGroups } from "../types.js";
|
|
7
8
|
export const healthCases = [
|
|
@@ -69,6 +70,19 @@ export const healthCases = [
|
|
|
69
70
|
}
|
|
70
71
|
},
|
|
71
72
|
},
|
|
73
|
+
{
|
|
74
|
+
// A computer is handed to an agent by the setting kind its machine kind belongs to. A desktop whose hello lists no
|
|
75
|
+
// input.pointer passes every case it declares, and is refused the first time an agent is given it; this fails it
|
|
76
|
+
// here instead, by the groups it lacks.
|
|
77
|
+
id: "health.kind-served",
|
|
78
|
+
level: "core",
|
|
79
|
+
group: "health",
|
|
80
|
+
needs: [],
|
|
81
|
+
async run(t) {
|
|
82
|
+
const missing = kindServed(t.hello);
|
|
83
|
+
t.deepEqual(missing, [], `the groups a ${t.hello.os} ${t.hello.kind} must declare in hello to be given to an agent, which it lacks`);
|
|
84
|
+
},
|
|
85
|
+
},
|
|
72
86
|
{
|
|
73
87
|
// The provider says what it is three times: in what it declares of itself (its descriptor), in capabilities(), and
|
|
74
88
|
// in each computer's hello. A runner trusts the first to pick a provider, the second to call it, and the third to
|
|
@@ -13,6 +13,7 @@ import { processCases } from "./process.js";
|
|
|
13
13
|
import { providerCases } from "./provider.js";
|
|
14
14
|
import { screenCases } from "./screen.js";
|
|
15
15
|
import { touchCases } from "./touch.js";
|
|
16
|
+
import { uiCases } from "./ui.js";
|
|
16
17
|
export { browserCases, browserOnlyCases } from "./browser.js";
|
|
17
18
|
export const conformanceCases = [
|
|
18
19
|
...healthCases,
|
|
@@ -27,6 +28,7 @@ export const conformanceCases = [
|
|
|
27
28
|
...inputCases,
|
|
28
29
|
...touchCases,
|
|
29
30
|
...appsCases,
|
|
31
|
+
...uiCases,
|
|
30
32
|
...lifetimeCases,
|
|
31
33
|
...gpuCases,
|
|
32
34
|
];
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ComputerClient } from "../../protocol.js";
|
|
2
2
|
import type { Case, CaseContext } from "../types.js";
|
|
3
3
|
/**
|
|
4
|
-
* The
|
|
5
|
-
*
|
|
4
|
+
* The unix sockets a program of the computer's user may connect to: the computer's own, computerd's and the Archil sync
|
|
5
|
+
* socket (which only syncs). A network namespace does not cut a path socket, and every program in the namespace reaches
|
|
6
|
+
* an abstract name (@...), so any other socket is a door out.
|
|
6
7
|
*/
|
|
7
8
|
export declare const OWN_SOCKETS: readonly string[];
|
|
8
9
|
/**
|
|
@@ -13,9 +14,10 @@ export declare const OUTSIDE_TARGETS: string[];
|
|
|
13
14
|
/**
|
|
14
15
|
* The isolation check, on the computer `client` reaches (the case's own by default): computerd's probe, run as the
|
|
15
16
|
* computer's user, sees its own loopback alone, and is refused at the vendor's agent's declared ports on 127.0.0.1 and
|
|
16
|
-
* ::1 and at OUTSIDE_TARGETS; and the
|
|
17
|
-
* computer's own (OWN_SOCKETS, and a desktop's display) alone, each recorded with its type
|
|
18
|
-
*
|
|
17
|
+
* ::1 and at OUTSIDE_TARGETS; and the unix sockets it connects to, paths and abstract names (the probe's own listing,
|
|
18
|
+
* --sockets), are the computer's own (OWN_SOCKETS, and a desktop's display) alone, each recorded with its type; and every TCP and UDP
|
|
19
|
+
* listener in its own network is computerd's (assertOnlyComputerdListens: today, none listens). A probe that reports no
|
|
20
|
+
* socket list or no listener list, or a search it could not finish, fails the check in words. The Archil case mount.archil-isolated-durable runs the same check on an Archil computer.
|
|
19
21
|
*/
|
|
20
22
|
export declare function assertIsolated(t: CaseContext, client?: ComputerClient): Promise<void>;
|
|
21
23
|
export declare const isolationCases: Case[];
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// A program the computer's user runs reaches none of the vendor's own agent, whose ports each provider declares
|
|
2
|
-
// (capabilities().vendorAgentPorts), and no outside address,
|
|
3
|
-
// --own-network at work.
|
|
2
|
+
// (capabilities().vendorAgentPorts), and no outside address, sees its own loopback alone, and finds nothing listening in
|
|
3
|
+
// its own network but computerd: computerd init --own-network at work.
|
|
4
4
|
import { DAEMON_IN_COMPUTER, SOCKET_DIR } from "../../drift.js";
|
|
5
5
|
import { ARCHIL_SYNC_SOCKET } from "../../mount-archil.js";
|
|
6
6
|
/**
|
|
7
|
-
* The
|
|
8
|
-
*
|
|
7
|
+
* The unix sockets a program of the computer's user may connect to: the computer's own, computerd's and the Archil sync
|
|
8
|
+
* socket (which only syncs). A network namespace does not cut a path socket, and every program in the namespace reaches
|
|
9
|
+
* an abstract name (@...), so any other socket is a door out.
|
|
9
10
|
*/
|
|
10
11
|
export const OWN_SOCKETS = [`${SOCKET_DIR}/computerd.sock`, ARCHIL_SYNC_SOCKET];
|
|
11
12
|
/**
|
|
@@ -16,9 +17,10 @@ export const OUTSIDE_TARGETS = ["1.1.1.1:443", "example.com:443"];
|
|
|
16
17
|
/**
|
|
17
18
|
* The isolation check, on the computer `client` reaches (the case's own by default): computerd's probe, run as the
|
|
18
19
|
* computer's user, sees its own loopback alone, and is refused at the vendor's agent's declared ports on 127.0.0.1 and
|
|
19
|
-
* ::1 and at OUTSIDE_TARGETS; and the
|
|
20
|
-
* computer's own (OWN_SOCKETS, and a desktop's display) alone, each recorded with its type
|
|
21
|
-
*
|
|
20
|
+
* ::1 and at OUTSIDE_TARGETS; and the unix sockets it connects to, paths and abstract names (the probe's own listing,
|
|
21
|
+
* --sockets), are the computer's own (OWN_SOCKETS, and a desktop's display) alone, each recorded with its type; and every TCP and UDP
|
|
22
|
+
* listener in its own network is computerd's (assertOnlyComputerdListens: today, none listens). A probe that reports no
|
|
23
|
+
* socket list or no listener list, or a search it could not finish, fails the check in words. The Archil case mount.archil-isolated-durable runs the same check on an Archil computer.
|
|
22
24
|
*/
|
|
23
25
|
export async function assertIsolated(t, client) {
|
|
24
26
|
const ports = t.provider.capabilities().vendorAgentPorts ?? [];
|
|
@@ -52,27 +54,55 @@ export async function assertIsolated(t, client) {
|
|
|
52
54
|
const what = agent.includes(target) ? "the vendor's agent" : "the outside";
|
|
53
55
|
t.equal(result?.outcome, "refused", `a program of the computer's user, to ${what} at ${target} (${String(result?.detail ?? "no result")})`);
|
|
54
56
|
}
|
|
55
|
-
// The
|
|
56
|
-
// the type that connected (stream, dgram, seqpacket); a
|
|
57
|
+
// The unix sockets: paths, which no network namespace cuts, and the abstract names of the user's own namespace.
|
|
58
|
+
// computerd's own listing, so no image can lack it. Each with the type that connected (stream, dgram, seqpacket); a
|
|
59
|
+
// search it could not finish proves nothing, and fails.
|
|
57
60
|
const search = probe.sockets;
|
|
58
61
|
if (search === null || typeof search !== "object" || !Array.isArray(search.sockets) || !Array.isArray(search.incomplete)) {
|
|
59
|
-
return t.assert(false, "the probe reported no list of the
|
|
62
|
+
return t.assert(false, "the probe reported no list of the unix sockets a program can connect to (a computerd too old for probe --sockets), so the socket fence could not run");
|
|
60
63
|
}
|
|
61
64
|
const found = search.sockets.map((one) => ({ path: String(one.path), type: String(one.type) }));
|
|
62
|
-
t.observe(`
|
|
65
|
+
t.observe(`unix sockets a tool can connect to: ${found.map(({ path, type }) => `${path} (${type})`).join(", ") || "none"}`);
|
|
63
66
|
const incomplete = search.incomplete.map(String);
|
|
64
67
|
t.assert(incomplete.length === 0, `the probe could not search every place a socket may be, so the socket fence is unproven: ${incomplete.join("; ")}`);
|
|
65
|
-
// A desktop's tools draw on its display: the
|
|
68
|
+
// A desktop's tools draw on its display: the X server of the display its hello names, on its path and on the same
|
|
69
|
+
// name as an abstract one, is the computer's own too.
|
|
66
70
|
const own = [...OWN_SOCKETS];
|
|
67
71
|
if (t.provider.capabilities().kind === "desktop") {
|
|
68
72
|
const display = await displaySocket(client ?? t.client);
|
|
69
73
|
if (display !== undefined)
|
|
70
|
-
own.push(display);
|
|
74
|
+
own.push(display, `@${display}`);
|
|
71
75
|
else
|
|
72
76
|
t.observe("the desktop's display socket: not known (its hello names no display of the form :N)");
|
|
73
77
|
}
|
|
74
78
|
const other = found.filter(({ path }) => !own.includes(path)).map(({ path, type }) => `${path} (${type})`);
|
|
75
|
-
t.assert(other.length === 0, `a program of the computer's user connects to
|
|
79
|
+
t.assert(other.length === 0, `a program of the computer's user connects to unix sockets that are not the computer's own (${own.join(", ")}): ${other.join(", ")}`);
|
|
80
|
+
assertOnlyComputerdListens(t, probe.listeners);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The TCP and UDP listeners in the network of the computer's user (the probe's listing, --sockets, from /proc/net/tcp,
|
|
84
|
+
* tcp6, udp and udp6 of its own namespace) are computerd's alone: each held by a process that runs computerd's own
|
|
85
|
+
* program, as the probe ties a socket's inode to the descriptors of the processes /proc shows it. Computerd listens on
|
|
86
|
+
* nothing there today: init's one TCP listener, the egress relay (--egress), is a Docker computer's, which takes no
|
|
87
|
+
* --own-network, and the Archil relay and sync server run as root beside the fence, in the vendor's network. So the rule
|
|
88
|
+
* now is that nothing listens. Init's own descriptors are not the probe's to read (it drops to the programs' uid
|
|
89
|
+
* non-dumpable), so a listener init opened there would fail here, named, until the probe ties it. A listing the probe did
|
|
90
|
+
* not report, or a table it could not read, fails in words.
|
|
91
|
+
*/
|
|
92
|
+
function assertOnlyComputerdListens(t, reported) {
|
|
93
|
+
const search = reported;
|
|
94
|
+
if (search === null || typeof search !== "object" || !Array.isArray(search.listeners) || !Array.isArray(search.incomplete)) {
|
|
95
|
+
return t.assert(false, "the probe reported no list of the TCP and UDP listeners in the user's own network (a computerd too old for its listeners), so the listener fence could not run");
|
|
96
|
+
}
|
|
97
|
+
const listeners = search.listeners.map((one) => {
|
|
98
|
+
const { protocol, address, port, owner, computerd } = one;
|
|
99
|
+
return { protocol: String(protocol), address: String(address), port: String(port), owner: typeof owner === "string" && owner !== "" ? owner : "its owner not shown", computerd: computerd === true };
|
|
100
|
+
});
|
|
101
|
+
t.observe(`TCP and UDP listeners in the user's own network: ${listeners.map((one) => `${one.protocol} ${one.address} port ${one.port} (${one.owner}${one.computerd ? ", computerd" : ""})`).join(", ") || "none"}`);
|
|
102
|
+
const incomplete = search.incomplete.map(String);
|
|
103
|
+
t.assert(incomplete.length === 0, `the probe could not read every table of listeners, so the listener fence is unproven: ${incomplete.join("; ")}`);
|
|
104
|
+
const stray = listeners.filter((one) => !one.computerd).map((one) => `${one.protocol} port ${one.port} listens in the user's own network (on ${one.address}, ${one.owner}), and it isn't computerd's`);
|
|
105
|
+
t.assert(stray.length === 0, stray.join("; "));
|
|
76
106
|
}
|
|
77
107
|
/**
|
|
78
108
|
* The X socket of the display a desktop's hello names (:N or :N.S, /tmp/.X11-unix/XN). Asked of the daemon itself: its
|
|
@@ -178,7 +178,7 @@ const archilIsolatedDurable = mount("archil-isolated-durable", async (t) => {
|
|
|
178
178
|
const { ref } = await mounted(t, folder, EPOCH, "mount-archil-isolated-durable");
|
|
179
179
|
const connected = await t.connect(ref);
|
|
180
180
|
// isolation.vendor-agent's own check, on this Archil computer: lo alone, refused at the vendor's agent and outside,
|
|
181
|
-
// and no
|
|
181
|
+
// and no unix socket a tool connects to but the computer's own (computerd's, the sync socket).
|
|
182
182
|
await assertIsolated(t, connected.client);
|
|
183
183
|
const nonce = randomBytes(6).toString("hex");
|
|
184
184
|
const ran = await t.exec(["sh", "-c", `printf '%s\\n' ${nonce} > exec-${nonce}.txt`], { cwd: WORKSPACE }, connected.client);
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// what they say, the network reads back as asked, a change to a network the provider does not declare is refused
|
|
3
3
|
// (Core) and one it does declare is refused or applied truthfully (Full), a computer does not run past its deadline,
|
|
4
4
|
// the janitor ends only the expired, stopped or running, and a takeover releases the run's lower epochs by label (Full).
|
|
5
|
+
// A create retried with its request id answers the computer the first made, and after release is refused (Full).
|
|
5
6
|
import { randomBytes } from "node:crypto";
|
|
6
7
|
import { releaseOlder, sweep } from "../../janitor.js";
|
|
7
8
|
import { EPOCH_LABEL, OWNER_LABEL, RUN_LABEL, runLabels } from "../../labels.js";
|
|
8
|
-
import { runLifetimeMs } from "../../provider.js";
|
|
9
|
+
import { computerNameFor, runLifetimeMs } from "../../provider.js";
|
|
9
10
|
import { b64, CASE_LABEL, decode } from "./util.js";
|
|
10
11
|
/** Labels for one case's computers: the run's, and the case's own. */
|
|
11
12
|
const own = (t, name) => ({ ...t.runLabels, [CASE_LABEL]: name });
|
|
@@ -146,6 +147,31 @@ export const providerCases = [
|
|
|
146
147
|
t.deepEqual(await names(t, labels), [], "listed after delete");
|
|
147
148
|
t.refused(await t.provider.connect(ref), "connect to a deleted computer", ["gone", "not_found"]);
|
|
148
149
|
}),
|
|
150
|
+
provider("create-retried", async (t) => {
|
|
151
|
+
// A retry of one request, at once and after it is up, answers the computer the first made: never a second.
|
|
152
|
+
const labels = own(t, "retried");
|
|
153
|
+
const spec = t.spec({ labels });
|
|
154
|
+
const requestId = `conformance-retried-${randomBytes(6).toString("hex")}`;
|
|
155
|
+
const [first, early] = await Promise.all([t.attempt(spec, t.provider, requestId), t.attempt(spec, t.provider, requestId)]);
|
|
156
|
+
const made = t.ok(first, "create");
|
|
157
|
+
t.deepEqual(refOf(t.ok(early, "the same create again while the first starts")), refOf(made), "the computer a create retried while it starts answers");
|
|
158
|
+
t.deepEqual(refOf(t.ok(await t.attempt(spec, t.provider, requestId), "the same create again once it is up")), refOf(made), "the computer a create retried once it is up answers");
|
|
159
|
+
t.equal(made.name, computerNameFor(requestId), "the computer's name, computer-<12 hex of sha256(request id)>");
|
|
160
|
+
t.deepEqual(await names(t, labels), [made.name], "the computers three creates of one request made");
|
|
161
|
+
const other = t.refused(await t.attempt(t.spec({ labels: { ...labels, role: "other" } }), t.provider, requestId), "the same request id with other labels", ["exists"]);
|
|
162
|
+
t.assert(other.message.includes(made.name), `the refusal names the request's computer ${made.name}: ${other.message}`);
|
|
163
|
+
}, { level: "full" }),
|
|
164
|
+
provider("create-after-release", async (t) => {
|
|
165
|
+
// A request whose computer has ended is spent: the same id again is refused exists, in words, and makes nothing.
|
|
166
|
+
const labels = own(t, "after-release");
|
|
167
|
+
const spec = t.spec({ labels });
|
|
168
|
+
const requestId = `conformance-after-release-${randomBytes(6).toString("hex")}`;
|
|
169
|
+
const made = t.ok(await t.attempt(spec, t.provider, requestId), "create");
|
|
170
|
+
t.ok(await t.provider.release(made, "delete"), "release delete");
|
|
171
|
+
const again = t.refused(await t.attempt(spec, t.provider, requestId), "the same request id after its computer was released", ["exists"]);
|
|
172
|
+
t.match(again.message, /was made for this request and has ended: create with a new request id/, "the refusal says what to do");
|
|
173
|
+
t.deepEqual(await names(t, labels), [], "the computers the refused create made");
|
|
174
|
+
}, { level: "full" }),
|
|
149
175
|
provider("attach", async (t) => {
|
|
150
176
|
const labels = own(t, "attach");
|
|
151
177
|
const spec = t.spec({ labels: { ...labels, role: "a" } });
|
|
@@ -6,4 +6,7 @@ export declare function shoot(t: CaseContext, region?: Rect): Promise<{
|
|
|
6
6
|
shot: ScreenShotResult;
|
|
7
7
|
image: Png;
|
|
8
8
|
}>;
|
|
9
|
+
/** Why this computer's screen is not captured, as hello's screen.capture says it off (an attached Mac whose owner has
|
|
10
|
+
* not granted the screen); undefined when it is on, or not declared, which a computer of the screen group means as on. */
|
|
11
|
+
export declare function captureOff(t: CaseContext): string | undefined;
|
|
9
12
|
export declare const screenCases: Case[];
|
|
@@ -38,6 +38,18 @@ export async function shoot(t, region) {
|
|
|
38
38
|
}
|
|
39
39
|
return { shot, image };
|
|
40
40
|
}
|
|
41
|
+
/** Why this computer's screen is not captured, as hello's screen.capture says it off (an attached Mac whose owner has
|
|
42
|
+
* not granted the screen); undefined when it is on, or not declared, which a computer of the screen group means as on. */
|
|
43
|
+
export function captureOff(t) {
|
|
44
|
+
const value = t.hello.features?.["screen.capture"];
|
|
45
|
+
return typeof value === "object" ? value.off : undefined;
|
|
46
|
+
}
|
|
47
|
+
/** With screen.capture off, `method` is refused `denied` with its reason, never ignored nor answered. */
|
|
48
|
+
async function refusedOff(t, off, method) {
|
|
49
|
+
const result = method === "screen.shot" ? await t.client.call("screen.shot", {}) : await t.client.call("screen.watch", { after: 0, waitMs: 0 });
|
|
50
|
+
const error = t.refused(result, `${method} with screen.capture off`, ["denied"]);
|
|
51
|
+
t.assert(error.message.includes(off), `${method}'s refusal says hello's screen.capture reason (${JSON.stringify(off)}): ${JSON.stringify(error.message)}`);
|
|
52
|
+
}
|
|
41
53
|
const QUADRANTS = ["top left", "top right", "bottom left", "bottom right"];
|
|
42
54
|
export const screenCases = [
|
|
43
55
|
{
|
|
@@ -46,6 +58,9 @@ export const screenCases = [
|
|
|
46
58
|
group: "screen",
|
|
47
59
|
needs: ["screen"],
|
|
48
60
|
async run(t) {
|
|
61
|
+
const off = captureOff(t);
|
|
62
|
+
if (off !== undefined)
|
|
63
|
+
return refusedOff(t, off, "screen.shot");
|
|
49
64
|
const { shot, image } = await shoot(t);
|
|
50
65
|
t.assert(shot.width > 0 && shot.height > 0, `the shot is ${shot.width}x${shot.height}`);
|
|
51
66
|
t.deepEqual([image.width, image.height], [shot.width, shot.height], "the PNG's size (IHDR), against the shot's width and height");
|
|
@@ -72,6 +87,9 @@ export const screenCases = [
|
|
|
72
87
|
group: "screen",
|
|
73
88
|
needs: ["screen"],
|
|
74
89
|
async run(t) {
|
|
90
|
+
const off = captureOff(t);
|
|
91
|
+
if (off !== undefined)
|
|
92
|
+
return refusedOff(t, off, "screen.watch");
|
|
75
93
|
const { shot } = await shoot(t);
|
|
76
94
|
const watcher = t.provider.watch;
|
|
77
95
|
t.assert(watcher !== undefined, "the provider has no watch(): a computer with a screen gives its live view through it");
|