@e2e-dev/electron 0.1.1 → 0.1.2-nightly-20261205030542
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/.build.json +1 -1
- package/dist/actions.d.ts +0 -2
- package/dist/actions.js +184 -58
- package/dist/app-process.js +9 -4
- package/dist/budget.d.ts +3 -0
- package/dist/budget.js +8 -2
- package/dist/capture.d.ts +22 -12
- package/dist/capture.js +71 -23
- package/dist/cdp/input.d.ts +64 -21
- package/dist/cdp/input.js +260 -71
- package/dist/devtools.d.ts +6 -0
- package/dist/devtools.js +23 -0
- package/dist/engine.js +4 -2
- package/dist/in-page/node-ops.d.ts +27 -4
- package/dist/in-page/node-ops.js +102 -14
- package/dist/options.d.ts +1 -1
- package/dist/options.js +12 -6
- package/dist/page.d.ts +3 -2
- package/dist/page.js +8 -4
- package/dist/surface.d.ts +3 -3
- package/dist/surface.js +8 -20
- package/package.json +6 -6
package/dist/in-page/node-ops.js
CHANGED
|
@@ -18,12 +18,61 @@ export function nodeOp(node, name, args) {
|
|
|
18
18
|
const TYPED_PICKER_TYPES = new Set(['date', 'time', 'datetime-local', 'month', 'week']);
|
|
19
19
|
/** What a click inside a label presses instead of the label's own control. */
|
|
20
20
|
const INTERACTIVE = 'a,button,input,select,textarea,summary,[contenteditable],[role="button"],[role="link"]';
|
|
21
|
+
/**
|
|
22
|
+
* What a field action on a node inside a label acts on itself, not
|
|
23
|
+
* retargeted to the label's control: Playwright's follow-label list, which
|
|
24
|
+
* differs from `INTERACTIVE` on purpose (a contenteditable is checked by
|
|
25
|
+
* `isContentEditable`, which covers its descendants too).
|
|
26
|
+
*/
|
|
27
|
+
const FOLLOW_LABEL_STOPS = 'a, input, textarea, button, select, [role=link], [role=button], [role=checkbox], [role=switch], [role=radio]';
|
|
21
28
|
/** The node's element. A node the document dropped fails as one: the harness locates it again, where a reason would only wait out the deadline. */
|
|
22
29
|
const live = () => {
|
|
23
30
|
if (owner?.isConnected !== true)
|
|
24
31
|
throw new Error('Node is detached: it is no longer in the document');
|
|
25
32
|
return owner;
|
|
26
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* The element a field action works on: the node, or, for a node inside a
|
|
36
|
+
* label that is no control itself (the label's own text), the label's
|
|
37
|
+
* control, as Playwright's follow-label retargeting does for web(). Read
|
|
38
|
+
* once, by `followLabel`: the checks and the writes after it take the
|
|
39
|
+
* control's own node, so a label that comes to name another control in
|
|
40
|
+
* between cannot send the write past the checks.
|
|
41
|
+
*/
|
|
42
|
+
const labelled = () => {
|
|
43
|
+
const element = live();
|
|
44
|
+
if (element.matches(FOLLOW_LABEL_STOPS) || (element instanceof HTMLElement && element.isContentEditable))
|
|
45
|
+
return element;
|
|
46
|
+
return element.closest('label')?.control ?? element;
|
|
47
|
+
};
|
|
48
|
+
/** The editing host an element in a contenteditable sits in, which takes focus for it: the element itself otherwise. */
|
|
49
|
+
const editingHost = (target) => {
|
|
50
|
+
let host = target;
|
|
51
|
+
if (target instanceof HTMLElement && target.isContentEditable)
|
|
52
|
+
while (host.parentElement?.isContentEditable === true)
|
|
53
|
+
host = host.parentElement;
|
|
54
|
+
return host;
|
|
55
|
+
};
|
|
56
|
+
/** Fails as `live` does for an element a handler took out of the document while the action ran. */
|
|
57
|
+
const stillThere = (element) => {
|
|
58
|
+
if (!element.isConnected)
|
|
59
|
+
throw new Error('Node is detached: it is no longer in the document');
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* The file input to give files to, read again right before they are given:
|
|
63
|
+
* the click that opened a file chooser can run a handler that makes the
|
|
64
|
+
* input a text one, which would take no files and still fire its events.
|
|
65
|
+
* An input the test named must still be in the document, as for any other
|
|
66
|
+
* action. A chooser's input need not be (`inDocument` false): the app can
|
|
67
|
+
* make one and click it without placing it, as DOM.setFileInputFiles allows.
|
|
68
|
+
*/
|
|
69
|
+
const fileInput = (inDocument) => {
|
|
70
|
+
if (inDocument)
|
|
71
|
+
live();
|
|
72
|
+
if (owner instanceof HTMLInputElement && owner.type === 'file')
|
|
73
|
+
return owner;
|
|
74
|
+
throw new Error(`the input no longer takes files: it is ${owner instanceof HTMLInputElement ? `a ${owner.type} input` : owner === null ? 'no element' : `a <${owner.tagName.toLowerCase()}>`}`);
|
|
75
|
+
};
|
|
27
76
|
/** An input's type as the browser reads it (an unknown type is `text`); another element's type attribute. */
|
|
28
77
|
const typeOf = (target) => (target instanceof HTMLInputElement ? target.type : (target.getAttribute('type') ?? '').toLowerCase());
|
|
29
78
|
/**
|
|
@@ -192,8 +241,9 @@ export function nodeOp(node, name, args) {
|
|
|
192
241
|
return { ok: false, reason: 'it is disabled' };
|
|
193
242
|
if (isInert(element))
|
|
194
243
|
return { ok: false, reason: 'it is inert (a modal or the app blocks it)' };
|
|
195
|
-
// An editing host says so itself: it has no readOnly of its own.
|
|
196
|
-
|
|
244
|
+
// An editing host says so itself: it has no readOnly of its own. An element inside one is as read-only as its host.
|
|
245
|
+
const readOnly = (at) => at.getAttribute('aria-readonly')?.toLowerCase() === 'true';
|
|
246
|
+
if (field?.readOnly === true || (field === undefined && (readOnly(element) || readOnly(editingHost(element)))))
|
|
197
247
|
return { ok: false, reason: 'it is read-only' };
|
|
198
248
|
// A value can be set on a field no user reaches; typing into one would fail on its own.
|
|
199
249
|
if (!element.checkVisibility({ visibilityProperty: true }))
|
|
@@ -221,37 +271,60 @@ export function nodeOp(node, name, args) {
|
|
|
221
271
|
return refused;
|
|
222
272
|
}
|
|
223
273
|
element.focus();
|
|
274
|
+
// A focus handler that rendered a new input leaves this one detached, and no value is set: the action fails as
|
|
275
|
+
// selectOption's does for a replaced select.
|
|
276
|
+
stillThere(element);
|
|
224
277
|
element.value = set;
|
|
225
278
|
fire(element);
|
|
226
279
|
return { ok: true };
|
|
227
280
|
},
|
|
228
281
|
selectContents() {
|
|
229
282
|
const target = live();
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
if (
|
|
233
|
-
|
|
283
|
+
// An element inside an editing host takes no focus of its own: the host does, and the target's contents are selected in it.
|
|
284
|
+
const host = editingHost(target);
|
|
285
|
+
if (host instanceof HTMLElement)
|
|
286
|
+
host.focus();
|
|
287
|
+
// A focus handler that replaced the element, or its whole host, leaves nothing of it to select: the focus already
|
|
288
|
+
// reached the app, so the action fails as detached, not as focus lost. A host still there that handed focus on is
|
|
289
|
+
// focus lost.
|
|
290
|
+
stillThere(target);
|
|
291
|
+
if (!holdsFocus(host))
|
|
292
|
+
return 'moved';
|
|
234
293
|
if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) {
|
|
235
294
|
target.select();
|
|
236
|
-
return
|
|
295
|
+
return 'selected';
|
|
237
296
|
}
|
|
238
297
|
const range = target.ownerDocument.createRange();
|
|
239
298
|
range.selectNodeContents(target);
|
|
240
299
|
const selection = target.ownerDocument.getSelection();
|
|
241
300
|
selection?.removeAllRanges();
|
|
242
301
|
selection?.addRange(range);
|
|
243
|
-
|
|
302
|
+
// A range around only a comment or an empty text node is not collapsed, but the caret it leaves is, and a Delete
|
|
303
|
+
// there would take the text after it: an element with no text and no child element has nothing to select.
|
|
304
|
+
if (target.textContent === '' && target.firstElementChild === null)
|
|
305
|
+
return 'empty';
|
|
306
|
+
return selection?.isCollapsed === false ? 'selected' : 'empty';
|
|
307
|
+
},
|
|
308
|
+
followLabel() {
|
|
309
|
+
return labelled();
|
|
310
|
+
},
|
|
311
|
+
checkControlEnabled() {
|
|
312
|
+
return isDisabled(live()) ? { ok: false, reason: 'the control its label names is disabled' } : { ok: true };
|
|
244
313
|
},
|
|
245
314
|
readChecked() {
|
|
246
315
|
const target = live();
|
|
247
316
|
if (target instanceof HTMLInputElement && (target.type === 'checkbox' || target.type === 'radio'))
|
|
248
317
|
return target.checked;
|
|
249
|
-
|
|
318
|
+
// A role list names the role first and a fallback after it; ARIA's values are read in any case.
|
|
319
|
+
if (!CHECKED_ROLES.has(target.getAttribute('role')?.trim().split(/\s+/)[0]?.toLowerCase() ?? ''))
|
|
250
320
|
return null;
|
|
251
|
-
const aria = target.getAttribute('aria-checked');
|
|
321
|
+
const aria = target.getAttribute('aria-checked')?.toLowerCase();
|
|
252
322
|
// A mixed checkbox is not checked: check() clicks it.
|
|
253
323
|
return aria === 'true' ? true : aria === 'false' || aria === 'mixed' ? false : null;
|
|
254
324
|
},
|
|
325
|
+
readCheckedAsLeft() {
|
|
326
|
+
return owner instanceof HTMLInputElement && (owner.type === 'checkbox' || owner.type === 'radio') ? owner.checked : null;
|
|
327
|
+
},
|
|
255
328
|
checkSelect(wanted) {
|
|
256
329
|
const element = live();
|
|
257
330
|
if (!(element instanceof HTMLSelectElement))
|
|
@@ -269,10 +342,14 @@ export function nodeOp(node, name, args) {
|
|
|
269
342
|
const element = live();
|
|
270
343
|
if (!(element instanceof HTMLSelectElement))
|
|
271
344
|
return { ok: false, reason: 'it is not a <select>' };
|
|
345
|
+
// Focused first: a focus handler can reorder the options, and the option is the one there after it. One that replaced
|
|
346
|
+
// the select leaves this one detached, and nothing is selected: the focus already went out, so the action fails as
|
|
347
|
+
// ACTION_MAY_HAVE_COMMITTED, which the harness does not retry.
|
|
348
|
+
element.focus();
|
|
349
|
+
live();
|
|
272
350
|
const found = findOption(element, wanted);
|
|
273
351
|
if (!('index' in found))
|
|
274
352
|
return found;
|
|
275
|
-
element.focus();
|
|
276
353
|
element.selectedIndex = found.index;
|
|
277
354
|
fire(element);
|
|
278
355
|
return { ok: true };
|
|
@@ -293,13 +370,24 @@ export function nodeOp(node, name, args) {
|
|
|
293
370
|
return { ok: false, reason: `the file input takes one file, not ${count}: it has no multiple attribute` };
|
|
294
371
|
return { ok: true };
|
|
295
372
|
},
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
373
|
+
takesDirectory() {
|
|
374
|
+
return owner instanceof HTMLInputElement && owner.webkitdirectory;
|
|
375
|
+
},
|
|
376
|
+
clearFiles(inDocument) {
|
|
377
|
+
const input = fileInput(inDocument);
|
|
378
|
+
if (input.files === null || input.files.length === 0)
|
|
299
379
|
return;
|
|
300
380
|
input.value = '';
|
|
301
381
|
fire(input);
|
|
302
382
|
},
|
|
383
|
+
setFiles(files, inDocument) {
|
|
384
|
+
const input = fileInput(inDocument);
|
|
385
|
+
const transfer = new DataTransfer();
|
|
386
|
+
for (const file of files)
|
|
387
|
+
transfer.items.add(new File([Uint8Array.from(atob(file.base64), (character) => character.charCodeAt(0))], file.name, { type: file.mimeType }));
|
|
388
|
+
input.files = transfer.files;
|
|
389
|
+
fire(input);
|
|
390
|
+
},
|
|
303
391
|
isNativeRadio() {
|
|
304
392
|
const target = live();
|
|
305
393
|
return target instanceof HTMLInputElement && target.type === 'radio';
|
package/dist/options.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export interface ResolvedElectronOptions {
|
|
|
48
48
|
* the DevTools transport the engine drives the app through (a fixed port
|
|
49
49
|
* would also collide between workers).
|
|
50
50
|
*/
|
|
51
|
-
export declare function ownedArgument(argument: string): string | undefined;
|
|
51
|
+
export declare function ownedArgument(argument: string, platform?: NodeJS.Platform): string | undefined;
|
|
52
52
|
/** Checks the target's `app.launchArguments`: the app's own switches and Chromium's, none of the engine's. */
|
|
53
53
|
export declare function checkLaunchArguments(launchArguments: readonly string[] | undefined): void;
|
|
54
54
|
/** Checks the option bag the way every config option is checked: unknown keys and wrong types fail the config load. */
|
package/dist/options.js
CHANGED
|
@@ -21,17 +21,19 @@ const OPTION_KEYS = Object.keys({
|
|
|
21
21
|
* the DevTools transport the engine drives the app through (a fixed port
|
|
22
22
|
* would also collide between workers).
|
|
23
23
|
*/
|
|
24
|
-
export function ownedArgument(argument) {
|
|
25
|
-
|
|
24
|
+
export function ownedArgument(argument, platform = process.platform) {
|
|
25
|
+
// On Windows Chromium also reads `/` as a switch prefix and trims U+0085 (NEXT LINE), which `trim()` keeps; elsewhere `/...` is a path.
|
|
26
|
+
const trimmed = platform === 'win32' ? argument.replace(/^[\s\u0085]+|[\s\u0085]+$/g, '').replace(/^\//, '-') : argument.trim();
|
|
27
|
+
if (/^--?user-data-dir(?:=|$)/i.test(trimmed))
|
|
26
28
|
return 'must not set --user-data-dir: the engine gives every attempt an empty one of its own';
|
|
27
|
-
const port =
|
|
29
|
+
const port = /^--?(inspect(?:-(?:brk(?:-node)?|port|publish-uid))?|debug-port|remote-debugging-port|remote-debugging-pipe)(?:=|$)/i.exec(trimmed);
|
|
28
30
|
if (port !== null)
|
|
29
|
-
return `must not set
|
|
31
|
+
return `must not set --${port[1].toLowerCase()}: the engine opens the inspector and the DevTools pipe it drives the app through itself`;
|
|
30
32
|
return undefined;
|
|
31
33
|
}
|
|
32
34
|
/** Checks the target's `app.launchArguments`: the app's own switches and Chromium's, none of the engine's. */
|
|
33
35
|
export function checkLaunchArguments(launchArguments) {
|
|
34
|
-
const owned = launchArguments?.map(ownedArgument).find((reason) => reason !== undefined);
|
|
36
|
+
const owned = launchArguments?.map((argument) => ownedArgument(argument)).find((reason) => reason !== undefined);
|
|
35
37
|
if (owned !== undefined)
|
|
36
38
|
throw new ConfigurationError('INVALID_CONFIG', `app.launchArguments ${owned}`);
|
|
37
39
|
}
|
|
@@ -80,6 +82,10 @@ function checkEnv(label, env, code) {
|
|
|
80
82
|
if (typeof env !== 'object' || env === null || Array.isArray(env) || Object.values(env).some((value) => typeof value !== 'string')) {
|
|
81
83
|
throw refusal(code, `${label} must be an object of variable name to string value`);
|
|
82
84
|
}
|
|
85
|
+
const invalid = Object.keys(env).find((name) => name === '' || name.includes('='));
|
|
86
|
+
if (invalid !== undefined) {
|
|
87
|
+
throw refusal(code, `${label} must not have ${invalid === '' ? 'an empty variable name' : 'a variable name containing "="'}`);
|
|
88
|
+
}
|
|
83
89
|
// Windows reads a variable's name in any case.
|
|
84
90
|
const refused = Object.keys(env).find((name) => REFUSED_ENV.has(name.toUpperCase()));
|
|
85
91
|
if (refused !== undefined) {
|
|
@@ -110,7 +116,7 @@ export function checkLaunchOptions(options, projectRoot) {
|
|
|
110
116
|
const { launchArguments: args = [], env, cwd } = options;
|
|
111
117
|
if (!Array.isArray(args) || args.some((argument) => typeof argument !== 'string'))
|
|
112
118
|
throw refusal('INVALID_ARGUMENT', 'electron.launch({ launchArguments }) must be a list of strings');
|
|
113
|
-
const owned = args.map(ownedArgument).find((reason) => reason !== undefined);
|
|
119
|
+
const owned = args.map((argument) => ownedArgument(argument)).find((reason) => reason !== undefined);
|
|
114
120
|
if (owned !== undefined)
|
|
115
121
|
throw refusal('INVALID_ARGUMENT', `electron.launch({ launchArguments }) ${owned}`);
|
|
116
122
|
checkEnv('electron.launch({ env })', env, 'INVALID_ARGUMENT');
|
package/dist/page.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { Deadline } from '@e2e-dev/core/engine';
|
|
7
7
|
import type { Session } from './cdp/connection.ts';
|
|
8
|
-
import { Keyboard, Mouse, type InputTarget } from './cdp/input.ts';
|
|
8
|
+
import { HeldInput, Keyboard, Mouse, type InputTarget } from './cdp/input.ts';
|
|
9
9
|
/** The isolated world the engine's own page-side reads run in, apart from the app's globals. */
|
|
10
10
|
export declare const WORLD_NAME = "__e2e_electron__";
|
|
11
11
|
type PageEvent = 'close' | 'crash' | 'load' | 'document';
|
|
@@ -23,6 +23,7 @@ export declare class PageTarget implements InputTarget {
|
|
|
23
23
|
readonly opener?: PageTarget | undefined;
|
|
24
24
|
readonly keyboard: Keyboard;
|
|
25
25
|
readonly mouse: Mouse;
|
|
26
|
+
readonly held: HeldInput;
|
|
26
27
|
private address;
|
|
27
28
|
private closed;
|
|
28
29
|
private isolated;
|
|
@@ -35,7 +36,7 @@ export declare class PageTarget implements InputTarget {
|
|
|
35
36
|
private readonly handlers;
|
|
36
37
|
constructor(targetId: string, session: Session, url: string,
|
|
37
38
|
/** The window whose page opened this one with `window.open` or a link, when one did. */
|
|
38
|
-
opener?: PageTarget | undefined);
|
|
39
|
+
opener?: PageTarget | undefined, held?: HeldInput);
|
|
39
40
|
url(): string;
|
|
40
41
|
navigated(url: string): void;
|
|
41
42
|
isClosed(): boolean;
|
package/dist/page.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* DevTools session, the isolated world the engine's page-side code runs in,
|
|
4
4
|
* and its keyboard and mouse.
|
|
5
5
|
*/
|
|
6
|
-
import { Keyboard, Mouse } from './cdp/input.js';
|
|
6
|
+
import { HeldInput, Keyboard, Mouse } from './cdp/input.js';
|
|
7
7
|
import { callForPlainData } from './evaluate.js';
|
|
8
8
|
/** How long past its operation's end a gesture may still hold the page's input, to release what it pressed. */
|
|
9
9
|
const RELEASE_MS = 1_000;
|
|
@@ -19,6 +19,7 @@ export class PageTarget {
|
|
|
19
19
|
opener;
|
|
20
20
|
keyboard;
|
|
21
21
|
mouse;
|
|
22
|
+
held;
|
|
22
23
|
address;
|
|
23
24
|
closed = false;
|
|
24
25
|
isolated;
|
|
@@ -31,13 +32,14 @@ export class PageTarget {
|
|
|
31
32
|
handlers = new Map();
|
|
32
33
|
constructor(targetId, session, url,
|
|
33
34
|
/** The window whose page opened this one with `window.open` or a link, when one did. */
|
|
34
|
-
opener) {
|
|
35
|
+
opener, held = opener?.held ?? new HeldInput()) {
|
|
35
36
|
this.targetId = targetId;
|
|
36
37
|
this.session = session;
|
|
37
38
|
this.opener = opener;
|
|
38
39
|
this.address = url;
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
40
|
+
this.held = held;
|
|
41
|
+
this.keyboard = new Keyboard(this, held);
|
|
42
|
+
this.mouse = new Mouse(this, this.keyboard, held);
|
|
41
43
|
}
|
|
42
44
|
url() {
|
|
43
45
|
return this.address;
|
|
@@ -71,6 +73,8 @@ export class PageTarget {
|
|
|
71
73
|
if (this.closed)
|
|
72
74
|
return;
|
|
73
75
|
this.closed = true;
|
|
76
|
+
this.keyboard.reset();
|
|
77
|
+
this.mouse.reset();
|
|
74
78
|
}
|
|
75
79
|
for (const handler of this.handlers.get(event) ?? [])
|
|
76
80
|
handler();
|
package/dist/surface.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* (options, executable), the attempt's (its user-data directory and
|
|
11
11
|
* artifacts), and the running app's (`AppProcess` and `Windows`).
|
|
12
12
|
*/
|
|
13
|
-
import type { ComputedStyleProperty, ComputedStyleValues, ViewportIntersection, VideoSegment, EngineAttemptContext, EngineCleanupContext, EngineDoctorCheck, EngineDoctorInfo, EngineInitInfo, EngineObserveOptions, EnginePrepareInfo, EngineSnapshot, LocatorAction, LocatorExpression, NodeRef, OperationContext, PointerAction, SemanticNode, ViewportPoint } from '@e2e-dev/core/engine';
|
|
13
|
+
import type { ComputedStyleProperty, ComputedStyleValues, ViewportIntersection, VideoSegment, EngineAttemptContext, EngineCleanupContext, EngineDoctorCheck, EngineDoctorInfo, EngineInitInfo, EngineObserveOptions, EngineScreenshotOptions, EnginePrepareInfo, EngineSnapshot, LocatorAction, LocatorExpression, NodeRef, OperationContext, PointerAction, SemanticNode, ViewportPoint } from '@e2e-dev/core/engine';
|
|
14
14
|
import { type LaunchExtra } from './app-process.ts';
|
|
15
15
|
import { Budget } from './budget.ts';
|
|
16
16
|
import { type DialogHandler } from './dialogs.ts';
|
|
@@ -28,7 +28,6 @@ export declare class ElectronSurface {
|
|
|
28
28
|
private userDataDir;
|
|
29
29
|
/** What `electron.launch()` added to this attempt's launches. */
|
|
30
30
|
private launchExtra;
|
|
31
|
-
private uploadsDir;
|
|
32
31
|
private artifactCounter;
|
|
33
32
|
private recorder;
|
|
34
33
|
/** Recordings started this attempt, for their file names. */
|
|
@@ -163,7 +162,8 @@ export declare class ElectronSurface {
|
|
|
163
162
|
readonly absolutePath: string;
|
|
164
163
|
readonly suggestedFilename: string;
|
|
165
164
|
}>;
|
|
166
|
-
|
|
165
|
+
/** The window's viewport, or with `options` its whole page, cut to their clip. */
|
|
166
|
+
screenshot(label: string | undefined, operation: OperationContext, options?: EngineScreenshotOptions): Promise<string>;
|
|
167
167
|
/** Starts a recording: of the shown window now, and of each one shown after it, through a relaunch too. */
|
|
168
168
|
startVideo(operation: OperationContext): Promise<void>;
|
|
169
169
|
stopVideo(): Promise<readonly VideoSegment[]>;
|
package/dist/surface.js
CHANGED
|
@@ -49,7 +49,6 @@ export class ElectronSurface {
|
|
|
49
49
|
userDataDir;
|
|
50
50
|
/** What `electron.launch()` added to this attempt's launches. */
|
|
51
51
|
launchExtra = NO_EXTRA;
|
|
52
|
-
uploadsDir;
|
|
53
52
|
artifactCounter = 0;
|
|
54
53
|
recorder;
|
|
55
54
|
/** Recordings started this attempt, for their file names. */
|
|
@@ -102,22 +101,14 @@ export class ElectronSurface {
|
|
|
102
101
|
this.recorder = undefined;
|
|
103
102
|
await uncollected?.abandon().catch(() => undefined);
|
|
104
103
|
await this.app.serialized(() => this.app.quit(context, DISCARD_CLOSE_MS));
|
|
105
|
-
const { userDataDir
|
|
104
|
+
const { userDataDir } = this;
|
|
106
105
|
this.userDataDir = undefined;
|
|
107
|
-
this.uploadsDir = undefined;
|
|
108
106
|
this.attempt = undefined;
|
|
109
107
|
// settleAttempt reported what the attempt's dialogs left; its handlers go with it.
|
|
110
108
|
this.dialogs.reset();
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
rmSync(userDataDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
|
|
115
|
-
}
|
|
116
|
-
finally {
|
|
117
|
-
// Removed even when the user-data directory could not be, so the next attempt never finds this one's files.
|
|
118
|
-
if (uploadsDir !== undefined)
|
|
119
|
-
rmSync(uploadsDir, { recursive: true, force: true });
|
|
120
|
-
}
|
|
109
|
+
// Retried: Chromium's helper processes can still be closing their files in it.
|
|
110
|
+
if (userDataDir !== undefined)
|
|
111
|
+
rmSync(userDataDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
|
|
121
112
|
}
|
|
122
113
|
/** A dialog the test's last step opened has no next step to fail: the attempt fails with it, as a step would. */
|
|
123
114
|
async settleAttempt(context) {
|
|
@@ -261,7 +252,7 @@ export class ElectronSurface {
|
|
|
261
252
|
if (left !== undefined)
|
|
262
253
|
throw new ConfigurationError('POLICY_DENIED', left);
|
|
263
254
|
const snapshot = projectRead(raw, 'tree', this.projection());
|
|
264
|
-
return options?.pixels === true ? await withPixels(this.devtools, raw, snapshot) : snapshot;
|
|
255
|
+
return options?.pixels === true ? await withPixels(this.devtools, raw, snapshot, { fullPage: options.fullPage === true }) : snapshot;
|
|
265
256
|
});
|
|
266
257
|
}
|
|
267
258
|
async locate(expression, operation) {
|
|
@@ -320,10 +311,6 @@ export class ElectronSurface {
|
|
|
320
311
|
devtools: this.devtools,
|
|
321
312
|
windows: this.windowList,
|
|
322
313
|
projectRoot: this.projectRoot,
|
|
323
|
-
uploads: () => {
|
|
324
|
-
this.uploadsDir ??= mkdtempSync(path.join(tmpdir(), 'e2e-electron-uploads-'));
|
|
325
|
-
return this.uploadsDir;
|
|
326
|
-
},
|
|
327
314
|
};
|
|
328
315
|
}
|
|
329
316
|
/** Why the window is not one to observe, trace, or capture: it shows a local file outside the app's directory. */
|
|
@@ -680,14 +667,15 @@ export class ElectronSurface {
|
|
|
680
667
|
return { path: relative, absolutePath: absolute, suggestedFilename: finished.filename };
|
|
681
668
|
}
|
|
682
669
|
// --- pixels ---
|
|
683
|
-
|
|
670
|
+
/** The window's viewport, or with `options` its whole page, cut to their clip. */
|
|
671
|
+
async screenshot(label, operation, options) {
|
|
684
672
|
const window = this.requireWindow();
|
|
685
673
|
const attempt = this.attempt;
|
|
686
674
|
if (attempt === undefined)
|
|
687
675
|
throw invalidState('a screenshot is taken inside a test');
|
|
688
676
|
return await withBudget(operation, 'screenshot', async () => {
|
|
689
677
|
this.artifactCounter += 1;
|
|
690
|
-
return await screenshotFile(this.devtools, window, attempt.artifactsDir, screenshotName(this.artifactCounter, label), () => this.leftApp(window));
|
|
678
|
+
return await screenshotFile(this.devtools, window, attempt.artifactsDir, screenshotName(this.artifactCounter, label), () => this.leftApp(window), options);
|
|
691
679
|
});
|
|
692
680
|
}
|
|
693
681
|
// --- video ---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e2e-dev/electron",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2-nightly-20261205030542",
|
|
4
4
|
"description": "Electron engine for e2e agentic end-to-end testing: launches an Electron app and drives its windows through Chromium's accessibility tree",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"e2e",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"NOTICE"
|
|
43
43
|
],
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@e2e-dev/core": "
|
|
46
|
-
"e2e": "
|
|
45
|
+
"@e2e-dev/core": "0.27.0-nightly-20261205030542",
|
|
46
|
+
"e2e": "0.27.0-nightly-20261205030542",
|
|
47
47
|
"electron": "*"
|
|
48
48
|
},
|
|
49
49
|
"peerDependenciesMeta": {
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@e2e-dev/core": "0.
|
|
56
|
-
"@
|
|
55
|
+
"@e2e-dev/core": "0.27.0-nightly-20261205030542",
|
|
56
|
+
"@swc/anyformat-image": "0.1.3",
|
|
57
57
|
"@types/node": "26.6.11",
|
|
58
58
|
"devtools-protocol": "0.0.1758431",
|
|
59
|
-
"e2e": "0.
|
|
59
|
+
"e2e": "0.27.0-nightly-20261205030542",
|
|
60
60
|
"electron": "45.5.0",
|
|
61
61
|
"typescript": "7.0.2",
|
|
62
62
|
"vitest": "5.1.2"
|