@ai-ecoverse/slicc-browsers 1.55.0 → 1.56.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/README.md +9 -8
- package/catalog.json +15 -0
- package/engine/engine-js.mjs +1 -1
- package/engine/engine-wasm.mjs +1 -1
- package/engine/engine.wasm +0 -0
- package/engine-vectors.json +813 -14
- package/failed-read-document.mjs +331 -0
- package/guard-driver.mjs +2 -0
- package/guard-runner.mjs +111 -17
- package/guard-vectors.json +650 -23
- package/package.json +7 -3
- package/persistent-subscriptions.mjs +136 -0
- package/protected-error-page.mjs +106 -54
- package/protected-js.mjs +1 -1
- package/protected.mjs +1 -1
- package/schema/catalog.schema.json +7 -1
- package/schema/engine-vectors.schema.json +4 -0
- package/schema/guard-vectors.schema.json +26 -0
- package/sealed-attach.mjs +406 -0
- package/sealed-event-rules.mjs +1 -0
|
@@ -316,7 +316,7 @@
|
|
|
316
316
|
"const": "slicc: refused: slicc can't parse this URL, so it could be a protected page"
|
|
317
317
|
},
|
|
318
318
|
"sealedAllowed": {
|
|
319
|
-
"description": "Exact commands allowed on a sealed document.
|
|
319
|
+
"description": "Exact commands allowed on a sealed document. Stock attach subscriptions are forwarded; replayed and subsequent content events from sealed documents are withheld. Target discovery is redacted, Page.enable is for lifecycle and navigation, and Fetch.enable still requires the guard’s request restrictions. Tree replies are separately projected. Exact sealedAllowed entries take precedence over sealedContent wildcards. Unlisted commands are refused except for the separately checked sealedPreloadSources shape.",
|
|
320
320
|
"type": "array",
|
|
321
321
|
"uniqueItems": true,
|
|
322
322
|
"items": {
|
|
@@ -324,6 +324,12 @@
|
|
|
324
324
|
"pattern": "^[A-Z][A-Za-z0-9]*\\.[a-z][A-Za-z0-9]*$"
|
|
325
325
|
}
|
|
326
326
|
},
|
|
327
|
+
"sealedPreloadSources": {
|
|
328
|
+
"description": "Exact inert source annotations for a named isolated world; no additional parameters, and the reply contains only a nonempty identifier. This is not a general preload grant.",
|
|
329
|
+
"type": "array",
|
|
330
|
+
"uniqueItems": true,
|
|
331
|
+
"items": { "type": "string", "pattern": "^(?:|//# sourceURL=[a-zA-Z0-9:._/-]+)$" }
|
|
332
|
+
},
|
|
327
333
|
"sealedEvents": {
|
|
328
334
|
"description": "Content events withheld on sealed documents even for earlier subscriptions. Domain.* covers every event in the domain; named events do not close other lifecycle or metadata events.",
|
|
329
335
|
"type": "array",
|
|
@@ -340,6 +340,10 @@
|
|
|
340
340
|
"type": "object",
|
|
341
341
|
"description": "A routed child receipt binds sessionId to parentSessionId, targetId and revision. Non-public children are never delivered. On a non-mixed page the reported targetInfo can prove an ordinary child without a receipt. For absent or empty targetInfo supply the bound child’s retained targetInfo, or a bound public attached/retiredOrdinary receipt. For an empty-URL dedicated worker without its own reported origin, context.frame identifies the attaching document and loader. Shared and service worker routes need their own script URL, never an owner verdict."
|
|
342
342
|
},
|
|
343
|
+
"request": {
|
|
344
|
+
"type": "object",
|
|
345
|
+
"description": "A guard-owned request receipt. Retain sealed:true and its requestId or interceptionId for traffic from a sealed document, scoped to the owning target across recovery and reattach. Supply it on dispatch, reply and event delivery; never use client-supplied provenance."
|
|
346
|
+
},
|
|
343
347
|
"queued": {
|
|
344
348
|
"type": "boolean",
|
|
345
349
|
"description": "True when releasing a queued event. Supply the original context.observed session, composition revision and mixed flag (plus realm or hop receipts where applicable) and the current release revision on both context and page. Missing or changed evidence withholds the item. An immediate event on a never-mixed page needs no queue receipt."
|
|
@@ -141,6 +141,9 @@
|
|
|
141
141
|
"type": "string",
|
|
142
142
|
"minLength": 1
|
|
143
143
|
},
|
|
144
|
+
"persistentSubscriptions": { "type": "string", "minLength": 1 },
|
|
145
|
+
"stockPuppeteer": { "type": "string", "minLength": 1 },
|
|
146
|
+
"originReadFault": { "type": "string", "minLength": 1 },
|
|
144
147
|
"inboundDelay": {
|
|
145
148
|
"type": "string",
|
|
146
149
|
"minLength": 1
|
|
@@ -240,6 +243,9 @@
|
|
|
240
243
|
"clientExit",
|
|
241
244
|
"siteIsolationOff",
|
|
242
245
|
"inboundDelay",
|
|
246
|
+
"originReadFault",
|
|
247
|
+
"stockPuppeteer",
|
|
248
|
+
"persistentSubscriptions",
|
|
243
249
|
"secureOrigin",
|
|
244
250
|
"forwardAudit",
|
|
245
251
|
"frameOwnershipProbe",
|
|
@@ -613,6 +619,26 @@
|
|
|
613
619
|
}
|
|
614
620
|
}
|
|
615
621
|
},
|
|
622
|
+
{
|
|
623
|
+
"type": "object",
|
|
624
|
+
"additionalProperties": false,
|
|
625
|
+
"required": ["sealedAttach", "as"],
|
|
626
|
+
"properties": {
|
|
627
|
+
"sealedAttach": { "enum": ["burst", "puppeteer", "child"] },
|
|
628
|
+
"as": { "$ref": "#/$defs/name" },
|
|
629
|
+
"requires": { "enum": [["stockPuppeteer"], ["iframeAutoAttach"]] }
|
|
630
|
+
}
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
"type": "object",
|
|
634
|
+
"additionalProperties": false,
|
|
635
|
+
"required": ["failedReadDocument", "as", "requires"],
|
|
636
|
+
"properties": {
|
|
637
|
+
"failedReadDocument": { "enum": ["blank", "srcdoc", "empty"] },
|
|
638
|
+
"requires": { "const": ["originReadFault"] },
|
|
639
|
+
"as": { "$ref": "#/$defs/name" }
|
|
640
|
+
}
|
|
641
|
+
},
|
|
616
642
|
{
|
|
617
643
|
"type": "object",
|
|
618
644
|
"additionalProperties": false,
|
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import { outcome, waitFor } from './guard-driver.mjs';
|
|
2
|
+
import { armPersistent, persistentEvent, persistentWitness } from './persistent-subscriptions.mjs';
|
|
3
|
+
import { sealedContentEvent } from './sealed-events.mjs';
|
|
4
|
+
|
|
5
|
+
const domains = ['Page', 'Network', 'Runtime', 'Log', 'DOM', 'CSS', 'Audits'];
|
|
6
|
+
const types = [
|
|
7
|
+
'Runtime.executionContextCreated',
|
|
8
|
+
'Log.entryAdded',
|
|
9
|
+
'CSS.styleSheetAdded',
|
|
10
|
+
'DOM.documentUpdated',
|
|
11
|
+
'Audits.issueAdded',
|
|
12
|
+
];
|
|
13
|
+
const missing = (reason) => ({ incomplete: `sealed attach: ${reason}` });
|
|
14
|
+
const slice = (conn, start, sid) => conn.events.slice(start).filter((e) => e.sessionId === sid);
|
|
15
|
+
|
|
16
|
+
const fixtureFailsNavigation = (side, mode) => side === 'control' || mode === 'child';
|
|
17
|
+
|
|
18
|
+
async function failNavigation(reader, session, failedURL, until, control) {
|
|
19
|
+
const from = reader.events.length;
|
|
20
|
+
if (control)
|
|
21
|
+
await reader.send(
|
|
22
|
+
'Fetch.enable',
|
|
23
|
+
{ patterns: [{ resourceType: 'Document', urlPattern: new URL(failedURL).origin + '/*' }] },
|
|
24
|
+
session
|
|
25
|
+
);
|
|
26
|
+
try {
|
|
27
|
+
const nav = outcome(reader.send('Page.navigate', { url: failedURL }, session));
|
|
28
|
+
if (control) {
|
|
29
|
+
const paused = () =>
|
|
30
|
+
slice(reader, from, session).find(
|
|
31
|
+
(e) => e.method === 'Fetch.requestPaused' && e.params.request.url === failedURL
|
|
32
|
+
);
|
|
33
|
+
if (!(await until(paused))) return false;
|
|
34
|
+
await reader.send(
|
|
35
|
+
'Fetch.failRequest',
|
|
36
|
+
{ requestId: paused().params.requestId, errorReason: 'BlockedByClient' },
|
|
37
|
+
session
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
if (!(await nav).ok) return false;
|
|
41
|
+
return until(async () => {
|
|
42
|
+
const { frameTree } = await reader.send('Page.getFrameTree', {}, session);
|
|
43
|
+
return (
|
|
44
|
+
frameTree.frame.url === 'chrome-error://chromewebdata/' &&
|
|
45
|
+
frameTree.frame.unreachableUrl === failedURL
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
} finally {
|
|
49
|
+
if (control) await reader.send('Fetch.disable', {}, session);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const prime = (tag) => `(() => {
|
|
54
|
+
const style = document.createElement('style'); style.textContent='html { --sealed-attach: 1 }'; document.head.append(style);
|
|
55
|
+
getComputedStyle(document.documentElement).getPropertyValue('--sealed-attach');
|
|
56
|
+
const meta = document.createElement('meta'); meta.httpEquiv='Content-Security-Policy'; meta.content='img-src https://${tag}.invalid'; document.head.append(meta);
|
|
57
|
+
new Image().src='https://blocked-${tag}.invalid/fixture.png'; return true;
|
|
58
|
+
})()`;
|
|
59
|
+
|
|
60
|
+
async function enableBurst({
|
|
61
|
+
client,
|
|
62
|
+
reader,
|
|
63
|
+
targetId,
|
|
64
|
+
observer,
|
|
65
|
+
until,
|
|
66
|
+
side,
|
|
67
|
+
tag,
|
|
68
|
+
ordinary,
|
|
69
|
+
persistentHidden,
|
|
70
|
+
}) {
|
|
71
|
+
const attach = async (conn) =>
|
|
72
|
+
(await conn.send('Target.attachToTarget', { targetId, flatten: true })).sessionId;
|
|
73
|
+
const logMark = `burst-${tag}`;
|
|
74
|
+
const from = reader.events.length;
|
|
75
|
+
await reader.send('Log.enable', {}, observer);
|
|
76
|
+
await reader.send('Audits.enable', {}, observer);
|
|
77
|
+
await reader.send(
|
|
78
|
+
'Runtime.evaluate',
|
|
79
|
+
{ expression: prime(logMark), returnByValue: true },
|
|
80
|
+
observer
|
|
81
|
+
);
|
|
82
|
+
const tagged = (e) => e.method === 'Log.entryAdded' && e.params.entry.text.includes(logMark);
|
|
83
|
+
const issue = (e, mark) =>
|
|
84
|
+
e.method === 'Audits.issueAdded' &&
|
|
85
|
+
e.params.issue.code === 'ContentSecurityPolicyIssue' &&
|
|
86
|
+
JSON.stringify(e.params.issue.details).includes(mark);
|
|
87
|
+
if (
|
|
88
|
+
!(await until(() => {
|
|
89
|
+
const ev = slice(reader, from, observer);
|
|
90
|
+
return ev.some(tagged) && ev.some((e) => issue(e, logMark));
|
|
91
|
+
}))
|
|
92
|
+
)
|
|
93
|
+
return missing(
|
|
94
|
+
`buffered CSP witness missing: log=${slice(reader, from, observer).some(tagged)}, issue=${slice(reader, from, observer).some((e) => issue(e, logMark))}`
|
|
95
|
+
);
|
|
96
|
+
const raw = await attach(reader);
|
|
97
|
+
const test = await attach(client);
|
|
98
|
+
try {
|
|
99
|
+
const a = reader.events.length,
|
|
100
|
+
b = client.events.length;
|
|
101
|
+
const events = () => slice(client, b, test);
|
|
102
|
+
for (const domain of domains) {
|
|
103
|
+
await reader.send(domain + '.enable', {}, raw);
|
|
104
|
+
const enable = await outcome(client.send(domain + '.enable', {}, test));
|
|
105
|
+
if (!enable.ok)
|
|
106
|
+
return { live: true, sealedEnableBurstWithheld: false, subscriptionsActive: false };
|
|
107
|
+
}
|
|
108
|
+
const rewritten = await reader.send(
|
|
109
|
+
'Runtime.evaluate',
|
|
110
|
+
{
|
|
111
|
+
expression:
|
|
112
|
+
"document.open();document.write('<title>sealed attach</title>');document.close();true",
|
|
113
|
+
returnByValue: true,
|
|
114
|
+
},
|
|
115
|
+
observer
|
|
116
|
+
);
|
|
117
|
+
if (rewritten.result?.value !== true) return missing('DOM update did not execute');
|
|
118
|
+
const witnessed = (ev) =>
|
|
119
|
+
ev.some(tagged) &&
|
|
120
|
+
ev.some((e) => issue(e, logMark)) &&
|
|
121
|
+
types.every((method) => ev.some((e) => e.method === method));
|
|
122
|
+
if (!(await until(() => witnessed(slice(reader, a, raw)))))
|
|
123
|
+
return missing(
|
|
124
|
+
`raw enable replay missing: ${types.filter((method) => !slice(reader, a, raw).some((e) => e.method === method)).join(', ') || 'tagged CSP marker'}`
|
|
125
|
+
);
|
|
126
|
+
if (side === 'control' && !(await until(() => witnessed(events()))))
|
|
127
|
+
return missing('control did not receive the enable burst');
|
|
128
|
+
await client.send('Page.getFrameTree', {}, test);
|
|
129
|
+
const leaked = events()
|
|
130
|
+
.filter((e) => sealedContentEvent(e.method))
|
|
131
|
+
.map((e) => e.method);
|
|
132
|
+
const sealedEnableBurstWithheld = leaked.length === 0;
|
|
133
|
+
const recovery = `${ordinary}/blank?burst=${tag}`;
|
|
134
|
+
const after = client.events.length;
|
|
135
|
+
const persistentResult = persistentHidden
|
|
136
|
+
? { persistentEventsWithheld: persistentHidden() }
|
|
137
|
+
: {};
|
|
138
|
+
await client.send('Page.navigate', { url: recovery }, test);
|
|
139
|
+
const committed = await until(
|
|
140
|
+
async () =>
|
|
141
|
+
(await reader.send('Page.getFrameTree', {}, observer)).frameTree.frame.url === recovery
|
|
142
|
+
);
|
|
143
|
+
if (!committed) return { live: true, sealedEnableBurstWithheld, subscriptionsActive: false };
|
|
144
|
+
const recoverMark = `recover-${tag}`;
|
|
145
|
+
await reader.send('Runtime.evaluate', { expression: prime(recoverMark) }, observer);
|
|
146
|
+
const subscriptionsActive = await until(() => {
|
|
147
|
+
const seen = slice(client, after, test);
|
|
148
|
+
return (
|
|
149
|
+
types.every((method) =>
|
|
150
|
+
seen.some(
|
|
151
|
+
(e) =>
|
|
152
|
+
e.method === method &&
|
|
153
|
+
(method !== 'Log.entryAdded' || e.params.entry.text.includes(recoverMark)) &&
|
|
154
|
+
(method !== 'Audits.issueAdded' || issue(e, recoverMark))
|
|
155
|
+
)
|
|
156
|
+
) &&
|
|
157
|
+
seen.some((e) => e.method === 'Network.requestWillBeSent') &&
|
|
158
|
+
seen.some((e) => e.method === 'Page.frameNavigated')
|
|
159
|
+
);
|
|
160
|
+
});
|
|
161
|
+
const late = events().some(
|
|
162
|
+
(e) => sealedContentEvent(e.method) && JSON.stringify(e.params).includes(logMark)
|
|
163
|
+
);
|
|
164
|
+
return {
|
|
165
|
+
live: true,
|
|
166
|
+
sealedEnableBurstWithheld: sealedEnableBurstWithheld && !late,
|
|
167
|
+
subscriptionsActive,
|
|
168
|
+
...persistentResult,
|
|
169
|
+
...(leaked.length ? { leakedMethods: [...new Set(leaked)] } : {}),
|
|
170
|
+
};
|
|
171
|
+
} finally {
|
|
172
|
+
await outcome(client.send('Target.detachFromTarget', { sessionId: test }));
|
|
173
|
+
await outcome(reader.send('Target.detachFromTarget', { sessionId: raw }));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function collectFixtureFrames(root, frameIds) {
|
|
178
|
+
const stack = [root];
|
|
179
|
+
while (stack.length) {
|
|
180
|
+
const node = stack.pop(),
|
|
181
|
+
attrs = node.attributes ?? [];
|
|
182
|
+
if (
|
|
183
|
+
node.nodeName === 'IFRAME' &&
|
|
184
|
+
node.frameId &&
|
|
185
|
+
attrs.some((key, i) => i % 2 === 0 && key === 'id' && attrs[i + 1] === 'slicc-sealed-child')
|
|
186
|
+
)
|
|
187
|
+
frameIds.add(node.frameId);
|
|
188
|
+
stack.push(...(node.children ?? []));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async function sealedChild({ client, reader, observer, targetId, ordinary, until, side, budget }) {
|
|
193
|
+
const url = new URL(
|
|
194
|
+
'/sealed-child',
|
|
195
|
+
ordinary.replace(new URL(ordinary).hostname, 'vault.sliccy.ai')
|
|
196
|
+
).href;
|
|
197
|
+
const rawStart = reader.events.length;
|
|
198
|
+
const prior = new Set(
|
|
199
|
+
(await reader.send('Target.getTargets')).targetInfos.map((i) => i.targetId)
|
|
200
|
+
);
|
|
201
|
+
await reader.send('Network.enable', {}, observer);
|
|
202
|
+
const added = await reader.send(
|
|
203
|
+
'Runtime.evaluate',
|
|
204
|
+
{
|
|
205
|
+
expression: `(() => {const f=document.createElement('iframe');f.id='slicc-sealed-child';f.src=${JSON.stringify(url)};document.body.append(f);return true})()`,
|
|
206
|
+
returnByValue: true,
|
|
207
|
+
},
|
|
208
|
+
observer
|
|
209
|
+
);
|
|
210
|
+
const linked = (info) =>
|
|
211
|
+
info.parentId === targetId ||
|
|
212
|
+
info.parentFrameId === targetId ||
|
|
213
|
+
reader.events.some(
|
|
214
|
+
(e) =>
|
|
215
|
+
e.sessionId === observer &&
|
|
216
|
+
e.method === 'Page.frameAttached' &&
|
|
217
|
+
e.params.parentFrameId === targetId &&
|
|
218
|
+
e.params.frameId === info.targetId
|
|
219
|
+
);
|
|
220
|
+
const requested = (id) =>
|
|
221
|
+
reader.events
|
|
222
|
+
.slice(rawStart)
|
|
223
|
+
.some(
|
|
224
|
+
(e) =>
|
|
225
|
+
e.sessionId === observer &&
|
|
226
|
+
e.params.frameId === id &&
|
|
227
|
+
(e.params.url === url || e.params.request?.url === url)
|
|
228
|
+
);
|
|
229
|
+
const frameIds = new Set();
|
|
230
|
+
const child = async () => {
|
|
231
|
+
const { root } = await reader.send('DOM.getDocument', { depth: -1 }, observer);
|
|
232
|
+
collectFixtureFrames(root, frameIds);
|
|
233
|
+
const list = (await reader.send('Target.getTargets')).targetInfos;
|
|
234
|
+
for (const info of list.filter((i) => i.type === 'iframe' && !prior.has(i.targetId))) {
|
|
235
|
+
if (
|
|
236
|
+
(linked(info) || frameIds.has(info.targetId)) &&
|
|
237
|
+
(info.url === url || requested(info.targetId))
|
|
238
|
+
)
|
|
239
|
+
return info;
|
|
240
|
+
const attach = await outcome(
|
|
241
|
+
reader.send('Target.attachToTarget', { targetId: info.targetId, flatten: true })
|
|
242
|
+
);
|
|
243
|
+
if (!attach.result?.sessionId) continue;
|
|
244
|
+
try {
|
|
245
|
+
const tree = await outcome(reader.send('Page.getFrameTree', {}, attach.result.sessionId));
|
|
246
|
+
const f = tree.result?.frameTree?.frame;
|
|
247
|
+
if (
|
|
248
|
+
f &&
|
|
249
|
+
(linked(info) || frameIds.has(f.id)) &&
|
|
250
|
+
(f.url === url || f.unreachableUrl === url || requested(f.id))
|
|
251
|
+
)
|
|
252
|
+
return { ...info, frameId: f.id };
|
|
253
|
+
} finally {
|
|
254
|
+
await outcome(
|
|
255
|
+
reader.send('Target.detachFromTarget', { sessionId: attach.result.sessionId })
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
if (added.result?.value !== true || !(await until(child)))
|
|
261
|
+
return missing('no independently identified protected child under the sealed root');
|
|
262
|
+
const found = await child();
|
|
263
|
+
if (!found) return missing('protected child did not persist');
|
|
264
|
+
const ids = new Set([found.targetId, found.frameId, ...frameIds].filter(Boolean));
|
|
265
|
+
const { sessionId: session } = await client.send('Target.attachToTarget', {
|
|
266
|
+
targetId,
|
|
267
|
+
flatten: true,
|
|
268
|
+
});
|
|
269
|
+
try {
|
|
270
|
+
const before = client.events.length;
|
|
271
|
+
await client.send(
|
|
272
|
+
'Target.setAutoAttach',
|
|
273
|
+
{ autoAttach: true, flatten: true, waitForDebuggerOnStart: false },
|
|
274
|
+
session
|
|
275
|
+
);
|
|
276
|
+
const matches = (info) =>
|
|
277
|
+
info &&
|
|
278
|
+
(ids.has(info.targetId) ||
|
|
279
|
+
ids.has(info.frameId) ||
|
|
280
|
+
info.url === url ||
|
|
281
|
+
(info.type === 'iframe' && linked(info)));
|
|
282
|
+
const listed = async () => (await client.send('Target.getTargets')).targetInfos.some(matches);
|
|
283
|
+
const attached = () =>
|
|
284
|
+
client.events
|
|
285
|
+
.slice(before)
|
|
286
|
+
.some(
|
|
287
|
+
(e) =>
|
|
288
|
+
e.method === 'Target.attachedToTarget' &&
|
|
289
|
+
(e.sessionId === session || matches(e.params?.targetInfo))
|
|
290
|
+
);
|
|
291
|
+
if (side === 'control' && !(await until(async () => attached() && (await listed()))))
|
|
292
|
+
return missing('raw child listing and auto-attachment not witnessed');
|
|
293
|
+
if (side === 'guarded' && (await waitFor(async () => attached() || (await listed()), budget)))
|
|
294
|
+
return { live: true, childHidden: false };
|
|
295
|
+
return { live: true, childHidden: !(await listed()) && !attached() };
|
|
296
|
+
} finally {
|
|
297
|
+
await outcome(client.send('Target.detachFromTarget', { sessionId: session }));
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export async function sealedAttach({
|
|
302
|
+
client,
|
|
303
|
+
reader,
|
|
304
|
+
targetId,
|
|
305
|
+
ordinary,
|
|
306
|
+
seven,
|
|
307
|
+
tag,
|
|
308
|
+
mode,
|
|
309
|
+
side,
|
|
310
|
+
budget,
|
|
311
|
+
fixture,
|
|
312
|
+
persistent = false,
|
|
313
|
+
session,
|
|
314
|
+
internalSessions = new Set(),
|
|
315
|
+
}) {
|
|
316
|
+
const { sessionId: observer } = await reader.send('Target.attachToTarget', {
|
|
317
|
+
targetId,
|
|
318
|
+
flatten: true,
|
|
319
|
+
});
|
|
320
|
+
internalSessions.add(observer);
|
|
321
|
+
const until = (check) => waitFor(check, budget);
|
|
322
|
+
try {
|
|
323
|
+
await reader.send('Page.enable', {}, observer);
|
|
324
|
+
const seed = persistent && mode === 'burst';
|
|
325
|
+
if (seed)
|
|
326
|
+
await armPersistent(
|
|
327
|
+
client,
|
|
328
|
+
session,
|
|
329
|
+
(await reader.send('Page.getFrameTree', {}, observer)).frameTree.frame.id
|
|
330
|
+
);
|
|
331
|
+
const failed = `${seven}/sealed-attach/${tag}`;
|
|
332
|
+
if (
|
|
333
|
+
!(await failNavigation(reader, observer, failed, until, fixtureFailsNavigation(side, mode)))
|
|
334
|
+
)
|
|
335
|
+
return side === 'control'
|
|
336
|
+
? missing('sealed Chromium error commit not witnessed')
|
|
337
|
+
: { live: false };
|
|
338
|
+
if (mode === 'child')
|
|
339
|
+
return await sealedChild({
|
|
340
|
+
client,
|
|
341
|
+
reader,
|
|
342
|
+
observer,
|
|
343
|
+
targetId,
|
|
344
|
+
ordinary,
|
|
345
|
+
until,
|
|
346
|
+
side,
|
|
347
|
+
budget,
|
|
348
|
+
});
|
|
349
|
+
if (mode === 'burst') {
|
|
350
|
+
const start = client.events.length;
|
|
351
|
+
if (seed) {
|
|
352
|
+
const reason = await persistentWitness({
|
|
353
|
+
reader,
|
|
354
|
+
observer,
|
|
355
|
+
witness: side === 'control' ? client : reader,
|
|
356
|
+
session: side === 'control' ? session : observer,
|
|
357
|
+
frameId: (await reader.send('Page.getFrameTree', {}, observer)).frameTree.frame.id,
|
|
358
|
+
marker: 'persistent-' + tag,
|
|
359
|
+
until,
|
|
360
|
+
});
|
|
361
|
+
if (reason) return missing(reason);
|
|
362
|
+
}
|
|
363
|
+
const persistentHidden = seed
|
|
364
|
+
? () => !slice(client, start, session).some((e) => persistentEvent(e.method))
|
|
365
|
+
: undefined;
|
|
366
|
+
return await enableBurst({
|
|
367
|
+
persistentHidden,
|
|
368
|
+
client,
|
|
369
|
+
reader,
|
|
370
|
+
targetId,
|
|
371
|
+
observer,
|
|
372
|
+
until,
|
|
373
|
+
side,
|
|
374
|
+
tag,
|
|
375
|
+
ordinary,
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
if (typeof fixture.connectPuppeteer !== 'function')
|
|
379
|
+
return missing('no stock Puppeteer transport factory');
|
|
380
|
+
const url = `${ordinary}/blank?stock=${tag}`;
|
|
381
|
+
const conn = await outcome(
|
|
382
|
+
Promise.resolve().then(() => fixture.connectPuppeteer({ client, targetId, leg: side }))
|
|
383
|
+
);
|
|
384
|
+
if (!conn.ok) throw new Error(`stock Puppeteer attach: ${conn.error.message}`);
|
|
385
|
+
try {
|
|
386
|
+
const page = conn.result.page;
|
|
387
|
+
await page.goto(url);
|
|
388
|
+
const observed = await until(
|
|
389
|
+
async () =>
|
|
390
|
+
(await reader.send('Page.getFrameTree', {}, observer)).frameTree.frame.url === url
|
|
391
|
+
);
|
|
392
|
+
const challenge = `stock-${tag}`;
|
|
393
|
+
const answer = await page.evaluate((value) => [location.href, value], challenge);
|
|
394
|
+
return {
|
|
395
|
+
live: true,
|
|
396
|
+
stockRecovered:
|
|
397
|
+
observed && answer?.[0] === url && answer[1] === challenge && (await conn.result.clean()),
|
|
398
|
+
};
|
|
399
|
+
} finally {
|
|
400
|
+
await conn.result.close();
|
|
401
|
+
}
|
|
402
|
+
} finally {
|
|
403
|
+
await outcome(reader.send('Target.detachFromTarget', { sessionId: observer }));
|
|
404
|
+
internalSessions.delete(observer);
|
|
405
|
+
}
|
|
406
|
+
}
|