@opensteer/engine-playwright 0.8.5 → 0.8.7
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/index.cjs +74 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +74 -10
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -770,6 +770,12 @@ interface BrowserInspector {
|
|
|
770
770
|
readonly args?: readonly unknown[];
|
|
771
771
|
readonly timeoutMs?: number;
|
|
772
772
|
}): Promise<StepResult<unknown>>;
|
|
773
|
+
evaluateFrame(input: {
|
|
774
|
+
readonly frameRef: FrameRef;
|
|
775
|
+
readonly script: string;
|
|
776
|
+
readonly args?: readonly unknown[];
|
|
777
|
+
readonly timeoutMs?: number;
|
|
778
|
+
}): Promise<StepResult<unknown>>;
|
|
773
779
|
}
|
|
774
780
|
interface SessionTransportExecutor {
|
|
775
781
|
readonly capabilities: Readonly<BrowserCapabilities>;
|
|
@@ -1015,6 +1021,7 @@ declare class PlaywrightBrowserCoreEngine implements BrowserCoreEngine {
|
|
|
1015
1021
|
private readonly pageByPlaywrightPage;
|
|
1016
1022
|
private readonly pendingPopupOpeners;
|
|
1017
1023
|
private readonly preassignedPopupPageRefs;
|
|
1024
|
+
private readonly queuedPopupOpenedPages;
|
|
1018
1025
|
private readonly actionSettler;
|
|
1019
1026
|
private pageCounter;
|
|
1020
1027
|
private frameCounter;
|
|
@@ -1191,6 +1198,12 @@ declare class PlaywrightBrowserCoreEngine implements BrowserCoreEngine {
|
|
|
1191
1198
|
readonly args?: readonly unknown[];
|
|
1192
1199
|
readonly timeoutMs?: number;
|
|
1193
1200
|
}): Promise<StepResult<unknown>>;
|
|
1201
|
+
evaluateFrame(input: {
|
|
1202
|
+
readonly frameRef: FrameRef;
|
|
1203
|
+
readonly script: string;
|
|
1204
|
+
readonly args?: readonly unknown[];
|
|
1205
|
+
readonly timeoutMs?: number;
|
|
1206
|
+
}): Promise<StepResult<unknown>>;
|
|
1194
1207
|
addInitScript(input: BrowserInitScriptInput): Promise<BrowserInitScriptRegistration>;
|
|
1195
1208
|
registerRoute(input: BrowserRouteRegistrationInput): Promise<BrowserRouteRegistration>;
|
|
1196
1209
|
executeRequest(input: {
|
|
@@ -1201,6 +1214,7 @@ declare class PlaywrightBrowserCoreEngine implements BrowserCoreEngine {
|
|
|
1201
1214
|
private handleContextPage;
|
|
1202
1215
|
private handleAttachedInitialPage;
|
|
1203
1216
|
private initializePageController;
|
|
1217
|
+
private queuePopupOpenedEvent;
|
|
1204
1218
|
private handleFrameAttached;
|
|
1205
1219
|
private handleFrameDetached;
|
|
1206
1220
|
private handleFrameNavigated;
|
package/dist/index.d.ts
CHANGED
|
@@ -770,6 +770,12 @@ interface BrowserInspector {
|
|
|
770
770
|
readonly args?: readonly unknown[];
|
|
771
771
|
readonly timeoutMs?: number;
|
|
772
772
|
}): Promise<StepResult<unknown>>;
|
|
773
|
+
evaluateFrame(input: {
|
|
774
|
+
readonly frameRef: FrameRef;
|
|
775
|
+
readonly script: string;
|
|
776
|
+
readonly args?: readonly unknown[];
|
|
777
|
+
readonly timeoutMs?: number;
|
|
778
|
+
}): Promise<StepResult<unknown>>;
|
|
773
779
|
}
|
|
774
780
|
interface SessionTransportExecutor {
|
|
775
781
|
readonly capabilities: Readonly<BrowserCapabilities>;
|
|
@@ -1015,6 +1021,7 @@ declare class PlaywrightBrowserCoreEngine implements BrowserCoreEngine {
|
|
|
1015
1021
|
private readonly pageByPlaywrightPage;
|
|
1016
1022
|
private readonly pendingPopupOpeners;
|
|
1017
1023
|
private readonly preassignedPopupPageRefs;
|
|
1024
|
+
private readonly queuedPopupOpenedPages;
|
|
1018
1025
|
private readonly actionSettler;
|
|
1019
1026
|
private pageCounter;
|
|
1020
1027
|
private frameCounter;
|
|
@@ -1191,6 +1198,12 @@ declare class PlaywrightBrowserCoreEngine implements BrowserCoreEngine {
|
|
|
1191
1198
|
readonly args?: readonly unknown[];
|
|
1192
1199
|
readonly timeoutMs?: number;
|
|
1193
1200
|
}): Promise<StepResult<unknown>>;
|
|
1201
|
+
evaluateFrame(input: {
|
|
1202
|
+
readonly frameRef: FrameRef;
|
|
1203
|
+
readonly script: string;
|
|
1204
|
+
readonly args?: readonly unknown[];
|
|
1205
|
+
readonly timeoutMs?: number;
|
|
1206
|
+
}): Promise<StepResult<unknown>>;
|
|
1194
1207
|
addInitScript(input: BrowserInitScriptInput): Promise<BrowserInitScriptRegistration>;
|
|
1195
1208
|
registerRoute(input: BrowserRouteRegistrationInput): Promise<BrowserRouteRegistration>;
|
|
1196
1209
|
executeRequest(input: {
|
|
@@ -1201,6 +1214,7 @@ declare class PlaywrightBrowserCoreEngine implements BrowserCoreEngine {
|
|
|
1201
1214
|
private handleContextPage;
|
|
1202
1215
|
private handleAttachedInitialPage;
|
|
1203
1216
|
private initializePageController;
|
|
1217
|
+
private queuePopupOpenedEvent;
|
|
1204
1218
|
private handleFrameAttached;
|
|
1205
1219
|
private handleFrameDetached;
|
|
1206
1220
|
private handleFrameNavigated;
|
package/dist/index.js
CHANGED
|
@@ -1576,6 +1576,13 @@ async function waitForActionBoundary(input) {
|
|
|
1576
1576
|
continue;
|
|
1577
1577
|
}
|
|
1578
1578
|
if (crossDocument) {
|
|
1579
|
+
if (!postLoadTrackerIsSettled(
|
|
1580
|
+
await input.readTrackerState(),
|
|
1581
|
+
DEFAULT_POST_LOAD_TRACKER_QUIET_WINDOW_MS
|
|
1582
|
+
)) {
|
|
1583
|
+
await delay(Math.min(pollIntervalMs, Math.max(0, deadline - Date.now())));
|
|
1584
|
+
continue;
|
|
1585
|
+
}
|
|
1579
1586
|
return {
|
|
1580
1587
|
trigger,
|
|
1581
1588
|
crossDocument,
|
|
@@ -3983,6 +3990,7 @@ var PlaywrightBrowserCoreEngine = class _PlaywrightBrowserCoreEngine {
|
|
|
3983
3990
|
pageByPlaywrightPage = /* @__PURE__ */ new WeakMap();
|
|
3984
3991
|
pendingPopupOpeners = /* @__PURE__ */ new WeakMap();
|
|
3985
3992
|
preassignedPopupPageRefs = /* @__PURE__ */ new WeakMap();
|
|
3993
|
+
queuedPopupOpenedPages = /* @__PURE__ */ new WeakSet();
|
|
3986
3994
|
actionSettler = createPlaywrightActionSettler({
|
|
3987
3995
|
flushPendingPageTasks: (sessionRef) => this.flushPendingPageTasks(sessionRef),
|
|
3988
3996
|
flushDomUpdateTask: (controller) => this.flushDomUpdateTask(controller),
|
|
@@ -4948,6 +4956,39 @@ var PlaywrightBrowserCoreEngine = class _PlaywrightBrowserCoreEngine {
|
|
|
4948
4956
|
throw normalizePlaywrightError(error, controller.pageRef);
|
|
4949
4957
|
}
|
|
4950
4958
|
}
|
|
4959
|
+
async evaluateFrame(input) {
|
|
4960
|
+
const frameState = this.requireFrame(input.frameRef);
|
|
4961
|
+
const controller = this.requirePage(frameState.pageRef);
|
|
4962
|
+
const startedAt = Date.now();
|
|
4963
|
+
const frame = this.requireLiveFrame(input.frameRef);
|
|
4964
|
+
try {
|
|
4965
|
+
const result = await withTimeout(
|
|
4966
|
+
frame.evaluate(
|
|
4967
|
+
({ script, args }) => {
|
|
4968
|
+
const evaluated = (0, eval)(script);
|
|
4969
|
+
if (typeof evaluated === "function") {
|
|
4970
|
+
return evaluated(...args ?? []);
|
|
4971
|
+
}
|
|
4972
|
+
return evaluated;
|
|
4973
|
+
},
|
|
4974
|
+
{
|
|
4975
|
+
script: input.script,
|
|
4976
|
+
args: input.args ?? []
|
|
4977
|
+
}
|
|
4978
|
+
),
|
|
4979
|
+
input.timeoutMs
|
|
4980
|
+
);
|
|
4981
|
+
return this.createStepResult(controller.sessionRef, controller.pageRef, startedAt, {
|
|
4982
|
+
frameRef: frameState.frameRef,
|
|
4983
|
+
documentRef: frameState.currentDocument.documentRef,
|
|
4984
|
+
documentEpoch: frameState.currentDocument.documentEpoch,
|
|
4985
|
+
events: this.drainQueuedEvents(controller.pageRef),
|
|
4986
|
+
data: result
|
|
4987
|
+
});
|
|
4988
|
+
} catch (error) {
|
|
4989
|
+
throw normalizePlaywrightError(error, controller.pageRef);
|
|
4990
|
+
}
|
|
4991
|
+
}
|
|
4951
4992
|
async addInitScript(input) {
|
|
4952
4993
|
if (!hasCapability(this.capabilities, "instrumentation.initScripts")) {
|
|
4953
4994
|
throw unsupportedCapabilityError("instrumentation.initScripts");
|
|
@@ -5319,17 +5360,19 @@ var PlaywrightBrowserCoreEngine = class _PlaywrightBrowserCoreEngine {
|
|
|
5319
5360
|
page.on(
|
|
5320
5361
|
"popup",
|
|
5321
5362
|
(popupPage) => this.runControllerEvent(controller, () => {
|
|
5322
|
-
const
|
|
5323
|
-
this.
|
|
5324
|
-
|
|
5325
|
-
|
|
5363
|
+
const existingPopupController = this.pageByPlaywrightPage.get(popupPage);
|
|
5364
|
+
const popupPageRef = existingPopupController?.pageRef ?? createPageRef(`playwright-${++this.pageCounter}`);
|
|
5365
|
+
if (!existingPopupController) {
|
|
5366
|
+
this.preassignedPopupPageRefs.set(popupPage, popupPageRef);
|
|
5367
|
+
this.pendingPopupOpeners.set(popupPage, controller.pageRef);
|
|
5368
|
+
} else if (existingPopupController.openerPageRef === void 0) {
|
|
5369
|
+
existingPopupController.openerPageRef = controller.pageRef;
|
|
5370
|
+
}
|
|
5371
|
+
this.queuePopupOpenedEvent(
|
|
5326
5372
|
controller.pageRef,
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
pageRef: popupPageRef,
|
|
5331
|
-
openerPageRef: controller.pageRef
|
|
5332
|
-
})
|
|
5373
|
+
popupPage,
|
|
5374
|
+
popupPageRef,
|
|
5375
|
+
controller.sessionRef
|
|
5333
5376
|
);
|
|
5334
5377
|
})
|
|
5335
5378
|
);
|
|
@@ -5390,10 +5433,31 @@ var PlaywrightBrowserCoreEngine = class _PlaywrightBrowserCoreEngine {
|
|
|
5390
5433
|
const openerController = pendingOpenerPageRef !== void 0 ? this.pages.get(pendingOpenerPageRef) : opener ? this.pageByPlaywrightPage.get(opener) : void 0;
|
|
5391
5434
|
if (openerController) {
|
|
5392
5435
|
controller.openerPageRef = openerController.pageRef;
|
|
5436
|
+
this.queuePopupOpenedEvent(
|
|
5437
|
+
openerController.pageRef,
|
|
5438
|
+
page,
|
|
5439
|
+
controller.pageRef,
|
|
5440
|
+
controller.sessionRef
|
|
5441
|
+
);
|
|
5393
5442
|
}
|
|
5394
5443
|
}
|
|
5395
5444
|
return controller;
|
|
5396
5445
|
}
|
|
5446
|
+
queuePopupOpenedEvent(openerPageRef, popupPage, popupPageRef, sessionRef) {
|
|
5447
|
+
if (this.queuedPopupOpenedPages.has(popupPage)) {
|
|
5448
|
+
return;
|
|
5449
|
+
}
|
|
5450
|
+
this.queuedPopupOpenedPages.add(popupPage);
|
|
5451
|
+
this.queueEvent(
|
|
5452
|
+
openerPageRef,
|
|
5453
|
+
this.createEvent({
|
|
5454
|
+
kind: "popup-opened",
|
|
5455
|
+
sessionRef,
|
|
5456
|
+
pageRef: popupPageRef,
|
|
5457
|
+
openerPageRef
|
|
5458
|
+
})
|
|
5459
|
+
);
|
|
5460
|
+
}
|
|
5397
5461
|
handleFrameAttached(controller, frameId, parentFrameId) {
|
|
5398
5462
|
if (controller.framesByCdpId.has(frameId)) {
|
|
5399
5463
|
return;
|