patchright-core 1.57.0 → 1.58.2
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/ThirdPartyNotices.txt +3223 -308
- package/browsers.json +21 -22
- package/lib/cli/program.js +4 -5
- package/lib/client/api.js +3 -0
- package/lib/client/browser.js +3 -5
- package/lib/client/browserContext.js +40 -4
- package/lib/client/browserType.js +4 -3
- package/lib/client/connection.js +4 -0
- package/lib/client/elementHandle.js +3 -0
- package/lib/client/events.js +3 -0
- package/lib/client/fetch.js +3 -4
- package/lib/client/frame.js +10 -1
- package/lib/client/locator.js +8 -0
- package/lib/client/network.js +5 -1
- package/lib/client/page.js +29 -1
- package/lib/client/pageAgent.js +64 -0
- package/lib/client/platform.js +3 -0
- package/lib/client/tracing.js +1 -1
- package/lib/generated/injectedScriptSource.js +1 -1
- package/lib/generated/pollingRecorderSource.js +1 -1
- package/lib/mcpBundle.js +84 -0
- package/lib/mcpBundleImpl/index.js +147 -0
- package/lib/protocol/serializers.js +5 -0
- package/lib/protocol/validator.js +88 -4
- package/lib/remote/playwrightServer.js +1 -2
- package/lib/server/agent/actionRunner.js +335 -0
- package/lib/server/agent/actions.js +128 -0
- package/lib/server/agent/codegen.js +111 -0
- package/lib/server/agent/context.js +150 -0
- package/lib/server/agent/expectTools.js +156 -0
- package/lib/server/agent/pageAgent.js +204 -0
- package/lib/server/agent/performTools.js +262 -0
- package/lib/server/agent/tool.js +109 -0
- package/lib/server/artifact.js +1 -1
- package/lib/server/bidi/bidiBrowser.js +56 -12
- package/lib/server/bidi/bidiChromium.js +8 -12
- package/lib/server/bidi/bidiConnection.js +1 -0
- package/lib/server/bidi/bidiDeserializer.js +116 -0
- package/lib/server/bidi/bidiExecutionContext.js +75 -29
- package/lib/server/bidi/bidiFirefox.js +6 -8
- package/lib/server/bidi/bidiNetworkManager.js +1 -1
- package/lib/server/bidi/bidiPage.js +39 -28
- package/lib/server/bidi/third_party/bidiProtocolCore.js +1 -0
- package/lib/server/browserContext.js +34 -26
- package/lib/server/browserType.js +12 -4
- package/lib/server/chromium/chromium.js +14 -20
- package/lib/server/chromium/chromiumSwitches.js +2 -2
- package/lib/server/chromium/crBrowser.js +22 -12
- package/lib/server/chromium/crConnection.js +0 -5
- package/lib/server/chromium/crCoverage.js +13 -1
- package/lib/server/chromium/crDevTools.js +0 -2
- package/lib/server/chromium/crNetworkManager.js +92 -12
- package/lib/server/chromium/crPage.js +62 -116
- package/lib/server/codegen/javascript.js +6 -29
- package/lib/server/deviceDescriptorsSource.json +56 -56
- package/lib/server/dispatchers/browserContextDispatcher.js +3 -2
- package/lib/server/dispatchers/dispatcher.js +6 -13
- package/lib/server/dispatchers/frameDispatcher.js +1 -1
- package/lib/server/dispatchers/jsHandleDispatcher.js +2 -2
- package/lib/server/dispatchers/pageAgentDispatcher.js +96 -0
- package/lib/server/dispatchers/pageDispatcher.js +4 -0
- package/lib/server/dom.js +12 -3
- package/lib/server/electron/electron.js +5 -2
- package/lib/server/firefox/ffBrowser.js +10 -20
- package/lib/server/firefox/ffConnection.js +0 -5
- package/lib/server/firefox/ffNetworkManager.js +2 -2
- package/lib/server/firefox/ffPage.js +15 -18
- package/lib/server/firefox/firefox.js +6 -8
- package/lib/server/frameSelectors.js +16 -4
- package/lib/server/frames.js +251 -86
- package/lib/server/instrumentation.js +3 -0
- package/lib/server/javascript.js +8 -4
- package/lib/server/launchApp.js +2 -1
- package/lib/server/network.js +50 -12
- package/lib/server/page.js +61 -91
- package/lib/server/progress.js +26 -6
- package/lib/server/recorder/recorderApp.js +79 -100
- package/lib/server/registry/browserFetcher.js +6 -4
- package/lib/server/registry/index.js +172 -149
- package/lib/server/registry/oopDownloadBrowserMain.js +3 -0
- package/lib/server/screencast.js +190 -0
- package/lib/server/screenshotter.js +6 -0
- package/lib/server/trace/recorder/snapshotter.js +17 -8
- package/lib/server/trace/recorder/snapshotterInjected.js +30 -72
- package/lib/server/trace/recorder/tracing.js +29 -21
- package/lib/server/trace/viewer/traceParser.js +72 -0
- package/lib/server/trace/viewer/traceViewer.js +21 -17
- package/lib/server/utils/expectUtils.js +87 -2
- package/lib/server/utils/hostPlatform.js +15 -0
- package/lib/server/utils/httpServer.js +5 -20
- package/lib/server/utils/network.js +37 -28
- package/lib/server/utils/nodePlatform.js +6 -0
- package/lib/server/{chromium/videoRecorder.js → videoRecorder.js} +22 -13
- package/lib/server/webkit/webkit.js +4 -6
- package/lib/server/webkit/wkBrowser.js +2 -6
- package/lib/server/webkit/wkConnection.js +1 -6
- package/lib/server/webkit/wkInterceptableRequest.js +29 -1
- package/lib/server/webkit/wkPage.js +75 -46
- package/lib/utils/isomorphic/ariaSnapshot.js +60 -2
- package/lib/utils/isomorphic/lruCache.js +51 -0
- package/lib/utils/isomorphic/protocolMetainfo.js +9 -1
- package/lib/utils/isomorphic/stringUtils.js +49 -0
- package/lib/utils/isomorphic/trace/entries.js +16 -0
- package/lib/utils/isomorphic/trace/snapshotRenderer.js +499 -0
- package/lib/utils/isomorphic/trace/snapshotServer.js +120 -0
- package/lib/utils/isomorphic/trace/snapshotStorage.js +89 -0
- package/lib/utils/isomorphic/trace/traceLoader.js +131 -0
- package/lib/utils/isomorphic/trace/traceModel.js +365 -0
- package/lib/utils/isomorphic/trace/traceModernizer.js +400 -0
- package/lib/utils/isomorphic/trace/versions/traceV3.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV4.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV5.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV6.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV7.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV8.js +16 -0
- package/lib/utils/isomorphic/yaml.js +84 -0
- package/lib/utils.js +2 -0
- package/lib/utilsBundle.js +2 -5
- package/lib/utilsBundleImpl/index.js +165 -165
- package/lib/vite/htmlReport/index.html +21 -21
- package/lib/vite/recorder/assets/codeMirrorModule-CFUTFUO7.js +32 -0
- package/lib/vite/{traceViewer/codeMirrorModule.C3UTv-Ge.css → recorder/assets/codeMirrorModule-DYBRYzYX.css} +1 -1
- package/lib/vite/recorder/assets/{index-Ri0uHF7I.css → index-BSjZa4pk.css} +1 -1
- package/lib/vite/recorder/assets/index-CVkBxsGf.js +193 -0
- package/lib/vite/recorder/index.html +2 -2
- package/lib/vite/traceViewer/assets/codeMirrorModule-BVA4h_ZY.js +32 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-CjfmcdOz.js +266 -0
- package/lib/vite/{recorder/assets/codeMirrorModule-C3UTv-Ge.css → traceViewer/codeMirrorModule.DYBRYzYX.css} +1 -1
- package/lib/vite/traceViewer/defaultSettingsView.7ch9cixO.css +1 -0
- package/lib/vite/traceViewer/index.BVu7tZDe.css +1 -0
- package/lib/vite/traceViewer/index.BtyWtaE-.js +2 -0
- package/lib/vite/traceViewer/index.html +4 -4
- package/lib/vite/traceViewer/sw.bundle.js +5 -3
- package/lib/vite/traceViewer/uiMode.fyrXARf2.js +5 -0
- package/lib/vite/traceViewer/uiMode.html +3 -3
- package/package.json +2 -1
- package/types/protocol.d.ts +738 -159
- package/types/types.d.ts +25 -38
- package/lib/server/bidi/third_party/bidiDeserializer.js +0 -98
- package/lib/server/trace/test/inMemorySnapshotter.js +0 -87
- package/lib/vite/recorder/assets/codeMirrorModule-CBbSe-ZI.js +0 -25
- package/lib/vite/recorder/assets/index-CpZVd2nA.js +0 -193
- package/lib/vite/traceViewer/assets/codeMirrorModule-DHz0wP2C.js +0 -25
- package/lib/vite/traceViewer/assets/defaultSettingsView-WsZP88O6.js +0 -266
- package/lib/vite/traceViewer/defaultSettingsView.ConWv5KN.css +0 -1
- package/lib/vite/traceViewer/index.C4Y3Aw8n.css +0 -1
- package/lib/vite/traceViewer/index.C8xAeo93.js +0 -2
- package/lib/vite/traceViewer/uiMode.BltraIJB.js +0 -5
|
@@ -31,10 +31,8 @@ __export(wkPage_exports, {
|
|
|
31
31
|
WKPage: () => WKPage
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(wkPage_exports);
|
|
34
|
-
var import_path = __toESM(require("path"));
|
|
35
34
|
var import_utils = require("../../utils");
|
|
36
35
|
var import_headers = require("../../utils/isomorphic/headers");
|
|
37
|
-
var import_crypto = require("../utils/crypto");
|
|
38
36
|
var import_eventsHelper = require("../utils/eventsHelper");
|
|
39
37
|
var import_hostPlatform = require("../utils/hostPlatform");
|
|
40
38
|
var import_stackTrace = require("../../utils/isomorphic/stackTrace");
|
|
@@ -51,12 +49,14 @@ var import_wkInput = require("./wkInput");
|
|
|
51
49
|
var import_wkInterceptableRequest = require("./wkInterceptableRequest");
|
|
52
50
|
var import_wkProvisionalPage = require("./wkProvisionalPage");
|
|
53
51
|
var import_wkWorkers = require("./wkWorkers");
|
|
54
|
-
var import_debugLogger = require("../utils/debugLogger");
|
|
55
52
|
var import_webkit = require("./webkit");
|
|
53
|
+
var import_registry = require("../registry");
|
|
56
54
|
const UTILITY_WORLD_NAME = "__playwright_utility_world__";
|
|
55
|
+
const enableFrameSessions = !process.env.WK_DISABLE_FRAME_SESSIONS && parseInt(import_registry.registry.findExecutable("webkit").revision, 10) >= 2245;
|
|
57
56
|
class WKPage {
|
|
58
57
|
constructor(browserContext, pageProxySession, opener) {
|
|
59
58
|
this._provisionalPage = null;
|
|
59
|
+
this._targetIdToFrameSession = /* @__PURE__ */ new Map();
|
|
60
60
|
this._requestIdToRequest = /* @__PURE__ */ new Map();
|
|
61
61
|
this._requestIdToRequestWillBeSentEvent = /* @__PURE__ */ new Map();
|
|
62
62
|
this._sessionListeners = [];
|
|
@@ -66,7 +66,6 @@ class WKPage {
|
|
|
66
66
|
};
|
|
67
67
|
this._lastConsoleMessage = null;
|
|
68
68
|
this._requestIdToResponseReceivedPayloadEvent = /* @__PURE__ */ new Map();
|
|
69
|
-
this._recordingVideoFile = null;
|
|
70
69
|
this._screencastGeneration = 0;
|
|
71
70
|
this._pageProxySession = pageProxySession;
|
|
72
71
|
this._opener = opener;
|
|
@@ -116,16 +115,7 @@ class WKPage {
|
|
|
116
115
|
for (const [key, value] of this._browserContext._permissions)
|
|
117
116
|
promises.push(this._grantPermissions(key, value));
|
|
118
117
|
}
|
|
119
|
-
|
|
120
|
-
const outputFile = import_path.default.join(this._browserContext._options.recordVideo.dir, (0, import_crypto.createGuid)() + ".webm");
|
|
121
|
-
promises.push(this._browserContext._ensureVideosPath().then(() => {
|
|
122
|
-
return this._startVideo({
|
|
123
|
-
// validateBrowserContextOptions ensures correct video size.
|
|
124
|
-
...this._browserContext._options.recordVideo.size,
|
|
125
|
-
outputFile
|
|
126
|
-
});
|
|
127
|
-
}));
|
|
128
|
-
}
|
|
118
|
+
promises.push(this._initializeVideoRecording());
|
|
129
119
|
await Promise.all(promises);
|
|
130
120
|
}
|
|
131
121
|
_setSession(session) {
|
|
@@ -159,10 +149,13 @@ class WKPage {
|
|
|
159
149
|
session.send("Page.createUserWorld", { name: UTILITY_WORLD_NAME }).catch((_) => {
|
|
160
150
|
}),
|
|
161
151
|
// Worlds are per-process
|
|
162
|
-
session.send("Console.enable"),
|
|
163
152
|
session.send("Network.enable"),
|
|
164
153
|
this._workers.initializeSession(session)
|
|
165
154
|
];
|
|
155
|
+
if (enableFrameSessions)
|
|
156
|
+
this._initializeFrameSessions(frameTree.frameTree, promises);
|
|
157
|
+
else
|
|
158
|
+
promises.push(session.send("Console.enable"));
|
|
166
159
|
if (this._page.browserContext.needsPlaywrightBinding())
|
|
167
160
|
promises.push(session.send("Runtime.addBinding", { name: import_page.PageBinding.kBindingName }));
|
|
168
161
|
if (this._page.needsRequestInterception()) {
|
|
@@ -219,6 +212,13 @@ class WKPage {
|
|
|
219
212
|
promises.push(session.send("Page.overrideSetting", { setting: "FixedBackgroundsPaintRelativeToDocument", value: contextOptions.isMobile }));
|
|
220
213
|
await Promise.all(promises);
|
|
221
214
|
}
|
|
215
|
+
_initializeFrameSessions(frame, promises) {
|
|
216
|
+
const session = this._targetIdToFrameSession.get(`frame-${frame.frame.id}`);
|
|
217
|
+
if (session)
|
|
218
|
+
promises.push(session.initialize());
|
|
219
|
+
for (const childFrame of frame.childFrames || [])
|
|
220
|
+
this._initializeFrameSessions(childFrame, promises);
|
|
221
|
+
}
|
|
222
222
|
_onDidCommitProvisionalTarget(event) {
|
|
223
223
|
const { oldTargetId, newTargetId } = event;
|
|
224
224
|
(0, import_utils.assert)(this._provisionalPage);
|
|
@@ -244,6 +244,9 @@ class WKPage {
|
|
|
244
244
|
this._session.markAsCrashed();
|
|
245
245
|
this._page._didCrash();
|
|
246
246
|
}
|
|
247
|
+
} else if (this._targetIdToFrameSession.has(targetId)) {
|
|
248
|
+
this._targetIdToFrameSession.get(targetId).dispose();
|
|
249
|
+
this._targetIdToFrameSession.delete(targetId);
|
|
247
250
|
}
|
|
248
251
|
}
|
|
249
252
|
didClose() {
|
|
@@ -257,7 +260,7 @@ class WKPage {
|
|
|
257
260
|
this._provisionalPage.dispose();
|
|
258
261
|
this._provisionalPage = null;
|
|
259
262
|
}
|
|
260
|
-
this._firstNonInitialNavigationCommittedReject(new import_errors.TargetClosedError());
|
|
263
|
+
this._firstNonInitialNavigationCommittedReject(new import_errors.TargetClosedError(this._page.closeReason()));
|
|
261
264
|
this._page._didClose();
|
|
262
265
|
}
|
|
263
266
|
dispatchMessageToSession(message) {
|
|
@@ -288,8 +291,15 @@ class WKPage {
|
|
|
288
291
|
session.dispatchMessage({ id: message.id, error: { message: e.message } });
|
|
289
292
|
});
|
|
290
293
|
});
|
|
291
|
-
if (targetInfo.type === "frame")
|
|
294
|
+
if (targetInfo.type === "frame") {
|
|
295
|
+
if (enableFrameSessions) {
|
|
296
|
+
const wkFrame = new WKFrame(this, session);
|
|
297
|
+
this._targetIdToFrameSession.set(targetInfo.targetId, wkFrame);
|
|
298
|
+
await wkFrame.initialize().catch((e) => {
|
|
299
|
+
});
|
|
300
|
+
}
|
|
292
301
|
return;
|
|
302
|
+
}
|
|
293
303
|
(0, import_utils.assert)(targetInfo.type === "page", "Only page targets are expected in WebKit, received: " + targetInfo.type);
|
|
294
304
|
if (!targetInfo.isProvisional) {
|
|
295
305
|
(0, import_utils.assert)(!this._page.initializedOrUndefined());
|
|
@@ -331,6 +341,8 @@ class WKPage {
|
|
|
331
341
|
this._provisionalPage._session.dispatchMessage(JSON.parse(message));
|
|
332
342
|
else if (this._session.sessionId === targetId)
|
|
333
343
|
this._session.dispatchMessage(JSON.parse(message));
|
|
344
|
+
else if (this._targetIdToFrameSession.has(targetId))
|
|
345
|
+
this._targetIdToFrameSession.get(targetId)._session.dispatchMessage(JSON.parse(message));
|
|
334
346
|
else
|
|
335
347
|
throw new Error("Unknown target: " + targetId);
|
|
336
348
|
}
|
|
@@ -453,7 +465,7 @@ class WKPage {
|
|
|
453
465
|
}
|
|
454
466
|
async navigateFrame(frame, url, referrer) {
|
|
455
467
|
if (this._pageProxySession.isDisposed())
|
|
456
|
-
throw new import_errors.TargetClosedError();
|
|
468
|
+
throw new import_errors.TargetClosedError(this._page.closeReason());
|
|
457
469
|
const pageProxyId = this._pageProxySession.sessionId;
|
|
458
470
|
const result = await this._pageProxySession.connection.browserSession.send("Playwright.navigate", { url, pageProxyId, frameId: frame._id, referrer });
|
|
459
471
|
return { newDocumentId: result.loaderId };
|
|
@@ -748,7 +760,6 @@ class WKPage {
|
|
|
748
760
|
await this._updateState("Page.setBootstrapScript", { source: this._calculateBootstrapScript() });
|
|
749
761
|
}
|
|
750
762
|
async closePage(runBeforeUnload) {
|
|
751
|
-
await this._stopVideo();
|
|
752
763
|
await this._pageProxySession.sendMayFail("Target.close", {
|
|
753
764
|
targetId: this._session.sessionId,
|
|
754
765
|
runBeforeUnload
|
|
@@ -762,22 +773,11 @@ class WKPage {
|
|
|
762
773
|
return import_hostPlatform.hostPlatform === "mac10.15" ? 55 : 59;
|
|
763
774
|
return 0;
|
|
764
775
|
}
|
|
765
|
-
async
|
|
766
|
-
|
|
767
|
-
const
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
height: options.height,
|
|
771
|
-
toolbarHeight: this._toolbarHeight()
|
|
772
|
-
});
|
|
773
|
-
this._recordingVideoFile = options.outputFile;
|
|
774
|
-
this._browserContext._browser._videoStarted(this._browserContext, screencastId, options.outputFile, this._page.waitForInitializedOrError());
|
|
775
|
-
}
|
|
776
|
-
async _stopVideo() {
|
|
777
|
-
if (!this._recordingVideoFile)
|
|
778
|
-
return;
|
|
779
|
-
await this._pageProxySession.sendMayFail("Screencast.stopVideo");
|
|
780
|
-
this._recordingVideoFile = null;
|
|
776
|
+
async _initializeVideoRecording() {
|
|
777
|
+
const screencast = this._page.screencast;
|
|
778
|
+
const videoOptions = screencast.launchVideoRecorder();
|
|
779
|
+
if (videoOptions)
|
|
780
|
+
await screencast.startVideoRecording(videoOptions);
|
|
781
781
|
}
|
|
782
782
|
validateScreenshotDimension(side, omitDeviceScaleFactor) {
|
|
783
783
|
if (process.platform === "darwin")
|
|
@@ -845,23 +845,27 @@ class WKPage {
|
|
|
845
845
|
throw e;
|
|
846
846
|
});
|
|
847
847
|
}
|
|
848
|
-
async
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
848
|
+
async startScreencast(options) {
|
|
849
|
+
const { generation } = await this._pageProxySession.send("Screencast.startScreencast", {
|
|
850
|
+
quality: options.quality,
|
|
851
|
+
width: options.width,
|
|
852
|
+
height: options.height,
|
|
853
|
+
toolbarHeight: this._toolbarHeight()
|
|
854
|
+
});
|
|
855
|
+
this._screencastGeneration = generation;
|
|
856
|
+
}
|
|
857
|
+
async stopScreencast() {
|
|
858
|
+
await this._pageProxySession.sendMayFail("Screencast.stopScreencast");
|
|
856
859
|
}
|
|
857
860
|
_onScreencastFrame(event) {
|
|
858
861
|
const generation = this._screencastGeneration;
|
|
859
|
-
this._page.
|
|
860
|
-
this._pageProxySession.
|
|
862
|
+
this._page.screencast.throttleFrameAck(() => {
|
|
863
|
+
this._pageProxySession.sendMayFail("Screencast.screencastFrameAck", { generation });
|
|
861
864
|
});
|
|
862
865
|
const buffer = Buffer.from(event.data, "base64");
|
|
863
866
|
this._page.emit(import_page.Page.Events.ScreencastFrame, {
|
|
864
867
|
buffer,
|
|
868
|
+
frameSwapWallTime: event.timestamp ? event.timestamp * 1e3 : Date.now(),
|
|
865
869
|
width: event.deviceWidth,
|
|
866
870
|
height: event.deviceHeight
|
|
867
871
|
});
|
|
@@ -886,7 +890,7 @@ class WKPage {
|
|
|
886
890
|
const pageProxyId = this._pageProxySession.sessionId;
|
|
887
891
|
const objectId = handle._objectId;
|
|
888
892
|
if (this._browserContext._browser?.options.channel === "webkit-wsl")
|
|
889
|
-
paths = await Promise.all(paths.map((
|
|
893
|
+
paths = await Promise.all(paths.map((path) => (0, import_webkit.translatePathToWSL)(path)));
|
|
890
894
|
await Promise.all([
|
|
891
895
|
this._pageProxySession.connection.browserSession.send("Playwright.grantFileReadAccess", { pageProxyId, paths }),
|
|
892
896
|
this._session.send("DOM.setInputFiles", { objectId, paths })
|
|
@@ -1085,6 +1089,31 @@ class WKPage {
|
|
|
1085
1089
|
return true;
|
|
1086
1090
|
}
|
|
1087
1091
|
}
|
|
1092
|
+
class WKFrame {
|
|
1093
|
+
constructor(page, session) {
|
|
1094
|
+
this._sessionListeners = [];
|
|
1095
|
+
this._initializePromise = null;
|
|
1096
|
+
this._page = page;
|
|
1097
|
+
this._session = session;
|
|
1098
|
+
}
|
|
1099
|
+
async initialize() {
|
|
1100
|
+
if (this._initializePromise)
|
|
1101
|
+
return this._initializePromise;
|
|
1102
|
+
this._initializePromise = this._initializeImpl();
|
|
1103
|
+
return this._initializePromise;
|
|
1104
|
+
}
|
|
1105
|
+
async _initializeImpl() {
|
|
1106
|
+
this._sessionListeners = [
|
|
1107
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Console.messageAdded", (event) => this._page._onConsoleMessage(event)),
|
|
1108
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Console.messageRepeatCountUpdated", (event) => this._page._onConsoleRepeatCountUpdated(event))
|
|
1109
|
+
];
|
|
1110
|
+
await this._session.send("Console.enable");
|
|
1111
|
+
}
|
|
1112
|
+
dispose() {
|
|
1113
|
+
import_eventsHelper.eventsHelper.removeEventListeners(this._sessionListeners);
|
|
1114
|
+
this._session.dispose();
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1088
1117
|
function parseRemoteAddress(value) {
|
|
1089
1118
|
if (!value)
|
|
1090
1119
|
return;
|
|
@@ -20,12 +20,26 @@ var ariaSnapshot_exports = {};
|
|
|
20
20
|
__export(ariaSnapshot_exports, {
|
|
21
21
|
KeyParser: () => KeyParser,
|
|
22
22
|
ParserError: () => ParserError,
|
|
23
|
-
|
|
23
|
+
ariaNodesEqual: () => ariaNodesEqual,
|
|
24
|
+
findNewNode: () => findNewNode,
|
|
25
|
+
hasPointerCursor: () => hasPointerCursor,
|
|
24
26
|
parseAriaSnapshot: () => parseAriaSnapshot,
|
|
25
27
|
parseAriaSnapshotUnsafe: () => parseAriaSnapshotUnsafe,
|
|
26
28
|
textValue: () => textValue
|
|
27
29
|
});
|
|
28
30
|
module.exports = __toCommonJS(ariaSnapshot_exports);
|
|
31
|
+
function ariaNodesEqual(a, b) {
|
|
32
|
+
if (a.role !== b.role || a.name !== b.name)
|
|
33
|
+
return false;
|
|
34
|
+
if (!ariaPropsEqual(a, b) || hasPointerCursor(a) !== hasPointerCursor(b))
|
|
35
|
+
return false;
|
|
36
|
+
const aKeys = Object.keys(a.props);
|
|
37
|
+
const bKeys = Object.keys(b.props);
|
|
38
|
+
return aKeys.length === bKeys.length && aKeys.every((k) => a.props[k] === b.props[k]);
|
|
39
|
+
}
|
|
40
|
+
function hasPointerCursor(ariaNode) {
|
|
41
|
+
return ariaNode.box.cursor === "pointer";
|
|
42
|
+
}
|
|
29
43
|
function ariaPropsEqual(a, b) {
|
|
30
44
|
return a.active === b.active && a.checked === b.checked && a.disabled === b.disabled && a.expanded === b.expanded && a.selected === b.selected && a.level === b.level && a.pressed === b.pressed;
|
|
31
45
|
}
|
|
@@ -386,11 +400,55 @@ class ParserError extends Error {
|
|
|
386
400
|
this.pos = pos;
|
|
387
401
|
}
|
|
388
402
|
}
|
|
403
|
+
function findNewNode(from, to) {
|
|
404
|
+
function fillMap(root, map, position) {
|
|
405
|
+
let size = 1;
|
|
406
|
+
let childPosition = position + size;
|
|
407
|
+
for (const child of root.children || []) {
|
|
408
|
+
if (typeof child === "string") {
|
|
409
|
+
size++;
|
|
410
|
+
childPosition++;
|
|
411
|
+
} else {
|
|
412
|
+
size += fillMap(child, map, childPosition);
|
|
413
|
+
childPosition += size;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
if (!["none", "presentation", "fragment", "iframe", "generic"].includes(root.role) && root.name) {
|
|
417
|
+
let byRole = map.get(root.role);
|
|
418
|
+
if (!byRole) {
|
|
419
|
+
byRole = /* @__PURE__ */ new Map();
|
|
420
|
+
map.set(root.role, byRole);
|
|
421
|
+
}
|
|
422
|
+
const existing = byRole.get(root.name);
|
|
423
|
+
const sizeAndPosition = size * 100 - position;
|
|
424
|
+
if (!existing || existing.sizeAndPosition < sizeAndPosition)
|
|
425
|
+
byRole.set(root.name, { node: root, sizeAndPosition });
|
|
426
|
+
}
|
|
427
|
+
return size;
|
|
428
|
+
}
|
|
429
|
+
const fromMap = /* @__PURE__ */ new Map();
|
|
430
|
+
if (from)
|
|
431
|
+
fillMap(from, fromMap, 0);
|
|
432
|
+
const toMap = /* @__PURE__ */ new Map();
|
|
433
|
+
fillMap(to, toMap, 0);
|
|
434
|
+
const result = [];
|
|
435
|
+
for (const [role, byRole] of toMap) {
|
|
436
|
+
for (const [name, byName] of byRole) {
|
|
437
|
+
const inFrom = fromMap.get(role)?.get(name);
|
|
438
|
+
if (!inFrom)
|
|
439
|
+
result.push(byName);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
result.sort((a, b) => b.sizeAndPosition - a.sizeAndPosition);
|
|
443
|
+
return result[0]?.node;
|
|
444
|
+
}
|
|
389
445
|
// Annotate the CommonJS export names for ESM import in node:
|
|
390
446
|
0 && (module.exports = {
|
|
391
447
|
KeyParser,
|
|
392
448
|
ParserError,
|
|
393
|
-
|
|
449
|
+
ariaNodesEqual,
|
|
450
|
+
findNewNode,
|
|
451
|
+
hasPointerCursor,
|
|
394
452
|
parseAriaSnapshot,
|
|
395
453
|
parseAriaSnapshotUnsafe,
|
|
396
454
|
textValue
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var lruCache_exports = {};
|
|
20
|
+
__export(lruCache_exports, {
|
|
21
|
+
LRUCache: () => LRUCache
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(lruCache_exports);
|
|
24
|
+
class LRUCache {
|
|
25
|
+
constructor(maxSize) {
|
|
26
|
+
this._maxSize = maxSize;
|
|
27
|
+
this._map = /* @__PURE__ */ new Map();
|
|
28
|
+
this._size = 0;
|
|
29
|
+
}
|
|
30
|
+
getOrCompute(key, compute) {
|
|
31
|
+
if (this._map.has(key)) {
|
|
32
|
+
const result2 = this._map.get(key);
|
|
33
|
+
this._map.delete(key);
|
|
34
|
+
this._map.set(key, result2);
|
|
35
|
+
return result2.value;
|
|
36
|
+
}
|
|
37
|
+
const result = compute();
|
|
38
|
+
while (this._map.size && this._size + result.size > this._maxSize) {
|
|
39
|
+
const [firstKey, firstValue] = this._map.entries().next().value;
|
|
40
|
+
this._size -= firstValue.size;
|
|
41
|
+
this._map.delete(firstKey);
|
|
42
|
+
}
|
|
43
|
+
this._map.set(key, result);
|
|
44
|
+
this._size += result.size;
|
|
45
|
+
return result.value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
LRUCache
|
|
51
|
+
});
|
|
@@ -71,6 +71,7 @@ const methodMetainfo = /* @__PURE__ */ new Map([
|
|
|
71
71
|
["WebSocket.waitForEventInfo", { title: 'Wait for event "{info.event}"', snapshot: true }],
|
|
72
72
|
["ElectronApplication.waitForEventInfo", { title: 'Wait for event "{info.event}"', snapshot: true }],
|
|
73
73
|
["AndroidDevice.waitForEventInfo", { title: 'Wait for event "{info.event}"', snapshot: true }],
|
|
74
|
+
["PageAgent.waitForEventInfo", { title: 'Wait for event "{info.event}"', snapshot: true }],
|
|
74
75
|
["BrowserContext.addCookies", { title: "Add cookies", group: "configuration" }],
|
|
75
76
|
["BrowserContext.addInitScript", { title: "Add init script", group: "configuration" }],
|
|
76
77
|
["BrowserContext.clearCookies", { title: "Clear cookies", group: "configuration" }],
|
|
@@ -92,6 +93,7 @@ const methodMetainfo = /* @__PURE__ */ new Map([
|
|
|
92
93
|
["BrowserContext.pause", { title: "Pause" }],
|
|
93
94
|
["BrowserContext.enableRecorder", { internal: true }],
|
|
94
95
|
["BrowserContext.disableRecorder", { internal: true }],
|
|
96
|
+
["BrowserContext.exposeConsoleApi", { internal: true }],
|
|
95
97
|
["BrowserContext.newCDPSession", { title: "Create CDP session", group: "configuration" }],
|
|
96
98
|
["BrowserContext.harStart", { internal: true }],
|
|
97
99
|
["BrowserContext.harExport", { internal: true }],
|
|
@@ -143,6 +145,7 @@ const methodMetainfo = /* @__PURE__ */ new Map([
|
|
|
143
145
|
["Page.stopCSSCoverage", { title: "Stop CSS coverage", group: "configuration" }],
|
|
144
146
|
["Page.bringToFront", { title: "Bring to front" }],
|
|
145
147
|
["Page.updateSubscription", { internal: true }],
|
|
148
|
+
["Page.agent", { internal: true }],
|
|
146
149
|
["Frame.evalOnSelector", { title: "Evaluate", snapshot: true, pausesBeforeAction: true }],
|
|
147
150
|
["Frame.evalOnSelectorAll", { title: "Evaluate", snapshot: true, pausesBeforeAction: true }],
|
|
148
151
|
["Frame.addScriptTag", { title: "Add script tag", snapshot: true, pausesBeforeAction: true }],
|
|
@@ -314,7 +317,12 @@ const methodMetainfo = /* @__PURE__ */ new Map([
|
|
|
314
317
|
["AndroidDevice.connectToWebView", { title: "Connect to Web View" }],
|
|
315
318
|
["AndroidDevice.close", { internal: true }],
|
|
316
319
|
["JsonPipe.send", { internal: true }],
|
|
317
|
-
["JsonPipe.close", { internal: true }]
|
|
320
|
+
["JsonPipe.close", { internal: true }],
|
|
321
|
+
["PageAgent.perform", { title: 'Perform "{task}"' }],
|
|
322
|
+
["PageAgent.expect", { title: 'Expect "{expectation}"' }],
|
|
323
|
+
["PageAgent.extract", { title: 'Extract "{query}"' }],
|
|
324
|
+
["PageAgent.dispose", { internal: true }],
|
|
325
|
+
["PageAgent.usage", { title: "Get agent usage", group: "configuration" }]
|
|
318
326
|
]);
|
|
319
327
|
// Annotate the CommonJS export names for ESM import in node:
|
|
320
328
|
0 && (module.exports = {
|
|
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var stringUtils_exports = {};
|
|
20
20
|
__export(stringUtils_exports, {
|
|
21
|
+
ansiRegex: () => ansiRegex,
|
|
21
22
|
cacheNormalizedWhitespaces: () => cacheNormalizedWhitespaces,
|
|
22
23
|
escapeForAttributeSelector: () => escapeForAttributeSelector,
|
|
23
24
|
escapeForTextSelector: () => escapeForTextSelector,
|
|
@@ -26,11 +27,15 @@ __export(stringUtils_exports, {
|
|
|
26
27
|
escapeRegExp: () => escapeRegExp,
|
|
27
28
|
escapeTemplateString: () => escapeTemplateString,
|
|
28
29
|
escapeWithQuotes: () => escapeWithQuotes,
|
|
30
|
+
formatObject: () => formatObject,
|
|
31
|
+
formatObjectOrVoid: () => formatObjectOrVoid,
|
|
29
32
|
isString: () => isString,
|
|
30
33
|
longestCommonSubstring: () => longestCommonSubstring,
|
|
31
34
|
normalizeEscapedRegexQuotes: () => normalizeEscapedRegexQuotes,
|
|
32
35
|
normalizeWhiteSpace: () => normalizeWhiteSpace,
|
|
36
|
+
parseRegex: () => parseRegex,
|
|
33
37
|
quoteCSSAttributeValue: () => quoteCSSAttributeValue,
|
|
38
|
+
stripAnsiEscapes: () => stripAnsiEscapes,
|
|
34
39
|
toSnakeCase: () => toSnakeCase,
|
|
35
40
|
toTitleCase: () => toTitleCase,
|
|
36
41
|
trimString: () => trimString,
|
|
@@ -60,6 +65,31 @@ function toTitleCase(name) {
|
|
|
60
65
|
function toSnakeCase(name) {
|
|
61
66
|
return name.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/([A-Z])([A-Z][a-z])/g, "$1_$2").toLowerCase();
|
|
62
67
|
}
|
|
68
|
+
function formatObject(value, indent = " ", mode = "multiline") {
|
|
69
|
+
if (typeof value === "string")
|
|
70
|
+
return escapeWithQuotes(value, "'");
|
|
71
|
+
if (Array.isArray(value))
|
|
72
|
+
return `[${value.map((o) => formatObject(o)).join(", ")}]`;
|
|
73
|
+
if (typeof value === "object") {
|
|
74
|
+
const keys = Object.keys(value).filter((key) => value[key] !== void 0).sort();
|
|
75
|
+
if (!keys.length)
|
|
76
|
+
return "{}";
|
|
77
|
+
const tokens = [];
|
|
78
|
+
for (const key of keys)
|
|
79
|
+
tokens.push(`${key}: ${formatObject(value[key])}`);
|
|
80
|
+
if (mode === "multiline")
|
|
81
|
+
return `{
|
|
82
|
+
${tokens.join(`,
|
|
83
|
+
${indent}`)}
|
|
84
|
+
}`;
|
|
85
|
+
return `{ ${tokens.join(", ")} }`;
|
|
86
|
+
}
|
|
87
|
+
return String(value);
|
|
88
|
+
}
|
|
89
|
+
function formatObjectOrVoid(value, indent = " ") {
|
|
90
|
+
const result = formatObject(value, indent);
|
|
91
|
+
return result === "{}" ? "" : result;
|
|
92
|
+
}
|
|
63
93
|
function quoteCSSAttributeValue(text) {
|
|
64
94
|
return `"${text.replace(/["\\]/g, (char) => "\\" + char)}"`;
|
|
65
95
|
}
|
|
@@ -133,8 +163,23 @@ function longestCommonSubstring(s1, s2) {
|
|
|
133
163
|
}
|
|
134
164
|
return s1.slice(endingIndex - maxLen, endingIndex);
|
|
135
165
|
}
|
|
166
|
+
function parseRegex(regex) {
|
|
167
|
+
if (regex[0] !== "/")
|
|
168
|
+
throw new Error(`Invalid regex, must start with '/': ${regex}`);
|
|
169
|
+
const lastSlash = regex.lastIndexOf("/");
|
|
170
|
+
if (lastSlash <= 0)
|
|
171
|
+
throw new Error(`Invalid regex, must end with '/' followed by optional flags: ${regex}`);
|
|
172
|
+
const source = regex.slice(1, lastSlash);
|
|
173
|
+
const flags = regex.slice(lastSlash + 1);
|
|
174
|
+
return new RegExp(source, flags);
|
|
175
|
+
}
|
|
176
|
+
const ansiRegex = new RegExp("([\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~])))", "g");
|
|
177
|
+
function stripAnsiEscapes(str) {
|
|
178
|
+
return str.replace(ansiRegex, "");
|
|
179
|
+
}
|
|
136
180
|
// Annotate the CommonJS export names for ESM import in node:
|
|
137
181
|
0 && (module.exports = {
|
|
182
|
+
ansiRegex,
|
|
138
183
|
cacheNormalizedWhitespaces,
|
|
139
184
|
escapeForAttributeSelector,
|
|
140
185
|
escapeForTextSelector,
|
|
@@ -143,11 +188,15 @@ function longestCommonSubstring(s1, s2) {
|
|
|
143
188
|
escapeRegExp,
|
|
144
189
|
escapeTemplateString,
|
|
145
190
|
escapeWithQuotes,
|
|
191
|
+
formatObject,
|
|
192
|
+
formatObjectOrVoid,
|
|
146
193
|
isString,
|
|
147
194
|
longestCommonSubstring,
|
|
148
195
|
normalizeEscapedRegexQuotes,
|
|
149
196
|
normalizeWhiteSpace,
|
|
197
|
+
parseRegex,
|
|
150
198
|
quoteCSSAttributeValue,
|
|
199
|
+
stripAnsiEscapes,
|
|
151
200
|
toSnakeCase,
|
|
152
201
|
toTitleCase,
|
|
153
202
|
trimString,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var entries_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(entries_exports);
|