@app-studio/qa-browser-linux-x64 0.11.3 → 0.12.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/bin/lightpanda +2 -2
- package/bin/lightpanda-build.json +16 -4
- package/bin/lightpanda-capture.mjs +53 -12
- package/bin/source.tar.gz +0 -0
- package/package.json +1 -1
package/bin/lightpanda
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/bin/lightpanda
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 79479560 bytes
|
|
4
|
+
sha256: 8dacd9961f7380a0bb5233f21b200d07ce5ce7b9f888a4b8ce7d2af69dc1a45b
|
|
@@ -5,6 +5,18 @@
|
|
|
5
5
|
"arch": "x64",
|
|
6
6
|
"version": "1.1.0-dev.8814+46c56fa55",
|
|
7
7
|
"rendering": "native-css",
|
|
8
|
+
"debugger": {
|
|
9
|
+
"revision": "qa-agent-debug-3-uncaught",
|
|
10
|
+
"pauseTransport": true,
|
|
11
|
+
"conditionalBreakpoints": true,
|
|
12
|
+
"steps": true,
|
|
13
|
+
"exceptionPause": true,
|
|
14
|
+
"exceptionPauseModes": [
|
|
15
|
+
"none",
|
|
16
|
+
"uncaught",
|
|
17
|
+
"all"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
8
20
|
"formats": [
|
|
9
21
|
"png",
|
|
10
22
|
"mp4",
|
|
@@ -14,14 +26,14 @@
|
|
|
14
26
|
"build": "release-fast",
|
|
15
27
|
"source": {
|
|
16
28
|
"commit": "46c56fa55fdb48b7fa30d83461c328c8a3635940",
|
|
17
|
-
"dirty":
|
|
29
|
+
"dirty": true
|
|
18
30
|
},
|
|
19
31
|
"files": {
|
|
20
|
-
"lightpanda": "
|
|
21
|
-
"lightpanda-capture.mjs": "
|
|
32
|
+
"lightpanda": "8dacd9961f7380a0bb5233f21b200d07ce5ce7b9f888a4b8ce7d2af69dc1a45b",
|
|
33
|
+
"lightpanda-capture.mjs": "91b5156c93b824a8b82817b81ad98c1373c61f99a030ce3a6d7b927a833fb071",
|
|
22
34
|
"lightpanda-scenario.mjs": "ad41177bd602e93f2d12c0e30444ebf06e957e1215f67179defc8cc68e6839e6",
|
|
23
35
|
"native-scenario.mjs": "b3efd2d0ad9eccff29f6d432e4eaa7eb9b2696c999577eed98f6fabc282a42b8",
|
|
24
36
|
"LICENSE": "8486a10c4393cee1c25392769ddd3b2d6c242d6ec7928e1414efff7dfb2f07ef",
|
|
25
|
-
"source.tar.gz": "
|
|
37
|
+
"source.tar.gz": "59cfa9cb4a627e7987903a3ccfce69ab54a2bc07ecc637362c179267c5309bb9"
|
|
26
38
|
}
|
|
27
39
|
}
|
|
@@ -16,11 +16,19 @@ const sleep = (ms, signal) => new Promise(resolve => {
|
|
|
16
16
|
signal?.addEventListener('abort', done, { once: true });
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
async function bounded(task, milliseconds, operation, signal) {
|
|
19
|
+
async function bounded(task, milliseconds, operation, signal, extendDeadline) {
|
|
20
20
|
let timer, abort;
|
|
21
21
|
try {
|
|
22
22
|
return await Promise.race([task, new Promise((_, reject) => {
|
|
23
|
-
|
|
23
|
+
let extended = false;
|
|
24
|
+
const expire = () => {
|
|
25
|
+
const remaining = extendDeadline?.() - performance.now();
|
|
26
|
+
if (remaining > 0) {
|
|
27
|
+
extended = true;
|
|
28
|
+
timer = setTimeout(expire, Math.min(milliseconds, remaining));
|
|
29
|
+
} else reject(new Error(extended ? `${operation} timed out at its navigation deadline` : `${operation} timed out after ${milliseconds}ms`));
|
|
30
|
+
};
|
|
31
|
+
timer = setTimeout(expire, milliseconds);
|
|
24
32
|
abort = () => reject(signal.reason ?? new Error(`${operation} aborted`));
|
|
25
33
|
if (signal?.aborted) abort();
|
|
26
34
|
else signal?.addEventListener('abort', abort, { once: true });
|
|
@@ -28,11 +36,11 @@ async function bounded(task, milliseconds, operation, signal) {
|
|
|
28
36
|
} finally { clearTimeout(timer); signal?.removeEventListener('abort', abort); }
|
|
29
37
|
}
|
|
30
38
|
|
|
31
|
-
async function capture(cdp, fullPage = false, timeout = 3000, signal) {
|
|
39
|
+
async function capture(cdp, fullPage = false, timeout = 3000, signal, extendDeadline) {
|
|
32
40
|
signal?.throwIfAborted();
|
|
33
41
|
const { data } = await bounded(cdp.send('Page.captureScreenshot', {
|
|
34
42
|
format: 'png', captureBeyondViewport: fullPage,
|
|
35
|
-
}), timeout, 'Native frame capture', signal);
|
|
43
|
+
}), timeout, 'Native frame capture', signal, extendDeadline);
|
|
36
44
|
const png = Buffer.from(data, 'base64');
|
|
37
45
|
if (png.length < 24 || !png.subarray(0, 8).equals(Buffer.from('89504e470d0a1a0a', 'hex'))) {
|
|
38
46
|
throw new Error('The browser returned an invalid PNG');
|
|
@@ -109,9 +117,10 @@ export async function encodeFrames({ directory, count, path, fps = 5, ffmpeg = '
|
|
|
109
117
|
* adds at most one frame period to the clip. A stalled owned encoder is
|
|
110
118
|
* terminated; the caller's browser page remains open.
|
|
111
119
|
*/
|
|
112
|
-
export async function recordVideo(cdp, { path, fps = 10, duration = 10, ffmpeg = 'ffmpeg', signal } = {}) {
|
|
120
|
+
export async function recordVideo(cdp, { path, fps = 10, duration = 10, ffmpeg = 'ffmpeg', frameTimeout = 30000, signal } = {}) {
|
|
113
121
|
if (!Number.isFinite(fps) || fps < 1 || fps > 60) throw new Error('fps must be between 1 and 60');
|
|
114
122
|
if (!Number.isFinite(duration) || duration <= 0) throw new Error('duration must be positive (seconds)');
|
|
123
|
+
if (!Number.isFinite(frameTimeout) || frameTimeout < 1 || frameTimeout > 120000) throw new Error('frameTimeout must be between 1 and 120000 milliseconds');
|
|
115
124
|
const extension = extname(path ?? '').toLowerCase();
|
|
116
125
|
if (!['.mp4', '.webm', '.gif'].includes(extension)) throw new Error('Recording path must end in .mp4, .webm or .gif');
|
|
117
126
|
signal?.throwIfAborted();
|
|
@@ -121,21 +130,39 @@ export async function recordVideo(cdp, { path, fps = 10, duration = 10, ffmpeg =
|
|
|
121
130
|
throw new Error('Recording needs CDP notifications from the same page session');
|
|
122
131
|
}
|
|
123
132
|
let frameId, loaderId, frameUrl, revision = 0, ready = false, observing = false, initial = true;
|
|
133
|
+
let pendingLoader, navigationDeadline;
|
|
134
|
+
const seenLoaders = new Set();
|
|
124
135
|
const initialStop = new AbortController();
|
|
125
136
|
const abortInitial = () => initialStop.abort(signal.reason);
|
|
126
137
|
const detached = () => initialStop.abort(new Error('Recording CDP session detached'));
|
|
138
|
+
const armNavigation = () => {
|
|
139
|
+
if (!initial) navigationDeadline ??= performance.now() + 30_000;
|
|
140
|
+
};
|
|
141
|
+
const starting = event => {
|
|
142
|
+
if (!observing || !frameId || event.frameId !== frameId || !event.loaderId
|
|
143
|
+
|| seenLoaders.has(event.loaderId)) return;
|
|
144
|
+
seenLoaders.add(event.loaderId);
|
|
145
|
+
pendingLoader = event.loaderId;
|
|
146
|
+
revision++; ready = false;
|
|
147
|
+
armNavigation();
|
|
148
|
+
};
|
|
127
149
|
const navigated = ({ frame }) => {
|
|
128
|
-
if (!frame || frame.parentId) return;
|
|
150
|
+
if (!frame || frame.parentId || !frame.id || !frame.loaderId || (frameId && frame.id !== frameId)) return;
|
|
151
|
+
if (seenLoaders.has(frame.loaderId) && pendingLoader !== frame.loaderId) return;
|
|
152
|
+
seenLoaders.add(frame.loaderId);
|
|
129
153
|
frameId = frame.id; loaderId = frame.loaderId; frameUrl = frame.url;
|
|
154
|
+
pendingLoader = undefined;
|
|
130
155
|
revision++; ready = false;
|
|
156
|
+
armNavigation();
|
|
131
157
|
};
|
|
132
158
|
const hasDocument = () => frameUrl && !/^about:blank(?:[?#]|$)/.test(frameUrl);
|
|
133
159
|
const lifecycle = event => {
|
|
134
160
|
// Enabling lifecycle notifications can replay old milestones, even for a
|
|
135
161
|
// waiting about:blank frame. Only matching, observed main-document events count.
|
|
136
|
-
if (observing && hasDocument() && event.name === 'DOMContentLoaded'
|
|
162
|
+
if (observing && !pendingLoader && hasDocument() && event.name === 'DOMContentLoaded'
|
|
137
163
|
&& event.frameId === frameId && event.loaderId === loaderId) ready = true;
|
|
138
164
|
};
|
|
165
|
+
cdp.on('Page.frameStartedNavigating', starting);
|
|
139
166
|
cdp.on('Page.frameNavigated', navigated);
|
|
140
167
|
cdp.on('Page.lifecycleEvent', lifecycle);
|
|
141
168
|
cdp.on('Inspector.detached', detached);
|
|
@@ -160,11 +187,12 @@ export async function recordVideo(cdp, { path, fps = 10, duration = 10, ffmpeg =
|
|
|
160
187
|
if (revision === before && frameTree?.frame) {
|
|
161
188
|
const frame = frameTree.frame;
|
|
162
189
|
frameId = frame.id; loaderId = frame.loaderId; frameUrl = frame.url;
|
|
190
|
+
if (loaderId) seenLoaders.add(loaderId);
|
|
163
191
|
}
|
|
164
192
|
observing = true;
|
|
165
193
|
const current = revision;
|
|
166
194
|
const state = await command('Runtime.evaluate', { expression: 'document.readyState', returnByValue: true });
|
|
167
|
-
if (revision === current && hasDocument()
|
|
195
|
+
if (revision === current && !pendingLoader && hasDocument()
|
|
168
196
|
&& ['interactive', 'complete'].includes(state.result?.value)) ready = true;
|
|
169
197
|
const firstRevision = revision, firstReady = ready;
|
|
170
198
|
const first = await capture(cdp, false, remaining(), initialStop.signal);
|
|
@@ -211,10 +239,21 @@ export async function recordVideo(cdp, { path, fps = 10, duration = 10, ffmpeg =
|
|
|
211
239
|
const sample = async () => {
|
|
212
240
|
const generation = revision;
|
|
213
241
|
const mainReady = ready;
|
|
214
|
-
|
|
215
|
-
//
|
|
216
|
-
//
|
|
217
|
-
|
|
242
|
+
// Extend the same pending capture when a main navigation starts; never issue a second screenshot.
|
|
243
|
+
// The frame deadline remains bounded; navigation can extend it only to
|
|
244
|
+
// the separately bounded main-document deadline.
|
|
245
|
+
const documentDeadline = () => initialStop.signal.aborted ? undefined : navigationDeadline;
|
|
246
|
+
if (navigationDeadline !== undefined && performance.now() >= navigationDeadline)
|
|
247
|
+
throw new Error('Navigated main document capture timed out after 30000ms');
|
|
248
|
+
const timeout = initial ? remaining() : Math.min(frameTimeout, Math.max(0, (documentDeadline() ?? Infinity) - performance.now()));
|
|
249
|
+
const png = await capture(cdp, false, timeout, initial ? initialStop.signal : undefined, initial ? undefined : documentDeadline);
|
|
250
|
+
if (navigationDeadline !== undefined && performance.now() >= navigationDeadline)
|
|
251
|
+
throw new Error('Navigated main document capture timed out after 30000ms');
|
|
252
|
+
// Only a capture begun after this document's DCL may restore steady-frame deadlines.
|
|
253
|
+
if (mainReady && generation === revision && !pendingLoader) {
|
|
254
|
+
initial = false;
|
|
255
|
+
navigationDeadline = undefined;
|
|
256
|
+
}
|
|
218
257
|
if (png.readUInt32BE(16) !== width || png.readUInt32BE(20) !== height) {
|
|
219
258
|
throw new Error('The viewport size changed during recording');
|
|
220
259
|
}
|
|
@@ -239,6 +278,7 @@ export async function recordVideo(cdp, { path, fps = 10, duration = 10, ffmpeg =
|
|
|
239
278
|
await write(await sample());
|
|
240
279
|
frames++;
|
|
241
280
|
if (initial) throw new Error('Recording ended before the first main document capture');
|
|
281
|
+
if (navigationDeadline !== undefined) throw new Error('Recording ended before the navigated main document capture');
|
|
242
282
|
encoder.stdin.end();
|
|
243
283
|
const code = await bounded(closed, 5000, 'FFmpeg finalization');
|
|
244
284
|
if (code !== 0) throw new Error(spawnError?.message ?? `FFmpeg exited with ${code}: ${diagnostics.trim()}`);
|
|
@@ -255,6 +295,7 @@ export async function recordVideo(cdp, { path, fps = 10, duration = 10, ffmpeg =
|
|
|
255
295
|
} finally {
|
|
256
296
|
initialStop.abort();
|
|
257
297
|
signal?.removeEventListener('abort', abortInitial);
|
|
298
|
+
cdp.off('Page.frameStartedNavigating', starting);
|
|
258
299
|
cdp.off('Page.frameNavigated', navigated);
|
|
259
300
|
cdp.off('Page.lifecycleEvent', lifecycle);
|
|
260
301
|
cdp.off('Inspector.detached', detached);
|
package/bin/source.tar.gz
CHANGED
|
Binary file
|