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,88 +1,99 @@
|
|
|
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 bidiPage_exports = {};
|
|
30
|
+
__export(bidiPage_exports, {
|
|
31
|
+
BidiPage: () => BidiPage,
|
|
32
|
+
addMainBinding: () => addMainBinding,
|
|
33
|
+
kPlaywrightBindingChannel: () => kPlaywrightBindingChannel
|
|
5
34
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var dialog =
|
|
11
|
-
var dom =
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var bidi =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Copyright (c) Microsoft Corporation.
|
|
22
|
-
*
|
|
23
|
-
* Licensed under the Apache License, Version 2.0 (the 'License');
|
|
24
|
-
* you may not use this file except in compliance with the License.
|
|
25
|
-
* You may obtain a copy of the License at
|
|
26
|
-
*
|
|
27
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
28
|
-
*
|
|
29
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
30
|
-
* distributed under the License is distributed on an 'AS IS' BASIS,
|
|
31
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
32
|
-
* See the License for the specific language governing permissions and
|
|
33
|
-
* limitations under the License.
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
const UTILITY_WORLD_NAME = '__playwright_utility_world__';
|
|
37
|
-
const kPlaywrightBindingChannel = 'playwrightChannel';
|
|
35
|
+
module.exports = __toCommonJS(bidiPage_exports);
|
|
36
|
+
var import_utils = require("../../utils");
|
|
37
|
+
var import_eventsHelper = require("../utils/eventsHelper");
|
|
38
|
+
var import_browserContext = require("../browserContext");
|
|
39
|
+
var dialog = __toESM(require("../dialog"));
|
|
40
|
+
var dom = __toESM(require("../dom"));
|
|
41
|
+
var import_page = require("../page");
|
|
42
|
+
var import_bidiExecutionContext = require("./bidiExecutionContext");
|
|
43
|
+
var import_bidiInput = require("./bidiInput");
|
|
44
|
+
var import_bidiNetworkManager = require("./bidiNetworkManager");
|
|
45
|
+
var import_bidiPdf = require("./bidiPdf");
|
|
46
|
+
var bidi = __toESM(require("./third_party/bidiProtocol"));
|
|
47
|
+
const UTILITY_WORLD_NAME = "__playwright_utility_world__";
|
|
48
|
+
const kPlaywrightBindingChannel = "playwrightChannel";
|
|
38
49
|
class BidiPage {
|
|
39
50
|
constructor(browserContext, bidiSession, opener) {
|
|
40
|
-
this.rawMouse = void 0;
|
|
41
|
-
this.rawKeyboard = void 0;
|
|
42
|
-
this.rawTouchscreen = void 0;
|
|
43
|
-
this._page = void 0;
|
|
44
|
-
this._session = void 0;
|
|
45
|
-
this._opener = void 0;
|
|
46
|
-
this._realmToContext = void 0;
|
|
47
51
|
this._sessionListeners = [];
|
|
48
|
-
this._browserContext = void 0;
|
|
49
|
-
this._networkManager = void 0;
|
|
50
|
-
this._pdf = void 0;
|
|
51
52
|
this._initScriptIds = [];
|
|
52
53
|
this._session = bidiSession;
|
|
53
54
|
this._opener = opener;
|
|
54
|
-
this.rawKeyboard = new
|
|
55
|
-
this.rawMouse = new
|
|
56
|
-
this.rawTouchscreen = new
|
|
57
|
-
this._realmToContext = new Map();
|
|
58
|
-
this._page = new
|
|
55
|
+
this.rawKeyboard = new import_bidiInput.RawKeyboardImpl(bidiSession);
|
|
56
|
+
this.rawMouse = new import_bidiInput.RawMouseImpl(bidiSession);
|
|
57
|
+
this.rawTouchscreen = new import_bidiInput.RawTouchscreenImpl(bidiSession);
|
|
58
|
+
this._realmToContext = /* @__PURE__ */ new Map();
|
|
59
|
+
this._page = new import_page.Page(this, browserContext);
|
|
59
60
|
this._browserContext = browserContext;
|
|
60
|
-
this._networkManager = new
|
|
61
|
-
this._pdf = new
|
|
62
|
-
this._page.on(
|
|
63
|
-
this._sessionListeners = [
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
61
|
+
this._networkManager = new import_bidiNetworkManager.BidiNetworkManager(this._session, this._page, this._onNavigationResponseStarted.bind(this));
|
|
62
|
+
this._pdf = new import_bidiPdf.BidiPDF(this._session);
|
|
63
|
+
this._page.on(import_page.Page.Events.FrameDetached, (frame) => this._removeContextsForFrame(frame, false));
|
|
64
|
+
this._sessionListeners = [
|
|
65
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "script.realmCreated", this._onRealmCreated.bind(this)),
|
|
66
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "script.message", this._onScriptMessage.bind(this)),
|
|
67
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.contextDestroyed", this._onBrowsingContextDestroyed.bind(this)),
|
|
68
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.navigationStarted", this._onNavigationStarted.bind(this)),
|
|
69
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.navigationAborted", this._onNavigationAborted.bind(this)),
|
|
70
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.navigationFailed", this._onNavigationFailed.bind(this)),
|
|
71
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.fragmentNavigated", this._onFragmentNavigated.bind(this)),
|
|
72
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.domContentLoaded", this._onDomContentLoaded.bind(this)),
|
|
73
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.load", this._onLoad.bind(this)),
|
|
74
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.userPromptOpened", this._onUserPromptOpened.bind(this)),
|
|
75
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "log.entryAdded", this._onLogEntryAdded.bind(this))
|
|
76
|
+
];
|
|
77
|
+
this._initialize().then(
|
|
78
|
+
() => this._page.reportAsNew(this._opener?._page),
|
|
79
|
+
(error) => this._page.reportAsNew(this._opener?._page, error)
|
|
80
|
+
);
|
|
74
81
|
}
|
|
75
82
|
async _initialize() {
|
|
76
|
-
// Initialize main frame.
|
|
77
83
|
this._onFrameAttached(this._session.sessionId, null);
|
|
78
|
-
await Promise.all([
|
|
84
|
+
await Promise.all([
|
|
85
|
+
this.updateHttpCredentials(),
|
|
86
|
+
this.updateRequestInterception(),
|
|
87
|
+
this._installMainBinding(),
|
|
88
|
+
this._addAllInitScripts()
|
|
89
|
+
]);
|
|
79
90
|
}
|
|
80
91
|
async _addAllInitScripts() {
|
|
81
|
-
return Promise.all(this._page.allInitScripts().map(initScript => this.addInitScript(initScript)));
|
|
92
|
+
return Promise.all(this._page.allInitScripts().map((initScript) => this.addInitScript(initScript)));
|
|
82
93
|
}
|
|
83
94
|
didClose() {
|
|
84
95
|
this._session.dispose();
|
|
85
|
-
|
|
96
|
+
import_eventsHelper.eventsHelper.removeEventListeners(this._sessionListeners);
|
|
86
97
|
this._page._didClose();
|
|
87
98
|
}
|
|
88
99
|
_onFrameAttached(frameId, parentFrameId) {
|
|
@@ -92,33 +103,36 @@ class BidiPage {
|
|
|
92
103
|
for (const [contextId, context] of this._realmToContext) {
|
|
93
104
|
if (context.frame === frame) {
|
|
94
105
|
this._realmToContext.delete(contextId);
|
|
95
|
-
if (notifyFrame)
|
|
106
|
+
if (notifyFrame)
|
|
107
|
+
frame._contextDestroyed(context);
|
|
96
108
|
}
|
|
97
109
|
}
|
|
98
110
|
}
|
|
99
111
|
_onRealmCreated(realmInfo) {
|
|
100
|
-
if (this._realmToContext.has(realmInfo.realm))
|
|
101
|
-
|
|
112
|
+
if (this._realmToContext.has(realmInfo.realm))
|
|
113
|
+
return;
|
|
114
|
+
if (realmInfo.type !== "window")
|
|
115
|
+
return;
|
|
102
116
|
const frame = this._page._frameManager.frame(realmInfo.context);
|
|
103
|
-
if (!frame)
|
|
117
|
+
if (!frame)
|
|
118
|
+
return;
|
|
104
119
|
let worldName;
|
|
105
120
|
if (!realmInfo.sandbox) {
|
|
106
|
-
worldName =
|
|
107
|
-
// Force creating utility world every time the main world is created (e.g. due to navigation).
|
|
121
|
+
worldName = "main";
|
|
108
122
|
this._touchUtilityWorld(realmInfo.context);
|
|
109
123
|
} else if (realmInfo.sandbox === UTILITY_WORLD_NAME) {
|
|
110
|
-
worldName =
|
|
124
|
+
worldName = "utility";
|
|
111
125
|
} else {
|
|
112
126
|
return;
|
|
113
127
|
}
|
|
114
|
-
const delegate = new
|
|
128
|
+
const delegate = new import_bidiExecutionContext.BidiExecutionContext(this._session, realmInfo);
|
|
115
129
|
const context = new dom.FrameExecutionContext(delegate, frame, worldName);
|
|
116
130
|
frame._contextCreated(worldName, context);
|
|
117
131
|
this._realmToContext.set(realmInfo.realm, context);
|
|
118
132
|
}
|
|
119
133
|
async _touchUtilityWorld(context) {
|
|
120
|
-
await this._session.sendMayFail(
|
|
121
|
-
expression:
|
|
134
|
+
await this._session.sendMayFail("script.evaluate", {
|
|
135
|
+
expression: "1 + 1",
|
|
122
136
|
target: {
|
|
123
137
|
context,
|
|
124
138
|
sandbox: UTILITY_WORLD_NAME
|
|
@@ -133,12 +147,12 @@ class BidiPage {
|
|
|
133
147
|
}
|
|
134
148
|
_onRealmDestroyed(params) {
|
|
135
149
|
const context = this._realmToContext.get(params.realm);
|
|
136
|
-
if (!context)
|
|
150
|
+
if (!context)
|
|
151
|
+
return false;
|
|
137
152
|
this._realmToContext.delete(params.realm);
|
|
138
153
|
context.frame._contextDestroyed(context);
|
|
139
154
|
return true;
|
|
140
155
|
}
|
|
141
|
-
|
|
142
156
|
// TODO: route the message directly to the browser
|
|
143
157
|
_onBrowsingContextDestroyed(params) {
|
|
144
158
|
this._browserContext._browser._onBrowsingContextDestroyed(params);
|
|
@@ -147,90 +161,96 @@ class BidiPage {
|
|
|
147
161
|
const frameId = params.context;
|
|
148
162
|
this._page._frameManager.frameRequestedNavigation(frameId, params.navigation);
|
|
149
163
|
const url = params.url.toLowerCase();
|
|
150
|
-
if (url.startsWith(
|
|
151
|
-
// Navigation to file urls doesn't emit network events, so we fire 'commit' event right when navigation is started.
|
|
152
|
-
// Doing it in domcontentload would be too late as we'd clear frame tree.
|
|
164
|
+
if (url.startsWith("file:") || url.startsWith("data:") || url === "about:blank") {
|
|
153
165
|
const frame = this._page._frameManager.frame(frameId);
|
|
154
|
-
if (frame)
|
|
166
|
+
if (frame)
|
|
167
|
+
this._page._frameManager.frameCommittedNewDocumentNavigation(
|
|
168
|
+
frameId,
|
|
169
|
+
params.url,
|
|
170
|
+
"",
|
|
171
|
+
params.navigation,
|
|
172
|
+
/* initial */
|
|
173
|
+
false
|
|
174
|
+
);
|
|
155
175
|
}
|
|
156
176
|
}
|
|
157
|
-
|
|
158
177
|
// TODO: there is no separate event for committed navigation, so we approximate it with responseStarted.
|
|
159
178
|
_onNavigationResponseStarted(params) {
|
|
160
179
|
const frameId = params.context;
|
|
161
180
|
const frame = this._page._frameManager.frame(frameId);
|
|
162
|
-
(0,
|
|
163
|
-
this._page._frameManager.frameCommittedNewDocumentNavigation(
|
|
164
|
-
|
|
165
|
-
|
|
181
|
+
(0, import_utils.assert)(frame);
|
|
182
|
+
this._page._frameManager.frameCommittedNewDocumentNavigation(
|
|
183
|
+
frameId,
|
|
184
|
+
params.response.url,
|
|
185
|
+
"",
|
|
186
|
+
params.navigation,
|
|
187
|
+
/* initial */
|
|
188
|
+
false
|
|
189
|
+
);
|
|
166
190
|
}
|
|
167
191
|
_onDomContentLoaded(params) {
|
|
168
192
|
const frameId = params.context;
|
|
169
|
-
this._page._frameManager.frameLifecycleEvent(frameId,
|
|
193
|
+
this._page._frameManager.frameLifecycleEvent(frameId, "domcontentloaded");
|
|
170
194
|
}
|
|
171
195
|
_onLoad(params) {
|
|
172
|
-
this._page._frameManager.frameLifecycleEvent(params.context,
|
|
196
|
+
this._page._frameManager.frameLifecycleEvent(params.context, "load");
|
|
173
197
|
}
|
|
174
198
|
_onNavigationAborted(params) {
|
|
175
|
-
this._page._frameManager.frameAbortedNavigation(params.context,
|
|
199
|
+
this._page._frameManager.frameAbortedNavigation(params.context, "Navigation aborted", params.navigation || void 0);
|
|
176
200
|
}
|
|
177
201
|
_onNavigationFailed(params) {
|
|
178
|
-
this._page._frameManager.frameAbortedNavigation(params.context,
|
|
202
|
+
this._page._frameManager.frameAbortedNavigation(params.context, "Navigation failed", params.navigation || void 0);
|
|
179
203
|
}
|
|
180
204
|
_onFragmentNavigated(params) {
|
|
181
205
|
this._page._frameManager.frameCommittedSameDocumentNavigation(params.context, params.url);
|
|
182
206
|
}
|
|
183
207
|
_onUserPromptOpened(event) {
|
|
184
|
-
this._page.emitOnContext(
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
208
|
+
this._page.emitOnContext(import_browserContext.BrowserContext.Events.Dialog, new dialog.Dialog(
|
|
209
|
+
this._page,
|
|
210
|
+
event.type,
|
|
211
|
+
event.message,
|
|
212
|
+
async (accept, userText) => {
|
|
213
|
+
await this._session.send("browsingContext.handleUserPrompt", { context: event.context, accept, userText });
|
|
214
|
+
},
|
|
215
|
+
event.defaultValue
|
|
216
|
+
));
|
|
191
217
|
}
|
|
192
218
|
_onLogEntryAdded(params) {
|
|
193
|
-
|
|
194
|
-
|
|
219
|
+
if (params.type !== "console")
|
|
220
|
+
return;
|
|
195
221
|
const entry = params;
|
|
196
222
|
const context = this._realmToContext.get(params.source.realm);
|
|
197
|
-
if (!context)
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
columnNumber: 1
|
|
203
|
-
};
|
|
204
|
-
this._page._addConsoleMessage(entry.method, entry.args.map(arg => (0, _bidiExecutionContext.createHandle)(context, arg)), location, params.text || undefined);
|
|
223
|
+
if (!context)
|
|
224
|
+
return;
|
|
225
|
+
const callFrame = params.stackTrace?.callFrames[0];
|
|
226
|
+
const location = callFrame ?? { url: "", lineNumber: 1, columnNumber: 1 };
|
|
227
|
+
this._page._addConsoleMessage(entry.method, entry.args.map((arg) => (0, import_bidiExecutionContext.createHandle)(context, arg)), location, params.text || void 0);
|
|
205
228
|
}
|
|
206
229
|
async navigateFrame(frame, url, referrer) {
|
|
207
|
-
const {
|
|
208
|
-
navigation
|
|
209
|
-
} = await this._session.send('browsingContext.navigate', {
|
|
230
|
+
const { navigation } = await this._session.send("browsingContext.navigate", {
|
|
210
231
|
context: frame._id,
|
|
211
232
|
url
|
|
212
233
|
});
|
|
213
|
-
return {
|
|
214
|
-
newDocumentId: navigation || undefined
|
|
215
|
-
};
|
|
234
|
+
return { newDocumentId: navigation || void 0 };
|
|
216
235
|
}
|
|
217
|
-
async updateExtraHTTPHeaders() {
|
|
218
|
-
|
|
219
|
-
async
|
|
220
|
-
|
|
236
|
+
async updateExtraHTTPHeaders() {
|
|
237
|
+
}
|
|
238
|
+
async updateEmulateMedia() {
|
|
239
|
+
}
|
|
240
|
+
async updateUserAgent() {
|
|
221
241
|
}
|
|
222
|
-
async updateUserAgent() {}
|
|
223
242
|
async bringToFront() {
|
|
224
|
-
await this._session.send(
|
|
243
|
+
await this._session.send("browsingContext.activate", {
|
|
225
244
|
context: this._session.sessionId
|
|
226
245
|
});
|
|
227
246
|
}
|
|
228
|
-
async
|
|
247
|
+
async updateEmulatedViewportSize() {
|
|
229
248
|
const options = this._browserContext._options;
|
|
230
249
|
const deviceSize = this._page.emulatedSize();
|
|
231
|
-
if (deviceSize === null)
|
|
250
|
+
if (deviceSize === null)
|
|
251
|
+
return;
|
|
232
252
|
const viewportSize = deviceSize.viewport;
|
|
233
|
-
await this._session.send(
|
|
253
|
+
await this._session.send("browsingContext.setViewport", {
|
|
234
254
|
context: this._session.sessionId,
|
|
235
255
|
viewport: {
|
|
236
256
|
width: viewportSize.width,
|
|
@@ -242,50 +262,54 @@ class BidiPage {
|
|
|
242
262
|
async updateRequestInterception() {
|
|
243
263
|
await this._networkManager.setRequestInterception(this._page.needsRequestInterception());
|
|
244
264
|
}
|
|
245
|
-
async updateOffline() {
|
|
265
|
+
async updateOffline() {
|
|
266
|
+
}
|
|
246
267
|
async updateHttpCredentials() {
|
|
247
268
|
await this._networkManager.setCredentials(this._browserContext._options.httpCredentials);
|
|
248
269
|
}
|
|
249
|
-
async updateFileChooserInterception() {
|
|
270
|
+
async updateFileChooserInterception() {
|
|
271
|
+
}
|
|
250
272
|
async reload() {
|
|
251
|
-
await this._session.send(
|
|
273
|
+
await this._session.send("browsingContext.reload", {
|
|
252
274
|
context: this._session.sessionId,
|
|
253
275
|
// ignoreCache: true,
|
|
254
276
|
wait: bidi.BrowsingContext.ReadinessState.Interactive
|
|
255
277
|
});
|
|
256
278
|
}
|
|
257
279
|
async goBack() {
|
|
258
|
-
return await this._session.send(
|
|
280
|
+
return await this._session.send("browsingContext.traverseHistory", {
|
|
259
281
|
context: this._session.sessionId,
|
|
260
282
|
delta: -1
|
|
261
283
|
}).then(() => true).catch(() => false);
|
|
262
284
|
}
|
|
263
285
|
async goForward() {
|
|
264
|
-
return await this._session.send(
|
|
286
|
+
return await this._session.send("browsingContext.traverseHistory", {
|
|
265
287
|
context: this._session.sessionId,
|
|
266
|
-
delta:
|
|
288
|
+
delta: 1
|
|
267
289
|
}).then(() => true).catch(() => false);
|
|
268
290
|
}
|
|
269
291
|
async requestGC() {
|
|
270
|
-
throw new Error(
|
|
292
|
+
throw new Error("Method not implemented.");
|
|
271
293
|
}
|
|
272
|
-
|
|
273
294
|
// TODO: consider calling this only when bindings are added.
|
|
295
|
+
// TODO: delete this method once we can add preload script for persistent context.
|
|
274
296
|
async _installMainBinding() {
|
|
297
|
+
if (this._browserContext._browserContextId)
|
|
298
|
+
return;
|
|
275
299
|
const functionDeclaration = addMainBinding.toString();
|
|
276
300
|
const args = [{
|
|
277
|
-
type:
|
|
301
|
+
type: "channel",
|
|
278
302
|
value: {
|
|
279
303
|
channel: kPlaywrightBindingChannel,
|
|
280
304
|
ownership: bidi.Script.ResultOwnership.Root
|
|
281
305
|
}
|
|
282
306
|
}];
|
|
283
307
|
const promises = [];
|
|
284
|
-
promises.push(this._session.send(
|
|
308
|
+
promises.push(this._session.send("script.addPreloadScript", {
|
|
285
309
|
functionDeclaration,
|
|
286
310
|
arguments: args
|
|
287
311
|
}));
|
|
288
|
-
promises.push(this._session.send(
|
|
312
|
+
promises.push(this._session.send("script.callFunction", {
|
|
289
313
|
functionDeclaration,
|
|
290
314
|
arguments: args,
|
|
291
315
|
target: toBidiExecutionContext(await this._page.mainFrame()._mainContext())._target,
|
|
@@ -295,105 +319,101 @@ class BidiPage {
|
|
|
295
319
|
await Promise.all(promises);
|
|
296
320
|
}
|
|
297
321
|
async _onScriptMessage(event) {
|
|
298
|
-
if (event.channel !== kPlaywrightBindingChannel)
|
|
322
|
+
if (event.channel !== kPlaywrightBindingChannel)
|
|
323
|
+
return;
|
|
299
324
|
const pageOrError = await this._page.waitForInitializedOrError();
|
|
300
|
-
if (pageOrError instanceof Error)
|
|
325
|
+
if (pageOrError instanceof Error)
|
|
326
|
+
return;
|
|
301
327
|
const context = this._realmToContext.get(event.source.realm);
|
|
302
|
-
if (!context)
|
|
303
|
-
|
|
328
|
+
if (!context)
|
|
329
|
+
return;
|
|
330
|
+
if (event.data.type !== "string")
|
|
331
|
+
return;
|
|
304
332
|
await this._page._onBindingCalled(event.data.value, context);
|
|
305
333
|
}
|
|
306
334
|
async addInitScript(initScript) {
|
|
307
|
-
const {
|
|
308
|
-
script
|
|
309
|
-
} = await this._session.send('script.addPreloadScript', {
|
|
335
|
+
const { script } = await this._session.send("script.addPreloadScript", {
|
|
310
336
|
// TODO: remove function call from the source.
|
|
311
337
|
functionDeclaration: `() => { return ${initScript.source} }`,
|
|
312
338
|
// TODO: push to iframes?
|
|
313
339
|
contexts: [this._session.sessionId]
|
|
314
340
|
});
|
|
315
|
-
if (!initScript.internal)
|
|
341
|
+
if (!initScript.internal)
|
|
342
|
+
this._initScriptIds.push(script);
|
|
316
343
|
}
|
|
317
344
|
async removeInitScripts() {
|
|
318
|
-
const promises = this._initScriptIds.map(script => this._session.send(
|
|
319
|
-
script
|
|
320
|
-
}));
|
|
345
|
+
const promises = this._initScriptIds.map((script) => this._session.send("script.removePreloadScript", { script }));
|
|
321
346
|
this._initScriptIds = [];
|
|
322
347
|
await Promise.all(promises);
|
|
323
348
|
}
|
|
324
349
|
async closePage(runBeforeUnload) {
|
|
325
|
-
await this._session.send(
|
|
350
|
+
await this._session.send("browsingContext.close", {
|
|
326
351
|
context: this._session.sessionId,
|
|
327
352
|
promptUnload: runBeforeUnload
|
|
328
353
|
});
|
|
329
354
|
}
|
|
330
|
-
async setBackgroundColor(color) {
|
|
355
|
+
async setBackgroundColor(color) {
|
|
356
|
+
}
|
|
331
357
|
async takeScreenshot(progress, format, documentRect, viewportRect, quality, fitsViewport, scale) {
|
|
332
358
|
const rect = documentRect || viewportRect;
|
|
333
|
-
const {
|
|
334
|
-
data
|
|
335
|
-
} = await this._session.send('browsingContext.captureScreenshot', {
|
|
359
|
+
const { data } = await this._session.send("browsingContext.captureScreenshot", {
|
|
336
360
|
context: this._session.sessionId,
|
|
337
361
|
format: {
|
|
338
|
-
type: `image/${format ===
|
|
362
|
+
type: `image/${format === "png" ? "png" : "jpeg"}`,
|
|
339
363
|
quality: quality ? quality / 100 : 0.8
|
|
340
364
|
},
|
|
341
|
-
origin: documentRect ?
|
|
365
|
+
origin: documentRect ? "document" : "viewport",
|
|
342
366
|
clip: {
|
|
343
|
-
type:
|
|
367
|
+
type: "box",
|
|
344
368
|
...rect
|
|
345
369
|
}
|
|
346
370
|
});
|
|
347
|
-
return Buffer.from(data,
|
|
371
|
+
return Buffer.from(data, "base64");
|
|
348
372
|
}
|
|
349
373
|
async getContentFrame(handle) {
|
|
350
374
|
const executionContext = toBidiExecutionContext(handle._context);
|
|
351
375
|
const frameId = await executionContext.contentFrameIdForFrame(handle);
|
|
352
|
-
if (!frameId)
|
|
376
|
+
if (!frameId)
|
|
377
|
+
return null;
|
|
353
378
|
return this._page._frameManager.frame(frameId);
|
|
354
379
|
}
|
|
355
380
|
async getOwnerFrame(handle) {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
var _node$ownerDocument;
|
|
359
|
-
const doc = (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 ? _node$ownerDocument : node;
|
|
381
|
+
const windowHandle = await handle.evaluateHandle((node) => {
|
|
382
|
+
const doc = node.ownerDocument ?? node;
|
|
360
383
|
return doc.defaultView;
|
|
361
384
|
});
|
|
362
|
-
if (!windowHandle)
|
|
385
|
+
if (!windowHandle)
|
|
386
|
+
return null;
|
|
363
387
|
const executionContext = toBidiExecutionContext(handle._context);
|
|
364
388
|
return executionContext.frameIdForWindowHandle(windowHandle);
|
|
365
389
|
}
|
|
366
390
|
async getBoundingBox(handle) {
|
|
367
|
-
const box = await handle.evaluate(element => {
|
|
368
|
-
if (!(element instanceof Element))
|
|
391
|
+
const box = await handle.evaluate((element) => {
|
|
392
|
+
if (!(element instanceof Element))
|
|
393
|
+
return null;
|
|
369
394
|
const rect = element.getBoundingClientRect();
|
|
370
|
-
return {
|
|
371
|
-
x: rect.x,
|
|
372
|
-
y: rect.y,
|
|
373
|
-
width: rect.width,
|
|
374
|
-
height: rect.height
|
|
375
|
-
};
|
|
395
|
+
return { x: rect.x, y: rect.y, width: rect.width, height: rect.height };
|
|
376
396
|
});
|
|
377
|
-
if (!box)
|
|
397
|
+
if (!box)
|
|
398
|
+
return null;
|
|
378
399
|
const position = await this._framePosition(handle._frame);
|
|
379
|
-
if (!position)
|
|
400
|
+
if (!position)
|
|
401
|
+
return null;
|
|
380
402
|
box.x += position.x;
|
|
381
403
|
box.y += position.y;
|
|
382
404
|
return box;
|
|
383
405
|
}
|
|
384
|
-
|
|
385
406
|
// TODO: move to Frame.
|
|
386
407
|
async _framePosition(frame) {
|
|
387
|
-
if (frame === this._page.mainFrame())
|
|
388
|
-
x: 0,
|
|
389
|
-
y: 0
|
|
390
|
-
};
|
|
408
|
+
if (frame === this._page.mainFrame())
|
|
409
|
+
return { x: 0, y: 0 };
|
|
391
410
|
const element = await frame.frameElement();
|
|
392
411
|
const box = await element.boundingBox();
|
|
393
|
-
if (!box)
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
412
|
+
if (!box)
|
|
413
|
+
return null;
|
|
414
|
+
const style = await element.evaluateInUtility(([injected, iframe]) => injected.describeIFrameStyle(iframe), {}).catch((e) => "error:notconnected");
|
|
415
|
+
if (style === "error:notconnected" || style === "transformed")
|
|
416
|
+
return null;
|
|
397
417
|
box.x += style.left;
|
|
398
418
|
box.y += style.top;
|
|
399
419
|
return box;
|
|
@@ -401,44 +421,43 @@ class BidiPage {
|
|
|
401
421
|
async scrollRectIntoViewIfNeeded(handle, rect) {
|
|
402
422
|
return await handle.evaluateInUtility(([injected, node]) => {
|
|
403
423
|
node.scrollIntoView({
|
|
404
|
-
block:
|
|
405
|
-
inline:
|
|
406
|
-
behavior:
|
|
424
|
+
block: "center",
|
|
425
|
+
inline: "center",
|
|
426
|
+
behavior: "instant"
|
|
407
427
|
});
|
|
408
|
-
}, null).then(() =>
|
|
409
|
-
if (e instanceof Error && e.message.includes(
|
|
410
|
-
|
|
428
|
+
}, null).then(() => "done").catch((e) => {
|
|
429
|
+
if (e instanceof Error && e.message.includes("Node is detached from document"))
|
|
430
|
+
return "error:notconnected";
|
|
431
|
+
if (e instanceof Error && e.message.includes("Node does not have a layout object"))
|
|
432
|
+
return "error:notvisible";
|
|
411
433
|
throw e;
|
|
412
434
|
});
|
|
413
435
|
}
|
|
414
|
-
async setScreencastOptions(options) {
|
|
436
|
+
async setScreencastOptions(options) {
|
|
437
|
+
}
|
|
415
438
|
rafCountForStablePosition() {
|
|
416
439
|
return 1;
|
|
417
440
|
}
|
|
418
441
|
async getContentQuads(handle) {
|
|
419
442
|
const quads = await handle.evaluateInUtility(([injected, node]) => {
|
|
420
|
-
if (!node.isConnected)
|
|
443
|
+
if (!node.isConnected)
|
|
444
|
+
return "error:notconnected";
|
|
421
445
|
const rects = node.getClientRects();
|
|
422
|
-
if (!rects)
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
y: rect.top
|
|
426
|
-
|
|
427
|
-
x: rect.right,
|
|
428
|
-
y: rect.
|
|
429
|
-
|
|
430
|
-
x: rect.right,
|
|
431
|
-
y: rect.bottom
|
|
432
|
-
}, {
|
|
433
|
-
x: rect.left,
|
|
434
|
-
y: rect.bottom
|
|
435
|
-
}]);
|
|
446
|
+
if (!rects)
|
|
447
|
+
return null;
|
|
448
|
+
return [...rects].map((rect) => [
|
|
449
|
+
{ x: rect.left, y: rect.top },
|
|
450
|
+
{ x: rect.right, y: rect.top },
|
|
451
|
+
{ x: rect.right, y: rect.bottom },
|
|
452
|
+
{ x: rect.left, y: rect.bottom }
|
|
453
|
+
]);
|
|
436
454
|
}, null);
|
|
437
|
-
if (!quads || quads ===
|
|
438
|
-
|
|
455
|
+
if (!quads || quads === "error:notconnected")
|
|
456
|
+
return quads;
|
|
439
457
|
const position = await this._framePosition(handle._frame);
|
|
440
|
-
if (!position)
|
|
441
|
-
|
|
458
|
+
if (!position)
|
|
459
|
+
return null;
|
|
460
|
+
quads.forEach((quad) => quad.forEach((point) => {
|
|
442
461
|
point.x += position.x;
|
|
443
462
|
point.y += position.y;
|
|
444
463
|
}));
|
|
@@ -446,7 +465,7 @@ class BidiPage {
|
|
|
446
465
|
}
|
|
447
466
|
async setInputFilePaths(handle, paths) {
|
|
448
467
|
const fromContext = toBidiExecutionContext(handle._context);
|
|
449
|
-
await this._session.send(
|
|
468
|
+
await this._session.send("input.setFiles", {
|
|
450
469
|
context: this._session.sessionId,
|
|
451
470
|
element: await fromContext.nodeIdForElementHandle(handle),
|
|
452
471
|
files: paths
|
|
@@ -459,24 +478,27 @@ class BidiPage {
|
|
|
459
478
|
return await executionContext.remoteObjectForNodeId(to, nodeId);
|
|
460
479
|
}
|
|
461
480
|
async getAccessibilityTree(needle) {
|
|
462
|
-
throw new Error(
|
|
481
|
+
throw new Error("Method not implemented.");
|
|
482
|
+
}
|
|
483
|
+
async inputActionEpilogue() {
|
|
484
|
+
}
|
|
485
|
+
async resetForReuse() {
|
|
463
486
|
}
|
|
464
|
-
async inputActionEpilogue() {}
|
|
465
|
-
async resetForReuse() {}
|
|
466
487
|
async pdf(options) {
|
|
467
488
|
return this._pdf.generate(options);
|
|
468
489
|
}
|
|
469
490
|
async getFrameElement(frame) {
|
|
470
491
|
const parent = frame.parentFrame();
|
|
471
|
-
if (!parent)
|
|
492
|
+
if (!parent)
|
|
493
|
+
throw new Error("Frame has been detached.");
|
|
472
494
|
const parentContext = await parent._mainContext();
|
|
473
495
|
const list = await parentContext.evaluateHandle(() => {
|
|
474
|
-
return [...document.querySelectorAll(
|
|
496
|
+
return [...document.querySelectorAll("iframe,frame")];
|
|
475
497
|
});
|
|
476
|
-
const length = await list.evaluate(
|
|
498
|
+
const length = await list.evaluate((list2) => list2.length);
|
|
477
499
|
let foundElement = null;
|
|
478
500
|
for (let i = 0; i < length; i++) {
|
|
479
|
-
const element = await list.evaluateHandle((
|
|
501
|
+
const element = await list.evaluateHandle((list2, i2) => list2[i2], i);
|
|
480
502
|
const candidate = await element.contentFrame();
|
|
481
503
|
if (frame === candidate) {
|
|
482
504
|
foundElement = element;
|
|
@@ -486,17 +508,23 @@ class BidiPage {
|
|
|
486
508
|
}
|
|
487
509
|
}
|
|
488
510
|
list.dispose();
|
|
489
|
-
if (!foundElement)
|
|
511
|
+
if (!foundElement)
|
|
512
|
+
throw new Error("Frame has been detached.");
|
|
490
513
|
return foundElement;
|
|
491
514
|
}
|
|
492
515
|
shouldToggleStyleSheetToSyncAnimations() {
|
|
493
516
|
return true;
|
|
494
517
|
}
|
|
495
518
|
}
|
|
496
|
-
exports.BidiPage = BidiPage;
|
|
497
519
|
function addMainBinding(callback) {
|
|
498
|
-
globalThis[
|
|
520
|
+
globalThis["__playwright__binding__"] = callback;
|
|
499
521
|
}
|
|
500
522
|
function toBidiExecutionContext(executionContext) {
|
|
501
523
|
return executionContext.delegate;
|
|
502
|
-
}
|
|
524
|
+
}
|
|
525
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
526
|
+
0 && (module.exports = {
|
|
527
|
+
BidiPage,
|
|
528
|
+
addMainBinding,
|
|
529
|
+
kPlaywrightBindingChannel
|
|
530
|
+
});
|