patchright-core 1.51.3 → 1.52.1
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/browsers.json +15 -13
- package/lib/androidServerImpl.js +42 -48
- package/lib/browserServerImpl.js +54 -67
- package/lib/cli/driver.js +71 -69
- package/lib/cli/program.js +312 -328
- package/lib/cli/programWithTestStub.js +51 -45
- package/lib/client/accessibility.js +31 -32
- package/lib/client/android.js +141 -228
- package/lib/client/api.js +135 -283
- package/lib/client/artifact.js +39 -36
- package/lib/client/browser.js +57 -61
- package/lib/client/browserContext.js +297 -326
- package/lib/client/browserType.js +92 -106
- package/lib/client/cdpSession.js +29 -31
- package/lib/client/channelOwner.js +82 -95
- package/lib/client/clientHelper.js +46 -38
- package/lib/client/clientInstrumentation.js +40 -37
- package/lib/client/clientStackTrace.js +41 -37
- package/lib/client/clock.js +36 -36
- package/lib/client/connection.js +190 -212
- package/lib/client/consoleMessage.js +31 -28
- package/lib/client/coverage.js +25 -22
- package/lib/client/dialog.js +30 -31
- package/lib/client/download.js +25 -25
- package/lib/client/electron.js +73 -75
- package/lib/client/elementHandle.js +111 -147
- package/lib/client/errors.js +53 -53
- package/lib/client/eventEmitter.js +124 -121
- package/lib/client/events.js +72 -68
- package/lib/client/fetch.js +135 -158
- package/lib/client/fileChooser.js +25 -24
- package/lib/client/fileUtils.js +31 -28
- package/lib/client/frame.js +187 -306
- package/lib/client/harRouter.js +42 -52
- package/lib/client/input.js +40 -69
- package/lib/client/jsHandle.js +56 -71
- package/lib/client/jsonPipe.js +27 -23
- package/lib/client/localUtils.js +29 -28
- package/lib/client/locator.js +161 -245
- package/lib/client/network.js +277 -295
- package/lib/client/page.js +270 -318
- package/lib/client/platform.js +46 -43
- package/lib/client/playwright.js +51 -66
- package/lib/client/selectors.js +48 -46
- package/lib/client/stream.js +29 -25
- package/lib/client/timeoutSettings.js +49 -39
- package/lib/client/tracing.js +48 -84
- package/lib/client/types.js +26 -22
- package/lib/client/video.js +35 -27
- package/lib/client/waiter.js +69 -88
- package/lib/client/webError.js +25 -23
- package/lib/client/webSocket.js +61 -56
- package/lib/client/worker.js +48 -58
- package/lib/client/writableStream.js +27 -23
- package/lib/generated/clockSource.js +26 -5
- package/lib/generated/consoleApiSource.js +26 -5
- package/lib/generated/injectedScriptSource.js +26 -5
- package/lib/generated/pollingRecorderSource.js +26 -5
- package/lib/generated/utilityScriptSource.js +26 -5
- package/lib/generated/webSocketMockSource.js +371 -4
- package/lib/inProcessFactory.js +53 -53
- package/lib/inprocess.js +2 -19
- package/lib/outofprocess.js +53 -46
- package/lib/protocol/debug.js +209 -25
- package/lib/protocol/serializers.js +153 -134
- package/lib/protocol/validator.js +2714 -2714
- package/lib/protocol/validatorPrimitives.js +114 -73
- package/lib/remote/playwrightConnection.js +140 -157
- package/lib/remote/playwrightServer.js +99 -84
- package/lib/server/accessibility.js +44 -37
- package/lib/server/android/android.js +216 -209
- package/lib/server/android/backendAdb.js +89 -82
- package/lib/server/artifact.js +78 -55
- package/lib/server/bidi/bidiBrowser.js +221 -155
- package/lib/server/bidi/bidiChromium.js +106 -79
- package/lib/server/bidi/bidiConnection.js +66 -83
- package/lib/server/bidi/bidiExecutionContext.js +128 -113
- package/lib/server/bidi/bidiFirefox.js +76 -69
- package/lib/server/bidi/bidiInput.js +86 -97
- package/lib/server/bidi/bidiNetworkManager.js +137 -154
- package/lib/server/bidi/bidiOverCdp.js +57 -58
- package/lib/server/bidi/bidiPage.js +247 -219
- package/lib/server/bidi/bidiPdf.js +52 -86
- package/lib/server/bidi/third_party/bidiCommands.d.js +22 -0
- package/lib/server/bidi/third_party/bidiDeserializer.js +55 -50
- package/lib/server/bidi/third_party/bidiKeyboard.js +236 -220
- package/lib/server/bidi/third_party/bidiProtocol.js +144 -131
- package/lib/server/bidi/third_party/bidiSerializer.js +67 -63
- package/lib/server/bidi/third_party/firefoxPrefs.js +141 -119
- package/lib/server/browser.js +76 -84
- package/lib/server/browserContext.js +321 -346
- package/lib/server/browserType.js +169 -182
- package/lib/server/callLog.js +47 -44
- package/lib/server/chromium/chromium.js +212 -190
- package/lib/server/chromium/chromiumSwitches.js +86 -64
- package/lib/server/chromium/crAccessibility.js +157 -131
- package/lib/server/chromium/crBrowser.js +253 -273
- package/lib/server/chromium/crConnection.js +91 -116
- package/lib/server/chromium/crCoverage.js +113 -127
- package/lib/server/chromium/crDevTools.js +59 -51
- package/lib/server/chromium/crDragDrop.js +62 -79
- package/lib/server/chromium/crExecutionContext.js +88 -83
- package/lib/server/chromium/crInput.js +97 -95
- package/lib/server/chromium/crNetworkManager.js +284 -404
- package/lib/server/chromium/crPage.js +522 -608
- package/lib/server/chromium/crPdf.js +54 -86
- package/lib/server/chromium/crProtocolHelper.js +92 -80
- package/lib/server/chromium/crServiceWorker.js +82 -67
- package/lib/server/chromium/defaultFontFamilies.js +152 -135
- package/lib/server/chromium/protocol.d.js +16 -0
- package/lib/server/chromium/videoRecorder.js +65 -99
- package/lib/server/clock.js +62 -50
- package/lib/server/codegen/csharp.js +185 -160
- package/lib/server/codegen/java.js +155 -128
- package/lib/server/codegen/javascript.js +163 -148
- package/lib/server/codegen/jsonl.js +32 -28
- package/lib/server/codegen/language.js +75 -52
- package/lib/server/codegen/languages.js +65 -27
- package/lib/server/codegen/python.js +140 -125
- package/lib/server/codegen/types.js +15 -4
- package/lib/server/console.js +28 -32
- package/lib/server/cookieStore.js +105 -86
- package/lib/server/debugController.js +97 -124
- package/lib/server/debugger.js +82 -78
- package/lib/server/deviceDescriptors.js +37 -24
- package/lib/server/deviceDescriptorsSource.json +50 -50
- package/lib/server/dialog.js +36 -35
- package/lib/server/dispatchers/androidDispatcher.js +196 -107
- package/lib/server/dispatchers/artifactDispatcher.js +62 -62
- package/lib/server/dispatchers/browserContextDispatcher.js +176 -205
- package/lib/server/dispatchers/browserDispatcher.js +78 -97
- package/lib/server/dispatchers/browserTypeDispatcher.js +35 -35
- package/lib/server/dispatchers/cdpSessionDispatcher.js +32 -36
- package/lib/server/dispatchers/debugControllerDispatcher.js +48 -66
- package/lib/server/dispatchers/dialogDispatcher.js +30 -27
- package/lib/server/dispatchers/dispatcher.js +169 -220
- package/lib/server/dispatchers/electronDispatcher.js +54 -57
- package/lib/server/dispatchers/elementHandlerDispatcher.js +77 -119
- package/lib/server/dispatchers/frameDispatcher.js +99 -163
- package/lib/server/dispatchers/jsHandleDispatcher.js +49 -66
- package/lib/server/dispatchers/jsonPipeDispatcher.js +35 -36
- package/lib/server/dispatchers/localUtilsDispatcher.js +95 -80
- package/lib/server/dispatchers/networkDispatchers.js +90 -107
- package/lib/server/dispatchers/pageDispatcher.js +128 -169
- package/lib/server/dispatchers/playwrightDispatcher.js +69 -76
- package/lib/server/dispatchers/selectorsDispatcher.js +28 -24
- package/lib/server/dispatchers/streamDispatcher.js +42 -45
- package/lib/server/dispatchers/tracingDispatcher.js +36 -41
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +96 -131
- package/lib/server/dispatchers/writableStreamDispatcher.js +54 -38
- package/lib/server/dom.js +413 -443
- package/lib/server/download.js +45 -35
- package/lib/server/electron/electron.js +156 -176
- package/lib/server/electron/loader.js +8 -36
- package/lib/server/errors.js +47 -46
- package/lib/server/fetch.js +289 -323
- package/lib/server/fileChooser.js +25 -24
- package/lib/server/fileUploadUtils.js +65 -59
- package/lib/server/firefox/ffAccessibility.js +153 -131
- package/lib/server/firefox/ffBrowser.js +213 -277
- package/lib/server/firefox/ffConnection.js +63 -84
- package/lib/server/firefox/ffExecutionContext.js +91 -73
- package/lib/server/firefox/ffInput.js +67 -69
- package/lib/server/firefox/ffNetworkManager.js +131 -110
- package/lib/server/firefox/ffPage.js +236 -273
- package/lib/server/firefox/firefox.js +76 -67
- package/lib/server/firefox/protocol.d.js +16 -0
- package/lib/server/formData.js +107 -35
- package/lib/server/frameSelectors.js +221 -112
- package/lib/server/frames.js +731 -894
- package/lib/server/har/harRecorder.js +85 -77
- package/lib/server/har/harTracer.js +287 -222
- package/lib/server/harBackend.js +80 -80
- package/lib/server/helper.js +56 -59
- package/lib/server/index.js +59 -99
- package/lib/server/input.js +134 -163
- package/lib/server/instrumentation.js +49 -44
- package/lib/server/javascript.js +143 -134
- package/lib/server/launchApp.js +92 -73
- package/lib/server/localUtils.js +130 -122
- package/lib/server/macEditingCommands.js +141 -137
- package/lib/server/network.js +262 -296
- package/lib/server/page.js +326 -423
- package/lib/server/pageBinding.js +88 -0
- package/lib/server/pipeTransport.js +49 -45
- package/lib/server/playwright.js +60 -67
- package/lib/server/progress.js +56 -51
- package/lib/server/protocolError.js +34 -31
- package/lib/server/recorder/chat.js +70 -86
- package/lib/server/recorder/contextRecorder.js +134 -138
- package/lib/server/recorder/recorderApp.js +127 -136
- package/lib/server/recorder/recorderCollection.js +56 -44
- package/lib/server/recorder/recorderFrontend.js +15 -4
- package/lib/server/recorder/recorderRunner.js +79 -103
- package/lib/server/recorder/recorderUtils.js +56 -45
- package/lib/server/recorder/throttledFile.js +42 -30
- package/lib/server/recorder.js +177 -186
- package/lib/server/registry/browserFetcher.js +106 -101
- package/lib/server/registry/dependencies.js +245 -196
- package/lib/server/registry/index.js +904 -792
- package/lib/server/registry/nativeDeps.js +1073 -464
- package/lib/server/registry/oopDownloadBrowserMain.js +57 -75
- package/lib/server/screenshotter.js +166 -182
- package/lib/server/selectors.js +85 -46
- package/lib/server/socksClientCertificatesInterceptor.js +166 -185
- package/lib/server/socksInterceptor.js +62 -70
- package/lib/server/storageScript.js +94 -100
- package/lib/server/timeoutSettings.js +58 -43
- package/lib/server/trace/recorder/snapshotter.js +70 -89
- package/lib/server/trace/recorder/snapshotterInjected.js +238 -217
- package/lib/server/trace/recorder/tracing.js +321 -333
- package/lib/server/trace/test/inMemorySnapshotter.js +46 -52
- package/lib/server/trace/viewer/traceViewer.js +168 -146
- package/lib/server/transport.js +124 -133
- package/lib/server/types.js +26 -22
- package/lib/server/usKeyboardLayout.js +135 -545
- package/lib/server/utils/ascii.js +39 -26
- package/lib/server/utils/comparators.js +105 -103
- package/lib/server/utils/crypto.js +157 -112
- package/lib/server/utils/debug.js +37 -28
- package/lib/server/utils/debugLogger.js +69 -48
- package/lib/server/utils/env.js +52 -37
- package/lib/server/utils/eventsHelper.js +29 -28
- package/lib/server/utils/expectUtils.js +31 -26
- package/lib/server/utils/fileUtils.js +123 -136
- package/lib/server/utils/happyEyeballs.js +138 -123
- package/lib/server/utils/hostPlatform.js +84 -120
- package/lib/server/utils/httpServer.js +106 -121
- package/lib/server/utils/image_tools/colorUtils.js +42 -51
- package/lib/server/utils/image_tools/compare.js +44 -43
- package/lib/server/utils/image_tools/imageChannel.js +38 -30
- package/lib/server/utils/image_tools/stats.js +40 -40
- package/lib/server/utils/linuxUtils.js +50 -37
- package/lib/server/utils/network.js +143 -86
- package/lib/server/utils/nodePlatform.js +87 -79
- package/lib/server/utils/pipeTransport.js +44 -42
- package/lib/server/utils/processLauncher.js +111 -121
- package/lib/server/utils/profiler.js +52 -39
- package/lib/server/utils/socksProxy.js +280 -339
- package/lib/server/utils/spawnAsync.js +37 -41
- package/lib/server/utils/task.js +31 -38
- package/lib/server/utils/userAgent.js +73 -66
- package/lib/server/utils/wsServer.js +73 -69
- package/lib/server/utils/zipFile.js +36 -37
- package/lib/server/utils/zones.js +37 -34
- package/lib/server/webkit/protocol.d.js +16 -0
- package/lib/server/webkit/webkit.js +76 -63
- package/lib/server/webkit/wkAccessibility.js +161 -118
- package/lib/server/webkit/wkBrowser.js +159 -176
- package/lib/server/webkit/wkConnection.js +59 -83
- package/lib/server/webkit/wkExecutionContext.js +84 -70
- package/lib/server/webkit/wkInput.js +82 -80
- package/lib/server/webkit/wkInterceptableRequest.js +102 -95
- package/lib/server/webkit/wkPage.js +525 -619
- package/lib/server/webkit/wkProvisionalPage.js +45 -56
- package/lib/server/webkit/wkWorkers.js +77 -77
- package/lib/utils/isomorphic/ariaSnapshot.js +144 -152
- package/lib/utils/isomorphic/assert.js +28 -22
- package/lib/utils/isomorphic/builtins.js +86 -0
- package/lib/utils/isomorphic/colors.js +66 -59
- package/lib/utils/isomorphic/cssParser.js +121 -125
- package/lib/utils/isomorphic/cssTokenizer.js +436 -364
- package/lib/utils/isomorphic/headers.js +38 -37
- package/lib/utils/isomorphic/locatorGenerators.js +340 -357
- package/lib/utils/isomorphic/locatorParser.js +96 -105
- package/lib/utils/isomorphic/locatorUtils.js +63 -44
- package/lib/utils/isomorphic/manualPromise.js +47 -39
- package/lib/utils/isomorphic/mimeType.js +448 -25
- package/lib/utils/isomorphic/multimap.js +35 -27
- package/lib/utils/isomorphic/rtti.js +35 -33
- package/lib/utils/isomorphic/selectorParser.js +183 -193
- package/lib/utils/isomorphic/semaphore.js +27 -24
- package/lib/utils/isomorphic/stackTrace.js +87 -98
- package/lib/utils/isomorphic/stringUtils.js +113 -106
- package/lib/utils/isomorphic/time.js +41 -22
- package/lib/utils/isomorphic/timeoutRunner.js +55 -54
- package/lib/utils/isomorphic/traceUtils.js +38 -41
- package/lib/utils/isomorphic/types.js +15 -4
- package/lib/utils/isomorphic/urlMatch.js +112 -67
- package/lib/utils/isomorphic/utilityScriptSerializers.js +248 -0
- package/lib/utils.js +97 -443
- package/lib/utilsBundle.js +101 -52
- package/lib/vite/htmlReport/index.html +21 -15
- package/lib/vite/recorder/assets/{codeMirrorModule-B9YMkrwa.js → codeMirrorModule-CXVeovup.js} +1 -1
- package/lib/vite/recorder/assets/index-BsWQsSGl.js +184 -0
- package/lib/vite/recorder/index.html +1 -1
- package/lib/vite/traceViewer/assets/{codeMirrorModule-1DiydmYA.js → codeMirrorModule-_GLjJL-7.js} +1 -1
- package/lib/vite/traceViewer/assets/defaultSettingsView-DtCQiGHe.js +265 -0
- package/lib/vite/traceViewer/{defaultSettingsView.5fN5lw10.css → defaultSettingsView.QdHITyLI.css} +1 -1
- package/lib/vite/traceViewer/index.cFZzK9RN.js +2 -0
- package/lib/vite/traceViewer/index.html +3 -3
- package/lib/vite/traceViewer/sw.bundle.js +3 -3
- package/lib/vite/traceViewer/uiMode.XVPIqBeS.js +5 -0
- package/lib/vite/traceViewer/uiMode.html +3 -3
- package/lib/zipBundle.js +32 -23
- package/package.json +1 -1
- package/types/protocol.d.ts +436 -17
- package/types/types.d.ts +35 -16
- package/lib/server/isomorphic/utilityScriptSerializers.js +0 -229
- package/lib/vite/recorder/assets/index-ELPgmkwA.js +0 -184
- package/lib/vite/traceViewer/assets/defaultSettingsView-l0TyP_G8.js +0 -259
- package/lib/vite/traceViewer/index.BqUZLSro.js +0 -2
- package/lib/vite/traceViewer/uiMode.C1d2m5sF.js +0 -5
package/lib/client/page.js
CHANGED
|
@@ -1,181 +1,162 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
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 page_exports = {};
|
|
20
|
+
__export(page_exports, {
|
|
21
|
+
BindingCall: () => BindingCall,
|
|
22
|
+
Page: () => Page
|
|
5
23
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
* Copyright 2017 Google Inc. All rights reserved.
|
|
35
|
-
* Modifications copyright (c) Microsoft Corporation.
|
|
36
|
-
*
|
|
37
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
38
|
-
* you may not use this file except in compliance with the License.
|
|
39
|
-
* You may obtain a copy of the License at
|
|
40
|
-
*
|
|
41
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
42
|
-
*
|
|
43
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
44
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
45
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
46
|
-
* See the License for the specific language governing permissions and
|
|
47
|
-
* limitations under the License.
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
class Page extends _channelOwner.ChannelOwner {
|
|
51
|
-
static from(page) {
|
|
52
|
-
return page._object;
|
|
53
|
-
}
|
|
54
|
-
static fromNullable(page) {
|
|
55
|
-
return page ? Page.from(page) : null;
|
|
56
|
-
}
|
|
24
|
+
module.exports = __toCommonJS(page_exports);
|
|
25
|
+
var import_accessibility = require("./accessibility");
|
|
26
|
+
var import_artifact = require("./artifact");
|
|
27
|
+
var import_channelOwner = require("./channelOwner");
|
|
28
|
+
var import_clientHelper = require("./clientHelper");
|
|
29
|
+
var import_coverage = require("./coverage");
|
|
30
|
+
var import_download = require("./download");
|
|
31
|
+
var import_elementHandle = require("./elementHandle");
|
|
32
|
+
var import_errors = require("./errors");
|
|
33
|
+
var import_events = require("./events");
|
|
34
|
+
var import_fileChooser = require("./fileChooser");
|
|
35
|
+
var import_frame = require("./frame");
|
|
36
|
+
var import_harRouter = require("./harRouter");
|
|
37
|
+
var import_input = require("./input");
|
|
38
|
+
var import_jsHandle = require("./jsHandle");
|
|
39
|
+
var import_network = require("./network");
|
|
40
|
+
var import_video = require("./video");
|
|
41
|
+
var import_waiter = require("./waiter");
|
|
42
|
+
var import_worker = require("./worker");
|
|
43
|
+
var import_timeoutSettings = require("./timeoutSettings");
|
|
44
|
+
var import_assert = require("../utils/isomorphic/assert");
|
|
45
|
+
var import_fileUtils = require("./fileUtils");
|
|
46
|
+
var import_headers = require("../utils/isomorphic/headers");
|
|
47
|
+
var import_stringUtils = require("../utils/isomorphic/stringUtils");
|
|
48
|
+
var import_urlMatch = require("../utils/isomorphic/urlMatch");
|
|
49
|
+
var import_manualPromise = require("../utils/isomorphic/manualPromise");
|
|
50
|
+
var import_rtti = require("../utils/isomorphic/rtti");
|
|
51
|
+
class Page extends import_channelOwner.ChannelOwner {
|
|
57
52
|
constructor(parent, type, guid, initializer) {
|
|
58
53
|
super(parent, type, guid, initializer);
|
|
59
|
-
this.
|
|
60
|
-
this.
|
|
61
|
-
this._mainFrame = void 0;
|
|
62
|
-
this._frames = new Set();
|
|
63
|
-
this._workers = new Set();
|
|
54
|
+
this._frames = /* @__PURE__ */ new Set();
|
|
55
|
+
this._workers = /* @__PURE__ */ new Set();
|
|
64
56
|
this._closed = false;
|
|
65
|
-
this._closedOrCrashedScope = new
|
|
66
|
-
this._viewportSize = void 0;
|
|
57
|
+
this._closedOrCrashedScope = new import_manualPromise.LongStandingScope();
|
|
67
58
|
this._routes = [];
|
|
68
59
|
this._webSocketRoutes = [];
|
|
69
|
-
this.
|
|
70
|
-
this.coverage = void 0;
|
|
71
|
-
this.keyboard = void 0;
|
|
72
|
-
this.mouse = void 0;
|
|
73
|
-
this.request = void 0;
|
|
74
|
-
this.touchscreen = void 0;
|
|
75
|
-
this.clock = void 0;
|
|
76
|
-
this._bindings = new Map();
|
|
77
|
-
this._timeoutSettings = void 0;
|
|
60
|
+
this._bindings = /* @__PURE__ */ new Map();
|
|
78
61
|
this._video = null;
|
|
79
|
-
this._opener = void 0;
|
|
80
|
-
this._closeReason = void 0;
|
|
81
62
|
this._closeWasCalled = false;
|
|
82
63
|
this._harRouters = [];
|
|
83
|
-
this._locatorHandlers = new Map();
|
|
64
|
+
this._locatorHandlers = /* @__PURE__ */ new Map();
|
|
84
65
|
this.routeInjecting = false;
|
|
85
66
|
this._browserContext = parent;
|
|
86
|
-
this._timeoutSettings = new
|
|
87
|
-
this.accessibility = new
|
|
88
|
-
this.keyboard = new
|
|
89
|
-
this.mouse = new
|
|
67
|
+
this._timeoutSettings = new import_timeoutSettings.TimeoutSettings(this._platform, this._browserContext._timeoutSettings);
|
|
68
|
+
this.accessibility = new import_accessibility.Accessibility(this._channel);
|
|
69
|
+
this.keyboard = new import_input.Keyboard(this);
|
|
70
|
+
this.mouse = new import_input.Mouse(this);
|
|
90
71
|
this.request = this._browserContext.request;
|
|
91
|
-
this.touchscreen = new
|
|
72
|
+
this.touchscreen = new import_input.Touchscreen(this);
|
|
92
73
|
this.clock = this._browserContext.clock;
|
|
93
|
-
this._mainFrame =
|
|
74
|
+
this._mainFrame = import_frame.Frame.from(initializer.mainFrame);
|
|
94
75
|
this._mainFrame._page = this;
|
|
95
76
|
this._frames.add(this._mainFrame);
|
|
96
77
|
this._viewportSize = initializer.viewportSize || null;
|
|
97
78
|
this._closed = initializer.isClosed;
|
|
98
79
|
this._opener = Page.fromNullable(initializer.opener);
|
|
99
|
-
this._channel.on(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
this._channel.on(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
url,
|
|
106
|
-
suggestedFilename,
|
|
107
|
-
artifact
|
|
108
|
-
}) => {
|
|
109
|
-
const artifactObject = _artifact.Artifact.from(artifact);
|
|
110
|
-
this.emit(_events.Events.Page.Download, new _download.Download(this, url, suggestedFilename, artifactObject));
|
|
80
|
+
this._channel.on("bindingCall", ({ binding }) => this._onBinding(BindingCall.from(binding)));
|
|
81
|
+
this._channel.on("close", () => this._onClose());
|
|
82
|
+
this._channel.on("crash", () => this._onCrash());
|
|
83
|
+
this._channel.on("download", ({ url, suggestedFilename, artifact }) => {
|
|
84
|
+
const artifactObject = import_artifact.Artifact.from(artifact);
|
|
85
|
+
this.emit(import_events.Events.Page.Download, new import_download.Download(this, url, suggestedFilename, artifactObject));
|
|
111
86
|
});
|
|
112
|
-
this._channel.on(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
this._channel.on(
|
|
117
|
-
|
|
118
|
-
}) =>
|
|
119
|
-
|
|
120
|
-
frame
|
|
121
|
-
}) => this._onFrameDetached(_frame.Frame.from(frame)));
|
|
122
|
-
this._channel.on('locatorHandlerTriggered', ({
|
|
123
|
-
uid
|
|
124
|
-
}) => this._onLocatorHandlerTriggered(uid));
|
|
125
|
-
this._channel.on('route', ({
|
|
126
|
-
route
|
|
127
|
-
}) => this._onRoute(_network.Route.from(route)));
|
|
128
|
-
this._channel.on('webSocketRoute', ({
|
|
129
|
-
webSocketRoute
|
|
130
|
-
}) => this._onWebSocketRoute(_network.WebSocketRoute.from(webSocketRoute)));
|
|
131
|
-
this._channel.on('video', ({
|
|
132
|
-
artifact
|
|
133
|
-
}) => {
|
|
134
|
-
const artifactObject = _artifact.Artifact.from(artifact);
|
|
87
|
+
this._channel.on("fileChooser", ({ element, isMultiple }) => this.emit(import_events.Events.Page.FileChooser, new import_fileChooser.FileChooser(this, import_elementHandle.ElementHandle.from(element), isMultiple)));
|
|
88
|
+
this._channel.on("frameAttached", ({ frame }) => this._onFrameAttached(import_frame.Frame.from(frame)));
|
|
89
|
+
this._channel.on("frameDetached", ({ frame }) => this._onFrameDetached(import_frame.Frame.from(frame)));
|
|
90
|
+
this._channel.on("locatorHandlerTriggered", ({ uid }) => this._onLocatorHandlerTriggered(uid));
|
|
91
|
+
this._channel.on("route", ({ route }) => this._onRoute(import_network.Route.from(route)));
|
|
92
|
+
this._channel.on("webSocketRoute", ({ webSocketRoute }) => this._onWebSocketRoute(import_network.WebSocketRoute.from(webSocketRoute)));
|
|
93
|
+
this._channel.on("video", ({ artifact }) => {
|
|
94
|
+
const artifactObject = import_artifact.Artifact.from(artifact);
|
|
135
95
|
this._forceVideo()._artifactReady(artifactObject);
|
|
136
96
|
});
|
|
137
|
-
this._channel.on(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
this.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
97
|
+
this._channel.on("webSocket", ({ webSocket }) => this.emit(import_events.Events.Page.WebSocket, import_network.WebSocket.from(webSocket)));
|
|
98
|
+
this._channel.on("worker", ({ worker }) => this._onWorker(import_worker.Worker.from(worker)));
|
|
99
|
+
this.coverage = new import_coverage.Coverage(this._channel);
|
|
100
|
+
this.once(import_events.Events.Page.Close, () => this._closedOrCrashedScope.close(this._closeErrorWithReason()));
|
|
101
|
+
this.once(import_events.Events.Page.Crash, () => this._closedOrCrashedScope.close(new import_errors.TargetClosedError()));
|
|
102
|
+
this._setEventToSubscriptionMapping(/* @__PURE__ */ new Map([
|
|
103
|
+
[import_events.Events.Page.Console, "console"],
|
|
104
|
+
[import_events.Events.Page.Dialog, "dialog"],
|
|
105
|
+
[import_events.Events.Page.Request, "request"],
|
|
106
|
+
[import_events.Events.Page.Response, "response"],
|
|
107
|
+
[import_events.Events.Page.RequestFinished, "requestFinished"],
|
|
108
|
+
[import_events.Events.Page.RequestFailed, "requestFailed"],
|
|
109
|
+
[import_events.Events.Page.FileChooser, "fileChooser"]
|
|
110
|
+
]));
|
|
111
|
+
}
|
|
112
|
+
static from(page) {
|
|
113
|
+
return page._object;
|
|
114
|
+
}
|
|
115
|
+
static fromNullable(page) {
|
|
116
|
+
return page ? Page.from(page) : null;
|
|
147
117
|
}
|
|
148
118
|
_onFrameAttached(frame) {
|
|
149
119
|
frame._page = this;
|
|
150
120
|
this._frames.add(frame);
|
|
151
|
-
if (frame._parentFrame)
|
|
152
|
-
|
|
121
|
+
if (frame._parentFrame)
|
|
122
|
+
frame._parentFrame._childFrames.add(frame);
|
|
123
|
+
this.emit(import_events.Events.Page.FrameAttached, frame);
|
|
153
124
|
}
|
|
154
125
|
_onFrameDetached(frame) {
|
|
155
126
|
this._frames.delete(frame);
|
|
156
127
|
frame._detached = true;
|
|
157
|
-
if (frame._parentFrame)
|
|
158
|
-
|
|
128
|
+
if (frame._parentFrame)
|
|
129
|
+
frame._parentFrame._childFrames.delete(frame);
|
|
130
|
+
this.emit(import_events.Events.Page.FrameDetached, frame);
|
|
159
131
|
}
|
|
160
132
|
async _onRoute(route) {
|
|
161
133
|
route._context = this.context();
|
|
162
134
|
const routeHandlers = this._routes.slice();
|
|
163
135
|
for (const routeHandler of routeHandlers) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if (!routeHandler.matches(route.request().url()))
|
|
136
|
+
if (this._closeWasCalled || this._browserContext._closeWasCalled)
|
|
137
|
+
return;
|
|
138
|
+
if (!routeHandler.matches(route.request().url()))
|
|
139
|
+
continue;
|
|
167
140
|
const index = this._routes.indexOf(routeHandler);
|
|
168
|
-
if (index === -1)
|
|
169
|
-
|
|
141
|
+
if (index === -1)
|
|
142
|
+
continue;
|
|
143
|
+
if (routeHandler.willExpire())
|
|
144
|
+
this._routes.splice(index, 1);
|
|
170
145
|
const handled = await routeHandler.handle(route);
|
|
171
|
-
if (!this._routes.length)
|
|
172
|
-
|
|
146
|
+
if (!this._routes.length)
|
|
147
|
+
this._wrapApiCall(() => this._updateInterceptionPatterns(), true).catch(() => {
|
|
148
|
+
});
|
|
149
|
+
if (handled)
|
|
150
|
+
return;
|
|
173
151
|
}
|
|
174
152
|
await this._browserContext._onRoute(route);
|
|
175
153
|
}
|
|
176
154
|
async _onWebSocketRoute(webSocketRoute) {
|
|
177
|
-
const routeHandler = this._webSocketRoutes.find(route => route.matches(webSocketRoute.url()));
|
|
178
|
-
if (routeHandler)
|
|
155
|
+
const routeHandler = this._webSocketRoutes.find((route) => route.matches(webSocketRoute.url()));
|
|
156
|
+
if (routeHandler)
|
|
157
|
+
await routeHandler.handle(webSocketRoute);
|
|
158
|
+
else
|
|
159
|
+
await this._browserContext._onWebSocketRoute(webSocketRoute);
|
|
179
160
|
}
|
|
180
161
|
async _onBinding(bindingCall) {
|
|
181
162
|
const func = this._bindings.get(bindingCall._initializer.name);
|
|
@@ -188,35 +169,37 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
188
169
|
_onWorker(worker) {
|
|
189
170
|
this._workers.add(worker);
|
|
190
171
|
worker._page = this;
|
|
191
|
-
this.emit(
|
|
172
|
+
this.emit(import_events.Events.Page.Worker, worker);
|
|
192
173
|
}
|
|
193
174
|
_onClose() {
|
|
194
175
|
this._closed = true;
|
|
195
176
|
this._browserContext._pages.delete(this);
|
|
196
177
|
this._browserContext._backgroundPages.delete(this);
|
|
197
178
|
this._disposeHarRouters();
|
|
198
|
-
this.emit(
|
|
179
|
+
this.emit(import_events.Events.Page.Close, this);
|
|
199
180
|
}
|
|
200
181
|
_onCrash() {
|
|
201
|
-
this.emit(
|
|
182
|
+
this.emit(import_events.Events.Page.Crash, this);
|
|
202
183
|
}
|
|
203
184
|
context() {
|
|
204
185
|
return this._browserContext;
|
|
205
186
|
}
|
|
206
187
|
async opener() {
|
|
207
|
-
if (!this._opener || this._opener.isClosed())
|
|
188
|
+
if (!this._opener || this._opener.isClosed())
|
|
189
|
+
return null;
|
|
208
190
|
return this._opener;
|
|
209
191
|
}
|
|
210
192
|
mainFrame() {
|
|
211
193
|
return this._mainFrame;
|
|
212
194
|
}
|
|
213
195
|
frame(frameSelector) {
|
|
214
|
-
const name = (0,
|
|
215
|
-
const url = (0,
|
|
216
|
-
(0,
|
|
217
|
-
return this.frames().find(f => {
|
|
218
|
-
if (name)
|
|
219
|
-
|
|
196
|
+
const name = (0, import_rtti.isString)(frameSelector) ? frameSelector : frameSelector.name;
|
|
197
|
+
const url = (0, import_rtti.isObject)(frameSelector) ? frameSelector.url : void 0;
|
|
198
|
+
(0, import_assert.assert)(name || url, "Either name or url matcher should be specified");
|
|
199
|
+
return this.frames().find((f) => {
|
|
200
|
+
if (name)
|
|
201
|
+
return f.name() === name;
|
|
202
|
+
return (0, import_urlMatch.urlMatches)(this._browserContext._options.baseURL, f.url(), url);
|
|
220
203
|
}) || null;
|
|
221
204
|
}
|
|
222
205
|
frames() {
|
|
@@ -225,28 +208,25 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
225
208
|
setDefaultNavigationTimeout(timeout) {
|
|
226
209
|
this._timeoutSettings.setDefaultNavigationTimeout(timeout);
|
|
227
210
|
this._wrapApiCall(async () => {
|
|
228
|
-
await this._channel.setDefaultNavigationTimeoutNoReply({
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}, true).catch(() => {});
|
|
211
|
+
await this._channel.setDefaultNavigationTimeoutNoReply({ timeout });
|
|
212
|
+
}, true).catch(() => {
|
|
213
|
+
});
|
|
232
214
|
}
|
|
233
215
|
setDefaultTimeout(timeout) {
|
|
234
216
|
this._timeoutSettings.setDefaultTimeout(timeout);
|
|
235
217
|
this._wrapApiCall(async () => {
|
|
236
|
-
await this._channel.setDefaultTimeoutNoReply({
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}, true).catch(() => {});
|
|
218
|
+
await this._channel.setDefaultTimeoutNoReply({ timeout });
|
|
219
|
+
}, true).catch(() => {
|
|
220
|
+
});
|
|
240
221
|
}
|
|
241
222
|
_forceVideo() {
|
|
242
|
-
if (!this._video)
|
|
223
|
+
if (!this._video)
|
|
224
|
+
this._video = new import_video.Video(this, this._connection);
|
|
243
225
|
return this._video;
|
|
244
226
|
}
|
|
245
227
|
video() {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
// too late during launchPersistentContext.
|
|
249
|
-
if (!this._browserContext._options.recordVideo) return null;
|
|
228
|
+
if (!this._browserContext._options.recordVideo)
|
|
229
|
+
return null;
|
|
250
230
|
return this._forceVideo();
|
|
251
231
|
}
|
|
252
232
|
async $(selector, options) {
|
|
@@ -259,15 +239,15 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
259
239
|
return await this._mainFrame.dispatchEvent(selector, type, eventInit, options);
|
|
260
240
|
}
|
|
261
241
|
async evaluateHandle(pageFunction, arg, isolatedContext = true) {
|
|
262
|
-
(0,
|
|
242
|
+
(0, import_jsHandle.assertMaxArguments)(arguments.length, 3);
|
|
263
243
|
return await this._mainFrame.evaluateHandle(pageFunction, arg, isolatedContext);
|
|
264
244
|
}
|
|
265
245
|
async $eval(selector, pageFunction, arg) {
|
|
266
|
-
(0,
|
|
246
|
+
(0, import_jsHandle.assertMaxArguments)(arguments.length, 3);
|
|
267
247
|
return await this._mainFrame.$eval(selector, pageFunction, arg);
|
|
268
248
|
}
|
|
269
249
|
async $$eval(selector, pageFunction, arg) {
|
|
270
|
-
(0,
|
|
250
|
+
(0, import_jsHandle.assertMaxArguments)(arguments.length, 3);
|
|
271
251
|
return await this._mainFrame.$$eval(selector, pageFunction, arg);
|
|
272
252
|
}
|
|
273
253
|
async $$(selector) {
|
|
@@ -281,25 +261,18 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
281
261
|
}
|
|
282
262
|
async exposeFunction(name, callback) {
|
|
283
263
|
await this.installInjectRoute();
|
|
284
|
-
await this._channel.exposeBinding({
|
|
285
|
-
name
|
|
286
|
-
});
|
|
264
|
+
await this._channel.exposeBinding({ name });
|
|
287
265
|
const binding = (source, ...args) => callback(...args);
|
|
288
266
|
this._bindings.set(name, binding);
|
|
289
267
|
}
|
|
290
268
|
async exposeBinding(name, callback, options = {}) {
|
|
291
269
|
await this.installInjectRoute();
|
|
292
|
-
await this._channel.exposeBinding({
|
|
293
|
-
name,
|
|
294
|
-
needsHandle: options.handle
|
|
295
|
-
});
|
|
270
|
+
await this._channel.exposeBinding({ name, needsHandle: options.handle });
|
|
296
271
|
this._bindings.set(name, callback);
|
|
297
272
|
}
|
|
298
273
|
async setExtraHTTPHeaders(headers) {
|
|
299
|
-
(0,
|
|
300
|
-
await this._channel.setExtraHTTPHeaders({
|
|
301
|
-
headers: (0, _headers.headersObjectToArray)(headers)
|
|
302
|
-
});
|
|
274
|
+
(0, import_network.validateHeaders)(headers);
|
|
275
|
+
await this._channel.setExtraHTTPHeaders({ headers: (0, import_headers.headersObjectToArray)(headers) });
|
|
303
276
|
}
|
|
304
277
|
url() {
|
|
305
278
|
return this._mainFrame.url();
|
|
@@ -314,51 +287,40 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
314
287
|
return await this._mainFrame.goto(url, options);
|
|
315
288
|
}
|
|
316
289
|
async reload(options = {}) {
|
|
317
|
-
const waitUntil = (0,
|
|
318
|
-
return
|
|
319
|
-
...options,
|
|
320
|
-
waitUntil
|
|
321
|
-
})).response);
|
|
290
|
+
const waitUntil = (0, import_frame.verifyLoadState)("waitUntil", options.waitUntil === void 0 ? "load" : options.waitUntil);
|
|
291
|
+
return import_network.Response.fromNullable((await this._channel.reload({ ...options, waitUntil })).response);
|
|
322
292
|
}
|
|
323
293
|
async addLocatorHandler(locator, handler, options = {}) {
|
|
324
|
-
if (locator._frame !== this._mainFrame)
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
} = await this._channel.registerLocatorHandler({
|
|
329
|
-
|
|
330
|
-
noWaitAfter: options.noWaitAfter
|
|
331
|
-
});
|
|
332
|
-
this._locatorHandlers.set(uid, {
|
|
333
|
-
locator,
|
|
334
|
-
handler,
|
|
335
|
-
times: options.times
|
|
336
|
-
});
|
|
294
|
+
if (locator._frame !== this._mainFrame)
|
|
295
|
+
throw new Error(`Locator must belong to the main frame of this page`);
|
|
296
|
+
if (options.times === 0)
|
|
297
|
+
return;
|
|
298
|
+
const { uid } = await this._channel.registerLocatorHandler({ selector: locator._selector, noWaitAfter: options.noWaitAfter });
|
|
299
|
+
this._locatorHandlers.set(uid, { locator, handler, times: options.times });
|
|
337
300
|
}
|
|
338
301
|
async _onLocatorHandlerTriggered(uid) {
|
|
339
302
|
let remove = false;
|
|
340
303
|
try {
|
|
341
304
|
const handler = this._locatorHandlers.get(uid);
|
|
342
305
|
if (handler && handler.times !== 0) {
|
|
343
|
-
if (handler.times !==
|
|
306
|
+
if (handler.times !== void 0)
|
|
307
|
+
handler.times--;
|
|
344
308
|
await handler.handler(handler.locator);
|
|
345
309
|
}
|
|
346
|
-
remove =
|
|
310
|
+
remove = handler?.times === 0;
|
|
347
311
|
} finally {
|
|
348
|
-
if (remove)
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
}), true).catch(() => {});
|
|
312
|
+
if (remove)
|
|
313
|
+
this._locatorHandlers.delete(uid);
|
|
314
|
+
this._wrapApiCall(() => this._channel.resolveLocatorHandlerNoReply({ uid, remove }), true).catch(() => {
|
|
315
|
+
});
|
|
353
316
|
}
|
|
354
317
|
}
|
|
355
318
|
async removeLocatorHandler(locator) {
|
|
356
319
|
for (const [uid, data] of this._locatorHandlers) {
|
|
357
320
|
if (data.locator._equals(locator)) {
|
|
358
321
|
this._locatorHandlers.delete(uid);
|
|
359
|
-
await this._channel.unregisterLocatorHandler({
|
|
360
|
-
|
|
361
|
-
}).catch(() => {});
|
|
322
|
+
await this._channel.unregisterLocatorHandler({ uid }).catch(() => {
|
|
323
|
+
});
|
|
362
324
|
}
|
|
363
325
|
}
|
|
364
326
|
}
|
|
@@ -372,180 +334,166 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
372
334
|
return await this._mainFrame.waitForURL(url, options);
|
|
373
335
|
}
|
|
374
336
|
async waitForRequest(urlOrPredicate, options = {}) {
|
|
375
|
-
const predicate = async request => {
|
|
376
|
-
if ((0,
|
|
337
|
+
const predicate = async (request) => {
|
|
338
|
+
if ((0, import_rtti.isString)(urlOrPredicate) || (0, import_rtti.isRegExp)(urlOrPredicate))
|
|
339
|
+
return (0, import_urlMatch.urlMatches)(this._browserContext._options.baseURL, request.url(), urlOrPredicate);
|
|
377
340
|
return await urlOrPredicate(request);
|
|
378
341
|
};
|
|
379
342
|
const trimmedUrl = trimUrl(urlOrPredicate);
|
|
380
|
-
const logLine = trimmedUrl ? `waiting for request ${trimmedUrl}` :
|
|
381
|
-
return await this._waitForEvent(
|
|
382
|
-
predicate,
|
|
383
|
-
timeout: options.timeout
|
|
384
|
-
}, logLine);
|
|
343
|
+
const logLine = trimmedUrl ? `waiting for request ${trimmedUrl}` : void 0;
|
|
344
|
+
return await this._waitForEvent(import_events.Events.Page.Request, { predicate, timeout: options.timeout }, logLine);
|
|
385
345
|
}
|
|
386
346
|
async waitForResponse(urlOrPredicate, options = {}) {
|
|
387
|
-
const predicate = async response => {
|
|
388
|
-
if ((0,
|
|
347
|
+
const predicate = async (response) => {
|
|
348
|
+
if ((0, import_rtti.isString)(urlOrPredicate) || (0, import_rtti.isRegExp)(urlOrPredicate))
|
|
349
|
+
return (0, import_urlMatch.urlMatches)(this._browserContext._options.baseURL, response.url(), urlOrPredicate);
|
|
389
350
|
return await urlOrPredicate(response);
|
|
390
351
|
};
|
|
391
352
|
const trimmedUrl = trimUrl(urlOrPredicate);
|
|
392
|
-
const logLine = trimmedUrl ? `waiting for response ${trimmedUrl}` :
|
|
393
|
-
return await this._waitForEvent(
|
|
394
|
-
predicate,
|
|
395
|
-
timeout: options.timeout
|
|
396
|
-
}, logLine);
|
|
353
|
+
const logLine = trimmedUrl ? `waiting for response ${trimmedUrl}` : void 0;
|
|
354
|
+
return await this._waitForEvent(import_events.Events.Page.Response, { predicate, timeout: options.timeout }, logLine);
|
|
397
355
|
}
|
|
398
356
|
async waitForEvent(event, optionsOrPredicate = {}) {
|
|
399
357
|
return await this._waitForEvent(event, optionsOrPredicate, `waiting for event "${event}"`);
|
|
400
358
|
}
|
|
401
359
|
_closeErrorWithReason() {
|
|
402
|
-
return new
|
|
360
|
+
return new import_errors.TargetClosedError(this._closeReason || this._browserContext._effectiveCloseReason());
|
|
403
361
|
}
|
|
404
362
|
async _waitForEvent(event, optionsOrPredicate, logLine) {
|
|
405
363
|
return await this._wrapApiCall(async () => {
|
|
406
|
-
const timeout = this._timeoutSettings.timeout(typeof optionsOrPredicate ===
|
|
407
|
-
const predicate = typeof optionsOrPredicate ===
|
|
408
|
-
const waiter =
|
|
409
|
-
if (logLine)
|
|
364
|
+
const timeout = this._timeoutSettings.timeout(typeof optionsOrPredicate === "function" ? {} : optionsOrPredicate);
|
|
365
|
+
const predicate = typeof optionsOrPredicate === "function" ? optionsOrPredicate : optionsOrPredicate.predicate;
|
|
366
|
+
const waiter = import_waiter.Waiter.createForEvent(this, event);
|
|
367
|
+
if (logLine)
|
|
368
|
+
waiter.log(logLine);
|
|
410
369
|
waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);
|
|
411
|
-
if (event !==
|
|
412
|
-
|
|
370
|
+
if (event !== import_events.Events.Page.Crash)
|
|
371
|
+
waiter.rejectOnEvent(this, import_events.Events.Page.Crash, new Error("Page crashed"));
|
|
372
|
+
if (event !== import_events.Events.Page.Close)
|
|
373
|
+
waiter.rejectOnEvent(this, import_events.Events.Page.Close, () => this._closeErrorWithReason());
|
|
413
374
|
const result = await waiter.waitForEvent(this, event, predicate);
|
|
414
375
|
waiter.dispose();
|
|
415
376
|
return result;
|
|
416
377
|
});
|
|
417
378
|
}
|
|
418
379
|
async goBack(options = {}) {
|
|
419
|
-
const waitUntil = (0,
|
|
420
|
-
return
|
|
421
|
-
...options,
|
|
422
|
-
waitUntil
|
|
423
|
-
})).response);
|
|
380
|
+
const waitUntil = (0, import_frame.verifyLoadState)("waitUntil", options.waitUntil === void 0 ? "load" : options.waitUntil);
|
|
381
|
+
return import_network.Response.fromNullable((await this._channel.goBack({ ...options, waitUntil })).response);
|
|
424
382
|
}
|
|
425
383
|
async goForward(options = {}) {
|
|
426
|
-
const waitUntil = (0,
|
|
427
|
-
return
|
|
428
|
-
...options,
|
|
429
|
-
waitUntil
|
|
430
|
-
})).response);
|
|
384
|
+
const waitUntil = (0, import_frame.verifyLoadState)("waitUntil", options.waitUntil === void 0 ? "load" : options.waitUntil);
|
|
385
|
+
return import_network.Response.fromNullable((await this._channel.goForward({ ...options, waitUntil })).response);
|
|
431
386
|
}
|
|
432
387
|
async requestGC() {
|
|
433
388
|
await this._channel.requestGC();
|
|
434
389
|
}
|
|
435
390
|
async emulateMedia(options = {}) {
|
|
436
391
|
await this._channel.emulateMedia({
|
|
437
|
-
media: options.media === null ?
|
|
438
|
-
colorScheme: options.colorScheme === null ?
|
|
439
|
-
reducedMotion: options.reducedMotion === null ?
|
|
440
|
-
forcedColors: options.forcedColors === null ?
|
|
441
|
-
contrast: options.contrast === null ?
|
|
392
|
+
media: options.media === null ? "no-override" : options.media,
|
|
393
|
+
colorScheme: options.colorScheme === null ? "no-override" : options.colorScheme,
|
|
394
|
+
reducedMotion: options.reducedMotion === null ? "no-override" : options.reducedMotion,
|
|
395
|
+
forcedColors: options.forcedColors === null ? "no-override" : options.forcedColors,
|
|
396
|
+
contrast: options.contrast === null ? "no-override" : options.contrast
|
|
442
397
|
});
|
|
443
398
|
}
|
|
444
399
|
async setViewportSize(viewportSize) {
|
|
445
400
|
this._viewportSize = viewportSize;
|
|
446
|
-
await this._channel.setViewportSize({
|
|
447
|
-
viewportSize
|
|
448
|
-
});
|
|
401
|
+
await this._channel.setViewportSize({ viewportSize });
|
|
449
402
|
}
|
|
450
403
|
viewportSize() {
|
|
451
404
|
return this._viewportSize;
|
|
452
405
|
}
|
|
453
406
|
async evaluate(pageFunction, arg, isolatedContext = true) {
|
|
454
|
-
(0,
|
|
407
|
+
(0, import_jsHandle.assertMaxArguments)(arguments.length, 3);
|
|
455
408
|
return await this._mainFrame.evaluate(pageFunction, arg, isolatedContext);
|
|
456
409
|
}
|
|
457
410
|
async addInitScript(script, arg) {
|
|
458
411
|
await this.installInjectRoute();
|
|
459
|
-
const source = await (0,
|
|
460
|
-
await this._channel.addInitScript({
|
|
461
|
-
source
|
|
462
|
-
});
|
|
412
|
+
const source = await (0, import_clientHelper.evaluationScript)(this._platform, script, arg);
|
|
413
|
+
await this._channel.addInitScript({ source });
|
|
463
414
|
}
|
|
464
415
|
async route(url, handler, options = {}) {
|
|
465
|
-
this._routes.unshift(new
|
|
416
|
+
this._routes.unshift(new import_network.RouteHandler(this._platform, this._browserContext._options.baseURL, url, handler, options.times));
|
|
466
417
|
await this._updateInterceptionPatterns();
|
|
467
418
|
}
|
|
468
419
|
async routeFromHAR(har, options = {}) {
|
|
469
420
|
const localUtils = this._connection.localUtils();
|
|
470
|
-
if (!localUtils)
|
|
421
|
+
if (!localUtils)
|
|
422
|
+
throw new Error("Route from har is not supported in thin clients");
|
|
471
423
|
if (options.update) {
|
|
472
424
|
await this._browserContext._recordIntoHAR(har, this, options);
|
|
473
425
|
return;
|
|
474
426
|
}
|
|
475
|
-
const harRouter = await
|
|
476
|
-
urlMatch: options.url
|
|
477
|
-
});
|
|
427
|
+
const harRouter = await import_harRouter.HarRouter.create(localUtils, har, options.notFound || "abort", { urlMatch: options.url });
|
|
478
428
|
this._harRouters.push(harRouter);
|
|
479
429
|
await harRouter.addPageRoute(this);
|
|
480
430
|
}
|
|
481
431
|
async routeWebSocket(url, handler) {
|
|
482
|
-
this._webSocketRoutes.unshift(new
|
|
432
|
+
this._webSocketRoutes.unshift(new import_network.WebSocketRouteHandler(this._browserContext._options.baseURL, url, handler));
|
|
483
433
|
await this._updateWebSocketInterceptionPatterns();
|
|
484
434
|
}
|
|
485
435
|
_disposeHarRouters() {
|
|
486
|
-
this._harRouters.forEach(router => router.dispose());
|
|
436
|
+
this._harRouters.forEach((router) => router.dispose());
|
|
487
437
|
this._harRouters = [];
|
|
488
438
|
}
|
|
489
439
|
async unrouteAll(options) {
|
|
490
|
-
await this._unrouteInternal(this._routes, [], options
|
|
440
|
+
await this._unrouteInternal(this._routes, [], options?.behavior);
|
|
491
441
|
this._disposeHarRouters();
|
|
492
442
|
}
|
|
493
443
|
async unroute(url, handler) {
|
|
494
444
|
const removed = [];
|
|
495
445
|
const remaining = [];
|
|
496
446
|
for (const route of this._routes) {
|
|
497
|
-
if ((0,
|
|
447
|
+
if ((0, import_urlMatch.urlMatchesEqual)(route.url, url) && (!handler || route.handler === handler))
|
|
448
|
+
removed.push(route);
|
|
449
|
+
else
|
|
450
|
+
remaining.push(route);
|
|
498
451
|
}
|
|
499
|
-
await this._unrouteInternal(removed, remaining,
|
|
452
|
+
await this._unrouteInternal(removed, remaining, "default");
|
|
500
453
|
}
|
|
501
454
|
async _unrouteInternal(removed, remaining, behavior) {
|
|
502
455
|
this._routes = remaining;
|
|
503
456
|
await this._updateInterceptionPatterns();
|
|
504
|
-
if (!behavior || behavior ===
|
|
505
|
-
|
|
457
|
+
if (!behavior || behavior === "default")
|
|
458
|
+
return;
|
|
459
|
+
const promises = removed.map((routeHandler) => routeHandler.stop(behavior));
|
|
506
460
|
await Promise.all(promises);
|
|
507
461
|
}
|
|
508
462
|
async _updateInterceptionPatterns() {
|
|
509
|
-
const patterns =
|
|
510
|
-
await this._channel.setNetworkInterceptionPatterns({
|
|
511
|
-
patterns
|
|
512
|
-
});
|
|
463
|
+
const patterns = import_network.RouteHandler.prepareInterceptionPatterns(this._routes);
|
|
464
|
+
await this._channel.setNetworkInterceptionPatterns({ patterns });
|
|
513
465
|
}
|
|
514
466
|
async _updateWebSocketInterceptionPatterns() {
|
|
515
|
-
const patterns =
|
|
516
|
-
await this._channel.setWebSocketInterceptionPatterns({
|
|
517
|
-
patterns
|
|
518
|
-
});
|
|
467
|
+
const patterns = import_network.WebSocketRouteHandler.prepareInterceptionPatterns(this._webSocketRoutes);
|
|
468
|
+
await this._channel.setWebSocketInterceptionPatterns({ patterns });
|
|
519
469
|
}
|
|
520
470
|
async screenshot(options = {}) {
|
|
521
471
|
const mask = options.mask;
|
|
522
|
-
const copy = {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
};
|
|
526
|
-
if (!copy.type) copy.type = (0, _elementHandle.determineScreenshotType)(options);
|
|
472
|
+
const copy = { ...options, mask: void 0 };
|
|
473
|
+
if (!copy.type)
|
|
474
|
+
copy.type = (0, import_elementHandle.determineScreenshotType)(options);
|
|
527
475
|
if (mask) {
|
|
528
|
-
copy.mask = mask.map(locator => ({
|
|
476
|
+
copy.mask = mask.map((locator) => ({
|
|
529
477
|
frame: locator._frame._channel,
|
|
530
478
|
selector: locator._selector
|
|
531
479
|
}));
|
|
532
480
|
}
|
|
533
481
|
const result = await this._channel.screenshot(copy);
|
|
534
482
|
if (options.path) {
|
|
535
|
-
await (0,
|
|
483
|
+
await (0, import_fileUtils.mkdirIfNeeded)(this._platform, options.path);
|
|
536
484
|
await this._platform.fs().promises.writeFile(options.path, result.binary);
|
|
537
485
|
}
|
|
538
486
|
return result.binary;
|
|
539
487
|
}
|
|
540
488
|
async _expectScreenshot(options) {
|
|
541
|
-
const mask = options
|
|
542
|
-
frame:
|
|
543
|
-
selector:
|
|
544
|
-
})) :
|
|
489
|
+
const mask = options?.mask ? options?.mask.map((locator2) => ({
|
|
490
|
+
frame: locator2._frame._channel,
|
|
491
|
+
selector: locator2._selector
|
|
492
|
+
})) : void 0;
|
|
545
493
|
const locator = options.locator ? {
|
|
546
494
|
frame: options.locator._frame._channel,
|
|
547
495
|
selector: options.locator._selector
|
|
548
|
-
} :
|
|
496
|
+
} : void 0;
|
|
549
497
|
return await this._channel.expectScreenshot({
|
|
550
498
|
...options,
|
|
551
499
|
isNot: !!options.isNot,
|
|
@@ -566,9 +514,13 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
566
514
|
this._closeReason = options.reason;
|
|
567
515
|
this._closeWasCalled = true;
|
|
568
516
|
try {
|
|
569
|
-
if (this._ownedContext)
|
|
517
|
+
if (this._ownedContext)
|
|
518
|
+
await this._ownedContext.close();
|
|
519
|
+
else
|
|
520
|
+
await this._channel.close(options);
|
|
570
521
|
} catch (e) {
|
|
571
|
-
if ((0,
|
|
522
|
+
if ((0, import_errors.isTargetClosedError)(e) && !options.runBeforeUnload)
|
|
523
|
+
return;
|
|
572
524
|
throw e;
|
|
573
525
|
}
|
|
574
526
|
}
|
|
@@ -687,51 +639,45 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
687
639
|
return [...this._workers];
|
|
688
640
|
}
|
|
689
641
|
async pause(_options) {
|
|
690
|
-
|
|
691
|
-
|
|
642
|
+
if (this._platform.isJSDebuggerAttached())
|
|
643
|
+
return;
|
|
692
644
|
const defaultNavigationTimeout = this._browserContext._timeoutSettings.defaultNavigationTimeout();
|
|
693
645
|
const defaultTimeout = this._browserContext._timeoutSettings.defaultTimeout();
|
|
694
646
|
this._browserContext.setDefaultNavigationTimeout(0);
|
|
695
647
|
this._browserContext.setDefaultTimeout(0);
|
|
696
|
-
|
|
697
|
-
keepTestTimeout: !!(_options !== null && _options !== void 0 && _options.__testHookKeepTestTimeout)
|
|
698
|
-
});
|
|
648
|
+
this._instrumentation?.onWillPause({ keepTestTimeout: !!_options?.__testHookKeepTestTimeout });
|
|
699
649
|
await this._closedOrCrashedScope.safeRace(this.context()._channel.pause());
|
|
700
650
|
this._browserContext.setDefaultNavigationTimeout(defaultNavigationTimeout);
|
|
701
651
|
this._browserContext.setDefaultTimeout(defaultTimeout);
|
|
702
652
|
}
|
|
703
653
|
async pdf(options = {}) {
|
|
704
|
-
const transportOptions = {
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
if (
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
for (const margin of ['top', 'right', 'bottom', 'left']) {
|
|
654
|
+
const transportOptions = { ...options };
|
|
655
|
+
if (transportOptions.margin)
|
|
656
|
+
transportOptions.margin = { ...transportOptions.margin };
|
|
657
|
+
if (typeof options.width === "number")
|
|
658
|
+
transportOptions.width = options.width + "px";
|
|
659
|
+
if (typeof options.height === "number")
|
|
660
|
+
transportOptions.height = options.height + "px";
|
|
661
|
+
for (const margin of ["top", "right", "bottom", "left"]) {
|
|
713
662
|
const index = margin;
|
|
714
|
-
if (options.margin && typeof options.margin[index] ===
|
|
663
|
+
if (options.margin && typeof options.margin[index] === "number")
|
|
664
|
+
transportOptions.margin[index] = transportOptions.margin[index] + "px";
|
|
715
665
|
}
|
|
716
666
|
const result = await this._channel.pdf(transportOptions);
|
|
717
667
|
if (options.path) {
|
|
718
668
|
const platform = this._platform;
|
|
719
|
-
await platform.fs().promises.mkdir(platform.path().dirname(options.path), {
|
|
720
|
-
recursive: true
|
|
721
|
-
});
|
|
669
|
+
await platform.fs().promises.mkdir(platform.path().dirname(options.path), { recursive: true });
|
|
722
670
|
await platform.fs().promises.writeFile(options.path, result.pdf);
|
|
723
671
|
}
|
|
724
672
|
return result.pdf;
|
|
725
673
|
}
|
|
726
674
|
async installInjectRoute() {
|
|
727
675
|
if (this.routeInjecting || this.context().routeInjecting) return;
|
|
728
|
-
await this.route(
|
|
676
|
+
await this.route("**/*", async (route) => {
|
|
729
677
|
try {
|
|
730
|
-
if (route.request().resourceType() ===
|
|
731
|
-
const protocol = route.request().url().split(
|
|
732
|
-
await route.continue({
|
|
733
|
-
url: protocol + '://patchright-init-script-inject.internal/'
|
|
734
|
-
});
|
|
678
|
+
if (route.request().resourceType() === "document" && route.request().url().startsWith("http")) {
|
|
679
|
+
const protocol = route.request().url().split(":")[0];
|
|
680
|
+
await route.continue({ url: protocol + "://patchright-init-script-inject.internal/" });
|
|
735
681
|
} else {
|
|
736
682
|
await route.continue();
|
|
737
683
|
}
|
|
@@ -741,8 +687,7 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
741
687
|
});
|
|
742
688
|
}
|
|
743
689
|
}
|
|
744
|
-
|
|
745
|
-
class BindingCall extends _channelOwner.ChannelOwner {
|
|
690
|
+
class BindingCall extends import_channelOwner.ChannelOwner {
|
|
746
691
|
static from(channel) {
|
|
747
692
|
return channel._object;
|
|
748
693
|
}
|
|
@@ -751,26 +696,33 @@ class BindingCall extends _channelOwner.ChannelOwner {
|
|
|
751
696
|
}
|
|
752
697
|
async call(func) {
|
|
753
698
|
try {
|
|
754
|
-
const frame =
|
|
699
|
+
const frame = import_frame.Frame.from(this._initializer.frame);
|
|
755
700
|
const source = {
|
|
756
701
|
context: frame._page.context(),
|
|
757
702
|
page: frame._page,
|
|
758
703
|
frame
|
|
759
704
|
};
|
|
760
705
|
let result;
|
|
761
|
-
if (this._initializer.handle)
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
706
|
+
if (this._initializer.handle)
|
|
707
|
+
result = await func(source, import_jsHandle.JSHandle.from(this._initializer.handle));
|
|
708
|
+
else
|
|
709
|
+
result = await func(source, ...this._initializer.args.map(import_jsHandle.parseResult));
|
|
710
|
+
this._channel.resolve({ result: (0, import_jsHandle.serializeArgument)(result) }).catch(() => {
|
|
711
|
+
});
|
|
765
712
|
} catch (e) {
|
|
766
|
-
this._channel.reject({
|
|
767
|
-
|
|
768
|
-
}).catch(() => {});
|
|
713
|
+
this._channel.reject({ error: (0, import_errors.serializeError)(e) }).catch(() => {
|
|
714
|
+
});
|
|
769
715
|
}
|
|
770
716
|
}
|
|
771
717
|
}
|
|
772
|
-
exports.BindingCall = BindingCall;
|
|
773
718
|
function trimUrl(param) {
|
|
774
|
-
if ((0,
|
|
775
|
-
|
|
776
|
-
|
|
719
|
+
if ((0, import_rtti.isRegExp)(param))
|
|
720
|
+
return `/${(0, import_stringUtils.trimStringWithEllipsis)(param.source, 50)}/${param.flags}`;
|
|
721
|
+
if ((0, import_rtti.isString)(param))
|
|
722
|
+
return `"${(0, import_stringUtils.trimStringWithEllipsis)(param, 50)}"`;
|
|
723
|
+
}
|
|
724
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
725
|
+
0 && (module.exports = {
|
|
726
|
+
BindingCall,
|
|
727
|
+
Page
|
|
728
|
+
});
|