patchright-core 1.52.4 → 1.55.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/ThirdPartyNotices.txt +65 -123
- package/bin/reinstall_chrome_beta_mac.sh +1 -1
- package/bin/reinstall_chrome_stable_mac.sh +1 -1
- package/bin/reinstall_msedge_beta_mac.sh +1 -1
- package/bin/reinstall_msedge_dev_mac.sh +1 -1
- package/bin/reinstall_msedge_stable_mac.sh +1 -1
- package/browsers.json +14 -14
- package/index.js +1 -1
- package/lib/androidServerImpl.js +4 -2
- package/lib/browserServerImpl.js +47 -12
- package/lib/cli/program.js +116 -50
- package/lib/cli/programWithTestStub.js +1 -1
- package/lib/client/android.js +30 -34
- package/lib/client/browser.js +54 -17
- package/lib/client/browserContext.js +67 -71
- package/lib/client/browserType.js +25 -34
- package/lib/client/channelOwner.js +20 -24
- package/lib/client/connection.js +6 -10
- package/lib/client/electron.js +8 -3
- package/lib/client/elementHandle.js +18 -21
- package/lib/client/fetch.js +5 -3
- package/lib/client/frame.js +57 -35
- package/lib/client/input.js +3 -1
- package/lib/client/jsHandle.js +4 -0
- package/lib/client/localUtils.js +0 -1
- package/lib/client/locator.js +32 -28
- package/lib/client/network.js +5 -12
- package/lib/client/page.js +32 -32
- package/lib/client/playwright.js +6 -16
- package/lib/client/selectors.js +18 -38
- package/lib/client/timeoutSettings.js +12 -8
- package/lib/client/tracing.js +24 -20
- package/lib/client/waiter.js +2 -2
- package/lib/client/webSocket.js +4 -22
- package/lib/generated/bindingsControllerSource.js +28 -0
- package/lib/generated/clockSource.js +1 -1
- package/lib/generated/injectedScriptSource.js +1 -1
- package/lib/generated/pollingRecorderSource.js +1 -1
- package/lib/generated/storageScriptSource.js +28 -0
- package/lib/generated/utilityScriptSource.js +1 -1
- package/lib/generated/webSocketMockSource.js +12 -50
- package/lib/inProcessFactory.js +9 -6
- package/lib/outofprocess.js +0 -2
- package/lib/protocol/validator.js +423 -346
- package/lib/protocol/validatorPrimitives.js +18 -4
- package/lib/remote/playwrightConnection.js +29 -166
- package/lib/remote/playwrightServer.js +233 -35
- package/lib/server/android/android.js +97 -83
- package/lib/server/android/backendAdb.js +0 -2
- package/lib/server/bidi/bidiBrowser.js +139 -73
- package/lib/server/bidi/bidiChromium.js +23 -22
- package/lib/server/bidi/bidiExecutionContext.js +2 -1
- package/lib/server/bidi/bidiFirefox.js +17 -14
- package/lib/server/bidi/bidiInput.js +22 -22
- package/lib/server/bidi/bidiNetworkManager.js +8 -11
- package/lib/server/bidi/bidiPage.js +42 -86
- package/lib/server/bidi/third_party/bidiProtocol.js +5 -133
- package/lib/server/bidi/third_party/bidiProtocolCore.js +179 -0
- package/lib/server/{dispatchers/selectorsDispatcher.js → bidi/third_party/bidiProtocolPermissions.js} +20 -18
- package/lib/server/browser.js +30 -21
- package/lib/server/browserContext.js +203 -165
- package/lib/server/browserType.js +109 -107
- package/lib/server/chromium/chromium.js +84 -69
- package/lib/server/chromium/chromiumSwitches.js +13 -20
- package/lib/server/chromium/crBrowser.js +74 -40
- package/lib/server/chromium/crConnection.js +8 -9
- package/lib/server/chromium/crCoverage.js +11 -8
- package/lib/server/chromium/crDragDrop.js +25 -20
- package/lib/server/chromium/crExecutionContext.js +2 -1
- package/lib/server/chromium/crInput.js +32 -29
- package/lib/server/chromium/crNetworkManager.js +45 -33
- package/lib/server/chromium/crPage.js +98 -73
- package/lib/server/chromium/crServiceWorker.js +13 -18
- package/lib/server/chromium/videoRecorder.js +10 -18
- package/lib/server/clock.js +51 -39
- package/lib/server/codegen/csharp.js +10 -5
- package/lib/server/codegen/java.js +1 -1
- package/lib/server/codegen/javascript.js +1 -1
- package/lib/server/codegen/jsonl.js +2 -1
- package/lib/server/codegen/language.js +22 -1
- package/lib/server/codegen/languages.js +4 -4
- package/lib/server/codegen/python.js +1 -1
- package/lib/server/cookieStore.js +3 -1
- package/lib/server/debugController.js +105 -71
- package/lib/server/debugger.js +6 -23
- package/lib/server/deviceDescriptorsSource.json +237 -127
- package/lib/server/dialog.js +50 -6
- package/lib/server/dispatchers/androidDispatcher.js +77 -62
- package/lib/server/dispatchers/artifactDispatcher.js +18 -18
- package/lib/server/dispatchers/browserContextDispatcher.js +141 -91
- package/lib/server/dispatchers/browserDispatcher.js +55 -88
- package/lib/server/dispatchers/browserTypeDispatcher.js +18 -9
- package/lib/server/dispatchers/cdpSessionDispatcher.js +4 -4
- package/lib/server/dispatchers/debugControllerDispatcher.js +12 -21
- package/lib/server/dispatchers/dialogDispatcher.js +4 -4
- package/lib/server/dispatchers/dispatcher.js +78 -53
- package/lib/server/dispatchers/electronDispatcher.js +19 -20
- package/lib/server/dispatchers/elementHandlerDispatcher.js +83 -93
- package/lib/server/dispatchers/frameDispatcher.js +99 -102
- package/lib/server/dispatchers/jsHandleDispatcher.js +21 -16
- package/lib/server/dispatchers/jsonPipeDispatcher.js +4 -4
- package/lib/server/dispatchers/localUtilsDispatcher.js +53 -59
- package/lib/server/dispatchers/networkDispatchers.js +41 -35
- package/lib/server/dispatchers/pageDispatcher.js +156 -107
- package/lib/server/dispatchers/playwrightDispatcher.js +37 -25
- package/lib/server/dispatchers/streamDispatcher.js +15 -8
- package/lib/server/dispatchers/tracingDispatcher.js +22 -13
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +46 -35
- package/lib/server/dispatchers/writableStreamDispatcher.js +16 -10
- package/lib/server/dom.js +198 -266
- package/lib/server/download.js +3 -3
- package/lib/server/electron/electron.js +96 -103
- package/lib/server/electron/loader.js +1 -1
- package/lib/server/fetch.js +22 -41
- package/lib/server/fileUploadUtils.js +1 -1
- package/lib/server/firefox/ffBrowser.js +79 -55
- package/lib/server/firefox/ffExecutionContext.js +2 -1
- package/lib/server/firefox/ffInput.js +23 -23
- package/lib/server/firefox/ffNetworkManager.js +8 -6
- package/lib/server/firefox/ffPage.js +39 -36
- package/lib/server/firefox/firefox.js +9 -10
- package/lib/server/frameSelectors.js +65 -22
- package/lib/server/frames.js +516 -544
- package/lib/server/har/harRecorder.js +1 -1
- package/lib/server/har/harTracer.js +4 -2
- package/lib/server/helper.js +3 -7
- package/lib/server/index.js +0 -3
- package/lib/server/input.js +47 -54
- package/lib/server/instrumentation.js +8 -14
- package/lib/server/javascript.js +9 -17
- package/lib/server/launchApp.js +48 -30
- package/lib/server/localUtils.js +45 -38
- package/lib/server/network.js +44 -10
- package/lib/server/page.js +233 -178
- package/lib/server/pageBinding.js +6 -7
- package/lib/server/playwright.js +4 -14
- package/lib/server/progress.js +57 -49
- package/lib/server/recorder/recorderApp.js +298 -95
- package/lib/server/recorder/recorderRunner.js +23 -24
- package/lib/server/recorder/recorderSignalProcessor.js +83 -0
- package/lib/server/recorder/recorderUtils.js +67 -10
- package/lib/server/recorder.js +284 -146
- package/lib/server/registry/index.js +83 -48
- package/lib/server/registry/nativeDeps.js +175 -0
- package/lib/server/registry/oopDownloadBrowserMain.js +1 -1
- package/lib/server/screenshotter.js +84 -83
- package/lib/server/selectors.js +12 -12
- package/lib/server/socksClientCertificatesInterceptor.js +198 -136
- package/lib/server/trace/recorder/snapshotter.js +12 -19
- package/lib/server/trace/recorder/tracing.js +36 -27
- package/lib/server/trace/viewer/traceViewer.js +11 -20
- package/lib/server/transport.js +20 -22
- package/lib/server/utils/comparators.js +2 -2
- package/lib/server/utils/debug.js +3 -8
- package/lib/server/utils/debugLogger.js +8 -0
- package/lib/server/utils/hostPlatform.js +3 -1
- package/lib/server/utils/network.js +35 -25
- package/lib/server/utils/nodePlatform.js +1 -1
- package/lib/server/utils/processLauncher.js +4 -1
- package/lib/server/utils/wsServer.js +11 -17
- package/lib/server/webkit/webkit.js +5 -2
- package/lib/server/webkit/wkBrowser.js +51 -28
- package/lib/server/webkit/wkExecutionContext.js +2 -1
- package/lib/server/webkit/wkInput.js +25 -25
- package/lib/server/webkit/wkInterceptableRequest.js +1 -1
- package/lib/server/webkit/wkPage.js +80 -59
- package/lib/server/webkit/wkProvisionalPage.js +1 -1
- package/lib/server/webkit/wkWorkers.js +7 -7
- package/lib/utils/isomorphic/ariaSnapshot.js +13 -7
- package/lib/utils/isomorphic/cssParser.js +1 -2
- package/lib/utils/isomorphic/locatorGenerators.js +18 -0
- package/lib/utils/isomorphic/manualPromise.js +1 -2
- package/lib/utils/isomorphic/mimeType.js +1 -2
- package/lib/utils/isomorphic/multimap.js +1 -2
- package/lib/utils/isomorphic/oldUtilityScriptSerializers.js +248 -0
- package/lib/utils/isomorphic/protocolFormatter.js +78 -0
- package/lib/utils/isomorphic/protocolMetainfo.js +318 -0
- package/lib/utils/isomorphic/selectorParser.js +3 -4
- package/lib/utils/isomorphic/stringUtils.js +3 -24
- package/lib/utils/isomorphic/time.js +9 -4
- package/lib/utils/isomorphic/timeoutRunner.js +3 -4
- package/lib/utils/isomorphic/traceUtils.js +2 -3
- package/lib/utils/isomorphic/urlMatch.js +21 -7
- package/lib/utils/isomorphic/utilityScriptSerializers.js +208 -205
- package/lib/utils.js +8 -2
- package/lib/utilsBundleImpl/index.js +160 -150
- package/lib/vite/htmlReport/index.html +17 -17
- package/lib/vite/recorder/assets/{codeMirrorModule-CXVeovup.js → codeMirrorModule-DzQ0k89p.js} +1 -1
- package/lib/vite/recorder/assets/{index-eHBmevrY.css → index-CI4HQ-Zb.css} +1 -1
- package/lib/vite/recorder/assets/index-D7C7daHH.js +184 -0
- package/lib/vite/recorder/index.html +3 -3
- package/lib/vite/traceViewer/assets/{codeMirrorModule-_GLjJL-7.js → codeMirrorModule-Di48jgWx.js} +1 -1
- package/lib/vite/traceViewer/assets/defaultSettingsView-szBn8781.js +256 -0
- package/lib/vite/traceViewer/defaultSettingsView.DVJHpiGt.css +1 -0
- package/lib/vite/traceViewer/index.BFsek2M6.css +1 -0
- package/lib/vite/traceViewer/index.DQvXoPLL.js +2 -0
- package/lib/vite/traceViewer/index.html +6 -6
- package/lib/vite/traceViewer/sw.bundle.js +3 -3
- package/lib/vite/traceViewer/uiMode.dBV3oN9h.js +5 -0
- package/lib/vite/traceViewer/uiMode.html +4 -4
- package/lib/zipBundleImpl.js +4 -4
- package/package.json +1 -1
- package/types/protocol.d.ts +712 -107
- package/types/types.d.ts +148 -37
- package/lib/generated/consoleApiSource.js +0 -28
- package/lib/protocol/debug.js +0 -211
- package/lib/server/recorder/contextRecorder.js +0 -286
- package/lib/server/recorder/recorderCollection.js +0 -116
- package/lib/server/recorder/recorderFrontend.js +0 -16
- package/lib/server/storageScript.js +0 -154
- package/lib/server/timeoutSettings.js +0 -89
- package/lib/utils/isomorphic/builtins.js +0 -86
- package/lib/vite/recorder/assets/index-BsWQsSGl.js +0 -184
- package/lib/vite/traceViewer/assets/defaultSettingsView-DtCQiGHe.js +0 -265
- package/lib/vite/traceViewer/defaultSettingsView.QdHITyLI.css +0 -1
- package/lib/vite/traceViewer/index.CFOW-Ezb.css +0 -1
- package/lib/vite/traceViewer/index.cFZzK9RN.js +0 -2
- package/lib/vite/traceViewer/uiMode.XVPIqBeS.js +0 -5
|
@@ -46,35 +46,26 @@ class DebugControllerDispatcher extends import_dispatcher.Dispatcher {
|
|
|
46
46
|
})
|
|
47
47
|
];
|
|
48
48
|
}
|
|
49
|
-
async initialize(params) {
|
|
49
|
+
async initialize(params, progress) {
|
|
50
50
|
this._object.initialize(params.codegenId, params.sdkLanguage);
|
|
51
51
|
}
|
|
52
|
-
async setReportStateChanged(params) {
|
|
52
|
+
async setReportStateChanged(params, progress) {
|
|
53
53
|
this._object.setReportStateChanged(params.enabled);
|
|
54
54
|
}
|
|
55
|
-
async
|
|
56
|
-
await this._object.
|
|
55
|
+
async setRecorderMode(params, progress) {
|
|
56
|
+
await this._object.setRecorderMode(progress, params);
|
|
57
57
|
}
|
|
58
|
-
async
|
|
59
|
-
await this._object.
|
|
58
|
+
async highlight(params, progress) {
|
|
59
|
+
await this._object.highlight(progress, params);
|
|
60
60
|
}
|
|
61
|
-
async
|
|
62
|
-
await this._object.
|
|
61
|
+
async hideHighlight(params, progress) {
|
|
62
|
+
await this._object.hideHighlight(progress);
|
|
63
63
|
}
|
|
64
|
-
async
|
|
65
|
-
await this._object.
|
|
64
|
+
async resume(params, progress) {
|
|
65
|
+
await this._object.resume(progress);
|
|
66
66
|
}
|
|
67
|
-
async
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
async resume() {
|
|
71
|
-
await this._object.resume();
|
|
72
|
-
}
|
|
73
|
-
async kill() {
|
|
74
|
-
await this._object.kill();
|
|
75
|
-
}
|
|
76
|
-
async closeAllBrowsers() {
|
|
77
|
-
await this._object.closeAllBrowsers();
|
|
67
|
+
async kill(params, progress) {
|
|
68
|
+
this._object.kill();
|
|
78
69
|
}
|
|
79
70
|
_onDispose() {
|
|
80
71
|
import_utils.eventsHelper.removeEventListeners(this._listeners);
|
|
@@ -34,11 +34,11 @@ class DialogDispatcher extends import_dispatcher.Dispatcher {
|
|
|
34
34
|
});
|
|
35
35
|
this._type_Dialog = true;
|
|
36
36
|
}
|
|
37
|
-
async accept(params) {
|
|
38
|
-
await this._object.accept(params.promptText);
|
|
37
|
+
async accept(params, progress) {
|
|
38
|
+
await progress.race(this._object.accept(params.promptText));
|
|
39
39
|
}
|
|
40
|
-
async dismiss() {
|
|
41
|
-
await this._object.dismiss();
|
|
40
|
+
async dismiss(params, progress) {
|
|
41
|
+
await progress.race(this._object.dismiss());
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -21,8 +21,6 @@ __export(dispatcher_exports, {
|
|
|
21
21
|
Dispatcher: () => Dispatcher,
|
|
22
22
|
DispatcherConnection: () => DispatcherConnection,
|
|
23
23
|
RootDispatcher: () => RootDispatcher,
|
|
24
|
-
dispatcherSymbol: () => dispatcherSymbol,
|
|
25
|
-
existingDispatcher: () => existingDispatcher,
|
|
26
24
|
setMaxDispatchersForTest: () => setMaxDispatchersForTest
|
|
27
25
|
});
|
|
28
26
|
module.exports = __toCommonJS(dispatcher_exports);
|
|
@@ -35,11 +33,9 @@ var import_errors = require("../errors");
|
|
|
35
33
|
var import_instrumentation = require("../instrumentation");
|
|
36
34
|
var import_protocolError = require("../protocolError");
|
|
37
35
|
var import_callLog = require("../callLog");
|
|
38
|
-
|
|
36
|
+
var import_protocolMetainfo = require("../../utils/isomorphic/protocolMetainfo");
|
|
37
|
+
var import_progress = require("../progress");
|
|
39
38
|
const metadataValidator = (0, import_validator.createMetadataValidator)();
|
|
40
|
-
function existingDispatcher(object) {
|
|
41
|
-
return object[dispatcherSymbol];
|
|
42
|
-
}
|
|
43
39
|
let maxDispatchersOverride;
|
|
44
40
|
function setMaxDispatchersForTest(value) {
|
|
45
41
|
maxDispatchersOverride = value;
|
|
@@ -53,27 +49,25 @@ function maxDispatchersForBucket(gcBucket) {
|
|
|
53
49
|
class Dispatcher extends import_events.EventEmitter {
|
|
54
50
|
constructor(parent, object, type, initializer, gcBucket) {
|
|
55
51
|
super();
|
|
56
|
-
// Only "isScope" channel owners have registered dispatchers inside.
|
|
57
52
|
this._dispatchers = /* @__PURE__ */ new Map();
|
|
58
53
|
this._disposed = false;
|
|
59
54
|
this._eventListeners = [];
|
|
60
|
-
this.
|
|
61
|
-
this.
|
|
55
|
+
this._activeProgressControllers = /* @__PURE__ */ new Set();
|
|
56
|
+
this.connection = parent instanceof DispatcherConnection ? parent : parent.connection;
|
|
62
57
|
this._parent = parent instanceof DispatcherConnection ? void 0 : parent;
|
|
63
58
|
const guid = object.guid;
|
|
64
59
|
this._guid = guid;
|
|
65
60
|
this._type = type;
|
|
66
61
|
this._object = object;
|
|
67
62
|
this._gcBucket = gcBucket ?? type;
|
|
68
|
-
|
|
69
|
-
this._connection.registerDispatcher(this);
|
|
63
|
+
this.connection.registerDispatcher(this);
|
|
70
64
|
if (this._parent) {
|
|
71
65
|
(0, import_utils.assert)(!this._parent._dispatchers.has(guid));
|
|
72
66
|
this._parent._dispatchers.set(guid, this);
|
|
73
67
|
}
|
|
74
68
|
if (this._parent)
|
|
75
|
-
this.
|
|
76
|
-
this.
|
|
69
|
+
this.connection.sendCreate(this._parent, type, guid, initializer);
|
|
70
|
+
this.connection.maybeDisposeStaleDispatchers(this._gcBucket);
|
|
77
71
|
}
|
|
78
72
|
parentScope() {
|
|
79
73
|
return this._parent;
|
|
@@ -88,16 +82,19 @@ class Dispatcher extends import_events.EventEmitter {
|
|
|
88
82
|
oldParent._dispatchers.delete(child._guid);
|
|
89
83
|
this._dispatchers.set(child._guid, child);
|
|
90
84
|
child._parent = this;
|
|
91
|
-
this.
|
|
85
|
+
this.connection.sendAdopt(this, child);
|
|
92
86
|
}
|
|
93
|
-
async
|
|
94
|
-
const
|
|
87
|
+
async _runCommand(callMetadata, method, validParams) {
|
|
88
|
+
const controller = new import_progress.ProgressController(callMetadata, (message) => {
|
|
89
|
+
const logName = this._object.logName || "api";
|
|
90
|
+
import_utils.debugLogger.log(logName, message);
|
|
91
|
+
this._object.instrumentation.onCallLog(this._object, callMetadata, logName, message);
|
|
92
|
+
});
|
|
93
|
+
this._activeProgressControllers.add(controller);
|
|
95
94
|
try {
|
|
96
|
-
return await
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return await commandPromise;
|
|
100
|
-
throw e;
|
|
95
|
+
return await controller.run((progress) => this[method](validParams, progress), validParams?.timeout);
|
|
96
|
+
} finally {
|
|
97
|
+
this._activeProgressControllers.delete(controller);
|
|
101
98
|
}
|
|
102
99
|
}
|
|
103
100
|
_dispatchEvent(method, params) {
|
|
@@ -106,28 +103,42 @@ class Dispatcher extends import_events.EventEmitter {
|
|
|
106
103
|
throw new Error(`${this._guid} is sending "${String(method)}" event after being disposed`);
|
|
107
104
|
return;
|
|
108
105
|
}
|
|
109
|
-
this.
|
|
106
|
+
this.connection.sendEvent(this, method, params);
|
|
110
107
|
}
|
|
111
108
|
_dispose(reason) {
|
|
112
109
|
this._disposeRecursively(new import_errors.TargetClosedError());
|
|
113
|
-
this.
|
|
110
|
+
this.connection.sendDispose(this, reason);
|
|
114
111
|
}
|
|
115
112
|
_onDispose() {
|
|
116
113
|
}
|
|
114
|
+
async stopPendingOperations(error) {
|
|
115
|
+
const controllers = [];
|
|
116
|
+
const collect = (dispatcher) => {
|
|
117
|
+
controllers.push(...dispatcher._activeProgressControllers);
|
|
118
|
+
for (const child of [...dispatcher._dispatchers.values()])
|
|
119
|
+
collect(child);
|
|
120
|
+
};
|
|
121
|
+
collect(this);
|
|
122
|
+
await Promise.all(controllers.map((controller) => controller.abort(error)));
|
|
123
|
+
}
|
|
117
124
|
_disposeRecursively(error) {
|
|
118
125
|
(0, import_utils.assert)(!this._disposed, `${this._guid} is disposed more than once`);
|
|
126
|
+
for (const controller of this._activeProgressControllers) {
|
|
127
|
+
if (!controller.metadata.potentiallyClosesScope)
|
|
128
|
+
controller.abort(error).catch(() => {
|
|
129
|
+
});
|
|
130
|
+
}
|
|
119
131
|
this._onDispose();
|
|
120
132
|
this._disposed = true;
|
|
121
133
|
import_eventsHelper.eventsHelper.removeEventListeners(this._eventListeners);
|
|
122
134
|
this._parent?._dispatchers.delete(this._guid);
|
|
123
|
-
const list = this.
|
|
135
|
+
const list = this.connection._dispatchersByBucket.get(this._gcBucket);
|
|
124
136
|
list?.delete(this._guid);
|
|
125
|
-
this.
|
|
137
|
+
this.connection._dispatcherByGuid.delete(this._guid);
|
|
138
|
+
this.connection._dispatcherByObject.delete(this._object);
|
|
126
139
|
for (const dispatcher of [...this._dispatchers.values()])
|
|
127
140
|
dispatcher._disposeRecursively(error);
|
|
128
141
|
this._dispatchers.clear();
|
|
129
|
-
delete this._object[dispatcherSymbol];
|
|
130
|
-
this._openScope.close(error);
|
|
131
142
|
}
|
|
132
143
|
_debugScopeState() {
|
|
133
144
|
return {
|
|
@@ -140,11 +151,11 @@ class Dispatcher extends import_events.EventEmitter {
|
|
|
140
151
|
}
|
|
141
152
|
class RootDispatcher extends Dispatcher {
|
|
142
153
|
constructor(connection, createPlaywright) {
|
|
143
|
-
super(connection,
|
|
154
|
+
super(connection, (0, import_instrumentation.createRootSdkObject)(), "Root", {});
|
|
144
155
|
this.createPlaywright = createPlaywright;
|
|
145
156
|
this._initialized = false;
|
|
146
157
|
}
|
|
147
|
-
async initialize(params) {
|
|
158
|
+
async initialize(params, progress) {
|
|
148
159
|
(0, import_utils.assert)(this.createPlaywright);
|
|
149
160
|
(0, import_utils.assert)(!this._initialized);
|
|
150
161
|
this._initialized = true;
|
|
@@ -155,7 +166,8 @@ class RootDispatcher extends Dispatcher {
|
|
|
155
166
|
}
|
|
156
167
|
class DispatcherConnection {
|
|
157
168
|
constructor(isLocal) {
|
|
158
|
-
this.
|
|
169
|
+
this._dispatcherByGuid = /* @__PURE__ */ new Map();
|
|
170
|
+
this._dispatcherByObject = /* @__PURE__ */ new Map();
|
|
159
171
|
this._dispatchersByBucket = /* @__PURE__ */ new Map();
|
|
160
172
|
this.onmessage = (message) => {
|
|
161
173
|
};
|
|
@@ -195,7 +207,7 @@ class DispatcherConnection {
|
|
|
195
207
|
_tChannelImplFromWire(names, arg, path, context) {
|
|
196
208
|
if (arg && typeof arg === "object" && typeof arg.guid === "string") {
|
|
197
209
|
const guid = arg.guid;
|
|
198
|
-
const dispatcher = this.
|
|
210
|
+
const dispatcher = this._dispatcherByGuid.get(guid);
|
|
199
211
|
if (!dispatcher)
|
|
200
212
|
throw new import_validator.ValidationError(`${path}: no object with guid ${guid}`);
|
|
201
213
|
if (names !== "*" && !names.includes(dispatcher._type))
|
|
@@ -212,9 +224,13 @@ class DispatcherConnection {
|
|
|
212
224
|
}
|
|
213
225
|
throw new import_validator.ValidationError(`${path}: expected dispatcher ${names.toString()}`);
|
|
214
226
|
}
|
|
227
|
+
existingDispatcher(object) {
|
|
228
|
+
return this._dispatcherByObject.get(object);
|
|
229
|
+
}
|
|
215
230
|
registerDispatcher(dispatcher) {
|
|
216
|
-
(0, import_utils.assert)(!this.
|
|
217
|
-
this.
|
|
231
|
+
(0, import_utils.assert)(!this._dispatcherByGuid.has(dispatcher._guid));
|
|
232
|
+
this._dispatcherByGuid.set(dispatcher._guid, dispatcher);
|
|
233
|
+
this._dispatcherByObject.set(dispatcher._object, dispatcher);
|
|
218
234
|
let list = this._dispatchersByBucket.get(dispatcher._gcBucket);
|
|
219
235
|
if (!list) {
|
|
220
236
|
list = /* @__PURE__ */ new Set();
|
|
@@ -231,7 +247,7 @@ class DispatcherConnection {
|
|
|
231
247
|
const disposeCount = maxDispatchers / 10 | 0;
|
|
232
248
|
this._dispatchersByBucket.set(gcBucket, new Set(dispatchersArray.slice(disposeCount)));
|
|
233
249
|
for (let i = 0; i < disposeCount; ++i) {
|
|
234
|
-
const d = this.
|
|
250
|
+
const d = this._dispatcherByGuid.get(dispatchersArray[i]);
|
|
235
251
|
if (!d)
|
|
236
252
|
continue;
|
|
237
253
|
d._dispose("gc");
|
|
@@ -239,7 +255,7 @@ class DispatcherConnection {
|
|
|
239
255
|
}
|
|
240
256
|
async dispatch(message) {
|
|
241
257
|
const { id, guid, method, params, metadata } = message;
|
|
242
|
-
const dispatcher = this.
|
|
258
|
+
const dispatcher = this._dispatcherByGuid.get(guid);
|
|
243
259
|
if (!dispatcher) {
|
|
244
260
|
this.onmessage({ id, error: (0, import_errors.serializeError)(new import_errors.TargetClosedError()) });
|
|
245
261
|
return;
|
|
@@ -257,16 +273,20 @@ class DispatcherConnection {
|
|
|
257
273
|
this.onmessage({ id, error: (0, import_errors.serializeError)(e) });
|
|
258
274
|
return;
|
|
259
275
|
}
|
|
260
|
-
const
|
|
276
|
+
const metainfo = import_protocolMetainfo.methodMetainfo.get(dispatcher._type + "." + method);
|
|
277
|
+
if (metainfo?.internal) {
|
|
278
|
+
validMetadata.internal = true;
|
|
279
|
+
}
|
|
280
|
+
const sdkObject = dispatcher._object;
|
|
261
281
|
const callMetadata = {
|
|
262
282
|
id: `call@${id}`,
|
|
263
283
|
location: validMetadata.location,
|
|
264
|
-
|
|
284
|
+
title: validMetadata.title,
|
|
265
285
|
internal: validMetadata.internal,
|
|
266
286
|
stepId: validMetadata.stepId,
|
|
267
|
-
objectId: sdkObject
|
|
268
|
-
pageId: sdkObject
|
|
269
|
-
frameId: sdkObject
|
|
287
|
+
objectId: sdkObject.guid,
|
|
288
|
+
pageId: sdkObject.attribution?.page?.guid,
|
|
289
|
+
frameId: sdkObject.attribution?.frame?.guid,
|
|
270
290
|
startTime: (0, import_utils.monotonicTime)(),
|
|
271
291
|
endTime: 0,
|
|
272
292
|
type: dispatcher._type,
|
|
@@ -274,7 +294,7 @@ class DispatcherConnection {
|
|
|
274
294
|
params: params || {},
|
|
275
295
|
log: []
|
|
276
296
|
};
|
|
277
|
-
if (
|
|
297
|
+
if (params?.info?.waitId) {
|
|
278
298
|
const info = params.info;
|
|
279
299
|
switch (info.phase) {
|
|
280
300
|
case "before": {
|
|
@@ -301,46 +321,51 @@ class DispatcherConnection {
|
|
|
301
321
|
}
|
|
302
322
|
}
|
|
303
323
|
}
|
|
304
|
-
await sdkObject
|
|
324
|
+
await sdkObject.instrumentation.onBeforeCall(sdkObject, callMetadata);
|
|
305
325
|
const response = { id };
|
|
306
326
|
try {
|
|
307
|
-
|
|
327
|
+
if (this._dispatcherByGuid.get(guid) !== dispatcher)
|
|
328
|
+
throw new import_errors.TargetClosedError(closeReason(sdkObject));
|
|
329
|
+
const result = await dispatcher._runCommand(callMetadata, method, validParams);
|
|
308
330
|
const validator = (0, import_validator.findValidator)(dispatcher._type, method, "Result");
|
|
309
331
|
response.result = validator(result, "", this._validatorToWireContext());
|
|
310
332
|
callMetadata.result = result;
|
|
311
333
|
} catch (e) {
|
|
312
|
-
if ((0, import_errors.isTargetClosedError)(e)
|
|
334
|
+
if ((0, import_errors.isTargetClosedError)(e)) {
|
|
313
335
|
const reason = closeReason(sdkObject);
|
|
314
336
|
if (reason)
|
|
315
337
|
(0, import_utils.rewriteErrorMessage)(e, reason);
|
|
316
338
|
} else if ((0, import_protocolError.isProtocolError)(e)) {
|
|
317
|
-
if (e.type === "closed")
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
} else if (e.type === "crashed") {
|
|
339
|
+
if (e.type === "closed")
|
|
340
|
+
e = new import_errors.TargetClosedError(closeReason(sdkObject), e.browserLogMessage());
|
|
341
|
+
else if (e.type === "crashed")
|
|
321
342
|
(0, import_utils.rewriteErrorMessage)(e, "Target crashed " + e.browserLogMessage());
|
|
322
|
-
}
|
|
323
343
|
}
|
|
324
344
|
response.error = (0, import_errors.serializeError)(e);
|
|
325
345
|
callMetadata.error = response.error;
|
|
326
346
|
} finally {
|
|
327
347
|
callMetadata.endTime = (0, import_utils.monotonicTime)();
|
|
328
|
-
await sdkObject
|
|
348
|
+
await sdkObject.instrumentation.onAfterCall(sdkObject, callMetadata);
|
|
349
|
+
if (metainfo?.slowMo)
|
|
350
|
+
await this._doSlowMo(sdkObject);
|
|
329
351
|
}
|
|
330
352
|
if (response.error)
|
|
331
353
|
response.log = (0, import_callLog.compressCallLog)(callMetadata.log);
|
|
332
354
|
this.onmessage(response);
|
|
333
355
|
}
|
|
356
|
+
async _doSlowMo(sdkObject) {
|
|
357
|
+
const slowMo = sdkObject.attribution.browser?.options.slowMo;
|
|
358
|
+
if (slowMo)
|
|
359
|
+
await new Promise((f) => setTimeout(f, slowMo));
|
|
360
|
+
}
|
|
334
361
|
}
|
|
335
362
|
function closeReason(sdkObject) {
|
|
336
|
-
return sdkObject.attribution.page?.
|
|
363
|
+
return sdkObject.attribution.page?.closeReason || sdkObject.attribution.context?._closeReason || sdkObject.attribution.browser?._closeReason;
|
|
337
364
|
}
|
|
338
365
|
// Annotate the CommonJS export names for ESM import in node:
|
|
339
366
|
0 && (module.exports = {
|
|
340
367
|
Dispatcher,
|
|
341
368
|
DispatcherConnection,
|
|
342
369
|
RootDispatcher,
|
|
343
|
-
dispatcherSymbol,
|
|
344
|
-
existingDispatcher,
|
|
345
370
|
setMaxDispatchersForTest
|
|
346
371
|
});
|
|
@@ -24,23 +24,25 @@ __export(electronDispatcher_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(electronDispatcher_exports);
|
|
25
25
|
var import_browserContextDispatcher = require("./browserContextDispatcher");
|
|
26
26
|
var import_dispatcher = require("./dispatcher");
|
|
27
|
-
var import_elementHandlerDispatcher = require("./elementHandlerDispatcher");
|
|
28
27
|
var import_jsHandleDispatcher = require("./jsHandleDispatcher");
|
|
29
28
|
var import_electron = require("../electron/electron");
|
|
30
29
|
class ElectronDispatcher extends import_dispatcher.Dispatcher {
|
|
31
|
-
constructor(scope, electron) {
|
|
30
|
+
constructor(scope, electron, denyLaunch) {
|
|
32
31
|
super(scope, electron, "Electron", {});
|
|
33
32
|
this._type_Electron = true;
|
|
33
|
+
this._denyLaunch = denyLaunch;
|
|
34
34
|
}
|
|
35
|
-
async launch(params) {
|
|
36
|
-
|
|
35
|
+
async launch(params, progress) {
|
|
36
|
+
if (this._denyLaunch)
|
|
37
|
+
throw new Error(`Launching more browsers is not allowed.`);
|
|
38
|
+
const electronApplication = await this._object.launch(progress, params);
|
|
37
39
|
return { electronApplication: new ElectronApplicationDispatcher(this, electronApplication) };
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
class ElectronApplicationDispatcher extends import_dispatcher.Dispatcher {
|
|
41
43
|
constructor(scope, electronApplication) {
|
|
42
44
|
super(scope, electronApplication, "ElectronApplication", {
|
|
43
|
-
context:
|
|
45
|
+
context: import_browserContextDispatcher.BrowserContextDispatcher.from(scope, electronApplication.context())
|
|
44
46
|
});
|
|
45
47
|
this._type_EventTarget = true;
|
|
46
48
|
this._type_ElectronApplication = true;
|
|
@@ -55,33 +57,30 @@ class ElectronApplicationDispatcher extends import_dispatcher.Dispatcher {
|
|
|
55
57
|
this._dispatchEvent("console", {
|
|
56
58
|
type: message.type(),
|
|
57
59
|
text: message.text(),
|
|
58
|
-
args: message.args().map((a) =>
|
|
60
|
+
args: message.args().map((a) => import_jsHandleDispatcher.JSHandleDispatcher.fromJSHandle(this, a)),
|
|
59
61
|
location: message.location()
|
|
60
62
|
});
|
|
61
63
|
});
|
|
62
64
|
}
|
|
63
|
-
async browserWindow(params) {
|
|
64
|
-
const handle = await this._object.browserWindow(params.page.page());
|
|
65
|
-
return { handle:
|
|
65
|
+
async browserWindow(params, progress) {
|
|
66
|
+
const handle = await progress.race(this._object.browserWindow(params.page.page()));
|
|
67
|
+
return { handle: import_jsHandleDispatcher.JSHandleDispatcher.fromJSHandle(this, handle) };
|
|
66
68
|
}
|
|
67
|
-
async evaluateExpression(params) {
|
|
68
|
-
const handle = await this._object._nodeElectronHandlePromise;
|
|
69
|
-
return { value: (0, import_jsHandleDispatcher.serializeResult)(await handle.evaluateExpression(params.expression, { isFunction: params.isFunction }, (0, import_jsHandleDispatcher.parseArgument)(params.arg))) };
|
|
69
|
+
async evaluateExpression(params, progress) {
|
|
70
|
+
const handle = await progress.race(this._object._nodeElectronHandlePromise);
|
|
71
|
+
return { value: (0, import_jsHandleDispatcher.serializeResult)(await progress.race(handle.evaluateExpression(params.expression, { isFunction: params.isFunction }, (0, import_jsHandleDispatcher.parseArgument)(params.arg)))) };
|
|
70
72
|
}
|
|
71
|
-
async evaluateExpressionHandle(params) {
|
|
72
|
-
const handle = await this._object._nodeElectronHandlePromise;
|
|
73
|
-
const result = await handle.evaluateExpressionHandle(params.expression, { isFunction: params.isFunction }, (0, import_jsHandleDispatcher.parseArgument)(params.arg));
|
|
74
|
-
return { handle:
|
|
73
|
+
async evaluateExpressionHandle(params, progress) {
|
|
74
|
+
const handle = await progress.race(this._object._nodeElectronHandlePromise);
|
|
75
|
+
const result = await progress.race(handle.evaluateExpressionHandle(params.expression, { isFunction: params.isFunction }, (0, import_jsHandleDispatcher.parseArgument)(params.arg)));
|
|
76
|
+
return { handle: import_jsHandleDispatcher.JSHandleDispatcher.fromJSHandle(this, result) };
|
|
75
77
|
}
|
|
76
|
-
async updateSubscription(params) {
|
|
78
|
+
async updateSubscription(params, progress) {
|
|
77
79
|
if (params.enabled)
|
|
78
80
|
this._subscriptions.add(params.event);
|
|
79
81
|
else
|
|
80
82
|
this._subscriptions.delete(params.event);
|
|
81
83
|
}
|
|
82
|
-
async close() {
|
|
83
|
-
await this._object.close();
|
|
84
|
-
}
|
|
85
84
|
}
|
|
86
85
|
// Annotate the CommonJS export names for ESM import in node:
|
|
87
86
|
0 && (module.exports = {
|