@ai-ecoverse/slicc-browsers 1.24.0 → 1.25.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/extension-frame.mjs +100 -23
- package/fixture-server.mjs +6 -4
- package/guard-vectors.json +464 -5
- package/package.json +5 -5
- package/protected-parent-iframes.mjs +1702 -2
- package/schema/guard-vectors.schema.json +7 -1
package/extension-frame.mjs
CHANGED
|
@@ -920,24 +920,110 @@ async function driveCast(client, page, frameMs) {
|
|
|
920
920
|
const start = await outcome(
|
|
921
921
|
client.send('Page.startScreencast', { format: 'png', everyNthFrame: 1 }, page)
|
|
922
922
|
);
|
|
923
|
-
const
|
|
923
|
+
const acked = new Set();
|
|
924
|
+
let leakFrom;
|
|
925
|
+
let pumping = start.ok;
|
|
926
|
+
let stopped = false;
|
|
927
|
+
const ackFrames = async () => {
|
|
928
|
+
for (const event of client.events ?? []) {
|
|
929
|
+
if (event.method !== 'Page.screencastFrame' || event.sessionId !== page) continue;
|
|
930
|
+
const id = event.params?.sessionId;
|
|
931
|
+
if (typeof id !== 'number' || acked.has(id)) continue;
|
|
932
|
+
acked.add(id);
|
|
933
|
+
await outcome(client.send('Page.screencastFrameAck', { sessionId: id }, page));
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
const halt = async () => {
|
|
937
|
+
pumping = false;
|
|
938
|
+
await pump;
|
|
939
|
+
if (start.ok && !stopped) {
|
|
940
|
+
stopped = true;
|
|
941
|
+
await outcome(client.send('Page.stopScreencast', {}, page));
|
|
942
|
+
}
|
|
943
|
+
};
|
|
944
|
+
const pump =
|
|
945
|
+
start.ok && frameMs > 0
|
|
946
|
+
? (async () => {
|
|
947
|
+
while (pumping) {
|
|
948
|
+
await ackFrames();
|
|
949
|
+
await pause(25);
|
|
950
|
+
}
|
|
951
|
+
})()
|
|
952
|
+
: Promise.resolve();
|
|
924
953
|
return {
|
|
925
954
|
castBefore: start.ok,
|
|
926
955
|
castBeforeRefusal: presentish(start),
|
|
927
|
-
async
|
|
956
|
+
async markInserted() {
|
|
957
|
+
await ackFrames();
|
|
958
|
+
leakFrom = client.events?.length ?? 0;
|
|
959
|
+
},
|
|
960
|
+
async afterEmbed({ inserted }) {
|
|
961
|
+
pumping = false;
|
|
962
|
+
await pump;
|
|
963
|
+
if (!start.ok) {
|
|
964
|
+
return { castLeak: false, castFramesAfter: 0, castInserted: Boolean(inserted) };
|
|
965
|
+
}
|
|
966
|
+
if (!inserted) {
|
|
967
|
+
await halt();
|
|
968
|
+
return { castLeak: false, castFramesAfter: 0, castInserted: false };
|
|
969
|
+
}
|
|
970
|
+
if (leakFrom == null) {
|
|
971
|
+
await ackFrames();
|
|
972
|
+
leakFrom = client.events?.length ?? 0;
|
|
973
|
+
}
|
|
928
974
|
await pause(Math.max(frameMs, 200));
|
|
975
|
+
await ackFrames();
|
|
929
976
|
const frames = (client.events ?? [])
|
|
930
|
-
.slice(
|
|
977
|
+
.slice(leakFrom)
|
|
931
978
|
.filter((event) => event.method === 'Page.screencastFrame' && event.sessionId === page);
|
|
932
|
-
|
|
979
|
+
await halt();
|
|
933
980
|
return {
|
|
934
981
|
castLeak: frames.length > 0,
|
|
935
982
|
castFramesAfter: frames.length,
|
|
983
|
+
castInserted: true,
|
|
936
984
|
};
|
|
937
985
|
},
|
|
986
|
+
stop: halt,
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
async function beginCast(client, session, targetId, frameMs) {
|
|
991
|
+
const attachEarly = await outcome(
|
|
992
|
+
client.send('Target.attachToTarget', { targetId, flatten: true })
|
|
993
|
+
);
|
|
994
|
+
const page = attachEarly.ok ? attachEarly.result.sessionId : session;
|
|
995
|
+
if (attachEarly.ok) {
|
|
996
|
+
await outcome(client.send('DOM.enable', {}, page));
|
|
997
|
+
await outcome(client.send('Accessibility.enable', {}, page));
|
|
998
|
+
}
|
|
999
|
+
return {
|
|
1000
|
+
page,
|
|
1001
|
+
pageAttached: attachEarly.ok,
|
|
1002
|
+
castDrive: await driveCast(client, page, frameMs),
|
|
938
1003
|
};
|
|
939
1004
|
}
|
|
940
1005
|
|
|
1006
|
+
async function noteCastInsertion(castDrive, embedded, missing) {
|
|
1007
|
+
if (!castDrive) return;
|
|
1008
|
+
if (embedded) await castDrive.markInserted();
|
|
1009
|
+
else missing.push('extension frame insertion was not confirmed');
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
function finishCast(castDrive, embedded) {
|
|
1013
|
+
if (!castDrive) return null;
|
|
1014
|
+
return castDrive.afterEmbed({ inserted: Boolean(embedded) });
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
function applyCastResult(result, castDrive, castAfter, side, missing) {
|
|
1018
|
+
if (!castDrive) return;
|
|
1019
|
+
result.castBefore = castDrive.castBefore;
|
|
1020
|
+
result.castBeforeRefusal = castDrive.castBeforeRefusal;
|
|
1021
|
+
result.castLeak = castAfter.castLeak;
|
|
1022
|
+
result.castFramesAfter = castAfter.castFramesAfter;
|
|
1023
|
+
if (side === 'control' && castDrive.castBefore && castAfter.castInserted && !castAfter.castLeak)
|
|
1024
|
+
missing.push('control screencast produced no frames after the extension frame appeared');
|
|
1025
|
+
}
|
|
1026
|
+
|
|
941
1027
|
function classifyRevealOverlap(
|
|
942
1028
|
captureStartedAt,
|
|
943
1029
|
revealAt,
|
|
@@ -1101,6 +1187,7 @@ export async function extensionFrame({
|
|
|
1101
1187
|
const frameURL = `chrome-extension://${extensionId}/frame.html`;
|
|
1102
1188
|
let page;
|
|
1103
1189
|
let pageAttached = false;
|
|
1190
|
+
let castDrive;
|
|
1104
1191
|
const discovery = hasCapability(capabilities, 'discovery')
|
|
1105
1192
|
? await outcome(client.send('Target.setDiscoverTargets', { discover: true }))
|
|
1106
1193
|
: { ok: false };
|
|
@@ -1108,18 +1195,14 @@ export async function extensionFrame({
|
|
|
1108
1195
|
await reader.send('Runtime.enable', {}, observer);
|
|
1109
1196
|
await reader.send('DOM.enable', {}, observer);
|
|
1110
1197
|
await reader.send('Accessibility.enable', {}, observer);
|
|
1111
|
-
let castDrive;
|
|
1112
1198
|
if (mode === 'cast') {
|
|
1113
|
-
const
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
pageAttached = attachEarly.ok;
|
|
1118
|
-
await outcome(client.send('DOM.enable', {}, page));
|
|
1119
|
-
await outcome(client.send('Accessibility.enable', {}, page));
|
|
1120
|
-
castDrive = await driveCast(client, page, frameMs);
|
|
1199
|
+
const started = await beginCast(client, session, targetId, frameMs);
|
|
1200
|
+
page = started.page;
|
|
1201
|
+
pageAttached = started.pageAttached;
|
|
1202
|
+
castDrive = started.castDrive;
|
|
1121
1203
|
}
|
|
1122
|
-
await embed(reader, observer, mode, frameURL);
|
|
1204
|
+
const embedded = await embed(reader, observer, mode, frameURL);
|
|
1205
|
+
await noteCastInsertion(castDrive, embedded, missing);
|
|
1123
1206
|
const want = mode === 'focused' ? 1 : 2;
|
|
1124
1207
|
const frames = await frameTargets(
|
|
1125
1208
|
reader,
|
|
@@ -1132,7 +1215,7 @@ export async function extensionFrame({
|
|
|
1132
1215
|
const frame = frames[0];
|
|
1133
1216
|
await paintMarker(reader, frame, mode === 'focused');
|
|
1134
1217
|
await painted(reader, observer, frameMs);
|
|
1135
|
-
const castAfter =
|
|
1218
|
+
const castAfter = await finishCast(castDrive, embedded);
|
|
1136
1219
|
if (!page) {
|
|
1137
1220
|
const attach = await outcome(
|
|
1138
1221
|
client.send('Target.attachToTarget', { targetId, flatten: true })
|
|
@@ -1179,14 +1262,7 @@ export async function extensionFrame({
|
|
|
1179
1262
|
input,
|
|
1180
1263
|
captures,
|
|
1181
1264
|
});
|
|
1182
|
-
|
|
1183
|
-
result.castBefore = castDrive.castBefore;
|
|
1184
|
-
result.castBeforeRefusal = castDrive.castBeforeRefusal;
|
|
1185
|
-
result.castLeak = castAfter.castLeak;
|
|
1186
|
-
result.castFramesAfter = castAfter.castFramesAfter;
|
|
1187
|
-
if (side === 'control' && castDrive.castBefore && !castAfter.castLeak)
|
|
1188
|
-
missing.push('control screencast produced no frames after the extension frame appeared');
|
|
1189
|
-
}
|
|
1265
|
+
applyCastResult(result, castDrive, castAfter, side, missing);
|
|
1190
1266
|
if (mode === 'revealed')
|
|
1191
1267
|
Object.assign(
|
|
1192
1268
|
result,
|
|
@@ -1226,6 +1302,7 @@ export async function extensionFrame({
|
|
|
1226
1302
|
result.alive = alive.ok && alive.result.result?.value === origin && !carries(alive.result);
|
|
1227
1303
|
return missing.length ? { ...result, incomplete: missing.join('; ') } : result;
|
|
1228
1304
|
} finally {
|
|
1305
|
+
if (castDrive) await castDrive.stop();
|
|
1229
1306
|
if (pageAttached) await outcome(client.send('Target.detachFromTarget', { sessionId: page }));
|
|
1230
1307
|
if (discovery.ok) await outcome(client.send('Target.setDiscoverTargets', { discover: false }));
|
|
1231
1308
|
await outcome(reader.send('Target.detachFromTarget', { sessionId: observer }));
|
package/fixture-server.mjs
CHANGED
|
@@ -115,11 +115,13 @@ function route(req, url, send, html, redirects) {
|
|
|
115
115
|
`<p>oopif-mid ${escape(p.get('n') ?? '')}</p><iframe src="${escape(inner)}"></iframe>`
|
|
116
116
|
);
|
|
117
117
|
},
|
|
118
|
-
'/oopif-srcdoc': () =>
|
|
119
|
-
|
|
118
|
+
'/oopif-srcdoc': () => {
|
|
119
|
+
const marker = p.get('n') ?? '';
|
|
120
|
+
return html(
|
|
120
121
|
'oopif-srcdoc',
|
|
121
|
-
`<p>oopif-srcdoc ${escape(
|
|
122
|
-
)
|
|
122
|
+
`<p>oopif-srcdoc ${escape(marker)}</p><iframe sandbox="allow-scripts allow-forms" srcdoc="${escape(`<!doctype html><title>srcdoc</title><p>ordinary srcdoc ${marker}</p>`)}"></iframe>`
|
|
123
|
+
);
|
|
124
|
+
},
|
|
123
125
|
'/bfcache': () => {
|
|
124
126
|
const marker = JSON.stringify(`bfcache-marker-${p.get('n') ?? ''}`).replaceAll(
|
|
125
127
|
'<',
|