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
package/lib/server/download.js
CHANGED
|
@@ -37,14 +37,14 @@ var import_utils = require("../utils");
|
|
|
37
37
|
var import_artifact = require("./artifact");
|
|
38
38
|
class Download {
|
|
39
39
|
constructor(page, downloadsPath, uuid, url, suggestedFilename) {
|
|
40
|
-
const unaccessibleErrorMessage = page.
|
|
40
|
+
const unaccessibleErrorMessage = page.browserContext._options.acceptDownloads === "deny" ? "Pass { acceptDownloads: true } when you are creating your browser context." : void 0;
|
|
41
41
|
this.artifact = new import_artifact.Artifact(page, import_path.default.join(downloadsPath, uuid), unaccessibleErrorMessage, () => {
|
|
42
|
-
return this._page.
|
|
42
|
+
return this._page.browserContext.cancelDownload(uuid);
|
|
43
43
|
});
|
|
44
44
|
this._page = page;
|
|
45
45
|
this.url = url;
|
|
46
46
|
this._suggestedFilename = suggestedFilename;
|
|
47
|
-
page.
|
|
47
|
+
page.browserContext._downloads.add(this);
|
|
48
48
|
if (suggestedFilename !== void 0)
|
|
49
49
|
this._fireDownloadEvent();
|
|
50
50
|
}
|
|
@@ -36,7 +36,6 @@ var import_fs = __toESM(require("fs"));
|
|
|
36
36
|
var import_os = __toESM(require("os"));
|
|
37
37
|
var import_path = __toESM(require("path"));
|
|
38
38
|
var readline = __toESM(require("readline"));
|
|
39
|
-
var import_timeoutSettings = require("../timeoutSettings");
|
|
40
39
|
var import_utils = require("../../utils");
|
|
41
40
|
var import_ascii = require("../utils/ascii");
|
|
42
41
|
var import_debugLogger = require("../utils/debugLogger");
|
|
@@ -51,14 +50,12 @@ var import_helper = require("../helper");
|
|
|
51
50
|
var import_instrumentation = require("../instrumentation");
|
|
52
51
|
var js = __toESM(require("../javascript"));
|
|
53
52
|
var import_processLauncher = require("../utils/processLauncher");
|
|
54
|
-
var import_progress = require("../progress");
|
|
55
53
|
var import_transport = require("../transport");
|
|
56
54
|
const ARTIFACTS_FOLDER = import_path.default.join(import_os.default.tmpdir(), "playwright-artifacts-");
|
|
57
55
|
class ElectronApplication extends import_instrumentation.SdkObject {
|
|
58
56
|
constructor(parent, browser, nodeConnection, process2) {
|
|
59
57
|
super(parent, "electron-app");
|
|
60
58
|
this._nodeElectronHandlePromise = new import_utils.ManualPromise();
|
|
61
|
-
this._timeoutSettings = new import_timeoutSettings.TimeoutSettings();
|
|
62
59
|
this._process = process2;
|
|
63
60
|
this._browserContext = browser._defaultContext;
|
|
64
61
|
this._nodeConnection = nodeConnection;
|
|
@@ -117,7 +114,7 @@ class ElectronApplication extends import_instrumentation.SdkObject {
|
|
|
117
114
|
await this._browserContext.close({ reason: "Application exited" });
|
|
118
115
|
}
|
|
119
116
|
async browserWindow(page) {
|
|
120
|
-
const targetId = page.
|
|
117
|
+
const targetId = page.delegate._targetId;
|
|
121
118
|
const electronHandle = await this._nodeElectronHandlePromise;
|
|
122
119
|
return await electronHandle.evaluateHandle(({ BrowserWindow, webContents }, targetId2) => {
|
|
123
120
|
const wc = webContents.fromDevToolsTargetId(targetId2);
|
|
@@ -128,84 +125,79 @@ class ElectronApplication extends import_instrumentation.SdkObject {
|
|
|
128
125
|
class Electron extends import_instrumentation.SdkObject {
|
|
129
126
|
constructor(playwright) {
|
|
130
127
|
super(playwright, "electron");
|
|
128
|
+
this.logName = "browser";
|
|
131
129
|
}
|
|
132
|
-
async launch(options) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
} catch (error) {
|
|
156
|
-
if (error?.code === "MODULE_NOT_FOUND") {
|
|
157
|
-
throw new Error("\n" + (0, import_ascii.wrapInASCIIBox)([
|
|
158
|
-
"Electron executablePath not found!",
|
|
159
|
-
"Please install it using `npm install -D electron` or set the executablePath to your Electron executable."
|
|
160
|
-
].join("\n"), 1));
|
|
161
|
-
}
|
|
162
|
-
throw error;
|
|
130
|
+
async launch(progress, options) {
|
|
131
|
+
let app = void 0;
|
|
132
|
+
let electronArguments = ["--inspect=0", "--remote-debugging-port=0", ...options.args || []];
|
|
133
|
+
if (import_os.default.platform() === "linux") {
|
|
134
|
+
const runningAsRoot = process.geteuid && process.geteuid() === 0;
|
|
135
|
+
if (runningAsRoot && electronArguments.indexOf("--no-sandbox") === -1)
|
|
136
|
+
electronArguments.unshift("--no-sandbox");
|
|
137
|
+
}
|
|
138
|
+
const artifactsDir = await progress.race(import_fs.default.promises.mkdtemp(ARTIFACTS_FOLDER));
|
|
139
|
+
const browserLogsCollector = new import_debugLogger.RecentLogsCollector();
|
|
140
|
+
const env = options.env ? (0, import_processLauncher.envArrayToObject)(options.env) : process.env;
|
|
141
|
+
let command;
|
|
142
|
+
if (options.executablePath) {
|
|
143
|
+
command = options.executablePath;
|
|
144
|
+
} else {
|
|
145
|
+
try {
|
|
146
|
+
command = require("electron/index.js");
|
|
147
|
+
} catch (error) {
|
|
148
|
+
if (error?.code === "MODULE_NOT_FOUND") {
|
|
149
|
+
throw new Error("\n" + (0, import_ascii.wrapInASCIIBox)([
|
|
150
|
+
"Electron executablePath not found!",
|
|
151
|
+
"Please install it using `npm install -D electron` or set the executablePath to your Electron executable."
|
|
152
|
+
].join("\n"), 1));
|
|
163
153
|
}
|
|
164
|
-
|
|
154
|
+
throw error;
|
|
165
155
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
156
|
+
electronArguments.unshift("-r", require.resolve("./loader"));
|
|
157
|
+
}
|
|
158
|
+
let shell = false;
|
|
159
|
+
if (process.platform === "win32") {
|
|
160
|
+
shell = true;
|
|
161
|
+
command = `"${command}"`;
|
|
162
|
+
electronArguments = electronArguments.map((arg) => `"${arg}"`);
|
|
163
|
+
}
|
|
164
|
+
delete env.NODE_OPTIONS;
|
|
165
|
+
const { launchedProcess, gracefullyClose, kill } = await (0, import_processLauncher.launchProcess)({
|
|
166
|
+
command,
|
|
167
|
+
args: electronArguments,
|
|
168
|
+
env,
|
|
169
|
+
log: (message) => {
|
|
170
|
+
progress.log(message);
|
|
171
|
+
browserLogsCollector.log(message);
|
|
172
|
+
},
|
|
173
|
+
shell,
|
|
174
|
+
stdio: "pipe",
|
|
175
|
+
cwd: options.cwd,
|
|
176
|
+
tempDirectories: [artifactsDir],
|
|
177
|
+
attemptToGracefullyClose: () => app.close(),
|
|
178
|
+
handleSIGINT: true,
|
|
179
|
+
handleSIGTERM: true,
|
|
180
|
+
handleSIGHUP: true,
|
|
181
|
+
onExit: () => app?.emit(ElectronApplication.Events.Close)
|
|
182
|
+
});
|
|
183
|
+
const waitForXserverError = waitForLine(progress, launchedProcess, /Unable to open X display/).then(() => {
|
|
184
|
+
throw new Error([
|
|
185
|
+
"Unable to open X display!",
|
|
186
|
+
`================================`,
|
|
187
|
+
"Most likely this is because there is no X server available.",
|
|
188
|
+
"Use 'xvfb-run' on Linux to launch your tests with an emulated display server.",
|
|
189
|
+
"For example: 'xvfb-run npm run test:e2e'",
|
|
190
|
+
`================================`,
|
|
191
|
+
progress.metadata.log
|
|
192
|
+
].join("\n"));
|
|
193
|
+
});
|
|
194
|
+
const nodeMatchPromise = waitForLine(progress, launchedProcess, /^Debugger listening on (ws:\/\/.*)$/);
|
|
195
|
+
const chromeMatchPromise = waitForLine(progress, launchedProcess, /^DevTools listening on (ws:\/\/.*)$/);
|
|
196
|
+
const debuggerDisconnectPromise = waitForLine(progress, launchedProcess, /Waiting for the debugger to disconnect\.\.\./);
|
|
197
|
+
try {
|
|
206
198
|
const nodeMatch = await nodeMatchPromise;
|
|
207
199
|
const nodeTransport = await import_transport.WebSocketTransport.connect(progress, nodeMatch[1]);
|
|
208
|
-
const nodeConnection = new import_crConnection.CRConnection(nodeTransport, import_helper.helper.debugProtocolLogger(), browserLogsCollector);
|
|
200
|
+
const nodeConnection = new import_crConnection.CRConnection(this, nodeTransport, import_helper.helper.debugProtocolLogger(), browserLogsCollector);
|
|
209
201
|
debuggerDisconnectPromise.then(() => {
|
|
210
202
|
nodeTransport.close();
|
|
211
203
|
}).catch(() => {
|
|
@@ -239,36 +231,37 @@ class Electron extends import_instrumentation.SdkObject {
|
|
|
239
231
|
originalLaunchOptions: {}
|
|
240
232
|
};
|
|
241
233
|
(0, import_browserContext.validateBrowserContextOptions)(contextOptions, browserOptions);
|
|
242
|
-
const browser = await import_crBrowser.CRBrowser.connect(this.attribution.playwright, chromeTransport, browserOptions);
|
|
234
|
+
const browser = await progress.race(import_crBrowser.CRBrowser.connect(this.attribution.playwright, chromeTransport, browserOptions));
|
|
243
235
|
app = new ElectronApplication(this, browser, nodeConnection, launchedProcess);
|
|
244
|
-
await app.initialize();
|
|
236
|
+
await progress.race(app.initialize());
|
|
245
237
|
return app;
|
|
246
|
-
}
|
|
238
|
+
} catch (error) {
|
|
239
|
+
await kill();
|
|
240
|
+
throw error;
|
|
241
|
+
}
|
|
247
242
|
}
|
|
248
243
|
}
|
|
249
|
-
function waitForLine(progress, process2, regex) {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
});
|
|
244
|
+
async function waitForLine(progress, process2, regex) {
|
|
245
|
+
const promise = new import_utils.ManualPromise();
|
|
246
|
+
const rl = readline.createInterface({ input: process2.stderr });
|
|
247
|
+
const failError = new Error("Process failed to launch!");
|
|
248
|
+
const listeners = [
|
|
249
|
+
import_eventsHelper.eventsHelper.addEventListener(rl, "line", onLine),
|
|
250
|
+
import_eventsHelper.eventsHelper.addEventListener(rl, "close", () => promise.reject(failError)),
|
|
251
|
+
import_eventsHelper.eventsHelper.addEventListener(process2, "exit", () => promise.reject(failError)),
|
|
252
|
+
// It is Ok to remove error handler because we did not create process and there is another listener.
|
|
253
|
+
import_eventsHelper.eventsHelper.addEventListener(process2, "error", () => promise.reject(failError))
|
|
254
|
+
];
|
|
255
|
+
function onLine(line) {
|
|
256
|
+
const match = line.match(regex);
|
|
257
|
+
if (match)
|
|
258
|
+
promise.resolve(match);
|
|
259
|
+
}
|
|
260
|
+
try {
|
|
261
|
+
return await progress.race(promise);
|
|
262
|
+
} finally {
|
|
263
|
+
import_eventsHelper.eventsHelper.removeEventListeners(listeners);
|
|
264
|
+
}
|
|
272
265
|
}
|
|
273
266
|
// Annotate the CommonJS export names for ESM import in node:
|
|
274
267
|
0 && (module.exports = {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const { app } = require("electron");
|
|
3
3
|
const { chromiumSwitches } = require("../chromium/chromiumSwitches");
|
|
4
4
|
process.argv.splice(1, process.argv.indexOf("--remote-debugging-port=0"));
|
|
5
|
-
for (const arg of chromiumSwitches) {
|
|
5
|
+
for (const arg of chromiumSwitches()) {
|
|
6
6
|
const match = arg.match(/--([^=]*)=?(.*)/);
|
|
7
7
|
app.commandLine.appendSwitch(match[1], match[2]);
|
|
8
8
|
}
|
package/lib/server/fetch.js
CHANGED
|
@@ -38,7 +38,6 @@ var import_https = __toESM(require("https"));
|
|
|
38
38
|
var import_stream = require("stream");
|
|
39
39
|
var import_tls = require("tls");
|
|
40
40
|
var zlib = __toESM(require("zlib"));
|
|
41
|
-
var import_timeoutSettings = require("./timeoutSettings");
|
|
42
41
|
var import_utils = require("../utils");
|
|
43
42
|
var import_crypto = require("./utils/crypto");
|
|
44
43
|
var import_userAgent = require("./utils/userAgent");
|
|
@@ -55,7 +54,6 @@ class APIRequestContext extends import_instrumentation.SdkObject {
|
|
|
55
54
|
super(parent, "request-context");
|
|
56
55
|
this.fetchResponses = /* @__PURE__ */ new Map();
|
|
57
56
|
this.fetchLog = /* @__PURE__ */ new Map();
|
|
58
|
-
this._activeProgressControllers = /* @__PURE__ */ new Set();
|
|
59
57
|
APIRequestContext.allInstances.add(this);
|
|
60
58
|
}
|
|
61
59
|
static {
|
|
@@ -91,7 +89,7 @@ class APIRequestContext extends import_instrumentation.SdkObject {
|
|
|
91
89
|
this.fetchResponses.set(uid, body);
|
|
92
90
|
return uid;
|
|
93
91
|
}
|
|
94
|
-
async fetch(
|
|
92
|
+
async fetch(progress, params) {
|
|
95
93
|
const defaults = this._defaultOptions();
|
|
96
94
|
const headers = {
|
|
97
95
|
"user-agent": defaults.userAgent,
|
|
@@ -123,15 +121,11 @@ class APIRequestContext extends import_instrumentation.SdkObject {
|
|
|
123
121
|
agent = (0, import_utils.createProxyAgent)(proxy, requestUrl);
|
|
124
122
|
let maxRedirects = params.maxRedirects ?? (defaults.maxRedirects ?? 20);
|
|
125
123
|
maxRedirects = maxRedirects === 0 ? -1 : maxRedirects;
|
|
126
|
-
const timeout = defaults.timeoutSettings.timeout(params);
|
|
127
|
-
const deadline = timeout && (0, import_utils.monotonicTime)() + timeout;
|
|
128
124
|
const options = {
|
|
129
125
|
method,
|
|
130
126
|
headers,
|
|
131
127
|
agent,
|
|
132
128
|
maxRedirects,
|
|
133
|
-
timeout,
|
|
134
|
-
deadline,
|
|
135
129
|
...(0, import_socksClientCertificatesInterceptor.getMatchingTLSOptionsForOrigin)(this._defaultOptions().clientCertificates, requestUrl.origin),
|
|
136
130
|
__testHookLookup: params.__testHookLookup
|
|
137
131
|
};
|
|
@@ -140,12 +134,9 @@ class APIRequestContext extends import_instrumentation.SdkObject {
|
|
|
140
134
|
const postData = serializePostData(params, headers);
|
|
141
135
|
if (postData)
|
|
142
136
|
setHeader(headers, "content-length", String(postData.byteLength));
|
|
143
|
-
const
|
|
144
|
-
const fetchResponse = await controller.run((progress) => {
|
|
145
|
-
return this._sendRequestWithRetries(progress, requestUrl, options, postData, params.maxRetries);
|
|
146
|
-
});
|
|
137
|
+
const fetchResponse = await this._sendRequestWithRetries(progress, requestUrl, options, postData, params.maxRetries);
|
|
147
138
|
const fetchUid = this._storeResponseBody(fetchResponse.body);
|
|
148
|
-
this.fetchLog.set(fetchUid,
|
|
139
|
+
this.fetchLog.set(fetchUid, progress.metadata.log);
|
|
149
140
|
const failOnStatusCode = params.failOnStatusCode !== void 0 ? params.failOnStatusCode : !!defaults.failOnStatusCode;
|
|
150
141
|
if (failOnStatusCode && (fetchResponse.status < 200 || fetchResponse.status >= 400)) {
|
|
151
142
|
let responseText = "";
|
|
@@ -183,10 +174,11 @@ ${text}`;
|
|
|
183
174
|
}
|
|
184
175
|
return cookies;
|
|
185
176
|
}
|
|
186
|
-
async _updateRequestCookieHeader(url, headers) {
|
|
177
|
+
async _updateRequestCookieHeader(progress, url, headers) {
|
|
187
178
|
if (getHeader(headers, "cookie") !== void 0)
|
|
188
179
|
return;
|
|
189
|
-
const
|
|
180
|
+
const contextCookies = await progress.race(this._cookies(url));
|
|
181
|
+
const cookies = contextCookies.filter((c) => new import_cookieStore.Cookie(c).matches(url));
|
|
190
182
|
if (cookies.length) {
|
|
191
183
|
const valueArray = cookies.map((c) => `${c.name}=${c.value}`);
|
|
192
184
|
setHeader(headers, "cookie", valueArray.join("; "));
|
|
@@ -199,22 +191,24 @@ ${text}`;
|
|
|
199
191
|
try {
|
|
200
192
|
return await this._sendRequest(progress, url, options, postData);
|
|
201
193
|
} catch (e) {
|
|
194
|
+
if ((0, import_progress.isAbortError)(e))
|
|
195
|
+
throw e;
|
|
202
196
|
e = (0, import_socksClientCertificatesInterceptor.rewriteOpenSSLErrorIfNeeded)(e);
|
|
203
197
|
if (maxRetries === 0)
|
|
204
198
|
throw e;
|
|
205
|
-
if (i === maxRetries
|
|
199
|
+
if (i === maxRetries)
|
|
206
200
|
throw new Error(`Failed after ${i + 1} attempt(s): ${e}`);
|
|
207
201
|
if (e.code !== "ECONNRESET")
|
|
208
202
|
throw e;
|
|
209
203
|
progress.log(` Received ECONNRESET, will retry after ${backoff}ms.`);
|
|
210
|
-
await
|
|
204
|
+
await progress.wait(backoff);
|
|
211
205
|
backoff *= 2;
|
|
212
206
|
}
|
|
213
207
|
}
|
|
214
208
|
throw new Error("Unreachable");
|
|
215
209
|
}
|
|
216
210
|
async _sendRequest(progress, url, options, postData) {
|
|
217
|
-
await this._updateRequestCookieHeader(url, options.headers);
|
|
211
|
+
await this._updateRequestCookieHeader(progress, url, options.headers);
|
|
218
212
|
const requestCookies = getHeader(options.headers, "cookie")?.split(";").map((p) => {
|
|
219
213
|
const [name, value] = p.split("=").map((v) => v.trim());
|
|
220
214
|
return { name, value };
|
|
@@ -227,7 +221,8 @@ ${text}`;
|
|
|
227
221
|
postData
|
|
228
222
|
};
|
|
229
223
|
this.emit(APIRequestContext.Events.Request, requestEvent);
|
|
230
|
-
|
|
224
|
+
let destroyRequest;
|
|
225
|
+
const resultPromise = new Promise((fulfill, reject) => {
|
|
231
226
|
const requestConstructor = (url.protocol === "https:" ? import_https.default : import_http.default).request;
|
|
232
227
|
const agent = options.agent || (url.protocol === "https:" ? import_happyEyeballs.httpsHappyEyeballsAgent : import_happyEyeballs.httpHappyEyeballsAgent);
|
|
233
228
|
const requestOptions = { ...options, agent };
|
|
@@ -308,8 +303,6 @@ ${text}`;
|
|
|
308
303
|
headers,
|
|
309
304
|
agent: options.agent,
|
|
310
305
|
maxRedirects: options.maxRedirects - 1,
|
|
311
|
-
timeout: options.timeout,
|
|
312
|
-
deadline: options.deadline,
|
|
313
306
|
...(0, import_socksClientCertificatesInterceptor.getMatchingTLSOptionsForOrigin)(this._defaultOptions().clientCertificates, url.origin),
|
|
314
307
|
__testHookLookup: options.__testHookLookup
|
|
315
308
|
};
|
|
@@ -387,6 +380,7 @@ ${text}`;
|
|
|
387
380
|
body.on("end", notifyBodyFinished);
|
|
388
381
|
});
|
|
389
382
|
request.on("error", reject);
|
|
383
|
+
destroyRequest = () => request.destroy();
|
|
390
384
|
listeners.push(
|
|
391
385
|
import_utils.eventsHelper.addEventListener(this, APIRequestContext.Events.Dispose, () => {
|
|
392
386
|
reject(new Error("Request context disposed."));
|
|
@@ -434,22 +428,14 @@ ${text}`;
|
|
|
434
428
|
for (const [name, value] of Object.entries(options.headers))
|
|
435
429
|
progress.log(` ${name}: ${value}`);
|
|
436
430
|
}
|
|
437
|
-
if (options.deadline) {
|
|
438
|
-
const rejectOnTimeout = () => {
|
|
439
|
-
reject(new Error(`Request timed out after ${options.timeout}ms`));
|
|
440
|
-
request.destroy();
|
|
441
|
-
};
|
|
442
|
-
const remaining = options.deadline - (0, import_utils.monotonicTime)();
|
|
443
|
-
if (remaining <= 0) {
|
|
444
|
-
rejectOnTimeout();
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
request.setTimeout(remaining, rejectOnTimeout);
|
|
448
|
-
}
|
|
449
431
|
if (postData)
|
|
450
432
|
request.write(postData);
|
|
451
433
|
request.end();
|
|
452
434
|
});
|
|
435
|
+
return progress.race(resultPromise).catch((error) => {
|
|
436
|
+
destroyRequest?.();
|
|
437
|
+
throw error;
|
|
438
|
+
});
|
|
453
439
|
}
|
|
454
440
|
_getHttpCredentials(url) {
|
|
455
441
|
if (!this._defaultOptions().httpCredentials?.origin || url.origin.toLowerCase() === this._defaultOptions().httpCredentials?.origin?.toLowerCase())
|
|
@@ -494,7 +480,6 @@ class BrowserContextAPIRequestContext extends APIRequestContext {
|
|
|
494
480
|
failOnStatusCode: void 0,
|
|
495
481
|
httpCredentials: this._context._options.httpCredentials,
|
|
496
482
|
proxy: this._context._options.proxy || this._context._browser.options.proxy,
|
|
497
|
-
timeoutSettings: this._context._timeoutSettings,
|
|
498
483
|
ignoreHTTPSErrors: this._context._options.ignoreHTTPSErrors,
|
|
499
484
|
baseURL: this._context._options.baseURL,
|
|
500
485
|
clientCertificates: this._context._options.clientCertificates
|
|
@@ -506,8 +491,8 @@ class BrowserContextAPIRequestContext extends APIRequestContext {
|
|
|
506
491
|
async _cookies(url) {
|
|
507
492
|
return await this._context.cookies(url.toString());
|
|
508
493
|
}
|
|
509
|
-
async storageState(indexedDB) {
|
|
510
|
-
return this._context.storageState(indexedDB);
|
|
494
|
+
async storageState(progress, indexedDB) {
|
|
495
|
+
return this._context.storageState(progress, indexedDB);
|
|
511
496
|
}
|
|
512
497
|
}
|
|
513
498
|
class GlobalAPIRequestContext extends APIRequestContext {
|
|
@@ -515,9 +500,6 @@ class GlobalAPIRequestContext extends APIRequestContext {
|
|
|
515
500
|
super(playwright);
|
|
516
501
|
this._cookieStore = new import_cookieStore.CookieStore();
|
|
517
502
|
this.attribution.context = this;
|
|
518
|
-
const timeoutSettings = new import_timeoutSettings.TimeoutSettings();
|
|
519
|
-
if (options.timeout !== void 0)
|
|
520
|
-
timeoutSettings.setDefaultTimeout(options.timeout);
|
|
521
503
|
if (options.storageState) {
|
|
522
504
|
this._origins = options.storageState.origins?.map((origin) => ({ indexedDB: [], ...origin }));
|
|
523
505
|
this._cookieStore.addCookies(options.storageState.cookies || []);
|
|
@@ -532,8 +514,7 @@ class GlobalAPIRequestContext extends APIRequestContext {
|
|
|
532
514
|
maxRedirects: options.maxRedirects,
|
|
533
515
|
httpCredentials: options.httpCredentials,
|
|
534
516
|
clientCertificates: options.clientCertificates,
|
|
535
|
-
proxy: options.proxy
|
|
536
|
-
timeoutSettings
|
|
517
|
+
proxy: options.proxy
|
|
537
518
|
};
|
|
538
519
|
this._tracing = new import_tracing.Tracing(this, options.tracesDir);
|
|
539
520
|
}
|
|
@@ -555,7 +536,7 @@ class GlobalAPIRequestContext extends APIRequestContext {
|
|
|
555
536
|
async _cookies(url) {
|
|
556
537
|
return this._cookieStore.cookies(url);
|
|
557
538
|
}
|
|
558
|
-
async storageState(indexedDB = false) {
|
|
539
|
+
async storageState(progress, indexedDB = false) {
|
|
559
540
|
return {
|
|
560
541
|
cookies: this._cookieStore.allCookies(),
|
|
561
542
|
origins: (this._origins || []).map((origin) => ({ ...origin, indexedDB: indexedDB ? origin.indexedDB : [] }))
|
|
@@ -55,7 +55,7 @@ async function prepareFilesForUpload(frame, params) {
|
|
|
55
55
|
(0, import_assert.assert)(import_path.default.isAbsolute(p) && import_path.default.resolve(p) === p, "Paths provided to localPaths must be absolute and fully resolved.");
|
|
56
56
|
}
|
|
57
57
|
let fileBuffers = payloads;
|
|
58
|
-
if (!frame._page.
|
|
58
|
+
if (!frame._page.browserContext._browser._isCollocatedWithServer) {
|
|
59
59
|
if (localPaths) {
|
|
60
60
|
if (await filesExceedUploadLimit(localPaths))
|
|
61
61
|
throw new Error("Cannot transfer files larger than 50Mb to a browser not co-located with the server");
|