patchright-core 1.51.3 → 1.52.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/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 +54 -69
- 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 +375 -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 +77 -111
- package/lib/server/frames.js +730 -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 +329 -426
- 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 +90 -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-DVQi6prl.js} +1 -1
- package/lib/vite/recorder/assets/index-97EUAAbk.js +184 -0
- package/lib/vite/recorder/index.html +1 -1
- package/lib/vite/traceViewer/assets/{codeMirrorModule-1DiydmYA.js → codeMirrorModule-dvXVzLxY.js} +1 -1
- package/lib/vite/traceViewer/assets/defaultSettingsView-BjymbO6M.js +265 -0
- package/lib/vite/traceViewer/{defaultSettingsView.5fN5lw10.css → defaultSettingsView.QdHITyLI.css} +1 -1
- package/lib/vite/traceViewer/index.ChIUCJnj.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.html +3 -3
- package/lib/vite/traceViewer/uiMode.jUCiCtdp.js +5 -0
- 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
|
@@ -1,95 +1,118 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty
|
|
4
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var ffPage_exports = {};
|
|
30
|
+
__export(ffPage_exports, {
|
|
31
|
+
FFPage: () => FFPage,
|
|
32
|
+
UTILITY_WORLD_NAME: () => UTILITY_WORLD_NAME
|
|
5
33
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var dialog =
|
|
9
|
-
var dom =
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Copyright 2019 Google Inc. All rights reserved.
|
|
24
|
-
* Modifications copyright (c) Microsoft Corporation.
|
|
25
|
-
*
|
|
26
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
27
|
-
* you may not use this file except in compliance with the License.
|
|
28
|
-
* You may obtain a copy of the License at
|
|
29
|
-
*
|
|
30
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
31
|
-
*
|
|
32
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
33
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
34
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
35
|
-
* See the License for the specific language governing permissions and
|
|
36
|
-
* limitations under the License.
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
const UTILITY_WORLD_NAME = exports.UTILITY_WORLD_NAME = '__playwright_utility_world__';
|
|
34
|
+
module.exports = __toCommonJS(ffPage_exports);
|
|
35
|
+
var import_eventsHelper = require("../utils/eventsHelper");
|
|
36
|
+
var dialog = __toESM(require("../dialog"));
|
|
37
|
+
var dom = __toESM(require("../dom"));
|
|
38
|
+
var import_page = require("../page");
|
|
39
|
+
var import_page2 = require("../page");
|
|
40
|
+
var import_ffAccessibility = require("./ffAccessibility");
|
|
41
|
+
var import_ffConnection = require("./ffConnection");
|
|
42
|
+
var import_ffExecutionContext = require("./ffExecutionContext");
|
|
43
|
+
var import_ffInput = require("./ffInput");
|
|
44
|
+
var import_ffNetworkManager = require("./ffNetworkManager");
|
|
45
|
+
var import_debugLogger = require("../utils/debugLogger");
|
|
46
|
+
var import_stackTrace = require("../../utils/isomorphic/stackTrace");
|
|
47
|
+
var import_browserContext = require("../browserContext");
|
|
48
|
+
var import_errors = require("../errors");
|
|
49
|
+
const UTILITY_WORLD_NAME = "__playwright_utility_world__";
|
|
40
50
|
class FFPage {
|
|
41
51
|
constructor(session, browserContext, opener) {
|
|
42
52
|
this.cspErrorsAsynchronousForInlineScripts = true;
|
|
43
|
-
this.rawMouse = void 0;
|
|
44
|
-
this.rawKeyboard = void 0;
|
|
45
|
-
this.rawTouchscreen = void 0;
|
|
46
|
-
this._session = void 0;
|
|
47
|
-
this._page = void 0;
|
|
48
|
-
this._networkManager = void 0;
|
|
49
|
-
this._browserContext = void 0;
|
|
50
53
|
this._reportedAsNew = false;
|
|
51
|
-
this.
|
|
52
|
-
this._contextIdToContext = void 0;
|
|
53
|
-
this._eventListeners = void 0;
|
|
54
|
-
this._workers = new Map();
|
|
55
|
-
this._screencastId = void 0;
|
|
54
|
+
this._workers = /* @__PURE__ */ new Map();
|
|
56
55
|
this._initScripts = [];
|
|
57
56
|
this._session = session;
|
|
58
57
|
this._opener = opener;
|
|
59
|
-
this.rawKeyboard = new
|
|
60
|
-
this.rawMouse = new
|
|
61
|
-
this.rawTouchscreen = new
|
|
62
|
-
this._contextIdToContext = new Map();
|
|
58
|
+
this.rawKeyboard = new import_ffInput.RawKeyboardImpl(session);
|
|
59
|
+
this.rawMouse = new import_ffInput.RawMouseImpl(session);
|
|
60
|
+
this.rawTouchscreen = new import_ffInput.RawTouchscreenImpl(session);
|
|
61
|
+
this._contextIdToContext = /* @__PURE__ */ new Map();
|
|
63
62
|
this._browserContext = browserContext;
|
|
64
|
-
this._page = new
|
|
63
|
+
this._page = new import_page2.Page(this, browserContext);
|
|
65
64
|
this.rawMouse.setPage(this._page);
|
|
66
|
-
this._networkManager = new
|
|
67
|
-
this._page.on(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
this._networkManager = new import_ffNetworkManager.FFNetworkManager(session, this._page);
|
|
66
|
+
this._page.on(import_page2.Page.Events.FrameDetached, (frame) => this._removeContextsForFrame(frame));
|
|
67
|
+
this._eventListeners = [
|
|
68
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.eventFired", this._onEventFired.bind(this)),
|
|
69
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.frameAttached", this._onFrameAttached.bind(this)),
|
|
70
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.frameDetached", this._onFrameDetached.bind(this)),
|
|
71
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.navigationAborted", this._onNavigationAborted.bind(this)),
|
|
72
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.navigationCommitted", this._onNavigationCommitted.bind(this)),
|
|
73
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.navigationStarted", this._onNavigationStarted.bind(this)),
|
|
74
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.sameDocumentNavigation", this._onSameDocumentNavigation.bind(this)),
|
|
75
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Runtime.executionContextCreated", this._onExecutionContextCreated.bind(this)),
|
|
76
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Runtime.executionContextDestroyed", this._onExecutionContextDestroyed.bind(this)),
|
|
77
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Runtime.executionContextsCleared", this._onExecutionContextsCleared.bind(this)),
|
|
78
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.linkClicked", (event) => this._onLinkClicked(event.phase)),
|
|
79
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.uncaughtError", this._onUncaughtError.bind(this)),
|
|
80
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Runtime.console", this._onConsole.bind(this)),
|
|
81
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.dialogOpened", this._onDialogOpened.bind(this)),
|
|
82
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.bindingCalled", this._onBindingCalled.bind(this)),
|
|
83
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.fileChooserOpened", this._onFileChooserOpened.bind(this)),
|
|
84
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.workerCreated", this._onWorkerCreated.bind(this)),
|
|
85
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.workerDestroyed", this._onWorkerDestroyed.bind(this)),
|
|
86
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.dispatchMessageFromWorker", this._onDispatchMessageFromWorker.bind(this)),
|
|
87
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.crashed", this._onCrashed.bind(this)),
|
|
88
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.videoRecordingStarted", this._onVideoRecordingStarted.bind(this)),
|
|
89
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.webSocketCreated", this._onWebSocketCreated.bind(this)),
|
|
90
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.webSocketClosed", this._onWebSocketClosed.bind(this)),
|
|
91
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.webSocketFrameReceived", this._onWebSocketFrameReceived.bind(this)),
|
|
92
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.webSocketFrameSent", this._onWebSocketFrameSent.bind(this)),
|
|
93
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.screencastFrame", this._onScreencastFrame.bind(this))
|
|
94
|
+
];
|
|
95
|
+
this._session.once("Page.ready", () => {
|
|
96
|
+
if (this._reportedAsNew)
|
|
97
|
+
return;
|
|
73
98
|
this._reportedAsNew = true;
|
|
74
|
-
this._page.reportAsNew(
|
|
99
|
+
this._page.reportAsNew(this._opener?._page);
|
|
75
100
|
});
|
|
76
|
-
|
|
77
|
-
// Therefore, we can end up with an initialized page without utility world, although very unlikely.
|
|
78
|
-
this.addInitScript(new _page.InitScript('', true), UTILITY_WORLD_NAME).catch(e => this._markAsError(e));
|
|
101
|
+
this.addInitScript(new import_page.InitScript("", true), UTILITY_WORLD_NAME).catch((e) => this._markAsError(e));
|
|
79
102
|
}
|
|
80
103
|
async _markAsError(error) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (this._reportedAsNew) return;
|
|
104
|
+
if (this._reportedAsNew)
|
|
105
|
+
return;
|
|
84
106
|
this._reportedAsNew = true;
|
|
85
|
-
this._page.reportAsNew(
|
|
107
|
+
this._page.reportAsNew(this._opener?._page, error);
|
|
86
108
|
}
|
|
87
109
|
_onWebSocketCreated(event) {
|
|
88
110
|
this._page._frameManager.onWebSocketCreated(webSocketId(event.frameId, event.wsid), event.requestURL);
|
|
89
111
|
this._page._frameManager.onWebSocketRequest(webSocketId(event.frameId, event.wsid));
|
|
90
112
|
}
|
|
91
113
|
_onWebSocketClosed(event) {
|
|
92
|
-
if (event.error)
|
|
114
|
+
if (event.error)
|
|
115
|
+
this._page._frameManager.webSocketError(webSocketId(event.frameId, event.wsid), event.error);
|
|
93
116
|
this._page._frameManager.webSocketClosed(webSocketId(event.frameId, event.wsid));
|
|
94
117
|
}
|
|
95
118
|
_onWebSocketFrameReceived(event) {
|
|
@@ -99,40 +122,44 @@ class FFPage {
|
|
|
99
122
|
this._page._frameManager.onWebSocketFrameSent(webSocketId(event.frameId, event.wsid), event.opcode, event.data);
|
|
100
123
|
}
|
|
101
124
|
_onExecutionContextCreated(payload) {
|
|
102
|
-
const {
|
|
103
|
-
executionContextId,
|
|
104
|
-
auxData
|
|
105
|
-
} = payload;
|
|
125
|
+
const { executionContextId, auxData } = payload;
|
|
106
126
|
const frame = this._page._frameManager.frame(auxData.frameId);
|
|
107
|
-
if (!frame)
|
|
108
|
-
|
|
127
|
+
if (!frame)
|
|
128
|
+
return;
|
|
129
|
+
const delegate = new import_ffExecutionContext.FFExecutionContext(this._session, executionContextId);
|
|
109
130
|
let worldName = null;
|
|
110
|
-
if (auxData.name === UTILITY_WORLD_NAME)
|
|
131
|
+
if (auxData.name === UTILITY_WORLD_NAME)
|
|
132
|
+
worldName = "utility";
|
|
133
|
+
else if (!auxData.name)
|
|
134
|
+
worldName = "main";
|
|
111
135
|
const context = new dom.FrameExecutionContext(delegate, frame, worldName);
|
|
112
|
-
if (worldName)
|
|
136
|
+
if (worldName)
|
|
137
|
+
frame._contextCreated(worldName, context);
|
|
113
138
|
this._contextIdToContext.set(executionContextId, context);
|
|
114
139
|
}
|
|
115
140
|
_onExecutionContextDestroyed(payload) {
|
|
116
|
-
const {
|
|
117
|
-
executionContextId
|
|
118
|
-
} = payload;
|
|
141
|
+
const { executionContextId } = payload;
|
|
119
142
|
const context = this._contextIdToContext.get(executionContextId);
|
|
120
|
-
if (!context)
|
|
143
|
+
if (!context)
|
|
144
|
+
return;
|
|
121
145
|
this._contextIdToContext.delete(executionContextId);
|
|
122
146
|
context.frame._contextDestroyed(context);
|
|
123
147
|
}
|
|
124
148
|
_onExecutionContextsCleared() {
|
|
125
|
-
for (const executionContextId of Array.from(this._contextIdToContext.keys()))
|
|
126
|
-
executionContextId
|
|
127
|
-
});
|
|
149
|
+
for (const executionContextId of Array.from(this._contextIdToContext.keys()))
|
|
150
|
+
this._onExecutionContextDestroyed({ executionContextId });
|
|
128
151
|
}
|
|
129
152
|
_removeContextsForFrame(frame) {
|
|
130
153
|
for (const [contextId, context] of this._contextIdToContext) {
|
|
131
|
-
if (context.frame === frame)
|
|
154
|
+
if (context.frame === frame)
|
|
155
|
+
this._contextIdToContext.delete(contextId);
|
|
132
156
|
}
|
|
133
157
|
}
|
|
134
158
|
_onLinkClicked(phase) {
|
|
135
|
-
if (phase ===
|
|
159
|
+
if (phase === "before")
|
|
160
|
+
this._page._frameManager.frameWillPotentiallyRequestNavigation();
|
|
161
|
+
else
|
|
162
|
+
this._page._frameManager.frameDidPotentiallyRequestNavigation();
|
|
136
163
|
}
|
|
137
164
|
_onNavigationStarted(params) {
|
|
138
165
|
this._page._frameManager.frameRequestedNavigation(params.frameId, params.navigationId);
|
|
@@ -142,11 +169,10 @@ class FFPage {
|
|
|
142
169
|
}
|
|
143
170
|
_onNavigationCommitted(params) {
|
|
144
171
|
for (const [workerId, worker] of this._workers) {
|
|
145
|
-
if (worker.frameId === params.frameId)
|
|
146
|
-
workerId
|
|
147
|
-
});
|
|
172
|
+
if (worker.frameId === params.frameId)
|
|
173
|
+
this._onWorkerDestroyed({ workerId });
|
|
148
174
|
}
|
|
149
|
-
this._page._frameManager.frameCommittedNewDocumentNavigation(params.frameId, params.url, params.name ||
|
|
175
|
+
this._page._frameManager.frameCommittedNewDocumentNavigation(params.frameId, params.url, params.name || "", params.navigationId || "", false);
|
|
150
176
|
}
|
|
151
177
|
_onSameDocumentNavigation(params) {
|
|
152
178
|
this._page._frameManager.frameCommittedSameDocumentNavigation(params.frameId, params.url);
|
|
@@ -158,111 +184,89 @@ class FFPage {
|
|
|
158
184
|
this._page._frameManager.frameDetached(params.frameId);
|
|
159
185
|
}
|
|
160
186
|
_onEventFired(payload) {
|
|
161
|
-
const {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if (name === 'DOMContentLoaded') this._page._frameManager.frameLifecycleEvent(frameId, 'domcontentloaded');
|
|
187
|
+
const { frameId, name } = payload;
|
|
188
|
+
if (name === "load")
|
|
189
|
+
this._page._frameManager.frameLifecycleEvent(frameId, "load");
|
|
190
|
+
if (name === "DOMContentLoaded")
|
|
191
|
+
this._page._frameManager.frameLifecycleEvent(frameId, "domcontentloaded");
|
|
167
192
|
}
|
|
168
193
|
_onUncaughtError(params) {
|
|
169
|
-
const {
|
|
170
|
-
name,
|
|
171
|
-
message
|
|
172
|
-
} = (0, _stackTrace.splitErrorMessage)(params.message);
|
|
194
|
+
const { name, message } = (0, import_stackTrace.splitErrorMessage)(params.message);
|
|
173
195
|
const error = new Error(message);
|
|
174
|
-
error.stack = params.message +
|
|
196
|
+
error.stack = params.message + "\n" + params.stack.split("\n").filter(Boolean).map((a) => a.replace(/([^@]*)@(.*)/, " at $1 ($2)")).join("\n");
|
|
175
197
|
error.name = name;
|
|
176
|
-
this._page.emitOnContextOnceInitialized(
|
|
198
|
+
this._page.emitOnContextOnceInitialized(import_browserContext.BrowserContext.Events.PageError, error, this._page);
|
|
177
199
|
}
|
|
178
200
|
_onConsole(payload) {
|
|
179
|
-
const {
|
|
180
|
-
type,
|
|
181
|
-
args,
|
|
182
|
-
executionContextId,
|
|
183
|
-
location
|
|
184
|
-
} = payload;
|
|
201
|
+
const { type, args, executionContextId, location } = payload;
|
|
185
202
|
const context = this._contextIdToContext.get(executionContextId);
|
|
186
|
-
if (!context)
|
|
187
|
-
|
|
188
|
-
this._page._addConsoleMessage(type ===
|
|
203
|
+
if (!context)
|
|
204
|
+
return;
|
|
205
|
+
this._page._addConsoleMessage(type === "warn" ? "warning" : type, args.map((arg) => (0, import_ffExecutionContext.createHandle)(context, arg)), location);
|
|
189
206
|
}
|
|
190
207
|
_onDialogOpened(params) {
|
|
191
|
-
this._page.emitOnContext(
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
208
|
+
this._page.emitOnContext(import_browserContext.BrowserContext.Events.Dialog, new dialog.Dialog(
|
|
209
|
+
this._page,
|
|
210
|
+
params.type,
|
|
211
|
+
params.message,
|
|
212
|
+
async (accept, promptText) => {
|
|
213
|
+
await this._session.sendMayFail("Page.handleDialog", { dialogId: params.dialogId, accept, promptText });
|
|
214
|
+
},
|
|
215
|
+
params.defaultValue
|
|
216
|
+
));
|
|
198
217
|
}
|
|
199
218
|
async _onBindingCalled(event) {
|
|
200
219
|
const pageOrError = await this._page.waitForInitializedOrError();
|
|
201
220
|
if (!(pageOrError instanceof Error)) {
|
|
202
221
|
const context = this._contextIdToContext.get(event.executionContextId);
|
|
203
|
-
if (context)
|
|
222
|
+
if (context)
|
|
223
|
+
await this._page._onBindingCalled(event.payload, context);
|
|
204
224
|
}
|
|
205
225
|
}
|
|
206
226
|
async _onFileChooserOpened(payload) {
|
|
207
|
-
const {
|
|
208
|
-
executionContextId,
|
|
209
|
-
element
|
|
210
|
-
} = payload;
|
|
227
|
+
const { executionContextId, element } = payload;
|
|
211
228
|
const context = this._contextIdToContext.get(executionContextId);
|
|
212
|
-
if (!context)
|
|
213
|
-
|
|
229
|
+
if (!context)
|
|
230
|
+
return;
|
|
231
|
+
const handle = (0, import_ffExecutionContext.createHandle)(context, element).asElement();
|
|
214
232
|
await this._page._onFileChooserOpened(handle);
|
|
215
233
|
}
|
|
216
234
|
async _onWorkerCreated(event) {
|
|
217
235
|
const workerId = event.workerId;
|
|
218
|
-
const worker = new
|
|
219
|
-
const workerSession = new
|
|
220
|
-
this._session.send(
|
|
236
|
+
const worker = new import_page2.Worker(this._page, event.url);
|
|
237
|
+
const workerSession = new import_ffConnection.FFSession(this._session._connection, workerId, (message) => {
|
|
238
|
+
this._session.send("Page.sendMessageToWorker", {
|
|
221
239
|
frameId: event.frameId,
|
|
222
|
-
workerId
|
|
240
|
+
workerId,
|
|
223
241
|
message: JSON.stringify(message)
|
|
224
|
-
}).catch(e => {
|
|
225
|
-
workerSession.dispatchMessage({
|
|
226
|
-
id: message.id,
|
|
227
|
-
method: '',
|
|
228
|
-
params: {},
|
|
229
|
-
error: {
|
|
230
|
-
message: e.message,
|
|
231
|
-
data: undefined
|
|
232
|
-
}
|
|
233
|
-
});
|
|
242
|
+
}).catch((e) => {
|
|
243
|
+
workerSession.dispatchMessage({ id: message.id, method: "", params: {}, error: { message: e.message, data: void 0 } });
|
|
234
244
|
});
|
|
235
245
|
});
|
|
236
|
-
this._workers.set(workerId, {
|
|
237
|
-
session: workerSession,
|
|
238
|
-
frameId: event.frameId
|
|
239
|
-
});
|
|
246
|
+
this._workers.set(workerId, { session: workerSession, frameId: event.frameId });
|
|
240
247
|
this._page._addWorker(workerId, worker);
|
|
241
|
-
workerSession.once(
|
|
242
|
-
worker._createExecutionContext(new
|
|
248
|
+
workerSession.once("Runtime.executionContextCreated", (event2) => {
|
|
249
|
+
worker._createExecutionContext(new import_ffExecutionContext.FFExecutionContext(workerSession, event2.executionContextId));
|
|
243
250
|
});
|
|
244
|
-
workerSession.on(
|
|
245
|
-
const {
|
|
246
|
-
type,
|
|
247
|
-
args,
|
|
248
|
-
location
|
|
249
|
-
} = event;
|
|
251
|
+
workerSession.on("Runtime.console", (event2) => {
|
|
252
|
+
const { type, args, location } = event2;
|
|
250
253
|
const context = worker._existingExecutionContext;
|
|
251
|
-
this._page._addConsoleMessage(type, args.map(arg => (0,
|
|
254
|
+
this._page._addConsoleMessage(type, args.map((arg) => (0, import_ffExecutionContext.createHandle)(context, arg)), location);
|
|
252
255
|
});
|
|
253
|
-
// Note: we receive worker exceptions directly from the page.
|
|
254
256
|
}
|
|
255
257
|
_onWorkerDestroyed(event) {
|
|
256
258
|
const workerId = event.workerId;
|
|
257
259
|
const worker = this._workers.get(workerId);
|
|
258
|
-
if (!worker)
|
|
260
|
+
if (!worker)
|
|
261
|
+
return;
|
|
259
262
|
worker.session.dispose();
|
|
260
263
|
this._workers.delete(workerId);
|
|
261
264
|
this._page._removeWorker(workerId);
|
|
262
265
|
}
|
|
263
266
|
async _onDispatchMessageFromWorker(event) {
|
|
264
267
|
const worker = this._workers.get(event.workerId);
|
|
265
|
-
if (!worker)
|
|
268
|
+
if (!worker)
|
|
269
|
+
return;
|
|
266
270
|
worker.session.dispatchMessage(JSON.parse(event.message));
|
|
267
271
|
}
|
|
268
272
|
async _onCrashed(event) {
|
|
@@ -273,45 +277,35 @@ class FFPage {
|
|
|
273
277
|
this._browserContext._browser._videoStarted(this._browserContext, event.screencastId, event.file, this._page.waitForInitializedOrError());
|
|
274
278
|
}
|
|
275
279
|
didClose() {
|
|
276
|
-
this._markAsError(new
|
|
280
|
+
this._markAsError(new import_errors.TargetClosedError());
|
|
277
281
|
this._session.dispose();
|
|
278
|
-
|
|
282
|
+
import_eventsHelper.eventsHelper.removeEventListeners(this._eventListeners);
|
|
279
283
|
this._networkManager.dispose();
|
|
280
284
|
this._page._didClose();
|
|
281
285
|
}
|
|
282
286
|
async navigateFrame(frame, url, referer) {
|
|
283
|
-
const response = await this._session.send(
|
|
284
|
-
|
|
285
|
-
referer,
|
|
286
|
-
frameId: frame._id
|
|
287
|
-
});
|
|
288
|
-
return {
|
|
289
|
-
newDocumentId: response.navigationId || undefined
|
|
290
|
-
};
|
|
287
|
+
const response = await this._session.send("Page.navigate", { url, referer, frameId: frame._id });
|
|
288
|
+
return { newDocumentId: response.navigationId || void 0 };
|
|
291
289
|
}
|
|
292
290
|
async updateExtraHTTPHeaders() {
|
|
293
|
-
await this._session.send(
|
|
294
|
-
headers: this._page.extraHTTPHeaders() || []
|
|
295
|
-
});
|
|
291
|
+
await this._session.send("Network.setExtraHTTPHeaders", { headers: this._page.extraHTTPHeaders() || [] });
|
|
296
292
|
}
|
|
297
293
|
async updateEmulatedViewportSize() {
|
|
298
294
|
const viewportSize = this._page.viewportSize();
|
|
299
|
-
await this._session.send(
|
|
300
|
-
viewportSize
|
|
301
|
-
});
|
|
295
|
+
await this._session.send("Page.setViewportSize", { viewportSize });
|
|
302
296
|
}
|
|
303
297
|
async bringToFront() {
|
|
304
|
-
await this._session.send(
|
|
298
|
+
await this._session.send("Page.bringToFront", {});
|
|
305
299
|
}
|
|
306
300
|
async updateEmulateMedia() {
|
|
307
301
|
const emulatedMedia = this._page.emulatedMedia();
|
|
308
|
-
const colorScheme = emulatedMedia.colorScheme ===
|
|
309
|
-
const reducedMotion = emulatedMedia.reducedMotion ===
|
|
310
|
-
const forcedColors = emulatedMedia.forcedColors ===
|
|
311
|
-
const contrast = emulatedMedia.contrast ===
|
|
312
|
-
await this._session.send(
|
|
302
|
+
const colorScheme = emulatedMedia.colorScheme === "no-override" ? void 0 : emulatedMedia.colorScheme;
|
|
303
|
+
const reducedMotion = emulatedMedia.reducedMotion === "no-override" ? void 0 : emulatedMedia.reducedMotion;
|
|
304
|
+
const forcedColors = emulatedMedia.forcedColors === "no-override" ? void 0 : emulatedMedia.forcedColors;
|
|
305
|
+
const contrast = emulatedMedia.contrast === "no-override" ? void 0 : emulatedMedia.contrast;
|
|
306
|
+
await this._session.send("Page.setEmulatedMedia", {
|
|
313
307
|
// Empty string means reset.
|
|
314
|
-
type: emulatedMedia.media ===
|
|
308
|
+
type: emulatedMedia.media === "no-override" ? "" : emulatedMedia.media,
|
|
315
309
|
colorScheme,
|
|
316
310
|
reducedMotion,
|
|
317
311
|
forcedColors,
|
|
@@ -323,67 +317,41 @@ class FFPage {
|
|
|
323
317
|
}
|
|
324
318
|
async updateFileChooserInterception() {
|
|
325
319
|
const enabled = this._page.fileChooserIntercepted();
|
|
326
|
-
await this._session.send(
|
|
327
|
-
|
|
328
|
-
}).catch(() => {}); // target can be closed.
|
|
320
|
+
await this._session.send("Page.setInterceptFileChooserDialog", { enabled }).catch(() => {
|
|
321
|
+
});
|
|
329
322
|
}
|
|
330
323
|
async reload() {
|
|
331
|
-
await this._session.send(
|
|
324
|
+
await this._session.send("Page.reload");
|
|
332
325
|
}
|
|
333
326
|
async goBack() {
|
|
334
|
-
const {
|
|
335
|
-
success
|
|
336
|
-
} = await this._session.send('Page.goBack', {
|
|
337
|
-
frameId: this._page.mainFrame()._id
|
|
338
|
-
});
|
|
327
|
+
const { success } = await this._session.send("Page.goBack", { frameId: this._page.mainFrame()._id });
|
|
339
328
|
return success;
|
|
340
329
|
}
|
|
341
330
|
async goForward() {
|
|
342
|
-
const {
|
|
343
|
-
success
|
|
344
|
-
} = await this._session.send('Page.goForward', {
|
|
345
|
-
frameId: this._page.mainFrame()._id
|
|
346
|
-
});
|
|
331
|
+
const { success } = await this._session.send("Page.goForward", { frameId: this._page.mainFrame()._id });
|
|
347
332
|
return success;
|
|
348
333
|
}
|
|
349
334
|
async requestGC() {
|
|
350
|
-
await this._session.send(
|
|
335
|
+
await this._session.send("Heap.collectGarbage");
|
|
351
336
|
}
|
|
352
337
|
async addInitScript(initScript, worldName) {
|
|
353
|
-
this._initScripts.push({
|
|
354
|
-
|
|
355
|
-
worldName
|
|
356
|
-
});
|
|
357
|
-
await this._session.send('Page.setInitScripts', {
|
|
358
|
-
scripts: this._initScripts.map(s => ({
|
|
359
|
-
script: s.initScript.source,
|
|
360
|
-
worldName: s.worldName
|
|
361
|
-
}))
|
|
362
|
-
});
|
|
338
|
+
this._initScripts.push({ initScript, worldName });
|
|
339
|
+
await this._session.send("Page.setInitScripts", { scripts: this._initScripts.map((s) => ({ script: s.initScript.source, worldName: s.worldName })) });
|
|
363
340
|
}
|
|
364
341
|
async removeInitScripts() {
|
|
365
|
-
this._initScripts = this._initScripts.filter(s => s.initScript.internal);
|
|
366
|
-
await this._session.send(
|
|
367
|
-
scripts: this._initScripts.map(s => ({
|
|
368
|
-
script: s.initScript.source,
|
|
369
|
-
worldName: s.worldName
|
|
370
|
-
}))
|
|
371
|
-
});
|
|
342
|
+
this._initScripts = this._initScripts.filter((s) => s.initScript.internal);
|
|
343
|
+
await this._session.send("Page.setInitScripts", { scripts: this._initScripts.map((s) => ({ script: s.initScript.source, worldName: s.worldName })) });
|
|
372
344
|
}
|
|
373
345
|
async closePage(runBeforeUnload) {
|
|
374
|
-
await this._session.send(
|
|
375
|
-
runBeforeUnload
|
|
376
|
-
});
|
|
346
|
+
await this._session.send("Page.close", { runBeforeUnload });
|
|
377
347
|
}
|
|
378
348
|
async setBackgroundColor(color) {
|
|
379
|
-
if (color)
|
|
349
|
+
if (color)
|
|
350
|
+
throw new Error("Not implemented");
|
|
380
351
|
}
|
|
381
352
|
async takeScreenshot(progress, format, documentRect, viewportRect, quality, fitsViewport, scale) {
|
|
382
353
|
if (!documentRect) {
|
|
383
|
-
const scrollOffset = await this._page.mainFrame().waitForFunctionValueInUtility(progress, () => ({
|
|
384
|
-
x: window.scrollX,
|
|
385
|
-
y: window.scrollY
|
|
386
|
-
}));
|
|
354
|
+
const scrollOffset = await this._page.mainFrame().waitForFunctionValueInUtility(progress, () => ({ x: window.scrollX, y: window.scrollY }));
|
|
387
355
|
documentRect = {
|
|
388
356
|
x: viewportRect.x + scrollOffset.x,
|
|
389
357
|
y: viewportRect.y + scrollOffset.y,
|
|
@@ -392,30 +360,25 @@ class FFPage {
|
|
|
392
360
|
};
|
|
393
361
|
}
|
|
394
362
|
progress.throwIfAborted();
|
|
395
|
-
const {
|
|
396
|
-
|
|
397
|
-
} = await this._session.send('Page.screenshot', {
|
|
398
|
-
mimeType: 'image/' + format,
|
|
363
|
+
const { data } = await this._session.send("Page.screenshot", {
|
|
364
|
+
mimeType: "image/" + format,
|
|
399
365
|
clip: documentRect,
|
|
400
366
|
quality,
|
|
401
|
-
omitDeviceScaleFactor: scale ===
|
|
367
|
+
omitDeviceScaleFactor: scale === "css"
|
|
402
368
|
});
|
|
403
|
-
return Buffer.from(data,
|
|
369
|
+
return Buffer.from(data, "base64");
|
|
404
370
|
}
|
|
405
371
|
async getContentFrame(handle) {
|
|
406
|
-
const {
|
|
407
|
-
contentFrameId
|
|
408
|
-
} = await this._session.send('Page.describeNode', {
|
|
372
|
+
const { contentFrameId } = await this._session.send("Page.describeNode", {
|
|
409
373
|
frameId: handle._context.frame._id,
|
|
410
374
|
objectId: handle._objectId
|
|
411
375
|
});
|
|
412
|
-
if (!contentFrameId)
|
|
376
|
+
if (!contentFrameId)
|
|
377
|
+
return null;
|
|
413
378
|
return this._page._frameManager.frame(contentFrameId);
|
|
414
379
|
}
|
|
415
380
|
async getOwnerFrame(handle) {
|
|
416
|
-
const {
|
|
417
|
-
ownerFrameId
|
|
418
|
-
} = await this._session.send('Page.describeNode', {
|
|
381
|
+
const { ownerFrameId } = await this._session.send("Page.describeNode", {
|
|
419
382
|
frameId: handle._context.frame._id,
|
|
420
383
|
objectId: handle._objectId
|
|
421
384
|
});
|
|
@@ -423,7 +386,8 @@ class FFPage {
|
|
|
423
386
|
}
|
|
424
387
|
async getBoundingBox(handle) {
|
|
425
388
|
const quads = await this.getContentQuads(handle);
|
|
426
|
-
if (!quads || !quads.length)
|
|
389
|
+
if (!quads || !quads.length)
|
|
390
|
+
return null;
|
|
427
391
|
let minX = Infinity;
|
|
428
392
|
let maxX = -Infinity;
|
|
429
393
|
let minY = Infinity;
|
|
@@ -436,44 +400,38 @@ class FFPage {
|
|
|
436
400
|
maxY = Math.max(maxY, point.y);
|
|
437
401
|
}
|
|
438
402
|
}
|
|
439
|
-
return {
|
|
440
|
-
x: minX,
|
|
441
|
-
y: minY,
|
|
442
|
-
width: maxX - minX,
|
|
443
|
-
height: maxY - minY
|
|
444
|
-
};
|
|
403
|
+
return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
445
404
|
}
|
|
446
405
|
async scrollRectIntoViewIfNeeded(handle, rect) {
|
|
447
|
-
return await this._session.send(
|
|
406
|
+
return await this._session.send("Page.scrollIntoViewIfNeeded", {
|
|
448
407
|
frameId: handle._context.frame._id,
|
|
449
408
|
objectId: handle._objectId,
|
|
450
409
|
rect
|
|
451
|
-
}).then(() =>
|
|
452
|
-
if (e instanceof Error && e.message.includes(
|
|
453
|
-
|
|
410
|
+
}).then(() => "done").catch((e) => {
|
|
411
|
+
if (e instanceof Error && e.message.includes("Node is detached from document"))
|
|
412
|
+
return "error:notconnected";
|
|
413
|
+
if (e instanceof Error && e.message.includes("Node does not have a layout object"))
|
|
414
|
+
return "error:notvisible";
|
|
454
415
|
throw e;
|
|
455
416
|
});
|
|
456
417
|
}
|
|
457
418
|
async setScreencastOptions(options) {
|
|
458
419
|
if (options) {
|
|
459
|
-
const {
|
|
460
|
-
screencastId
|
|
461
|
-
} = await this._session.send('Page.startScreencast', options);
|
|
420
|
+
const { screencastId } = await this._session.send("Page.startScreencast", options);
|
|
462
421
|
this._screencastId = screencastId;
|
|
463
422
|
} else {
|
|
464
|
-
await this._session.send(
|
|
423
|
+
await this._session.send("Page.stopScreencast");
|
|
465
424
|
}
|
|
466
425
|
}
|
|
467
426
|
_onScreencastFrame(event) {
|
|
468
|
-
if (!this._screencastId)
|
|
427
|
+
if (!this._screencastId)
|
|
428
|
+
return;
|
|
469
429
|
const screencastId = this._screencastId;
|
|
470
430
|
this._page.throttleScreencastFrameAck(() => {
|
|
471
|
-
this._session.send(
|
|
472
|
-
screencastId
|
|
473
|
-
}).catch(e => _debugLogger.debugLogger.log('error', e));
|
|
431
|
+
this._session.send("Page.screencastFrameAck", { screencastId }).catch((e) => import_debugLogger.debugLogger.log("error", e));
|
|
474
432
|
});
|
|
475
|
-
const buffer = Buffer.from(event.data,
|
|
476
|
-
this._page.emit(
|
|
433
|
+
const buffer = Buffer.from(event.data, "base64");
|
|
434
|
+
this._page.emit(import_page2.Page.Events.ScreencastFrame, {
|
|
477
435
|
buffer,
|
|
478
436
|
width: event.deviceWidth,
|
|
479
437
|
height: event.deviceHeight
|
|
@@ -483,56 +441,61 @@ class FFPage {
|
|
|
483
441
|
return 1;
|
|
484
442
|
}
|
|
485
443
|
async getContentQuads(handle) {
|
|
486
|
-
const result = await this._session.sendMayFail(
|
|
444
|
+
const result = await this._session.sendMayFail("Page.getContentQuads", {
|
|
487
445
|
frameId: handle._context.frame._id,
|
|
488
446
|
objectId: handle._objectId
|
|
489
447
|
});
|
|
490
|
-
if (!result)
|
|
491
|
-
|
|
448
|
+
if (!result)
|
|
449
|
+
return null;
|
|
450
|
+
return result.quads.map((quad) => [quad.p1, quad.p2, quad.p3, quad.p4]);
|
|
492
451
|
}
|
|
493
452
|
async setInputFilePaths(handle, files) {
|
|
494
|
-
await this._session.send(
|
|
453
|
+
await this._session.send("Page.setFileInputFiles", {
|
|
495
454
|
frameId: handle._context.frame._id,
|
|
496
455
|
objectId: handle._objectId,
|
|
497
456
|
files
|
|
498
457
|
});
|
|
499
458
|
}
|
|
500
459
|
async adoptElementHandle(handle, to) {
|
|
501
|
-
const result = await this._session.send(
|
|
460
|
+
const result = await this._session.send("Page.adoptNode", {
|
|
502
461
|
frameId: handle._context.frame._id,
|
|
503
462
|
objectId: handle._objectId,
|
|
504
463
|
executionContextId: to.delegate._executionContextId
|
|
505
464
|
});
|
|
506
|
-
if (!result.remoteObject)
|
|
507
|
-
|
|
465
|
+
if (!result.remoteObject)
|
|
466
|
+
throw new Error(dom.kUnableToAdoptErrorMessage);
|
|
467
|
+
return (0, import_ffExecutionContext.createHandle)(to, result.remoteObject);
|
|
508
468
|
}
|
|
509
469
|
async getAccessibilityTree(needle) {
|
|
510
|
-
return (0,
|
|
470
|
+
return (0, import_ffAccessibility.getAccessibilityTree)(this._session, needle);
|
|
471
|
+
}
|
|
472
|
+
async inputActionEpilogue() {
|
|
511
473
|
}
|
|
512
|
-
async inputActionEpilogue() {}
|
|
513
474
|
async resetForReuse() {
|
|
514
|
-
|
|
515
|
-
// which affects things like hovered state.
|
|
516
|
-
// See https://github.com/microsoft/playwright/issues/22432.
|
|
517
|
-
// Move mouse to (-1, -1) to avoid anything being hovered.
|
|
518
|
-
await this.rawMouse.move(-1, -1, 'none', new Set(), new Set(), false);
|
|
475
|
+
await this.rawMouse.move(-1, -1, "none", /* @__PURE__ */ new Set(), /* @__PURE__ */ new Set(), false);
|
|
519
476
|
}
|
|
520
477
|
async getFrameElement(frame) {
|
|
521
478
|
const parent = frame.parentFrame();
|
|
522
|
-
if (!parent)
|
|
479
|
+
if (!parent)
|
|
480
|
+
throw new Error("Frame has been detached.");
|
|
523
481
|
const context = await parent._mainContext();
|
|
524
|
-
const result = await this._session.send(
|
|
482
|
+
const result = await this._session.send("Page.adoptNode", {
|
|
525
483
|
frameId: frame._id,
|
|
526
484
|
executionContextId: context.delegate._executionContextId
|
|
527
485
|
});
|
|
528
|
-
if (!result.remoteObject)
|
|
529
|
-
|
|
486
|
+
if (!result.remoteObject)
|
|
487
|
+
throw new Error("Frame has been detached.");
|
|
488
|
+
return (0, import_ffExecutionContext.createHandle)(context, result.remoteObject);
|
|
530
489
|
}
|
|
531
490
|
shouldToggleStyleSheetToSyncAnimations() {
|
|
532
491
|
return false;
|
|
533
492
|
}
|
|
534
493
|
}
|
|
535
|
-
exports.FFPage = FFPage;
|
|
536
494
|
function webSocketId(frameId, wsid) {
|
|
537
495
|
return `${frameId}---${wsid}`;
|
|
538
|
-
}
|
|
496
|
+
}
|
|
497
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
498
|
+
0 && (module.exports = {
|
|
499
|
+
FFPage,
|
|
500
|
+
UTILITY_WORLD_NAME
|
|
501
|
+
});
|