patchright-core 1.51.2 → 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 +288 -403
- 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 +741 -891
- 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-DpJ-EmBQ.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-DTenqiGw.js +0 -259
- package/lib/vite/traceViewer/index.CUq7VgrV.js +0 -2
- package/lib/vite/traceViewer/uiMode.CHJSAD7F.js +0 -5
package/lib/server/frames.js
CHANGED
|
@@ -1,82 +1,86 @@
|
|
|
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 frames_exports = {};
|
|
30
|
+
__export(frames_exports, {
|
|
31
|
+
Frame: () => Frame,
|
|
32
|
+
FrameManager: () => FrameManager,
|
|
33
|
+
NavigationAbortedError: () => NavigationAbortedError
|
|
5
34
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var js =
|
|
18
|
-
var network =
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var types =
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
30
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
31
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
32
|
-
// undetected-undetected_playwright-patch - custom imports
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Copyright 2017 Google Inc. All rights reserved.
|
|
36
|
-
* Modifications copyright (c) Microsoft Corporation.
|
|
37
|
-
*
|
|
38
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
39
|
-
* you may not use this file except in compliance with the License.
|
|
40
|
-
* You may obtain a copy of the License at
|
|
41
|
-
*
|
|
42
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
43
|
-
*
|
|
44
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
45
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
46
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
47
|
-
* See the License for the specific language governing permissions and
|
|
48
|
-
* limitations under the License.
|
|
49
|
-
*/
|
|
50
|
-
|
|
35
|
+
module.exports = __toCommonJS(frames_exports);
|
|
36
|
+
var import_crExecutionContext = require("./chromium/crExecutionContext");
|
|
37
|
+
var import_dom = require("./dom");
|
|
38
|
+
var import_crypto = __toESM(require("crypto"));
|
|
39
|
+
var import_browserContext = require("./browserContext");
|
|
40
|
+
var dom = __toESM(require("./dom"));
|
|
41
|
+
var import_errors = require("./errors");
|
|
42
|
+
var import_fileUploadUtils = require("./fileUploadUtils");
|
|
43
|
+
var import_frameSelectors = require("./frameSelectors");
|
|
44
|
+
var import_helper = require("./helper");
|
|
45
|
+
var import_instrumentation = require("./instrumentation");
|
|
46
|
+
var js = __toESM(require("./javascript"));
|
|
47
|
+
var network = __toESM(require("./network"));
|
|
48
|
+
var import_page = require("./page");
|
|
49
|
+
var import_progress = require("./progress");
|
|
50
|
+
var types = __toESM(require("./types"));
|
|
51
|
+
var import_utils = require("../utils");
|
|
52
|
+
var import_protocolError = require("./protocolError");
|
|
53
|
+
var import_debugLogger = require("./utils/debugLogger");
|
|
54
|
+
var import_eventsHelper = require("./utils/eventsHelper");
|
|
55
|
+
var import_selectorParser = require("../utils/isomorphic/selectorParser");
|
|
56
|
+
var import_manualPromise = require("../utils/isomorphic/manualPromise");
|
|
57
|
+
var import_callLog = require("./callLog");
|
|
51
58
|
class NavigationAbortedError extends Error {
|
|
52
59
|
constructor(documentId, message) {
|
|
53
60
|
super(message);
|
|
54
|
-
this.documentId = void 0;
|
|
55
61
|
this.documentId = documentId;
|
|
56
62
|
}
|
|
57
63
|
}
|
|
58
|
-
|
|
59
|
-
const kDummyFrameId = '<dummy>';
|
|
64
|
+
const kDummyFrameId = "<dummy>";
|
|
60
65
|
class FrameManager {
|
|
61
66
|
constructor(page) {
|
|
62
|
-
this.
|
|
63
|
-
this.
|
|
64
|
-
this.
|
|
65
|
-
this.
|
|
66
|
-
this.
|
|
67
|
-
this._webSockets = new Map();
|
|
68
|
-
this._openedDialogs = new Set();
|
|
67
|
+
this._frames = /* @__PURE__ */ new Map();
|
|
68
|
+
this._consoleMessageTags = /* @__PURE__ */ new Map();
|
|
69
|
+
this._signalBarriers = /* @__PURE__ */ new Set();
|
|
70
|
+
this._webSockets = /* @__PURE__ */ new Map();
|
|
71
|
+
this._openedDialogs = /* @__PURE__ */ new Set();
|
|
69
72
|
this._closeAllOpeningDialogs = false;
|
|
70
73
|
this._page = page;
|
|
71
|
-
this._mainFrame =
|
|
74
|
+
this._mainFrame = void 0;
|
|
72
75
|
}
|
|
73
76
|
createDummyMainFrameIfNeeded() {
|
|
74
|
-
if (!this._mainFrame)
|
|
77
|
+
if (!this._mainFrame)
|
|
78
|
+
this.frameAttached(kDummyFrameId, null);
|
|
75
79
|
}
|
|
76
80
|
dispose() {
|
|
77
81
|
for (const frame of this._frames.values()) {
|
|
78
82
|
frame._stopNetworkIdleTimer();
|
|
79
|
-
frame._invalidateNonStallingEvaluations(
|
|
83
|
+
frame._invalidateNonStallingEvaluations("Target crashed");
|
|
80
84
|
}
|
|
81
85
|
}
|
|
82
86
|
mainFrame() {
|
|
@@ -88,7 +92,8 @@ class FrameManager {
|
|
|
88
92
|
return frames;
|
|
89
93
|
function collect(frame) {
|
|
90
94
|
frames.push(frame);
|
|
91
|
-
for (const subframe of frame.childFrames())
|
|
95
|
+
for (const subframe of frame.childFrames())
|
|
96
|
+
collect(subframe);
|
|
92
97
|
}
|
|
93
98
|
}
|
|
94
99
|
frame(frameId) {
|
|
@@ -98,55 +103,55 @@ class FrameManager {
|
|
|
98
103
|
const parentFrame = parentFrameId ? this._frames.get(parentFrameId) : null;
|
|
99
104
|
if (!parentFrame) {
|
|
100
105
|
if (this._mainFrame) {
|
|
101
|
-
// Update frame id to retain frame identity on cross-process navigation.
|
|
102
106
|
this._frames.delete(this._mainFrame._id);
|
|
103
107
|
this._mainFrame._id = frameId;
|
|
104
108
|
} else {
|
|
105
|
-
(0,
|
|
109
|
+
(0, import_utils.assert)(!this._frames.has(frameId));
|
|
106
110
|
this._mainFrame = new Frame(this._page, frameId, parentFrame);
|
|
107
111
|
}
|
|
108
112
|
this._frames.set(frameId, this._mainFrame);
|
|
109
113
|
return this._mainFrame;
|
|
110
114
|
} else {
|
|
111
|
-
(0,
|
|
115
|
+
(0, import_utils.assert)(!this._frames.has(frameId));
|
|
112
116
|
const frame = new Frame(this._page, frameId, parentFrame);
|
|
113
117
|
this._frames.set(frameId, frame);
|
|
114
|
-
this._page.emit(
|
|
118
|
+
this._page.emit(import_page.Page.Events.FrameAttached, frame);
|
|
115
119
|
return frame;
|
|
116
120
|
}
|
|
117
121
|
}
|
|
118
122
|
async waitForSignalsCreatedBy(progress, waitAfter, action) {
|
|
119
|
-
if (!waitAfter)
|
|
123
|
+
if (!waitAfter)
|
|
124
|
+
return action();
|
|
120
125
|
const barrier = new SignalBarrier(progress);
|
|
121
126
|
this._signalBarriers.add(barrier);
|
|
122
|
-
if (progress)
|
|
127
|
+
if (progress)
|
|
128
|
+
progress.cleanupWhenAborted(() => this._signalBarriers.delete(barrier));
|
|
123
129
|
const result = await action();
|
|
124
130
|
await this._page._delegate.inputActionEpilogue();
|
|
125
131
|
await barrier.waitFor();
|
|
126
132
|
this._signalBarriers.delete(barrier);
|
|
127
|
-
|
|
128
|
-
await new Promise((0, _utils.makeWaitForNextTask)());
|
|
133
|
+
await new Promise((0, import_utils.makeWaitForNextTask)());
|
|
129
134
|
return result;
|
|
130
135
|
}
|
|
131
136
|
frameWillPotentiallyRequestNavigation() {
|
|
132
|
-
for (const barrier of this._signalBarriers)
|
|
137
|
+
for (const barrier of this._signalBarriers)
|
|
138
|
+
barrier.retain();
|
|
133
139
|
}
|
|
134
140
|
frameDidPotentiallyRequestNavigation() {
|
|
135
|
-
for (const barrier of this._signalBarriers)
|
|
141
|
+
for (const barrier of this._signalBarriers)
|
|
142
|
+
barrier.release();
|
|
136
143
|
}
|
|
137
144
|
frameRequestedNavigation(frameId, documentId) {
|
|
138
145
|
const frame = this._frames.get(frameId);
|
|
139
|
-
if (!frame)
|
|
140
|
-
|
|
146
|
+
if (!frame)
|
|
147
|
+
return;
|
|
148
|
+
for (const barrier of this._signalBarriers)
|
|
149
|
+
barrier.addFrameNavigation(frame);
|
|
141
150
|
if (frame.pendingDocument() && frame.pendingDocument().documentId === documentId) {
|
|
142
|
-
// Do not override request with undefined.
|
|
143
151
|
return;
|
|
144
152
|
}
|
|
145
|
-
const request = documentId ? Array.from(frame._inflightRequests).find(
|
|
146
|
-
frame.setPendingDocument({
|
|
147
|
-
documentId,
|
|
148
|
-
request
|
|
149
|
-
});
|
|
153
|
+
const request = documentId ? Array.from(frame._inflightRequests).find((request2) => request2._documentId === documentId) : void 0;
|
|
154
|
+
frame.setPendingDocument({ documentId, request });
|
|
150
155
|
}
|
|
151
156
|
frameCommittedNewDocumentNavigation(frameId, url, name, documentId, initial) {
|
|
152
157
|
const frame = this._frames.get(frameId);
|
|
@@ -157,69 +162,47 @@ class FrameManager {
|
|
|
157
162
|
let keepPending;
|
|
158
163
|
const pendingDocument = frame.pendingDocument();
|
|
159
164
|
if (pendingDocument) {
|
|
160
|
-
if (pendingDocument.documentId ===
|
|
161
|
-
// Pending with unknown documentId - assume it is the one being committed.
|
|
165
|
+
if (pendingDocument.documentId === void 0) {
|
|
162
166
|
pendingDocument.documentId = documentId;
|
|
163
167
|
}
|
|
164
168
|
if (pendingDocument.documentId === documentId) {
|
|
165
|
-
// Committing a pending document.
|
|
166
169
|
frame._currentDocument = pendingDocument;
|
|
167
170
|
} else {
|
|
168
|
-
// Sometimes, we already have a new pending when the old one commits.
|
|
169
|
-
// An example would be Chromium error page followed by a new navigation request,
|
|
170
|
-
// where the error page commit arrives after Network.requestWillBeSent for the
|
|
171
|
-
// new navigation.
|
|
172
|
-
// We commit, but keep the pending request since it's not done yet.
|
|
173
171
|
keepPending = pendingDocument;
|
|
174
|
-
frame._currentDocument = {
|
|
175
|
-
documentId,
|
|
176
|
-
request: undefined
|
|
177
|
-
};
|
|
172
|
+
frame._currentDocument = { documentId, request: void 0 };
|
|
178
173
|
}
|
|
179
|
-
frame.setPendingDocument(
|
|
174
|
+
frame.setPendingDocument(void 0);
|
|
180
175
|
} else {
|
|
181
|
-
|
|
182
|
-
frame._currentDocument = {
|
|
183
|
-
documentId,
|
|
184
|
-
request: undefined
|
|
185
|
-
};
|
|
176
|
+
frame._currentDocument = { documentId, request: void 0 };
|
|
186
177
|
}
|
|
187
178
|
frame._onClearLifecycle();
|
|
188
|
-
const navigationEvent = {
|
|
189
|
-
url,
|
|
190
|
-
name,
|
|
191
|
-
newDocument: frame._currentDocument,
|
|
192
|
-
isPublic: true
|
|
193
|
-
};
|
|
179
|
+
const navigationEvent = { url, name, newDocument: frame._currentDocument, isPublic: true };
|
|
194
180
|
this._fireInternalFrameNavigation(frame, navigationEvent);
|
|
195
181
|
if (!initial) {
|
|
196
|
-
|
|
182
|
+
import_debugLogger.debugLogger.log("api", ` navigated to "${url}"`);
|
|
197
183
|
this._page.frameNavigatedToNewDocument(frame);
|
|
198
184
|
}
|
|
199
|
-
// Restore pending if any - see comments above about keepPending.
|
|
200
185
|
frame.setPendingDocument(keepPending);
|
|
201
186
|
}
|
|
202
187
|
frameCommittedSameDocumentNavigation(frameId, url) {
|
|
203
188
|
const frame = this._frames.get(frameId);
|
|
204
|
-
if (!frame)
|
|
189
|
+
if (!frame)
|
|
190
|
+
return;
|
|
205
191
|
const pending = frame.pendingDocument();
|
|
206
|
-
if (pending && pending.documentId ===
|
|
207
|
-
|
|
208
|
-
frame.setPendingDocument(undefined);
|
|
192
|
+
if (pending && pending.documentId === void 0 && pending.request === void 0) {
|
|
193
|
+
frame.setPendingDocument(void 0);
|
|
209
194
|
}
|
|
210
195
|
frame._url = url;
|
|
211
|
-
const navigationEvent = {
|
|
212
|
-
url,
|
|
213
|
-
name: frame._name,
|
|
214
|
-
isPublic: true
|
|
215
|
-
};
|
|
196
|
+
const navigationEvent = { url, name: frame._name, isPublic: true };
|
|
216
197
|
this._fireInternalFrameNavigation(frame, navigationEvent);
|
|
217
|
-
|
|
198
|
+
import_debugLogger.debugLogger.log("api", ` navigated to "${url}"`);
|
|
218
199
|
}
|
|
219
200
|
frameAbortedNavigation(frameId, errorText, documentId) {
|
|
220
201
|
const frame = this._frames.get(frameId);
|
|
221
|
-
if (!frame || !frame.pendingDocument())
|
|
222
|
-
|
|
202
|
+
if (!frame || !frame.pendingDocument())
|
|
203
|
+
return;
|
|
204
|
+
if (documentId !== void 0 && frame.pendingDocument().documentId !== documentId)
|
|
205
|
+
return;
|
|
223
206
|
const navigationEvent = {
|
|
224
207
|
url: frame._url,
|
|
225
208
|
name: frame._name,
|
|
@@ -227,7 +210,7 @@ class FrameManager {
|
|
|
227
210
|
error: new NavigationAbortedError(documentId, errorText),
|
|
228
211
|
isPublic: !(documentId && frame._redirectedNavigations.has(documentId))
|
|
229
212
|
};
|
|
230
|
-
frame.setPendingDocument(
|
|
213
|
+
frame.setPendingDocument(void 0);
|
|
231
214
|
this._fireInternalFrameNavigation(frame, navigationEvent);
|
|
232
215
|
}
|
|
233
216
|
frameDetached(frameId) {
|
|
@@ -239,104 +222,119 @@ class FrameManager {
|
|
|
239
222
|
}
|
|
240
223
|
frameLifecycleEvent(frameId, event) {
|
|
241
224
|
const frame = this._frames.get(frameId);
|
|
242
|
-
if (frame)
|
|
225
|
+
if (frame)
|
|
226
|
+
frame._onLifecycleEvent(event);
|
|
243
227
|
}
|
|
244
228
|
requestStarted(request, route) {
|
|
245
229
|
const frame = request.frame();
|
|
246
230
|
this._inflightRequestStarted(request);
|
|
247
|
-
if (request._documentId)
|
|
248
|
-
documentId: request._documentId,
|
|
249
|
-
request
|
|
250
|
-
});
|
|
231
|
+
if (request._documentId)
|
|
232
|
+
frame.setPendingDocument({ documentId: request._documentId, request });
|
|
251
233
|
if (request._isFavicon) {
|
|
252
|
-
|
|
253
|
-
|
|
234
|
+
route?.abort("aborted").catch(() => {
|
|
235
|
+
});
|
|
254
236
|
return;
|
|
255
237
|
}
|
|
256
|
-
this._page.emitOnContext(
|
|
238
|
+
this._page.emitOnContext(import_browserContext.BrowserContext.Events.Request, request);
|
|
257
239
|
if (route) {
|
|
258
|
-
var _this$_page$_serverRe, _this$_page, _this$_page$_clientRe, _this$_page2, _this$_page$_browserC, _this$_page$_browserC2;
|
|
259
240
|
const r = new network.Route(request, route);
|
|
260
|
-
if (
|
|
261
|
-
|
|
262
|
-
if (
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
241
|
+
if (this._page._serverRequestInterceptor?.(r, request))
|
|
242
|
+
return;
|
|
243
|
+
if (this._page._clientRequestInterceptor?.(r, request))
|
|
244
|
+
return;
|
|
245
|
+
if (this._page._browserContext._requestInterceptor?.(r, request))
|
|
246
|
+
return;
|
|
247
|
+
r.continue({ isFallback: true }).catch(() => {
|
|
248
|
+
});
|
|
266
249
|
}
|
|
267
250
|
}
|
|
268
251
|
requestReceivedResponse(response) {
|
|
269
|
-
if (response.request()._isFavicon)
|
|
270
|
-
|
|
252
|
+
if (response.request()._isFavicon)
|
|
253
|
+
return;
|
|
254
|
+
this._page.emitOnContext(import_browserContext.BrowserContext.Events.Response, response);
|
|
271
255
|
}
|
|
272
256
|
reportRequestFinished(request, response) {
|
|
273
257
|
this._inflightRequestFinished(request);
|
|
274
|
-
if (request._isFavicon)
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
response
|
|
278
|
-
});
|
|
258
|
+
if (request._isFavicon)
|
|
259
|
+
return;
|
|
260
|
+
this._page.emitOnContext(import_browserContext.BrowserContext.Events.RequestFinished, { request, response });
|
|
279
261
|
}
|
|
280
262
|
requestFailed(request, canceled) {
|
|
281
263
|
const frame = request.frame();
|
|
282
264
|
this._inflightRequestFinished(request);
|
|
283
265
|
if (frame.pendingDocument() && frame.pendingDocument().request === request) {
|
|
284
266
|
let errorText = request.failure().errorText;
|
|
285
|
-
if (canceled)
|
|
267
|
+
if (canceled)
|
|
268
|
+
errorText += "; maybe frame was detached?";
|
|
286
269
|
this.frameAbortedNavigation(frame._id, errorText, frame.pendingDocument().documentId);
|
|
287
270
|
}
|
|
288
|
-
if (request._isFavicon)
|
|
289
|
-
|
|
271
|
+
if (request._isFavicon)
|
|
272
|
+
return;
|
|
273
|
+
this._page.emitOnContext(import_browserContext.BrowserContext.Events.RequestFailed, request);
|
|
290
274
|
}
|
|
291
275
|
dialogDidOpen(dialog) {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
if (this._closeAllOpeningDialogs)
|
|
276
|
+
for (const frame of this._frames.values())
|
|
277
|
+
frame._invalidateNonStallingEvaluations("JavaScript dialog interrupted evaluation");
|
|
278
|
+
if (this._closeAllOpeningDialogs)
|
|
279
|
+
dialog.close().then(() => {
|
|
280
|
+
});
|
|
281
|
+
else
|
|
282
|
+
this._openedDialogs.add(dialog);
|
|
295
283
|
}
|
|
296
284
|
dialogWillClose(dialog) {
|
|
297
285
|
this._openedDialogs.delete(dialog);
|
|
298
286
|
}
|
|
299
287
|
async closeOpenDialogs() {
|
|
300
|
-
await Promise.all([...this._openedDialogs].map(dialog => dialog.close())).catch(() => {
|
|
288
|
+
await Promise.all([...this._openedDialogs].map((dialog) => dialog.close())).catch(() => {
|
|
289
|
+
});
|
|
301
290
|
this._openedDialogs.clear();
|
|
302
291
|
}
|
|
303
292
|
setCloseAllOpeningDialogs(closeDialogs) {
|
|
304
293
|
this._closeAllOpeningDialogs = closeDialogs;
|
|
305
294
|
}
|
|
306
295
|
removeChildFramesRecursively(frame) {
|
|
307
|
-
for (const child of frame.childFrames())
|
|
296
|
+
for (const child of frame.childFrames())
|
|
297
|
+
this._removeFramesRecursively(child);
|
|
308
298
|
}
|
|
309
299
|
_removeFramesRecursively(frame) {
|
|
310
300
|
this.removeChildFramesRecursively(frame);
|
|
311
301
|
frame._onDetached();
|
|
312
302
|
this._frames.delete(frame._id);
|
|
313
|
-
if (!this._page.isClosed())
|
|
303
|
+
if (!this._page.isClosed())
|
|
304
|
+
this._page.emit(import_page.Page.Events.FrameDetached, frame);
|
|
314
305
|
}
|
|
315
306
|
_inflightRequestFinished(request) {
|
|
316
307
|
const frame = request.frame();
|
|
317
|
-
if (request._isFavicon)
|
|
318
|
-
|
|
308
|
+
if (request._isFavicon)
|
|
309
|
+
return;
|
|
310
|
+
if (!frame._inflightRequests.has(request))
|
|
311
|
+
return;
|
|
319
312
|
frame._inflightRequests.delete(request);
|
|
320
|
-
if (frame._inflightRequests.size === 0)
|
|
313
|
+
if (frame._inflightRequests.size === 0)
|
|
314
|
+
frame._startNetworkIdleTimer();
|
|
321
315
|
}
|
|
322
316
|
_inflightRequestStarted(request) {
|
|
323
317
|
const frame = request.frame();
|
|
324
|
-
if (request._isFavicon)
|
|
318
|
+
if (request._isFavicon)
|
|
319
|
+
return;
|
|
325
320
|
frame._inflightRequests.add(request);
|
|
326
|
-
if (frame._inflightRequests.size === 1)
|
|
321
|
+
if (frame._inflightRequests.size === 1)
|
|
322
|
+
frame._stopNetworkIdleTimer();
|
|
327
323
|
}
|
|
328
324
|
interceptConsoleMessage(message) {
|
|
329
|
-
if (message.type() !==
|
|
325
|
+
if (message.type() !== "debug")
|
|
326
|
+
return false;
|
|
330
327
|
const tag = message.text();
|
|
331
328
|
const handler = this._consoleMessageTags.get(tag);
|
|
332
|
-
if (!handler)
|
|
329
|
+
if (!handler)
|
|
330
|
+
return false;
|
|
333
331
|
this._consoleMessageTags.delete(tag);
|
|
334
332
|
handler();
|
|
335
333
|
return true;
|
|
336
334
|
}
|
|
337
335
|
clearWebSockets(frame) {
|
|
338
|
-
|
|
339
|
-
|
|
336
|
+
if (frame.parentFrame())
|
|
337
|
+
return;
|
|
340
338
|
this._webSockets.clear();
|
|
341
339
|
}
|
|
342
340
|
onWebSocketCreated(requestId, url) {
|
|
@@ -345,125 +343,131 @@ class FrameManager {
|
|
|
345
343
|
}
|
|
346
344
|
onWebSocketRequest(requestId) {
|
|
347
345
|
const ws = this._webSockets.get(requestId);
|
|
348
|
-
if (ws && ws.markAsNotified())
|
|
346
|
+
if (ws && ws.markAsNotified())
|
|
347
|
+
this._page.emit(import_page.Page.Events.WebSocket, ws);
|
|
349
348
|
}
|
|
350
349
|
onWebSocketResponse(requestId, status, statusText) {
|
|
351
350
|
const ws = this._webSockets.get(requestId);
|
|
352
|
-
if (status < 400)
|
|
353
|
-
|
|
351
|
+
if (status < 400)
|
|
352
|
+
return;
|
|
353
|
+
if (ws)
|
|
354
|
+
ws.error(`${statusText}: ${status}`);
|
|
354
355
|
}
|
|
355
356
|
onWebSocketFrameSent(requestId, opcode, data) {
|
|
356
357
|
const ws = this._webSockets.get(requestId);
|
|
357
|
-
if (ws)
|
|
358
|
+
if (ws)
|
|
359
|
+
ws.frameSent(opcode, data);
|
|
358
360
|
}
|
|
359
361
|
webSocketFrameReceived(requestId, opcode, data) {
|
|
360
362
|
const ws = this._webSockets.get(requestId);
|
|
361
|
-
if (ws)
|
|
363
|
+
if (ws)
|
|
364
|
+
ws.frameReceived(opcode, data);
|
|
362
365
|
}
|
|
363
366
|
webSocketClosed(requestId) {
|
|
364
367
|
const ws = this._webSockets.get(requestId);
|
|
365
|
-
if (ws)
|
|
368
|
+
if (ws)
|
|
369
|
+
ws.closed();
|
|
366
370
|
this._webSockets.delete(requestId);
|
|
367
371
|
}
|
|
368
372
|
webSocketError(requestId, errorMessage) {
|
|
369
373
|
const ws = this._webSockets.get(requestId);
|
|
370
|
-
if (ws)
|
|
374
|
+
if (ws)
|
|
375
|
+
ws.error(errorMessage);
|
|
371
376
|
}
|
|
372
377
|
_fireInternalFrameNavigation(frame, event) {
|
|
373
378
|
frame.emit(Frame.Events.InternalNavigation, event);
|
|
374
379
|
}
|
|
375
380
|
}
|
|
376
|
-
|
|
377
|
-
class Frame extends _instrumentation.SdkObject {
|
|
381
|
+
class Frame extends import_instrumentation.SdkObject {
|
|
378
382
|
constructor(page, id, parentFrame) {
|
|
379
|
-
super(page,
|
|
380
|
-
this.
|
|
381
|
-
this._firedLifecycleEvents = new Set();
|
|
383
|
+
super(page, "frame");
|
|
384
|
+
this._firedLifecycleEvents = /* @__PURE__ */ new Set();
|
|
382
385
|
this._firedNetworkIdleSelf = false;
|
|
383
|
-
this.
|
|
384
|
-
this.
|
|
385
|
-
this.
|
|
386
|
-
this.
|
|
387
|
-
this.
|
|
388
|
-
this._contextData = new Map();
|
|
389
|
-
this._childFrames = new Set();
|
|
390
|
-
this._name = '';
|
|
391
|
-
this._inflightRequests = new Set();
|
|
392
|
-
this._networkIdleTimer = void 0;
|
|
386
|
+
this._url = "";
|
|
387
|
+
this._contextData = /* @__PURE__ */ new Map();
|
|
388
|
+
this._childFrames = /* @__PURE__ */ new Set();
|
|
389
|
+
this._name = "";
|
|
390
|
+
this._inflightRequests = /* @__PURE__ */ new Set();
|
|
393
391
|
this._setContentCounter = 0;
|
|
394
|
-
this._detachedScope = new
|
|
395
|
-
this._raceAgainstEvaluationStallingEventsPromises = new Set();
|
|
396
|
-
this._redirectedNavigations = new Map();
|
|
397
|
-
// documentId -> data
|
|
398
|
-
this.selectors = void 0;
|
|
399
|
-
this._isolatedWorld = void 0;
|
|
400
|
-
this._mainWorld = void 0;
|
|
401
|
-
this._iframeWorld = void 0;
|
|
392
|
+
this._detachedScope = new import_utils.LongStandingScope();
|
|
393
|
+
this._raceAgainstEvaluationStallingEventsPromises = /* @__PURE__ */ new Set();
|
|
394
|
+
this._redirectedNavigations = /* @__PURE__ */ new Map();
|
|
402
395
|
this.attribution.frame = this;
|
|
403
396
|
this._id = id;
|
|
404
397
|
this._page = page;
|
|
405
398
|
this._parentFrame = parentFrame;
|
|
406
|
-
this._currentDocument = {
|
|
407
|
-
|
|
408
|
-
|
|
399
|
+
this._currentDocument = { documentId: void 0, request: void 0 };
|
|
400
|
+
this.selectors = new import_frameSelectors.FrameSelectors(this);
|
|
401
|
+
this._contextData.set("main", { contextPromise: new import_manualPromise.ManualPromise(), context: null });
|
|
402
|
+
this._contextData.set("utility", { contextPromise: new import_manualPromise.ManualPromise(), context: null });
|
|
403
|
+
this._setContext("main", null);
|
|
404
|
+
this._setContext("utility", null);
|
|
405
|
+
if (this._parentFrame)
|
|
406
|
+
this._parentFrame._childFrames.add(this);
|
|
407
|
+
this._firedLifecycleEvents.add("commit");
|
|
408
|
+
if (id !== kDummyFrameId)
|
|
409
|
+
this._startNetworkIdleTimer();
|
|
410
|
+
}
|
|
411
|
+
static {
|
|
412
|
+
this.Events = {
|
|
413
|
+
InternalNavigation: "internalnavigation",
|
|
414
|
+
AddLifecycle: "addlifecycle",
|
|
415
|
+
RemoveLifecycle: "removelifecycle"
|
|
409
416
|
};
|
|
410
|
-
this.selectors = new _frameSelectors.FrameSelectors(this);
|
|
411
|
-
this._contextData.set('main', {
|
|
412
|
-
contextPromise: new _manualPromise.ManualPromise(),
|
|
413
|
-
context: null
|
|
414
|
-
});
|
|
415
|
-
this._contextData.set('utility', {
|
|
416
|
-
contextPromise: new _manualPromise.ManualPromise(),
|
|
417
|
-
context: null
|
|
418
|
-
});
|
|
419
|
-
this._setContext('main', null);
|
|
420
|
-
this._setContext('utility', null);
|
|
421
|
-
if (this._parentFrame) this._parentFrame._childFrames.add(this);
|
|
422
|
-
this._firedLifecycleEvents.add('commit');
|
|
423
|
-
if (id !== kDummyFrameId) this._startNetworkIdleTimer();
|
|
424
417
|
}
|
|
425
418
|
isDetached() {
|
|
426
419
|
return this._detachedScope.isClosed();
|
|
427
420
|
}
|
|
428
421
|
_onLifecycleEvent(event) {
|
|
429
|
-
if (this._firedLifecycleEvents.has(event))
|
|
422
|
+
if (this._firedLifecycleEvents.has(event))
|
|
423
|
+
return;
|
|
430
424
|
this._firedLifecycleEvents.add(event);
|
|
431
425
|
this.emit(Frame.Events.AddLifecycle, event);
|
|
432
|
-
if (this === this._page.mainFrame() && this._url !==
|
|
426
|
+
if (this === this._page.mainFrame() && this._url !== "about:blank")
|
|
427
|
+
import_debugLogger.debugLogger.log("api", ` "${event}" event fired`);
|
|
433
428
|
this._page.mainFrame()._recalculateNetworkIdle();
|
|
434
429
|
}
|
|
435
430
|
_onClearLifecycle() {
|
|
436
|
-
this._isolatedWorld =
|
|
437
|
-
this._mainWorld =
|
|
438
|
-
this._iframeWorld =
|
|
439
|
-
for (const event of this._firedLifecycleEvents)
|
|
431
|
+
this._isolatedWorld = void 0;
|
|
432
|
+
this._mainWorld = void 0;
|
|
433
|
+
this._iframeWorld = void 0;
|
|
434
|
+
for (const event of this._firedLifecycleEvents)
|
|
435
|
+
this.emit(Frame.Events.RemoveLifecycle, event);
|
|
440
436
|
this._firedLifecycleEvents.clear();
|
|
441
|
-
|
|
442
|
-
this._inflightRequests = new Set(Array.from(this._inflightRequests).filter(request => request === this._currentDocument.request));
|
|
437
|
+
this._inflightRequests = new Set(Array.from(this._inflightRequests).filter((request) => request === this._currentDocument.request));
|
|
443
438
|
this._stopNetworkIdleTimer();
|
|
444
|
-
if (this._inflightRequests.size === 0)
|
|
439
|
+
if (this._inflightRequests.size === 0)
|
|
440
|
+
this._startNetworkIdleTimer();
|
|
445
441
|
this._page.mainFrame()._recalculateNetworkIdle(this);
|
|
446
|
-
this._onLifecycleEvent(
|
|
442
|
+
this._onLifecycleEvent("commit");
|
|
447
443
|
}
|
|
448
444
|
setPendingDocument(documentInfo) {
|
|
449
445
|
this._pendingDocument = documentInfo;
|
|
450
|
-
if (documentInfo)
|
|
446
|
+
if (documentInfo)
|
|
447
|
+
this._invalidateNonStallingEvaluations("Navigation interrupted the evaluation");
|
|
451
448
|
}
|
|
452
449
|
pendingDocument() {
|
|
453
450
|
return this._pendingDocument;
|
|
454
451
|
}
|
|
455
452
|
_invalidateNonStallingEvaluations(message) {
|
|
456
|
-
if (!this._raceAgainstEvaluationStallingEventsPromises.size)
|
|
453
|
+
if (!this._raceAgainstEvaluationStallingEventsPromises.size)
|
|
454
|
+
return;
|
|
457
455
|
const error = new Error(message);
|
|
458
|
-
for (const promise of this._raceAgainstEvaluationStallingEventsPromises)
|
|
456
|
+
for (const promise of this._raceAgainstEvaluationStallingEventsPromises)
|
|
457
|
+
promise.reject(error);
|
|
459
458
|
}
|
|
460
459
|
async raceAgainstEvaluationStallingEvents(cb) {
|
|
461
|
-
if (this._pendingDocument)
|
|
462
|
-
|
|
463
|
-
|
|
460
|
+
if (this._pendingDocument)
|
|
461
|
+
throw new Error("Frame is currently attempting a navigation");
|
|
462
|
+
if (this._page._frameManager._openedDialogs.size)
|
|
463
|
+
throw new Error("Open JavaScript dialog prevents evaluation");
|
|
464
|
+
const promise = new import_manualPromise.ManualPromise();
|
|
464
465
|
this._raceAgainstEvaluationStallingEventsPromises.add(promise);
|
|
465
466
|
try {
|
|
466
|
-
return await Promise.race([
|
|
467
|
+
return await Promise.race([
|
|
468
|
+
cb(),
|
|
469
|
+
promise
|
|
470
|
+
]);
|
|
467
471
|
} finally {
|
|
468
472
|
this._raceAgainstEvaluationStallingEventsPromises.delete(promise);
|
|
469
473
|
}
|
|
@@ -471,41 +475,42 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
471
475
|
nonStallingRawEvaluateInExistingMainContext(expression) {
|
|
472
476
|
return this.raceAgainstEvaluationStallingEvents(() => {
|
|
473
477
|
const context = this._existingMainContext();
|
|
474
|
-
if (!context)
|
|
478
|
+
if (!context)
|
|
479
|
+
throw new Error("Frame does not yet have a main execution context");
|
|
475
480
|
return context.rawEvaluateJSON(expression);
|
|
476
481
|
});
|
|
477
482
|
}
|
|
478
483
|
nonStallingEvaluateInExistingContext(expression, world) {
|
|
479
484
|
return this.raceAgainstEvaluationStallingEvents(() => {
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
return context.evaluateExpression(expression, {
|
|
484
|
-
isFunction: false
|
|
485
|
-
});
|
|
485
|
+
const context = this._contextData.get(world)?.context;
|
|
486
|
+
if (!context)
|
|
487
|
+
throw new Error("Frame does not yet have the execution context");
|
|
488
|
+
return context.evaluateExpression(expression, { isFunction: false });
|
|
486
489
|
});
|
|
487
490
|
}
|
|
488
491
|
_recalculateNetworkIdle(frameThatAllowsRemovingNetworkIdle) {
|
|
489
492
|
let isNetworkIdle = this._firedNetworkIdleSelf;
|
|
490
493
|
for (const child of this._childFrames) {
|
|
491
494
|
child._recalculateNetworkIdle(frameThatAllowsRemovingNetworkIdle);
|
|
492
|
-
|
|
493
|
-
|
|
495
|
+
if (!child._firedLifecycleEvents.has("networkidle"))
|
|
496
|
+
isNetworkIdle = false;
|
|
494
497
|
}
|
|
495
|
-
if (isNetworkIdle && !this._firedLifecycleEvents.has(
|
|
496
|
-
this._firedLifecycleEvents.add(
|
|
497
|
-
this.emit(Frame.Events.AddLifecycle,
|
|
498
|
-
if (this === this._page.mainFrame() && this._url !==
|
|
498
|
+
if (isNetworkIdle && !this._firedLifecycleEvents.has("networkidle")) {
|
|
499
|
+
this._firedLifecycleEvents.add("networkidle");
|
|
500
|
+
this.emit(Frame.Events.AddLifecycle, "networkidle");
|
|
501
|
+
if (this === this._page.mainFrame() && this._url !== "about:blank")
|
|
502
|
+
import_debugLogger.debugLogger.log("api", ` "networkidle" event fired`);
|
|
499
503
|
}
|
|
500
|
-
if (frameThatAllowsRemovingNetworkIdle !== this && this._firedLifecycleEvents.has(
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
this._firedLifecycleEvents.delete('networkidle');
|
|
504
|
-
this.emit(Frame.Events.RemoveLifecycle, 'networkidle');
|
|
504
|
+
if (frameThatAllowsRemovingNetworkIdle !== this && this._firedLifecycleEvents.has("networkidle") && !isNetworkIdle) {
|
|
505
|
+
this._firedLifecycleEvents.delete("networkidle");
|
|
506
|
+
this.emit(Frame.Events.RemoveLifecycle, "networkidle");
|
|
505
507
|
}
|
|
506
508
|
}
|
|
507
509
|
async raceNavigationAction(progress, options, action) {
|
|
508
|
-
return
|
|
510
|
+
return import_utils.LongStandingScope.raceMultiple([
|
|
511
|
+
this._detachedScope,
|
|
512
|
+
this._page.openScope
|
|
513
|
+
], action().catch((e) => {
|
|
509
514
|
if (e instanceof NavigationAbortedError && e.documentId) {
|
|
510
515
|
const data = this._redirectedNavigations.get(e.documentId);
|
|
511
516
|
if (data) {
|
|
@@ -517,95 +522,96 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
517
522
|
}));
|
|
518
523
|
}
|
|
519
524
|
redirectNavigation(url, documentId, referer) {
|
|
520
|
-
const controller = new
|
|
525
|
+
const controller = new import_progress.ProgressController((0, import_instrumentation.serverSideCallMetadata)(), this);
|
|
521
526
|
const data = {
|
|
522
527
|
url,
|
|
523
|
-
gotoPromise: controller.run(progress => this._gotoAction(progress, url, {
|
|
524
|
-
referer
|
|
525
|
-
}), 0)
|
|
528
|
+
gotoPromise: controller.run((progress) => this._gotoAction(progress, url, { referer }), 0)
|
|
526
529
|
};
|
|
527
530
|
this._redirectedNavigations.set(documentId, data);
|
|
528
531
|
data.gotoPromise.finally(() => this._redirectedNavigations.delete(documentId));
|
|
529
532
|
}
|
|
530
533
|
async goto(metadata, url, options = {}) {
|
|
531
|
-
const constructedNavigationURL = (0,
|
|
532
|
-
const controller = new
|
|
533
|
-
return controller.run(progress => this._goto(progress, constructedNavigationURL, options), this._page._timeoutSettings.navigationTimeout(options));
|
|
534
|
+
const constructedNavigationURL = (0, import_utils.constructURLBasedOnBaseURL)(this._page._browserContext._options.baseURL, url);
|
|
535
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
536
|
+
return controller.run((progress) => this._goto(progress, constructedNavigationURL, options), this._page._timeoutSettings.navigationTimeout(options));
|
|
534
537
|
}
|
|
535
538
|
async _goto(progress, url, options) {
|
|
536
539
|
return this.raceNavigationAction(progress, options, async () => this._gotoAction(progress, url, options));
|
|
537
540
|
}
|
|
538
541
|
async _gotoAction(progress, url, options) {
|
|
539
|
-
const waitUntil = verifyLifecycle(
|
|
542
|
+
const waitUntil = verifyLifecycle("waitUntil", options.waitUntil === void 0 ? "load" : options.waitUntil);
|
|
540
543
|
progress.log(`navigating to "${url}", waiting until "${waitUntil}"`);
|
|
541
544
|
const headers = this._page.extraHTTPHeaders() || [];
|
|
542
|
-
const refererHeader = headers.find(h => h.name.toLowerCase() ===
|
|
543
|
-
let referer = refererHeader ? refererHeader.value :
|
|
544
|
-
if (options.referer !==
|
|
545
|
-
if (referer !==
|
|
545
|
+
const refererHeader = headers.find((h) => h.name.toLowerCase() === "referer");
|
|
546
|
+
let referer = refererHeader ? refererHeader.value : void 0;
|
|
547
|
+
if (options.referer !== void 0) {
|
|
548
|
+
if (referer !== void 0 && referer !== options.referer)
|
|
549
|
+
throw new Error('"referer" is already specified as extra HTTP header');
|
|
546
550
|
referer = options.referer;
|
|
547
551
|
}
|
|
548
|
-
url =
|
|
552
|
+
url = import_helper.helper.completeUserURL(url);
|
|
549
553
|
const navigationEvents = [];
|
|
550
|
-
const collectNavigations = arg => navigationEvents.push(arg);
|
|
554
|
+
const collectNavigations = (arg) => navigationEvents.push(arg);
|
|
551
555
|
this.on(Frame.Events.InternalNavigation, collectNavigations);
|
|
552
|
-
const navigateResult = await this._page._delegate.navigateFrame(this, url, referer).finally(
|
|
556
|
+
const navigateResult = await this._page._delegate.navigateFrame(this, url, referer).finally(
|
|
557
|
+
() => this.off(Frame.Events.InternalNavigation, collectNavigations)
|
|
558
|
+
);
|
|
553
559
|
let event;
|
|
554
560
|
if (navigateResult.newDocumentId) {
|
|
555
|
-
const predicate =
|
|
556
|
-
|
|
557
|
-
// did commit and replaced the expected document.
|
|
558
|
-
return event.newDocument && (event.newDocument.documentId === navigateResult.newDocumentId || !event.error);
|
|
561
|
+
const predicate = (event2) => {
|
|
562
|
+
return event2.newDocument && (event2.newDocument.documentId === navigateResult.newDocumentId || !event2.error);
|
|
559
563
|
};
|
|
560
564
|
const events = navigationEvents.filter(predicate);
|
|
561
|
-
if (events.length)
|
|
565
|
+
if (events.length)
|
|
566
|
+
event = events[0];
|
|
567
|
+
else
|
|
568
|
+
event = await import_helper.helper.waitForEvent(progress, this, Frame.Events.InternalNavigation, predicate).promise;
|
|
562
569
|
if (event.newDocument.documentId !== navigateResult.newDocumentId) {
|
|
563
|
-
// This is just a sanity check. In practice, new navigation should
|
|
564
|
-
// cancel the previous one and report "request cancelled"-like error.
|
|
565
570
|
throw new NavigationAbortedError(navigateResult.newDocumentId, `Navigation to "${url}" is interrupted by another navigation to "${event.url}"`);
|
|
566
571
|
}
|
|
567
|
-
if (event.error)
|
|
572
|
+
if (event.error)
|
|
573
|
+
throw event.error;
|
|
568
574
|
} else {
|
|
569
|
-
|
|
570
|
-
const predicate = e => !e.newDocument;
|
|
575
|
+
const predicate = (e) => !e.newDocument;
|
|
571
576
|
const events = navigationEvents.filter(predicate);
|
|
572
|
-
if (events.length)
|
|
577
|
+
if (events.length)
|
|
578
|
+
event = events[0];
|
|
579
|
+
else
|
|
580
|
+
event = await import_helper.helper.waitForEvent(progress, this, Frame.Events.InternalNavigation, predicate).promise;
|
|
573
581
|
}
|
|
574
|
-
if (!this._firedLifecycleEvents.has(waitUntil))
|
|
575
|
-
|
|
582
|
+
if (!this._firedLifecycleEvents.has(waitUntil))
|
|
583
|
+
await import_helper.helper.waitForEvent(progress, this, Frame.Events.AddLifecycle, (e) => e === waitUntil).promise;
|
|
584
|
+
const request = event.newDocument ? event.newDocument.request : void 0;
|
|
576
585
|
const response = request ? request._finalRequest().response() : null;
|
|
577
586
|
return response;
|
|
578
587
|
}
|
|
579
588
|
async _waitForNavigation(progress, requiresNewDocument, options) {
|
|
580
|
-
const waitUntil = verifyLifecycle(
|
|
589
|
+
const waitUntil = verifyLifecycle("waitUntil", options.waitUntil === void 0 ? "load" : options.waitUntil);
|
|
581
590
|
progress.log(`waiting for navigation until "${waitUntil}"`);
|
|
582
|
-
const navigationEvent = await
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
if (requiresNewDocument && !event.newDocument)
|
|
591
|
+
const navigationEvent = await import_helper.helper.waitForEvent(progress, this, Frame.Events.InternalNavigation, (event) => {
|
|
592
|
+
if (event.error)
|
|
593
|
+
return true;
|
|
594
|
+
if (requiresNewDocument && !event.newDocument)
|
|
595
|
+
return false;
|
|
586
596
|
progress.log(` navigated to "${this._url}"`);
|
|
587
597
|
return true;
|
|
588
598
|
}).promise;
|
|
589
|
-
if (navigationEvent.error)
|
|
590
|
-
|
|
591
|
-
|
|
599
|
+
if (navigationEvent.error)
|
|
600
|
+
throw navigationEvent.error;
|
|
601
|
+
if (!this._firedLifecycleEvents.has(waitUntil))
|
|
602
|
+
await import_helper.helper.waitForEvent(progress, this, Frame.Events.AddLifecycle, (e) => e === waitUntil).promise;
|
|
603
|
+
const request = navigationEvent.newDocument ? navigationEvent.newDocument.request : void 0;
|
|
592
604
|
return request ? request._finalRequest().response() : null;
|
|
593
605
|
}
|
|
594
606
|
async _waitForLoadState(progress, state) {
|
|
595
|
-
const waitUntil = verifyLifecycle(
|
|
596
|
-
if (!this._firedLifecycleEvents.has(waitUntil))
|
|
607
|
+
const waitUntil = verifyLifecycle("state", state);
|
|
608
|
+
if (!this._firedLifecycleEvents.has(waitUntil))
|
|
609
|
+
await import_helper.helper.waitForEvent(progress, this, Frame.Events.AddLifecycle, (e) => e === waitUntil).promise;
|
|
597
610
|
}
|
|
598
611
|
async frameElement() {
|
|
599
612
|
return this._page._delegate.getFrameElement(this);
|
|
600
613
|
}
|
|
601
614
|
async _context(world) {
|
|
602
|
-
/* await this._page._delegate._mainFrameSession._client._sendMayFail('DOM.enable');
|
|
603
|
-
var globalDoc = await this._page._delegate._mainFrameSession._client._sendMayFail('DOM.getFrameOwner', { frameId: this._id });
|
|
604
|
-
if (globalDoc) {
|
|
605
|
-
await this._page._delegate._mainFrameSession._client._sendMayFail("DOM.resolveNode", { nodeId: globalDoc.nodeId })
|
|
606
|
-
} */
|
|
607
|
-
|
|
608
|
-
// if (this.isDetached()) throw new Error('Frame was detached');
|
|
609
615
|
try {
|
|
610
616
|
var client = this._page._delegate._sessionForFrame(this)._client;
|
|
611
617
|
} catch (e) {
|
|
@@ -613,76 +619,54 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
613
619
|
}
|
|
614
620
|
var iframeExecutionContextId = await this._getFrameMainFrameContextId(client);
|
|
615
621
|
if (world == "main") {
|
|
616
|
-
|
|
617
|
-
if (this != this._page.mainFrame() && iframeExecutionContextId && this._iframeWorld == undefined) {
|
|
622
|
+
if (this != this._page.mainFrame() && iframeExecutionContextId && this._iframeWorld == void 0) {
|
|
618
623
|
var executionContextId = iframeExecutionContextId;
|
|
619
|
-
var crContext = new
|
|
620
|
-
|
|
621
|
-
}, this._id);
|
|
622
|
-
this._iframeWorld = new _dom.FrameExecutionContext(crContext, this, world);
|
|
624
|
+
var crContext = new import_crExecutionContext.CRExecutionContext(client, { id: executionContextId }, this._id);
|
|
625
|
+
this._iframeWorld = new import_dom.FrameExecutionContext(crContext, this, world);
|
|
623
626
|
this._page._delegate._mainFrameSession._onExecutionContextCreated({
|
|
624
627
|
id: executionContextId,
|
|
625
628
|
origin: world,
|
|
626
629
|
name: world,
|
|
627
|
-
auxData: {
|
|
628
|
-
isDefault: this === this._page.mainFrame(),
|
|
629
|
-
type: 'isolated',
|
|
630
|
-
frameId: this._id
|
|
631
|
-
}
|
|
630
|
+
auxData: { isDefault: this === this._page.mainFrame(), type: "isolated", frameId: this._id }
|
|
632
631
|
});
|
|
633
|
-
} else if (this._mainWorld ==
|
|
634
|
-
var
|
|
632
|
+
} else if (this._mainWorld == void 0) {
|
|
633
|
+
var globalThis2 = await client._sendMayFail("Runtime.evaluate", {
|
|
635
634
|
expression: "globalThis",
|
|
636
|
-
serializationOptions: {
|
|
637
|
-
serialization: "idOnly"
|
|
638
|
-
}
|
|
635
|
+
serializationOptions: { serialization: "idOnly" }
|
|
639
636
|
});
|
|
640
|
-
if (!
|
|
637
|
+
if (!globalThis2) {
|
|
641
638
|
return;
|
|
642
639
|
}
|
|
643
|
-
var globalThisObjId =
|
|
644
|
-
var executionContextId = parseInt(globalThisObjId.split(
|
|
645
|
-
var crContext = new
|
|
646
|
-
|
|
647
|
-
}, this._id);
|
|
648
|
-
this._mainWorld = new _dom.FrameExecutionContext(crContext, this, world);
|
|
640
|
+
var globalThisObjId = globalThis2["result"]["objectId"];
|
|
641
|
+
var executionContextId = parseInt(globalThisObjId.split(".")[1], 10);
|
|
642
|
+
var crContext = new import_crExecutionContext.CRExecutionContext(client, { id: executionContextId }, this._id);
|
|
643
|
+
this._mainWorld = new import_dom.FrameExecutionContext(crContext, this, world);
|
|
649
644
|
this._page._delegate._mainFrameSession._onExecutionContextCreated({
|
|
650
645
|
id: executionContextId,
|
|
651
646
|
origin: world,
|
|
652
647
|
name: world,
|
|
653
|
-
auxData: {
|
|
654
|
-
isDefault: this === this._page.mainFrame(),
|
|
655
|
-
type: 'isolated',
|
|
656
|
-
frameId: this._id
|
|
657
|
-
}
|
|
648
|
+
auxData: { isDefault: this === this._page.mainFrame(), type: "isolated", frameId: this._id }
|
|
658
649
|
});
|
|
659
650
|
}
|
|
660
651
|
}
|
|
661
|
-
if (world != "main" && this._isolatedWorld ==
|
|
652
|
+
if (world != "main" && this._isolatedWorld == void 0) {
|
|
662
653
|
world = "utility";
|
|
663
|
-
var result = await client._sendMayFail(
|
|
654
|
+
var result = await client._sendMayFail("Page.createIsolatedWorld", {
|
|
664
655
|
frameId: this._id,
|
|
665
656
|
grantUniveralAccess: true,
|
|
666
657
|
worldName: world
|
|
667
658
|
});
|
|
668
659
|
if (!result) {
|
|
669
|
-
// if (this.isDetached()) throw new Error("Frame was detached");
|
|
670
660
|
return;
|
|
671
661
|
}
|
|
672
662
|
var executionContextId = result.executionContextId;
|
|
673
|
-
var crContext = new
|
|
674
|
-
|
|
675
|
-
}, this._id);
|
|
676
|
-
this._isolatedWorld = new _dom.FrameExecutionContext(crContext, this, world);
|
|
663
|
+
var crContext = new import_crExecutionContext.CRExecutionContext(client, { id: executionContextId }, this._id);
|
|
664
|
+
this._isolatedWorld = new import_dom.FrameExecutionContext(crContext, this, world);
|
|
677
665
|
this._page._delegate._mainFrameSession._onExecutionContextCreated({
|
|
678
666
|
id: executionContextId,
|
|
679
667
|
origin: world,
|
|
680
668
|
name: world,
|
|
681
|
-
auxData: {
|
|
682
|
-
isDefault: this === this._page.mainFrame(),
|
|
683
|
-
type: 'isolated',
|
|
684
|
-
frameId: this._id
|
|
685
|
-
}
|
|
669
|
+
auxData: { isDefault: this === this._page.mainFrame(), type: "isolated", frameId: this._id }
|
|
686
670
|
});
|
|
687
671
|
}
|
|
688
672
|
if (world != "main") {
|
|
@@ -694,65 +678,59 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
694
678
|
}
|
|
695
679
|
}
|
|
696
680
|
_mainContext() {
|
|
697
|
-
return this._context(
|
|
681
|
+
return this._context("main");
|
|
698
682
|
}
|
|
699
683
|
_existingMainContext() {
|
|
700
|
-
|
|
701
|
-
return ((_this$_contextData$ge2 = this._contextData.get('main')) === null || _this$_contextData$ge2 === void 0 ? void 0 : _this$_contextData$ge2.context) || null;
|
|
684
|
+
return this._contextData.get("main")?.context || null;
|
|
702
685
|
}
|
|
703
686
|
_utilityContext() {
|
|
704
|
-
return this._context(
|
|
687
|
+
return this._context("utility");
|
|
705
688
|
}
|
|
706
689
|
async evaluateExpression(expression, options = {}, arg) {
|
|
707
|
-
|
|
708
|
-
const context = await this._context((_options$world = options.world) !== null && _options$world !== void 0 ? _options$world : 'main');
|
|
690
|
+
const context = await this._context(options.world ?? "main");
|
|
709
691
|
const value = await context.evaluateExpression(expression, options, arg);
|
|
710
692
|
return value;
|
|
711
693
|
}
|
|
712
694
|
async evaluateExpressionHandle(expression, options = {}, arg) {
|
|
713
|
-
|
|
714
|
-
const context = await this._context((_options$world2 = options.world) !== null && _options$world2 !== void 0 ? _options$world2 : 'main');
|
|
695
|
+
const context = await this._context(options.world ?? "main");
|
|
715
696
|
const value = await context.evaluateExpressionHandle(expression, options, arg);
|
|
716
697
|
return value;
|
|
717
698
|
}
|
|
718
699
|
async querySelector(selector, options) {
|
|
719
|
-
|
|
700
|
+
import_debugLogger.debugLogger.log("api", ` finding element using the selector "${selector}"`);
|
|
720
701
|
return this.selectors.query(selector, options);
|
|
721
702
|
}
|
|
722
703
|
async waitForSelector(metadata, selector, options, scope) {
|
|
723
|
-
const controller = new
|
|
724
|
-
if (options.visibility)
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
} = options;
|
|
729
|
-
if (![
|
|
730
|
-
|
|
731
|
-
|
|
704
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
705
|
+
if (options.visibility)
|
|
706
|
+
throw new Error("options.visibility is not supported, did you mean options.state?");
|
|
707
|
+
if (options.waitFor && options.waitFor !== "visible")
|
|
708
|
+
throw new Error("options.waitFor is not supported, did you mean options.state?");
|
|
709
|
+
const { state = "visible" } = options;
|
|
710
|
+
if (!["attached", "detached", "visible", "hidden"].includes(state))
|
|
711
|
+
throw new Error(`state: expected one of (attached|detached|visible|hidden)`);
|
|
712
|
+
return controller.run(async (progress) => {
|
|
713
|
+
progress.log(`waiting for ${this._asLocator(selector)}${state === "attached" ? "" : " to be " + state}`);
|
|
732
714
|
return await this.waitForSelectorInternal(progress, selector, true, options, scope);
|
|
733
715
|
}, this._page._timeoutSettings.timeout(options));
|
|
734
716
|
}
|
|
735
717
|
async waitForSelectorInternal(progress, selector, performActionPreChecks, options, scope) {
|
|
736
718
|
const {
|
|
737
|
-
state =
|
|
719
|
+
state = "visible"
|
|
738
720
|
} = options;
|
|
739
|
-
const promise = this._retryWithProgressIfNotConnected(progress, selector, options.strict, true, async handle => {
|
|
721
|
+
const promise = this._retryWithProgressIfNotConnected(progress, selector, options.strict, true, async (handle) => {
|
|
740
722
|
const attached = !!handle;
|
|
741
723
|
var visible = false;
|
|
742
724
|
if (attached) {
|
|
743
725
|
if (handle.parentNode.constructor.name == "ElementHandle") {
|
|
744
|
-
visible = await handle.parentNode.evaluateInUtility(([injected, node, {
|
|
745
|
-
|
|
746
|
-
}]) => {
|
|
747
|
-
return handle ? injected.utils.isElementVisible(handle) : false;
|
|
726
|
+
visible = await handle.parentNode.evaluateInUtility(([injected, node, { handle: handle2 }]) => {
|
|
727
|
+
return handle2 ? injected.utils.isElementVisible(handle2) : false;
|
|
748
728
|
}, {
|
|
749
729
|
handle
|
|
750
730
|
});
|
|
751
731
|
} else {
|
|
752
|
-
visible = await handle.parentNode.evaluate((injected, {
|
|
753
|
-
|
|
754
|
-
}) => {
|
|
755
|
-
return handle ? injected.utils.isElementVisible(handle) : false;
|
|
732
|
+
visible = await handle.parentNode.evaluate((injected, { handle: handle2 }) => {
|
|
733
|
+
return handle2 ? injected.utils.isElementVisible(handle2) : false;
|
|
756
734
|
}, {
|
|
757
735
|
handle
|
|
758
736
|
});
|
|
@@ -770,7 +748,7 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
770
748
|
if (options.omitReturnValue) {
|
|
771
749
|
return null;
|
|
772
750
|
}
|
|
773
|
-
const element = state ===
|
|
751
|
+
const element = state === "attached" || state === "visible" ? handle : null;
|
|
774
752
|
if (!element) return null;
|
|
775
753
|
if (options.__testHookBeforeAdoptNode) await options.__testHookBeforeAdoptNode();
|
|
776
754
|
try {
|
|
@@ -778,101 +756,94 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
778
756
|
} catch (e) {
|
|
779
757
|
return "internal:continuepolling";
|
|
780
758
|
}
|
|
781
|
-
}
|
|
759
|
+
});
|
|
782
760
|
return scope ? scope._context._raceAgainstContextDestroyed(promise) : promise;
|
|
783
761
|
}
|
|
784
762
|
async dispatchEvent(metadata, selector, type, eventInit = {}, options = {}, scope) {
|
|
785
763
|
await this._callOnElementOnceMatches(metadata, selector, (injectedScript, element, data) => {
|
|
786
764
|
injectedScript.dispatchEvent(element, data.type, data.eventInit);
|
|
787
|
-
}, {
|
|
788
|
-
type,
|
|
789
|
-
eventInit
|
|
790
|
-
}, {
|
|
791
|
-
mainWorld: true,
|
|
792
|
-
...options
|
|
793
|
-
}, scope);
|
|
765
|
+
}, { type, eventInit }, { mainWorld: true, ...options }, scope);
|
|
794
766
|
}
|
|
795
767
|
async evalOnSelector(selector, strict, expression, isFunction, arg, scope) {
|
|
796
|
-
const handle = await this.selectors.query(selector, {
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
const result = await handle.evaluateExpression(expression, {
|
|
801
|
-
isFunction
|
|
802
|
-
}, arg);
|
|
768
|
+
const handle = await this.selectors.query(selector, { strict }, scope);
|
|
769
|
+
if (!handle)
|
|
770
|
+
throw new Error(`Failed to find element matching selector "${selector}"`);
|
|
771
|
+
const result = await handle.evaluateExpression(expression, { isFunction }, arg);
|
|
803
772
|
handle.dispose();
|
|
804
773
|
return result;
|
|
805
774
|
}
|
|
806
775
|
async evalOnSelectorAll(selector, expression, isFunction, arg, scope) {
|
|
807
776
|
const arrayHandle = await this.selectors.queryArrayInMainWorld(selector, scope);
|
|
808
|
-
const result = await arrayHandle.evaluateExpression(expression, {
|
|
809
|
-
isFunction
|
|
810
|
-
}, arg);
|
|
777
|
+
const result = await arrayHandle.evaluateExpression(expression, { isFunction }, arg);
|
|
811
778
|
arrayHandle.dispose();
|
|
812
779
|
return result;
|
|
813
780
|
}
|
|
814
781
|
async maskSelectors(selectors, color) {
|
|
815
782
|
const context = await this._utilityContext();
|
|
816
783
|
const injectedScript = await context.injectedScript();
|
|
817
|
-
await injectedScript.evaluate((injected, {
|
|
818
|
-
parsed,
|
|
819
|
-
|
|
820
|
-
}) => {
|
|
821
|
-
injected.maskSelectors(parsed, color);
|
|
822
|
-
}, {
|
|
823
|
-
parsed: selectors,
|
|
824
|
-
color: color
|
|
825
|
-
});
|
|
784
|
+
await injectedScript.evaluate((injected, { parsed, color: color2 }) => {
|
|
785
|
+
injected.maskSelectors(parsed, color2);
|
|
786
|
+
}, { parsed: selectors, color });
|
|
826
787
|
}
|
|
827
788
|
async querySelectorAll(selector) {
|
|
828
789
|
return this.selectors.queryAll(selector);
|
|
829
790
|
}
|
|
830
791
|
async queryCount(selector) {
|
|
831
|
-
|
|
792
|
+
const custom_metadata = {
|
|
793
|
+
"internal": false,
|
|
794
|
+
"log": []
|
|
795
|
+
};
|
|
796
|
+
const controller = new import_progress.ProgressController(custom_metadata, this);
|
|
797
|
+
return await controller.run(async (progress) => {
|
|
798
|
+
progress.log("waiting for " + this._asLocator(selector));
|
|
799
|
+
const promise = await this._retryWithProgressIfNotConnected(progress, selector, false, false, async (result) => {
|
|
800
|
+
const handle = result[0];
|
|
801
|
+
const handles = result[1];
|
|
802
|
+
return handle ? handles.length : 0;
|
|
803
|
+
}, "returnAll");
|
|
804
|
+
return promise;
|
|
805
|
+
}, 100);
|
|
832
806
|
}
|
|
833
807
|
async content() {
|
|
834
808
|
try {
|
|
835
809
|
const context = await this._utilityContext();
|
|
836
810
|
return await context.evaluate(() => {
|
|
837
|
-
let retVal =
|
|
838
|
-
if (document.doctype)
|
|
839
|
-
|
|
811
|
+
let retVal = "";
|
|
812
|
+
if (document.doctype)
|
|
813
|
+
retVal = new XMLSerializer().serializeToString(document.doctype);
|
|
814
|
+
if (document.documentElement)
|
|
815
|
+
retVal += document.documentElement.outerHTML;
|
|
840
816
|
return retVal;
|
|
841
817
|
});
|
|
842
818
|
} catch (e) {
|
|
843
|
-
if (js.isJavaScriptErrorInEvaluate(e) || (0,
|
|
819
|
+
if (js.isJavaScriptErrorInEvaluate(e) || (0, import_protocolError.isSessionClosedError)(e))
|
|
820
|
+
throw e;
|
|
844
821
|
throw new Error(`Unable to retrieve content because the page is navigating and changing the content.`);
|
|
845
822
|
}
|
|
846
823
|
}
|
|
847
824
|
async setContent(metadata, html, options = {}) {
|
|
848
|
-
const controller = new
|
|
849
|
-
return controller.run(async progress => {
|
|
825
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
826
|
+
return controller.run(async (progress) => {
|
|
850
827
|
await this.raceNavigationAction(progress, options, async () => {
|
|
851
|
-
const waitUntil = options.waitUntil ===
|
|
828
|
+
const waitUntil = options.waitUntil === void 0 ? "load" : options.waitUntil;
|
|
852
829
|
progress.log(`setting frame content, waiting until "${waitUntil}"`);
|
|
853
830
|
const tag = `--playwright--set--content--${this._id}--${++this._setContentCounter}--`;
|
|
854
|
-
const bindingName = "_tagDebug" +
|
|
831
|
+
const bindingName = "_tagDebug" + import_crypto.default.randomBytes(20).toString("hex");
|
|
855
832
|
const context = await this._utilityContext();
|
|
856
|
-
await this._page._delegate._mainFrameSession._client.send(
|
|
857
|
-
name: bindingName
|
|
858
|
-
});
|
|
833
|
+
await this._page._delegate._mainFrameSession._client.send("Runtime.addBinding", { name: bindingName });
|
|
859
834
|
const lifecyclePromise = new Promise(async (resolve, reject) => {
|
|
860
|
-
await this._page.exposeBinding(bindingName, false,
|
|
835
|
+
await this._page.exposeBinding(bindingName, false, (tag2) => {
|
|
861
836
|
this._onClearLifecycle();
|
|
862
837
|
this._waitForLoadState(progress, waitUntil).then(resolve).catch(reject);
|
|
863
838
|
});
|
|
864
839
|
});
|
|
865
|
-
const contentPromise = context.evaluate(({
|
|
866
|
-
html,
|
|
867
|
-
tag,
|
|
868
|
-
bindingName
|
|
869
|
-
}) => {
|
|
840
|
+
const contentPromise = context.evaluate(({ html: html2, tag: tag2, bindingName: bindingName2 }) => {
|
|
870
841
|
document.open();
|
|
871
|
-
var _tagDebug = window[
|
|
872
|
-
delete window[
|
|
873
|
-
_tagDebug('{ "name": "' +
|
|
874
|
-
console.debug(
|
|
875
|
-
document.write(
|
|
842
|
+
var _tagDebug = window[bindingName2].bind({});
|
|
843
|
+
delete window[bindingName2];
|
|
844
|
+
_tagDebug('{ "name": "' + bindingName2 + '", "seq": 1, "serializedArgs": ["' + tag2 + '"] }');
|
|
845
|
+
console.debug(tag2);
|
|
846
|
+
document.write(html2);
|
|
876
847
|
document.close();
|
|
877
848
|
}, {
|
|
878
849
|
html,
|
|
@@ -885,15 +856,15 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
885
856
|
}, this._page._timeoutSettings.navigationTimeout(options));
|
|
886
857
|
}
|
|
887
858
|
name() {
|
|
888
|
-
return this._name ||
|
|
859
|
+
return this._name || "";
|
|
889
860
|
}
|
|
890
861
|
url() {
|
|
891
862
|
return this._url;
|
|
892
863
|
}
|
|
893
864
|
origin() {
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
return
|
|
865
|
+
if (!this._url.startsWith("http"))
|
|
866
|
+
return;
|
|
867
|
+
return network.parseURL(this._url)?.origin;
|
|
897
868
|
}
|
|
898
869
|
parentFrame() {
|
|
899
870
|
return this._parentFrame;
|
|
@@ -905,44 +876,41 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
905
876
|
const {
|
|
906
877
|
url = null,
|
|
907
878
|
content = null,
|
|
908
|
-
type =
|
|
879
|
+
type = ""
|
|
909
880
|
} = params;
|
|
910
|
-
if (!url && !content)
|
|
881
|
+
if (!url && !content)
|
|
882
|
+
throw new Error("Provide an object with a `url`, `path` or `content` property");
|
|
911
883
|
const context = await this._mainContext();
|
|
912
884
|
return this._raceWithCSPError(async () => {
|
|
913
|
-
if (url !== null)
|
|
914
|
-
url,
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
content: content,
|
|
919
|
-
type
|
|
920
|
-
})).asElement();
|
|
921
|
-
// Another round trip to the browser to ensure that we receive CSP error messages
|
|
922
|
-
// (if any) logged asynchronously in a separate task on the content main thread.
|
|
923
|
-
if (this._page._delegate.cspErrorsAsynchronousForInlineScripts) await context.evaluate(() => true);
|
|
885
|
+
if (url !== null)
|
|
886
|
+
return (await context.evaluateHandle(addScriptUrl, { url, type })).asElement();
|
|
887
|
+
const result = (await context.evaluateHandle(addScriptContent, { content, type })).asElement();
|
|
888
|
+
if (this._page._delegate.cspErrorsAsynchronousForInlineScripts)
|
|
889
|
+
await context.evaluate(() => true);
|
|
924
890
|
return result;
|
|
925
891
|
});
|
|
926
|
-
async function addScriptUrl(
|
|
927
|
-
const script = document.createElement(
|
|
928
|
-
script.src =
|
|
929
|
-
if (
|
|
892
|
+
async function addScriptUrl(params2) {
|
|
893
|
+
const script = document.createElement("script");
|
|
894
|
+
script.src = params2.url;
|
|
895
|
+
if (params2.type)
|
|
896
|
+
script.type = params2.type;
|
|
930
897
|
const promise = new Promise((res, rej) => {
|
|
931
898
|
script.onload = res;
|
|
932
|
-
script.onerror = e => rej(typeof e ===
|
|
899
|
+
script.onerror = (e) => rej(typeof e === "string" ? new Error(e) : new Error(`Failed to load script at ${script.src}`));
|
|
933
900
|
});
|
|
934
901
|
document.head.appendChild(script);
|
|
935
902
|
await promise;
|
|
936
903
|
return script;
|
|
937
904
|
}
|
|
938
|
-
function addScriptContent(
|
|
939
|
-
const script = document.createElement(
|
|
940
|
-
script.type =
|
|
941
|
-
script.text =
|
|
905
|
+
function addScriptContent(params2) {
|
|
906
|
+
const script = document.createElement("script");
|
|
907
|
+
script.type = params2.type || "text/javascript";
|
|
908
|
+
script.text = params2.content;
|
|
942
909
|
let error = null;
|
|
943
|
-
script.onerror = e => error = e;
|
|
910
|
+
script.onerror = (e) => error = e;
|
|
944
911
|
document.head.appendChild(script);
|
|
945
|
-
if (error)
|
|
912
|
+
if (error)
|
|
913
|
+
throw error;
|
|
946
914
|
return script;
|
|
947
915
|
}
|
|
948
916
|
}
|
|
@@ -951,16 +919,18 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
951
919
|
url = null,
|
|
952
920
|
content = null
|
|
953
921
|
} = params;
|
|
954
|
-
if (!url && !content)
|
|
922
|
+
if (!url && !content)
|
|
923
|
+
throw new Error("Provide an object with a `url`, `path` or `content` property");
|
|
955
924
|
const context = await this._mainContext();
|
|
956
925
|
return this._raceWithCSPError(async () => {
|
|
957
|
-
if (url !== null)
|
|
926
|
+
if (url !== null)
|
|
927
|
+
return (await context.evaluateHandle(addStyleUrl, url)).asElement();
|
|
958
928
|
return (await context.evaluateHandle(addStyleContent, content)).asElement();
|
|
959
929
|
});
|
|
960
|
-
async function addStyleUrl(
|
|
961
|
-
const link = document.createElement(
|
|
962
|
-
link.rel =
|
|
963
|
-
link.href =
|
|
930
|
+
async function addStyleUrl(url2) {
|
|
931
|
+
const link = document.createElement("link");
|
|
932
|
+
link.rel = "stylesheet";
|
|
933
|
+
link.href = url2;
|
|
964
934
|
const promise = new Promise((res, rej) => {
|
|
965
935
|
link.onload = res;
|
|
966
936
|
link.onerror = rej;
|
|
@@ -969,10 +939,10 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
969
939
|
await promise;
|
|
970
940
|
return link;
|
|
971
941
|
}
|
|
972
|
-
async function addStyleContent(
|
|
973
|
-
const style = document.createElement(
|
|
974
|
-
style.type =
|
|
975
|
-
style.appendChild(document.createTextNode(
|
|
942
|
+
async function addStyleContent(content2) {
|
|
943
|
+
const style = document.createElement("style");
|
|
944
|
+
style.type = "text/css";
|
|
945
|
+
style.appendChild(document.createTextNode(content2));
|
|
976
946
|
const promise = new Promise((res, rej) => {
|
|
977
947
|
style.onload = res;
|
|
978
948
|
style.onerror = rej;
|
|
@@ -987,68 +957,73 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
987
957
|
let result;
|
|
988
958
|
let error;
|
|
989
959
|
let cspMessage;
|
|
990
|
-
const actionPromise = func().then(r => result = r).catch(e => error = e);
|
|
991
|
-
const errorPromise = new Promise(resolve => {
|
|
992
|
-
listeners.push(
|
|
993
|
-
if (message.page() !== this._page || message.type() !==
|
|
994
|
-
|
|
960
|
+
const actionPromise = func().then((r) => result = r).catch((e) => error = e);
|
|
961
|
+
const errorPromise = new Promise((resolve) => {
|
|
962
|
+
listeners.push(import_eventsHelper.eventsHelper.addEventListener(this._page._browserContext, import_browserContext.BrowserContext.Events.Console, (message) => {
|
|
963
|
+
if (message.page() !== this._page || message.type() !== "error")
|
|
964
|
+
return;
|
|
965
|
+
if (message.text().includes("Content-Security-Policy") || message.text().includes("Content Security Policy")) {
|
|
995
966
|
cspMessage = message;
|
|
996
967
|
resolve();
|
|
997
968
|
}
|
|
998
969
|
}));
|
|
999
970
|
});
|
|
1000
971
|
await Promise.race([actionPromise, errorPromise]);
|
|
1001
|
-
|
|
1002
|
-
if (cspMessage)
|
|
1003
|
-
|
|
972
|
+
import_eventsHelper.eventsHelper.removeEventListeners(listeners);
|
|
973
|
+
if (cspMessage)
|
|
974
|
+
throw new Error(cspMessage.text());
|
|
975
|
+
if (error)
|
|
976
|
+
throw error;
|
|
1004
977
|
return result;
|
|
1005
978
|
}
|
|
1006
979
|
async retryWithProgressAndTimeouts(progress, timeouts, action) {
|
|
1007
|
-
const
|
|
980
|
+
const continuePolling2 = Symbol("continuePolling");
|
|
1008
981
|
timeouts = [0, ...timeouts];
|
|
1009
982
|
let timeoutIndex = 0;
|
|
1010
983
|
while (progress.isRunning()) {
|
|
1011
984
|
const timeout = timeouts[Math.min(timeoutIndex++, timeouts.length - 1)];
|
|
1012
985
|
if (timeout) {
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
986
|
+
const actionPromise = new Promise((f) => setTimeout(f, timeout));
|
|
987
|
+
await import_utils.LongStandingScope.raceMultiple([
|
|
988
|
+
this._page.openScope,
|
|
989
|
+
this._detachedScope
|
|
990
|
+
], actionPromise);
|
|
1017
991
|
}
|
|
1018
992
|
progress.throwIfAborted();
|
|
1019
993
|
try {
|
|
1020
|
-
const result = await action(
|
|
1021
|
-
if (result ===
|
|
994
|
+
const result = await action(continuePolling2);
|
|
995
|
+
if (result === continuePolling2)
|
|
996
|
+
continue;
|
|
1022
997
|
return result;
|
|
1023
998
|
} catch (e) {
|
|
1024
|
-
if (this._isErrorThatCannotBeRetried(e))
|
|
999
|
+
if (this._isErrorThatCannotBeRetried(e))
|
|
1000
|
+
throw e;
|
|
1025
1001
|
continue;
|
|
1026
1002
|
}
|
|
1027
1003
|
}
|
|
1028
1004
|
progress.throwIfAborted();
|
|
1029
|
-
return
|
|
1005
|
+
return void 0;
|
|
1030
1006
|
}
|
|
1031
1007
|
_isErrorThatCannotBeRetried(e) {
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
// Retry upon all other errors.
|
|
1008
|
+
if (js.isJavaScriptErrorInEvaluate(e) || (0, import_protocolError.isSessionClosedError)(e))
|
|
1009
|
+
return true;
|
|
1010
|
+
if (dom.isNonRecoverableDOMError(e) || (0, import_selectorParser.isInvalidSelectorError)(e))
|
|
1011
|
+
return true;
|
|
1012
|
+
if (this.isDetached())
|
|
1013
|
+
return true;
|
|
1039
1014
|
return false;
|
|
1040
1015
|
}
|
|
1041
1016
|
async _retryWithProgressIfNotConnected(progress, selector, strict, performActionPreChecks, action, returnAction) {
|
|
1042
1017
|
progress.log("waiting for " + this._asLocator(selector));
|
|
1043
|
-
return this.retryWithProgressAndTimeouts(progress, [0, 20, 50, 100, 100, 500], async
|
|
1018
|
+
return this.retryWithProgressAndTimeouts(progress, [0, 20, 50, 100, 100, 500], async (continuePolling2) => {
|
|
1044
1019
|
if (performActionPreChecks) await this._page.performActionPreChecks(progress);
|
|
1045
1020
|
const resolved = await this.selectors.resolveInjectedForSelector(selector, {
|
|
1046
1021
|
strict
|
|
1047
1022
|
});
|
|
1048
1023
|
progress.throwIfAborted();
|
|
1049
1024
|
if (!resolved) {
|
|
1050
|
-
if (returnAction ===
|
|
1051
|
-
return
|
|
1025
|
+
if (returnAction === "returnOnNotResolved" || returnAction === "returnAll") return null;
|
|
1026
|
+
return continuePolling2;
|
|
1052
1027
|
}
|
|
1053
1028
|
try {
|
|
1054
1029
|
var client = this._page._delegate._sessionForFrame(resolved.frame)._client;
|
|
@@ -1056,7 +1031,7 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1056
1031
|
var client = this._page._delegate._mainFrameSession._client;
|
|
1057
1032
|
}
|
|
1058
1033
|
var context = await resolved.frame._context("main");
|
|
1059
|
-
const documentNode = await client.send(
|
|
1034
|
+
const documentNode = await client.send("Runtime.evaluate", {
|
|
1060
1035
|
expression: "document",
|
|
1061
1036
|
serializationOptions: {
|
|
1062
1037
|
serialization: "idOnly"
|
|
@@ -1066,9 +1041,8 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1066
1041
|
const documentScope = new dom.ElementHandle(context, documentNode.result.objectId);
|
|
1067
1042
|
const currentScopingElements = await this._customFindElementsByParsed(resolved, client, context, documentScope, progress, resolved.info.parsed);
|
|
1068
1043
|
if (currentScopingElements.length == 0) {
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
return continuePolling;
|
|
1044
|
+
if (returnAction === "returnOnNotResolved" || returnAction === "returnAll") return null;
|
|
1045
|
+
return continuePolling2;
|
|
1072
1046
|
}
|
|
1073
1047
|
const resultElement = currentScopingElements[0];
|
|
1074
1048
|
if (currentScopingElements.length > 1) {
|
|
@@ -1089,64 +1063,61 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1089
1063
|
}
|
|
1090
1064
|
try {
|
|
1091
1065
|
var result = null;
|
|
1092
|
-
if (returnAction ===
|
|
1066
|
+
if (returnAction === "returnAll") {
|
|
1093
1067
|
result = await action([resultElement, currentScopingElements]);
|
|
1094
1068
|
} else {
|
|
1095
1069
|
result = await action(resultElement);
|
|
1096
1070
|
}
|
|
1097
|
-
if (result ===
|
|
1098
|
-
progress.log(
|
|
1099
|
-
return
|
|
1100
|
-
} else if (result ===
|
|
1101
|
-
return
|
|
1071
|
+
if (result === "error:notconnected") {
|
|
1072
|
+
progress.log("element was detached from the DOM, retrying");
|
|
1073
|
+
return continuePolling2;
|
|
1074
|
+
} else if (result === "internal:continuepolling") {
|
|
1075
|
+
return continuePolling2;
|
|
1102
1076
|
}
|
|
1103
1077
|
return result;
|
|
1104
|
-
} finally {
|
|
1078
|
+
} finally {
|
|
1079
|
+
}
|
|
1105
1080
|
});
|
|
1106
1081
|
}
|
|
1107
1082
|
async rafrafTimeoutScreenshotElementWithProgress(progress, selector, timeout, options) {
|
|
1108
|
-
return await this._retryWithProgressIfNotConnected(progress, selector, true
|
|
1083
|
+
return await this._retryWithProgressIfNotConnected(progress, selector, true, true, async (handle) => {
|
|
1109
1084
|
await handle._frame.rafrafTimeout(timeout);
|
|
1110
1085
|
return await this._page._screenshotter.screenshotElement(progress, handle, options);
|
|
1111
1086
|
});
|
|
1112
1087
|
}
|
|
1113
1088
|
async click(metadata, selector, options) {
|
|
1114
|
-
const controller = new
|
|
1115
|
-
return controller.run(async progress => {
|
|
1116
|
-
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force
|
|
1117
|
-
...options,
|
|
1118
|
-
waitAfter: !options.noWaitAfter
|
|
1119
|
-
})));
|
|
1089
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
1090
|
+
return controller.run(async (progress) => {
|
|
1091
|
+
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._click(progress, { ...options, waitAfter: !options.noWaitAfter })));
|
|
1120
1092
|
}, this._page._timeoutSettings.timeout(options));
|
|
1121
1093
|
}
|
|
1122
1094
|
async dblclick(metadata, selector, options = {}) {
|
|
1123
|
-
const controller = new
|
|
1124
|
-
return controller.run(async progress => {
|
|
1125
|
-
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force
|
|
1095
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
1096
|
+
return controller.run(async (progress) => {
|
|
1097
|
+
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._dblclick(progress, options)));
|
|
1126
1098
|
}, this._page._timeoutSettings.timeout(options));
|
|
1127
1099
|
}
|
|
1128
1100
|
async dragAndDrop(metadata, source, target, options = {}) {
|
|
1129
|
-
const controller = new
|
|
1130
|
-
await controller.run(async progress => {
|
|
1131
|
-
dom.assertDone(await this._retryWithProgressIfNotConnected(progress, source, options.strict, !options.force
|
|
1132
|
-
return handle._retryPointerAction(progress,
|
|
1101
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
1102
|
+
await controller.run(async (progress) => {
|
|
1103
|
+
dom.assertDone(await this._retryWithProgressIfNotConnected(progress, source, options.strict, !options.force, async (handle) => {
|
|
1104
|
+
return handle._retryPointerAction(progress, "move and down", false, async (point) => {
|
|
1133
1105
|
await this._page.mouse.move(point.x, point.y);
|
|
1134
1106
|
await this._page.mouse.down();
|
|
1135
1107
|
}, {
|
|
1136
1108
|
...options,
|
|
1137
|
-
waitAfter:
|
|
1109
|
+
waitAfter: "disabled",
|
|
1138
1110
|
position: options.sourcePosition,
|
|
1139
1111
|
timeout: progress.timeUntilDeadline()
|
|
1140
1112
|
});
|
|
1141
1113
|
}));
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
return handle._retryPointerAction(progress, 'move and up', false, async point => {
|
|
1114
|
+
dom.assertDone(await this._retryWithProgressIfNotConnected(progress, target, options.strict, false, async (handle) => {
|
|
1115
|
+
return handle._retryPointerAction(progress, "move and up", false, async (point) => {
|
|
1145
1116
|
await this._page.mouse.move(point.x, point.y);
|
|
1146
1117
|
await this._page.mouse.up();
|
|
1147
1118
|
}, {
|
|
1148
1119
|
...options,
|
|
1149
|
-
waitAfter:
|
|
1120
|
+
waitAfter: "disabled",
|
|
1150
1121
|
position: options.targetPosition,
|
|
1151
1122
|
timeout: progress.timeUntilDeadline()
|
|
1152
1123
|
});
|
|
@@ -1154,70 +1125,68 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1154
1125
|
}, this._page._timeoutSettings.timeout(options));
|
|
1155
1126
|
}
|
|
1156
1127
|
async tap(metadata, selector, options) {
|
|
1157
|
-
if (!this._page._browserContext._options.hasTouch)
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1128
|
+
if (!this._page._browserContext._options.hasTouch)
|
|
1129
|
+
throw new Error("The page does not support tap. Use hasTouch context option to enable touch support.");
|
|
1130
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
1131
|
+
return controller.run(async (progress) => {
|
|
1132
|
+
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._tap(progress, options)));
|
|
1161
1133
|
}, this._page._timeoutSettings.timeout(options));
|
|
1162
1134
|
}
|
|
1163
1135
|
async fill(metadata, selector, value, options) {
|
|
1164
|
-
const controller = new
|
|
1165
|
-
return controller.run(async progress => {
|
|
1166
|
-
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force
|
|
1136
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
1137
|
+
return controller.run(async (progress) => {
|
|
1138
|
+
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._fill(progress, value, options)));
|
|
1167
1139
|
}, this._page._timeoutSettings.timeout(options));
|
|
1168
1140
|
}
|
|
1169
1141
|
async focus(metadata, selector, options = {}) {
|
|
1170
|
-
const controller = new
|
|
1171
|
-
await controller.run(async progress => {
|
|
1172
|
-
dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true
|
|
1142
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
1143
|
+
await controller.run(async (progress) => {
|
|
1144
|
+
dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true, (handle) => handle._focus(progress)));
|
|
1173
1145
|
}, this._page._timeoutSettings.timeout(options));
|
|
1174
1146
|
}
|
|
1175
1147
|
async blur(metadata, selector, options = {}) {
|
|
1176
|
-
const controller = new
|
|
1177
|
-
await controller.run(async progress => {
|
|
1178
|
-
dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true
|
|
1148
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
1149
|
+
await controller.run(async (progress) => {
|
|
1150
|
+
dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true, (handle) => handle._blur(progress)));
|
|
1179
1151
|
}, this._page._timeoutSettings.timeout(options));
|
|
1180
1152
|
}
|
|
1181
1153
|
async textContent(metadata, selector, options = {}, scope) {
|
|
1182
|
-
return this._callOnElementOnceMatches(metadata, selector, (injected, element) => element.textContent,
|
|
1154
|
+
return this._callOnElementOnceMatches(metadata, selector, (injected, element) => element.textContent, void 0, options, scope);
|
|
1183
1155
|
}
|
|
1184
1156
|
async innerText(metadata, selector, options = {}, scope) {
|
|
1185
1157
|
return this._callOnElementOnceMatches(metadata, selector, (injectedScript, element) => {
|
|
1186
|
-
if (element.namespaceURI !==
|
|
1158
|
+
if (element.namespaceURI !== "http://www.w3.org/1999/xhtml")
|
|
1159
|
+
throw injectedScript.createStacklessError("Node is not an HTMLElement");
|
|
1187
1160
|
return element.innerText;
|
|
1188
|
-
},
|
|
1161
|
+
}, void 0, options, scope);
|
|
1189
1162
|
}
|
|
1190
1163
|
async innerHTML(metadata, selector, options = {}, scope) {
|
|
1191
|
-
return this._callOnElementOnceMatches(metadata, selector, (injected, element) => element.innerHTML,
|
|
1164
|
+
return this._callOnElementOnceMatches(metadata, selector, (injected, element) => element.innerHTML, void 0, options, scope);
|
|
1192
1165
|
}
|
|
1193
1166
|
async getAttribute(metadata, selector, name, options = {}, scope) {
|
|
1194
|
-
return this._callOnElementOnceMatches(metadata, selector, (injected, element, data) => element.getAttribute(data.name), {
|
|
1195
|
-
name
|
|
1196
|
-
}, options, scope);
|
|
1167
|
+
return this._callOnElementOnceMatches(metadata, selector, (injected, element, data) => element.getAttribute(data.name), { name }, options, scope);
|
|
1197
1168
|
}
|
|
1198
1169
|
async inputValue(metadata, selector, options = {}, scope) {
|
|
1199
1170
|
return this._callOnElementOnceMatches(metadata, selector, (injectedScript, node) => {
|
|
1200
|
-
const element = injectedScript.retarget(node,
|
|
1201
|
-
if (!element || element.nodeName !==
|
|
1171
|
+
const element = injectedScript.retarget(node, "follow-label");
|
|
1172
|
+
if (!element || element.nodeName !== "INPUT" && element.nodeName !== "TEXTAREA" && element.nodeName !== "SELECT")
|
|
1173
|
+
throw injectedScript.createStacklessError("Node is not an <input>, <textarea> or <select> element");
|
|
1202
1174
|
return element.value;
|
|
1203
|
-
},
|
|
1175
|
+
}, void 0, options, scope);
|
|
1204
1176
|
}
|
|
1205
1177
|
async highlight(selector) {
|
|
1206
1178
|
const resolved = await this.selectors.resolveInjectedForSelector(selector);
|
|
1207
|
-
if (!resolved)
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
}) => {
|
|
1179
|
+
if (!resolved)
|
|
1180
|
+
return;
|
|
1181
|
+
return await resolved.injected.evaluate((injected, { info }) => {
|
|
1211
1182
|
return injected.highlight(info.parsed);
|
|
1212
|
-
}, {
|
|
1213
|
-
info: resolved.info
|
|
1214
|
-
});
|
|
1183
|
+
}, { info: resolved.info });
|
|
1215
1184
|
}
|
|
1216
1185
|
async hideHighlight() {
|
|
1217
1186
|
return this.raceAgainstEvaluationStallingEvents(async () => {
|
|
1218
1187
|
const context = await this._utilityContext();
|
|
1219
1188
|
const injectedScript = await context.injectedScript();
|
|
1220
|
-
return await injectedScript.evaluate(injected => {
|
|
1189
|
+
return await injectedScript.evaluate((injected) => {
|
|
1221
1190
|
return injected.hideHighlight();
|
|
1222
1191
|
});
|
|
1223
1192
|
});
|
|
@@ -1225,248 +1194,189 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1225
1194
|
async _elementState(metadata, selector, state, options = {}, scope) {
|
|
1226
1195
|
const result = await this._callOnElementOnceMatches(metadata, selector, (injected, element, data) => {
|
|
1227
1196
|
return injected.elementState(element, data.state);
|
|
1228
|
-
}, {
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
if (result.received === 'error:notconnected') dom.throwElementIsNotAttached();
|
|
1197
|
+
}, { state }, options, scope);
|
|
1198
|
+
if (result.received === "error:notconnected")
|
|
1199
|
+
dom.throwElementIsNotAttached();
|
|
1232
1200
|
return result.matches;
|
|
1233
1201
|
}
|
|
1234
1202
|
async isVisible(metadata, selector, options = {}, scope) {
|
|
1235
|
-
const controller = new
|
|
1236
|
-
return controller.run(async progress => {
|
|
1203
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
1204
|
+
return controller.run(async (progress) => {
|
|
1237
1205
|
progress.log(` checking visibility of ${this._asLocator(selector)}`);
|
|
1238
1206
|
return await this.isVisibleInternal(selector, options, scope);
|
|
1239
1207
|
}, this._page._timeoutSettings.timeout({}));
|
|
1240
1208
|
}
|
|
1241
1209
|
async isVisibleInternal(selector, options = {}, scope) {
|
|
1242
1210
|
try {
|
|
1243
|
-
const custom_metadata = {
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
};
|
|
1247
|
-
const controller = new _progress.ProgressController(custom_metadata, this);
|
|
1248
|
-
return await controller.run(async progress => {
|
|
1211
|
+
const custom_metadata = { "internal": false, "log": [] };
|
|
1212
|
+
const controller = new import_progress.ProgressController(custom_metadata, this);
|
|
1213
|
+
return await controller.run(async (progress) => {
|
|
1249
1214
|
progress.log("waiting for " + this._asLocator(selector));
|
|
1250
|
-
const promise = this._retryWithProgressIfNotConnected(progress, selector, options.strict, false, async handle => {
|
|
1215
|
+
const promise = this._retryWithProgressIfNotConnected(progress, selector, options.strict, false, async (handle) => {
|
|
1251
1216
|
if (handle.parentNode.constructor.name == "ElementHandle") {
|
|
1252
|
-
return await handle.parentNode.evaluateInUtility(([injected, node, {
|
|
1253
|
-
|
|
1254
|
-
}]) => {
|
|
1255
|
-
const state = handle ? injected.elementState(handle, 'visible') : {
|
|
1217
|
+
return await handle.parentNode.evaluateInUtility(([injected, node, { handle: handle2 }]) => {
|
|
1218
|
+
const state = handle2 ? injected.elementState(handle2, "visible") : {
|
|
1256
1219
|
matches: false,
|
|
1257
|
-
received:
|
|
1220
|
+
received: "error:notconnected"
|
|
1258
1221
|
};
|
|
1259
1222
|
return state.matches;
|
|
1260
|
-
}, {
|
|
1261
|
-
handle
|
|
1262
|
-
});
|
|
1223
|
+
}, { handle });
|
|
1263
1224
|
} else {
|
|
1264
|
-
return await handle.parentNode.evaluate((injected, {
|
|
1265
|
-
|
|
1266
|
-
}) => {
|
|
1267
|
-
const state = handle ? injected.elementState(handle, 'visible') : {
|
|
1225
|
+
return await handle.parentNode.evaluate((injected, { handle: handle2 }) => {
|
|
1226
|
+
const state = handle2 ? injected.elementState(handle2, "visible") : {
|
|
1268
1227
|
matches: false,
|
|
1269
|
-
received:
|
|
1228
|
+
received: "error:notconnected"
|
|
1270
1229
|
};
|
|
1271
1230
|
return state.matches;
|
|
1272
|
-
}, {
|
|
1273
|
-
handle
|
|
1274
|
-
});
|
|
1231
|
+
}, { handle });
|
|
1275
1232
|
}
|
|
1276
1233
|
});
|
|
1277
1234
|
return scope ? scope._context._raceAgainstContextDestroyed(promise) : promise;
|
|
1278
|
-
}, 100);
|
|
1235
|
+
}, 100);
|
|
1279
1236
|
} catch (e) {
|
|
1280
|
-
if (js.isJavaScriptErrorInEvaluate(e) || (0,
|
|
1237
|
+
if (js.isJavaScriptErrorInEvaluate(e) || (0, import_selectorParser.isInvalidSelectorError)(e) || (0, import_protocolError.isSessionClosedError)(e)) throw e;
|
|
1281
1238
|
return false;
|
|
1282
1239
|
}
|
|
1283
1240
|
}
|
|
1284
1241
|
async isHidden(metadata, selector, options = {}, scope) {
|
|
1285
|
-
return !
|
|
1242
|
+
return !await this.isVisible(metadata, selector, options, scope);
|
|
1286
1243
|
}
|
|
1287
1244
|
async isDisabled(metadata, selector, options = {}, scope) {
|
|
1288
|
-
return this._elementState(metadata, selector,
|
|
1245
|
+
return this._elementState(metadata, selector, "disabled", options, scope);
|
|
1289
1246
|
}
|
|
1290
1247
|
async isEnabled(metadata, selector, options = {}, scope) {
|
|
1291
|
-
return this._elementState(metadata, selector,
|
|
1248
|
+
return this._elementState(metadata, selector, "enabled", options, scope);
|
|
1292
1249
|
}
|
|
1293
1250
|
async isEditable(metadata, selector, options = {}, scope) {
|
|
1294
|
-
return this._elementState(metadata, selector,
|
|
1251
|
+
return this._elementState(metadata, selector, "editable", options, scope);
|
|
1295
1252
|
}
|
|
1296
1253
|
async isChecked(metadata, selector, options = {}, scope) {
|
|
1297
|
-
return this._elementState(metadata, selector,
|
|
1254
|
+
return this._elementState(metadata, selector, "checked", options, scope);
|
|
1298
1255
|
}
|
|
1299
1256
|
async hover(metadata, selector, options = {}) {
|
|
1300
|
-
const controller = new
|
|
1301
|
-
return controller.run(async progress => {
|
|
1302
|
-
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force
|
|
1257
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
1258
|
+
return controller.run(async (progress) => {
|
|
1259
|
+
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._hover(progress, options)));
|
|
1303
1260
|
}, this._page._timeoutSettings.timeout(options));
|
|
1304
1261
|
}
|
|
1305
1262
|
async selectOption(metadata, selector, elements, values, options = {}) {
|
|
1306
|
-
const controller = new
|
|
1307
|
-
return controller.run(async progress => {
|
|
1308
|
-
return await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force
|
|
1263
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
1264
|
+
return controller.run(async (progress) => {
|
|
1265
|
+
return await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._selectOption(progress, elements, values, options));
|
|
1309
1266
|
}, this._page._timeoutSettings.timeout(options));
|
|
1310
1267
|
}
|
|
1311
1268
|
async setInputFiles(metadata, selector, params) {
|
|
1312
|
-
const inputFileItems = await (0,
|
|
1313
|
-
const controller = new
|
|
1314
|
-
return controller.run(async progress => {
|
|
1315
|
-
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, params.strict, true
|
|
1269
|
+
const inputFileItems = await (0, import_fileUploadUtils.prepareFilesForUpload)(this, params);
|
|
1270
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
1271
|
+
return controller.run(async (progress) => {
|
|
1272
|
+
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, params.strict, true, (handle) => handle._setInputFiles(progress, inputFileItems)));
|
|
1316
1273
|
}, this._page._timeoutSettings.timeout(params));
|
|
1317
1274
|
}
|
|
1318
1275
|
async type(metadata, selector, text, options = {}) {
|
|
1319
|
-
const controller = new
|
|
1320
|
-
return controller.run(async progress => {
|
|
1321
|
-
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true
|
|
1276
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
1277
|
+
return controller.run(async (progress) => {
|
|
1278
|
+
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true, (handle) => handle._type(progress, text, options)));
|
|
1322
1279
|
}, this._page._timeoutSettings.timeout(options));
|
|
1323
1280
|
}
|
|
1324
1281
|
async press(metadata, selector, key, options = {}) {
|
|
1325
|
-
const controller = new
|
|
1326
|
-
return controller.run(async progress => {
|
|
1327
|
-
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true
|
|
1282
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
1283
|
+
return controller.run(async (progress) => {
|
|
1284
|
+
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true, (handle) => handle._press(progress, key, options)));
|
|
1328
1285
|
}, this._page._timeoutSettings.timeout(options));
|
|
1329
1286
|
}
|
|
1330
1287
|
async check(metadata, selector, options = {}) {
|
|
1331
|
-
const controller = new
|
|
1332
|
-
return controller.run(async progress => {
|
|
1333
|
-
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force
|
|
1288
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
1289
|
+
return controller.run(async (progress) => {
|
|
1290
|
+
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._setChecked(progress, true, options)));
|
|
1334
1291
|
}, this._page._timeoutSettings.timeout(options));
|
|
1335
1292
|
}
|
|
1336
1293
|
async uncheck(metadata, selector, options = {}) {
|
|
1337
|
-
const controller = new
|
|
1338
|
-
return controller.run(async progress => {
|
|
1339
|
-
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force
|
|
1294
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
1295
|
+
return controller.run(async (progress) => {
|
|
1296
|
+
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._setChecked(progress, false, options)));
|
|
1340
1297
|
}, this._page._timeoutSettings.timeout(options));
|
|
1341
1298
|
}
|
|
1342
1299
|
async waitForTimeout(metadata, timeout) {
|
|
1343
|
-
const controller = new
|
|
1300
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
1344
1301
|
return controller.run(async () => {
|
|
1345
|
-
await new Promise(resolve => setTimeout(resolve, timeout));
|
|
1302
|
+
await new Promise((resolve) => setTimeout(resolve, timeout));
|
|
1346
1303
|
});
|
|
1347
1304
|
}
|
|
1348
1305
|
async ariaSnapshot(metadata, selector, options = {}) {
|
|
1349
|
-
const controller = new
|
|
1350
|
-
return controller.run(async progress => {
|
|
1351
|
-
return await this._retryWithProgressIfNotConnected(progress, selector, true
|
|
1306
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
1307
|
+
return controller.run(async (progress) => {
|
|
1308
|
+
return await this._retryWithProgressIfNotConnected(progress, selector, true, true, (handle) => handle.ariaSnapshot(options));
|
|
1352
1309
|
}, this._page._timeoutSettings.timeout(options));
|
|
1353
1310
|
}
|
|
1354
1311
|
async expect(metadata, selector, options) {
|
|
1355
1312
|
const result = await this._expectImpl(metadata, selector, options);
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
error: {
|
|
1359
|
-
name: 'Expect',
|
|
1360
|
-
message: 'Expect failed'
|
|
1361
|
-
}
|
|
1362
|
-
};
|
|
1313
|
+
if (result.matches === options.isNot)
|
|
1314
|
+
metadata.error = { error: { name: "Expect", message: "Expect failed" } };
|
|
1363
1315
|
return result;
|
|
1364
1316
|
}
|
|
1365
1317
|
async _expectImpl(metadata, selector, options) {
|
|
1366
|
-
const lastIntermediateResult = {
|
|
1367
|
-
isSet: false
|
|
1368
|
-
};
|
|
1318
|
+
const lastIntermediateResult = { isSet: false };
|
|
1369
1319
|
try {
|
|
1370
1320
|
let timeout = this._page._timeoutSettings.timeout(options);
|
|
1371
|
-
const start = timeout > 0 ? (0,
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
await new _progress.ProgressController(metadata, this).run(async progress => {
|
|
1375
|
-
progress.log(`${metadata.apiName}${timeout ? ` with timeout ${timeout}ms` : ''}`);
|
|
1321
|
+
const start = timeout > 0 ? (0, import_utils.monotonicTime)() : 0;
|
|
1322
|
+
await new import_progress.ProgressController(metadata, this).run(async (progress) => {
|
|
1323
|
+
progress.log(`${metadata.apiName}${timeout ? ` with timeout ${timeout}ms` : ""}`);
|
|
1376
1324
|
progress.log(`waiting for ${this._asLocator(selector)}`);
|
|
1377
1325
|
await this._page.performActionPreChecks(progress);
|
|
1378
1326
|
}, timeout);
|
|
1379
|
-
|
|
1380
|
-
// Step 2: perform one-shot expect check without a timeout.
|
|
1381
|
-
// Supports the case of `expect(locator).toBeVisible({ timeout: 1 })`
|
|
1382
|
-
// that should succeed when the locator is already visible.
|
|
1383
1327
|
try {
|
|
1384
|
-
const resultOneShot = await new
|
|
1328
|
+
const resultOneShot = await new import_progress.ProgressController(metadata, this).run(async (progress) => {
|
|
1385
1329
|
return await this._expectInternal(progress, selector, options, lastIntermediateResult);
|
|
1386
1330
|
});
|
|
1387
|
-
if (resultOneShot.matches !== options.isNot)
|
|
1331
|
+
if (resultOneShot.matches !== options.isNot)
|
|
1332
|
+
return resultOneShot;
|
|
1388
1333
|
} catch (e) {
|
|
1389
|
-
if (js.isJavaScriptErrorInEvaluate(e) || (0,
|
|
1390
|
-
|
|
1334
|
+
if (js.isJavaScriptErrorInEvaluate(e) || (0, import_selectorParser.isInvalidSelectorError)(e))
|
|
1335
|
+
throw e;
|
|
1391
1336
|
}
|
|
1392
1337
|
if (timeout > 0) {
|
|
1393
|
-
const elapsed = (0,
|
|
1338
|
+
const elapsed = (0, import_utils.monotonicTime)() - start;
|
|
1394
1339
|
timeout -= elapsed;
|
|
1395
1340
|
}
|
|
1396
|
-
if (timeout < 0)
|
|
1397
|
-
matches: options.isNot,
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
received: lastIntermediateResult.received
|
|
1401
|
-
};
|
|
1402
|
-
|
|
1403
|
-
// Step 3: auto-retry expect with increasing timeouts. Bounded by the total remaining time.
|
|
1404
|
-
return await new _progress.ProgressController(metadata, this).run(async progress => {
|
|
1405
|
-
return await this.retryWithProgressAndTimeouts(progress, [100, 250, 500, 1000], async continuePolling => {
|
|
1341
|
+
if (timeout < 0)
|
|
1342
|
+
return { matches: options.isNot, log: (0, import_callLog.compressCallLog)(metadata.log), timedOut: true, received: lastIntermediateResult.received };
|
|
1343
|
+
return await new import_progress.ProgressController(metadata, this).run(async (progress) => {
|
|
1344
|
+
return await this.retryWithProgressAndTimeouts(progress, [100, 250, 500, 1e3], async (continuePolling2) => {
|
|
1406
1345
|
await this._page.performActionPreChecks(progress);
|
|
1407
|
-
const {
|
|
1408
|
-
matches,
|
|
1409
|
-
received
|
|
1410
|
-
} = await this._expectInternal(progress, selector, options, lastIntermediateResult);
|
|
1346
|
+
const { matches, received } = await this._expectInternal(progress, selector, options, lastIntermediateResult);
|
|
1411
1347
|
if (matches === options.isNot) {
|
|
1412
|
-
|
|
1413
|
-
// expect(locator).conditionThatDoesNotMatch
|
|
1414
|
-
// expect(locator).not.conditionThatDoesMatch
|
|
1415
|
-
return continuePolling;
|
|
1348
|
+
return continuePolling2;
|
|
1416
1349
|
}
|
|
1417
|
-
return {
|
|
1418
|
-
matches,
|
|
1419
|
-
received
|
|
1420
|
-
};
|
|
1350
|
+
return { matches, received };
|
|
1421
1351
|
});
|
|
1422
1352
|
}, timeout);
|
|
1423
1353
|
} catch (e) {
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
if (lastIntermediateResult.isSet) result.received = lastIntermediateResult.received;
|
|
1432
|
-
if (e instanceof _errors.TimeoutError) result.timedOut = true;
|
|
1354
|
+
if (js.isJavaScriptErrorInEvaluate(e) || (0, import_selectorParser.isInvalidSelectorError)(e))
|
|
1355
|
+
throw e;
|
|
1356
|
+
const result = { matches: options.isNot, log: (0, import_callLog.compressCallLog)(metadata.log) };
|
|
1357
|
+
if (lastIntermediateResult.isSet)
|
|
1358
|
+
result.received = lastIntermediateResult.received;
|
|
1359
|
+
if (e instanceof import_errors.TimeoutError)
|
|
1360
|
+
result.timedOut = true;
|
|
1433
1361
|
return result;
|
|
1434
1362
|
}
|
|
1435
1363
|
}
|
|
1436
1364
|
async _expectInternal(progress, selector, options, lastIntermediateResult) {
|
|
1437
1365
|
progress.log("waiting for " + this._asLocator(selector));
|
|
1438
|
-
const isArray = options.expression ===
|
|
1439
|
-
const promise = await this._retryWithProgressIfNotConnected(progress, selector, !isArray, false, async result => {
|
|
1366
|
+
const isArray = options.expression === "to.have.count" || options.expression.endsWith(".array");
|
|
1367
|
+
const promise = await this._retryWithProgressIfNotConnected(progress, selector, !isArray, false, async (result) => {
|
|
1440
1368
|
const handle = result[0];
|
|
1441
1369
|
const handles = result[1];
|
|
1442
1370
|
if (handle.parentNode.constructor.name == "ElementHandle") {
|
|
1443
|
-
return await handle.parentNode.evaluateInUtility(async ([injected, node, {
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
handles
|
|
1447
|
-
}]) => {
|
|
1448
|
-
return await injected.expect(handle, options, handles);
|
|
1449
|
-
}, {
|
|
1450
|
-
handle,
|
|
1451
|
-
options,
|
|
1452
|
-
handles
|
|
1453
|
-
});
|
|
1371
|
+
return await handle.parentNode.evaluateInUtility(async ([injected, node, { handle: handle2, options: options2, handles: handles2 }]) => {
|
|
1372
|
+
return await injected.expect(handle2, options2, handles2);
|
|
1373
|
+
}, { handle, options, handles });
|
|
1454
1374
|
} else {
|
|
1455
|
-
return await handle.parentNode.evaluate(async (injected, {
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
handles
|
|
1459
|
-
}) => {
|
|
1460
|
-
return await injected.expect(handle, options, handles);
|
|
1461
|
-
}, {
|
|
1462
|
-
handle,
|
|
1463
|
-
options,
|
|
1464
|
-
handles
|
|
1465
|
-
});
|
|
1375
|
+
return await handle.parentNode.evaluate(async (injected, { handle: handle2, options: options2, handles: handles2 }) => {
|
|
1376
|
+
return await injected.expect(handle2, options2, handles2);
|
|
1377
|
+
}, { handle, options, handles });
|
|
1466
1378
|
}
|
|
1467
|
-
},
|
|
1468
|
-
|
|
1469
|
-
// Default Values, if no Elements found
|
|
1379
|
+
}, "returnAll");
|
|
1470
1380
|
var matches = false;
|
|
1471
1381
|
var received = 0;
|
|
1472
1382
|
var missingReceived = null;
|
|
@@ -1477,10 +1387,8 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1477
1387
|
} else if (options.expectedNumber === 0) {
|
|
1478
1388
|
matches = true;
|
|
1479
1389
|
}
|
|
1480
|
-
|
|
1481
|
-
// Note: missingReceived avoids unexpected value "undefined" when element was not found.
|
|
1482
1390
|
if (matches === options.isNot) {
|
|
1483
|
-
lastIntermediateResult.received = missingReceived ?
|
|
1391
|
+
lastIntermediateResult.received = missingReceived ? "<element(s) not found>" : received;
|
|
1484
1392
|
lastIntermediateResult.isSet = true;
|
|
1485
1393
|
if (!missingReceived && !Array.isArray(received)) progress.log(' unexpected value "' + renderUnexpectedValue(options.expression, received) + '"');
|
|
1486
1394
|
}
|
|
@@ -1489,34 +1397,27 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1489
1397
|
received
|
|
1490
1398
|
};
|
|
1491
1399
|
}
|
|
1492
|
-
async _waitForFunctionExpression(metadata, expression, isFunction, arg, options, world =
|
|
1493
|
-
const controller = new
|
|
1494
|
-
if (typeof options.pollingInterval ===
|
|
1400
|
+
async _waitForFunctionExpression(metadata, expression, isFunction, arg, options, world = "main") {
|
|
1401
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
1402
|
+
if (typeof options.pollingInterval === "number")
|
|
1403
|
+
(0, import_utils.assert)(options.pollingInterval > 0, "Cannot poll with non-positive interval: " + options.pollingInterval);
|
|
1495
1404
|
expression = js.normalizeEvaluationExpression(expression, isFunction);
|
|
1496
|
-
return controller.run(async progress => {
|
|
1405
|
+
return controller.run(async (progress) => {
|
|
1497
1406
|
return this.retryWithProgressAndTimeouts(progress, [100], async () => {
|
|
1498
|
-
const context = world ===
|
|
1407
|
+
const context = world === "main" ? await this._mainContext() : await this._utilityContext();
|
|
1499
1408
|
const injectedScript = await context.injectedScript();
|
|
1500
|
-
const handle = await injectedScript.evaluateHandle((injected, {
|
|
1501
|
-
expression,
|
|
1502
|
-
isFunction,
|
|
1503
|
-
polling,
|
|
1504
|
-
arg
|
|
1505
|
-
}) => {
|
|
1409
|
+
const handle = await injectedScript.evaluateHandle((injected, { expression: expression2, isFunction: isFunction2, polling, arg: arg2 }) => {
|
|
1506
1410
|
const predicate = () => {
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
result = result(arg);
|
|
1513
|
-
} else if (isFunction === false) {
|
|
1514
|
-
result = result;
|
|
1411
|
+
let result2 = globalThis.eval(expression2);
|
|
1412
|
+
if (isFunction2 === true) {
|
|
1413
|
+
result2 = result2(arg2);
|
|
1414
|
+
} else if (isFunction2 === false) {
|
|
1415
|
+
result2 = result2;
|
|
1515
1416
|
} else {
|
|
1516
|
-
|
|
1517
|
-
|
|
1417
|
+
if (typeof result2 === "function")
|
|
1418
|
+
result2 = result2(arg2);
|
|
1518
1419
|
}
|
|
1519
|
-
return
|
|
1420
|
+
return result2;
|
|
1520
1421
|
};
|
|
1521
1422
|
let fulfill;
|
|
1522
1423
|
let reject;
|
|
@@ -1526,31 +1427,28 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1526
1427
|
reject = r;
|
|
1527
1428
|
});
|
|
1528
1429
|
const next = () => {
|
|
1529
|
-
if (aborted)
|
|
1430
|
+
if (aborted)
|
|
1431
|
+
return;
|
|
1530
1432
|
try {
|
|
1531
1433
|
const success = predicate();
|
|
1532
1434
|
if (success) {
|
|
1533
1435
|
fulfill(success);
|
|
1534
1436
|
return;
|
|
1535
1437
|
}
|
|
1536
|
-
if (typeof polling !==
|
|
1438
|
+
if (typeof polling !== "number")
|
|
1439
|
+
injected.utils.builtins.requestAnimationFrame(next);
|
|
1440
|
+
else
|
|
1441
|
+
injected.utils.builtins.setTimeout(next, polling);
|
|
1537
1442
|
} catch (e) {
|
|
1538
1443
|
reject(e);
|
|
1539
1444
|
}
|
|
1540
1445
|
};
|
|
1541
1446
|
next();
|
|
1542
|
-
return {
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
expression,
|
|
1548
|
-
isFunction,
|
|
1549
|
-
polling: options.pollingInterval,
|
|
1550
|
-
arg
|
|
1551
|
-
});
|
|
1552
|
-
progress.cleanupWhenAborted(() => handle.evaluate(h => h.abort()).catch(() => {}));
|
|
1553
|
-
return handle.evaluateHandle(h => h.result);
|
|
1447
|
+
return { result, abort: () => aborted = true };
|
|
1448
|
+
}, { expression, isFunction, polling: options.pollingInterval, arg });
|
|
1449
|
+
progress.cleanupWhenAborted(() => handle.evaluate((h) => h.abort()).catch(() => {
|
|
1450
|
+
}));
|
|
1451
|
+
return handle.evaluateHandle((h) => h.result);
|
|
1554
1452
|
});
|
|
1555
1453
|
}, this._page._timeoutSettings.timeout(options));
|
|
1556
1454
|
}
|
|
@@ -1561,9 +1459,7 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1561
1459
|
return result;
|
|
1562
1460
|
return JSON.stringify(result);
|
|
1563
1461
|
}`;
|
|
1564
|
-
const handle = await this._waitForFunctionExpression((0,
|
|
1565
|
-
timeout: progress.timeUntilDeadline()
|
|
1566
|
-
}, 'utility');
|
|
1462
|
+
const handle = await this._waitForFunctionExpression((0, import_instrumentation.serverSideCallMetadata)(), expression, true, void 0, { timeout: progress.timeUntilDeadline() }, "utility");
|
|
1567
1463
|
return JSON.parse(handle.rawValue());
|
|
1568
1464
|
}
|
|
1569
1465
|
async title() {
|
|
@@ -1571,55 +1467,50 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1571
1467
|
return context.evaluate(() => document.title);
|
|
1572
1468
|
}
|
|
1573
1469
|
async rafrafTimeout(timeout) {
|
|
1574
|
-
if (timeout === 0)
|
|
1470
|
+
if (timeout === 0)
|
|
1471
|
+
return;
|
|
1575
1472
|
const context = await this._utilityContext();
|
|
1576
1473
|
await Promise.all([
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1474
|
+
// wait for double raf
|
|
1475
|
+
context.evaluate(() => new Promise((x) => {
|
|
1476
|
+
requestAnimationFrame(() => {
|
|
1477
|
+
requestAnimationFrame(x);
|
|
1478
|
+
});
|
|
1479
|
+
})),
|
|
1480
|
+
new Promise((fulfill) => setTimeout(fulfill, timeout))
|
|
1481
|
+
]);
|
|
1583
1482
|
}
|
|
1584
1483
|
_onDetached() {
|
|
1585
1484
|
this._stopNetworkIdleTimer();
|
|
1586
|
-
this._detachedScope.close(new Error(
|
|
1485
|
+
this._detachedScope.close(new Error("Frame was detached"));
|
|
1587
1486
|
for (const data of this._contextData.values()) {
|
|
1588
|
-
if (data.context)
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
});
|
|
1487
|
+
if (data.context)
|
|
1488
|
+
data.context.contextDestroyed("Frame was detached");
|
|
1489
|
+
data.contextPromise.resolve({ destroyedReason: "Frame was detached" });
|
|
1592
1490
|
}
|
|
1593
|
-
if (this._parentFrame)
|
|
1491
|
+
if (this._parentFrame)
|
|
1492
|
+
this._parentFrame._childFrames.delete(this);
|
|
1594
1493
|
this._parentFrame = null;
|
|
1595
1494
|
}
|
|
1596
1495
|
async _callOnElementOnceMatches(metadata, selector, body, taskData, options = {}, scope) {
|
|
1597
1496
|
const callbackText = body.toString();
|
|
1598
|
-
const controller = new
|
|
1599
|
-
return controller.run(async progress => {
|
|
1497
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
1498
|
+
return controller.run(async (progress) => {
|
|
1600
1499
|
progress.log("waiting for " + this._asLocator(selector));
|
|
1601
|
-
const promise = this._retryWithProgressIfNotConnected(progress, selector, false, false, async handle => {
|
|
1500
|
+
const promise = this._retryWithProgressIfNotConnected(progress, selector, false, false, async (handle) => {
|
|
1602
1501
|
if (handle.parentNode.constructor.name == "ElementHandle") {
|
|
1603
|
-
return await handle.parentNode.evaluateInUtility(([injected, node, {
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
taskData
|
|
1607
|
-
}]) => {
|
|
1608
|
-
const callback = injected.eval(callbackText);
|
|
1609
|
-
return callback(injected, handle, taskData);
|
|
1502
|
+
return await handle.parentNode.evaluateInUtility(([injected, node, { callbackText: callbackText2, handle: handle2, taskData: taskData2 }]) => {
|
|
1503
|
+
const callback = injected.eval(callbackText2);
|
|
1504
|
+
return callback(injected, handle2, taskData2);
|
|
1610
1505
|
}, {
|
|
1611
1506
|
callbackText,
|
|
1612
1507
|
handle,
|
|
1613
1508
|
taskData
|
|
1614
1509
|
});
|
|
1615
1510
|
} else {
|
|
1616
|
-
return await handle.parentNode.evaluate((injected, {
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
taskData
|
|
1620
|
-
}) => {
|
|
1621
|
-
const callback = injected.eval(callbackText);
|
|
1622
|
-
return callback(injected, handle, taskData);
|
|
1511
|
+
return await handle.parentNode.evaluate((injected, { callbackText: callbackText2, handle: handle2, taskData: taskData2 }) => {
|
|
1512
|
+
const callback = injected.eval(callbackText2);
|
|
1513
|
+
return callback(injected, handle2, taskData2);
|
|
1623
1514
|
}, {
|
|
1624
1515
|
callbackText,
|
|
1625
1516
|
handle,
|
|
@@ -1633,98 +1524,79 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1633
1524
|
_setContext(world, context) {
|
|
1634
1525
|
const data = this._contextData.get(world);
|
|
1635
1526
|
data.context = context;
|
|
1636
|
-
if (context)
|
|
1527
|
+
if (context)
|
|
1528
|
+
data.contextPromise.resolve(context);
|
|
1529
|
+
else
|
|
1530
|
+
data.contextPromise = new import_manualPromise.ManualPromise();
|
|
1637
1531
|
}
|
|
1638
1532
|
_contextCreated(world, context) {
|
|
1639
1533
|
const data = this._contextData.get(world);
|
|
1640
|
-
// In case of multiple sessions to the same target, there's a race between
|
|
1641
|
-
// connections so we might end up creating multiple isolated worlds.
|
|
1642
|
-
// We can use either.
|
|
1643
1534
|
if (data.context) {
|
|
1644
|
-
data.context.contextDestroyed(
|
|
1535
|
+
data.context.contextDestroyed("Execution context was destroyed, most likely because of a navigation");
|
|
1645
1536
|
this._setContext(world, null);
|
|
1646
1537
|
}
|
|
1647
1538
|
this._setContext(world, context);
|
|
1648
1539
|
}
|
|
1649
1540
|
_contextDestroyed(context) {
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
context.contextDestroyed('Execution context was destroyed, most likely because of a navigation');
|
|
1541
|
+
if (this._detachedScope.isClosed())
|
|
1542
|
+
return;
|
|
1543
|
+
context.contextDestroyed("Execution context was destroyed, most likely because of a navigation");
|
|
1654
1544
|
for (const [world, data] of this._contextData) {
|
|
1655
|
-
if (data.context === context)
|
|
1545
|
+
if (data.context === context)
|
|
1546
|
+
this._setContext(world, null);
|
|
1656
1547
|
}
|
|
1657
1548
|
}
|
|
1658
1549
|
_startNetworkIdleTimer() {
|
|
1659
|
-
(0,
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
// after the frame was detached - probably a race in the Firefox itself.
|
|
1663
|
-
if (this._firedLifecycleEvents.has('networkidle') || this._detachedScope.isClosed()) return;
|
|
1550
|
+
(0, import_utils.assert)(!this._networkIdleTimer);
|
|
1551
|
+
if (this._firedLifecycleEvents.has("networkidle") || this._detachedScope.isClosed())
|
|
1552
|
+
return;
|
|
1664
1553
|
this._networkIdleTimer = setTimeout(() => {
|
|
1665
1554
|
this._firedNetworkIdleSelf = true;
|
|
1666
1555
|
this._page.mainFrame()._recalculateNetworkIdle();
|
|
1667
1556
|
}, 500);
|
|
1668
1557
|
}
|
|
1669
1558
|
_stopNetworkIdleTimer() {
|
|
1670
|
-
if (this._networkIdleTimer)
|
|
1671
|
-
|
|
1559
|
+
if (this._networkIdleTimer)
|
|
1560
|
+
clearTimeout(this._networkIdleTimer);
|
|
1561
|
+
this._networkIdleTimer = void 0;
|
|
1672
1562
|
this._firedNetworkIdleSelf = false;
|
|
1673
1563
|
}
|
|
1674
1564
|
async extendInjectedScript(source, arg) {
|
|
1675
|
-
const context = await this._context(
|
|
1565
|
+
const context = await this._context("main");
|
|
1676
1566
|
const injectedScriptHandle = await context.injectedScript();
|
|
1677
|
-
return injectedScriptHandle.evaluateHandle((injectedScript, {
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
}) => {
|
|
1681
|
-
return injectedScript.extend(source, arg);
|
|
1682
|
-
}, {
|
|
1683
|
-
source,
|
|
1684
|
-
arg
|
|
1685
|
-
});
|
|
1567
|
+
return injectedScriptHandle.evaluateHandle((injectedScript, { source: source2, arg: arg2 }) => {
|
|
1568
|
+
return injectedScript.extend(source2, arg2);
|
|
1569
|
+
}, { source, arg });
|
|
1686
1570
|
}
|
|
1687
1571
|
async resetStorageForCurrentOriginBestEffort(newStorage) {
|
|
1688
1572
|
const context = await this._utilityContext();
|
|
1689
|
-
await context.evaluate(async ({
|
|
1690
|
-
ls
|
|
1691
|
-
}) => {
|
|
1692
|
-
// Clean DOMStorage.
|
|
1573
|
+
await context.evaluate(async ({ ls }) => {
|
|
1693
1574
|
sessionStorage.clear();
|
|
1694
1575
|
localStorage.clear();
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
for (const entry of ls || []) localStorage[entry.name] = entry.value;
|
|
1698
|
-
|
|
1699
|
-
// Clean Service Workers
|
|
1576
|
+
for (const entry of ls || [])
|
|
1577
|
+
localStorage[entry.name] = entry.value;
|
|
1700
1578
|
const registrations = navigator.serviceWorker ? await navigator.serviceWorker.getRegistrations() : [];
|
|
1701
|
-
await Promise.all(registrations.map(async r => {
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1579
|
+
await Promise.all(registrations.map(async (r) => {
|
|
1580
|
+
if (!r.installing && !r.waiting && !r.active)
|
|
1581
|
+
r.unregister().catch(() => {
|
|
1582
|
+
});
|
|
1583
|
+
else
|
|
1584
|
+
await r.unregister().catch(() => {
|
|
1585
|
+
});
|
|
1708
1586
|
}));
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
var _indexedDB$databases, _indexedDB;
|
|
1713
|
-
// Do not wait for the callback - it is called on timer in Chromium (slow).
|
|
1714
|
-
if (db.name) indexedDB.deleteDatabase(db.name);
|
|
1587
|
+
for (const db of await indexedDB.databases?.() || []) {
|
|
1588
|
+
if (db.name)
|
|
1589
|
+
indexedDB.deleteDatabase(db.name);
|
|
1715
1590
|
}
|
|
1716
|
-
}, {
|
|
1717
|
-
|
|
1718
|
-
}).catch(() => {});
|
|
1591
|
+
}, { ls: newStorage?.localStorage }).catch(() => {
|
|
1592
|
+
});
|
|
1719
1593
|
}
|
|
1720
1594
|
_asLocator(selector) {
|
|
1721
|
-
return (0,
|
|
1595
|
+
return (0, import_utils.asLocator)(this._page.attribution.playwright.options.sdkLanguage, selector);
|
|
1722
1596
|
}
|
|
1723
1597
|
async _getFrameMainFrameContextId(client) {
|
|
1724
1598
|
try {
|
|
1725
|
-
var globalDocument = await client._sendMayFail("DOM.getFrameOwner", {
|
|
1726
|
-
frameId: this._id
|
|
1727
|
-
});
|
|
1599
|
+
var globalDocument = await client._sendMayFail("DOM.getFrameOwner", { frameId: this._id });
|
|
1728
1600
|
if (globalDocument && globalDocument.nodeId) {
|
|
1729
1601
|
var describedNode = await client._sendMayFail("DOM.describeNode", {
|
|
1730
1602
|
backendNodeId: globalDocument.backendNodeId
|
|
@@ -1737,25 +1609,23 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1737
1609
|
return _executionContextId;
|
|
1738
1610
|
}
|
|
1739
1611
|
}
|
|
1740
|
-
} catch (e) {
|
|
1612
|
+
} catch (e) {
|
|
1613
|
+
}
|
|
1741
1614
|
return 0;
|
|
1742
1615
|
}
|
|
1743
1616
|
async _customFindElementsByParsed(resolved, client, context, documentScope, progress, parsed) {
|
|
1744
|
-
var parsedEdits = {
|
|
1745
|
-
...parsed
|
|
1746
|
-
};
|
|
1747
|
-
// Note: We start scoping at document level
|
|
1617
|
+
var parsedEdits = { ...parsed };
|
|
1748
1618
|
var currentScopingElements = [documentScope];
|
|
1749
1619
|
while (parsed.parts.length > 0) {
|
|
1750
1620
|
var part = parsed.parts.shift();
|
|
1751
1621
|
parsedEdits.parts = [part];
|
|
1752
1622
|
var isUsingXPath = false;
|
|
1753
|
-
// Getting All Elements
|
|
1754
1623
|
var elements = [];
|
|
1755
1624
|
var elementsIndexes = [];
|
|
1756
1625
|
if (part.name == "xpath") {
|
|
1757
1626
|
isUsingXPath = true;
|
|
1758
|
-
}
|
|
1627
|
+
}
|
|
1628
|
+
if (part.name == "nth") {
|
|
1759
1629
|
const partNth = Number(part.body);
|
|
1760
1630
|
if (partNth > currentScopingElements.length || partNth < -currentScopingElements.length) {
|
|
1761
1631
|
return continuePolling;
|
|
@@ -1768,53 +1638,49 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1768
1638
|
elements = currentScopingElements.concat(orredElements);
|
|
1769
1639
|
} else if (part.name == "internal:and") {
|
|
1770
1640
|
var andedElements = await this._customFindElementsByParsed(resolved, client, context, documentScope, progress, part.body.parsed);
|
|
1771
|
-
const backendNodeIds = new Set(andedElements.map(item => item.backendNodeId));
|
|
1772
|
-
elements = currentScopingElements.filter(item => backendNodeIds.has(item.backendNodeId));
|
|
1641
|
+
const backendNodeIds = new Set(andedElements.map((item) => item.backendNodeId));
|
|
1642
|
+
elements = currentScopingElements.filter((item) => backendNodeIds.has(item.backendNodeId));
|
|
1773
1643
|
} else {
|
|
1774
1644
|
for (const scope of currentScopingElements) {
|
|
1775
|
-
const describedScope = await client.send(
|
|
1645
|
+
const describedScope = await client.send("DOM.describeNode", {
|
|
1776
1646
|
objectId: scope._objectId,
|
|
1777
1647
|
depth: -1,
|
|
1778
1648
|
pierce: true
|
|
1779
1649
|
});
|
|
1780
|
-
|
|
1781
|
-
// Elements Queryed in the "current round"
|
|
1782
1650
|
var queryingElements = [];
|
|
1783
1651
|
if (!isUsingXPath) {
|
|
1784
|
-
function
|
|
1785
|
-
if (!node || typeof node !==
|
|
1652
|
+
let findClosedShadowRoots2 = function(node, results = []) {
|
|
1653
|
+
if (!node || typeof node !== "object") return results;
|
|
1786
1654
|
if (node.shadowRoots && Array.isArray(node.shadowRoots)) {
|
|
1787
|
-
for (const
|
|
1788
|
-
if (
|
|
1789
|
-
results.push(
|
|
1655
|
+
for (const shadowRoot2 of node.shadowRoots) {
|
|
1656
|
+
if (shadowRoot2.shadowRootType === "closed" && shadowRoot2.backendNodeId) {
|
|
1657
|
+
results.push(shadowRoot2.backendNodeId);
|
|
1790
1658
|
}
|
|
1791
|
-
|
|
1659
|
+
findClosedShadowRoots2(shadowRoot2, results);
|
|
1792
1660
|
}
|
|
1793
1661
|
}
|
|
1794
|
-
if (node.nodeName !==
|
|
1662
|
+
if (node.nodeName !== "IFRAME" && node.children && Array.isArray(node.children)) {
|
|
1795
1663
|
for (const child of node.children) {
|
|
1796
|
-
|
|
1664
|
+
findClosedShadowRoots2(child, results);
|
|
1797
1665
|
}
|
|
1798
1666
|
}
|
|
1799
1667
|
return results;
|
|
1800
|
-
}
|
|
1801
|
-
var
|
|
1668
|
+
};
|
|
1669
|
+
var findClosedShadowRoots = findClosedShadowRoots2;
|
|
1670
|
+
var shadowRootBackendIds = findClosedShadowRoots2(describedScope.node);
|
|
1802
1671
|
var shadowRoots = [];
|
|
1803
1672
|
for (var shadowRootBackendId of shadowRootBackendIds) {
|
|
1804
|
-
var resolvedShadowRoot = await client.send(
|
|
1673
|
+
var resolvedShadowRoot = await client.send("DOM.resolveNode", {
|
|
1805
1674
|
backendNodeId: shadowRootBackendId,
|
|
1806
1675
|
contextId: context.delegate._contextId
|
|
1807
1676
|
});
|
|
1808
1677
|
shadowRoots.push(new dom.ElementHandle(context, resolvedShadowRoot.object.objectId));
|
|
1809
1678
|
}
|
|
1810
1679
|
for (var shadowRoot of shadowRoots) {
|
|
1811
|
-
const shadowElements = await shadowRoot.evaluateHandleInUtility(([injected, node, {
|
|
1812
|
-
|
|
1813
|
-
callId
|
|
1814
|
-
|
|
1815
|
-
const elements = injected.querySelectorAll(parsed, node);
|
|
1816
|
-
if (callId) injected.markTargetElements(new Set(elements), callId);
|
|
1817
|
-
return elements;
|
|
1680
|
+
const shadowElements = await shadowRoot.evaluateHandleInUtility(([injected, node, { parsed: parsed2, callId }]) => {
|
|
1681
|
+
const elements2 = injected.querySelectorAll(parsed2, node);
|
|
1682
|
+
if (callId) injected.markTargetElements(new Set(elements2), callId);
|
|
1683
|
+
return elements2;
|
|
1818
1684
|
}, {
|
|
1819
1685
|
parsed: parsedEdits,
|
|
1820
1686
|
callId: progress.metadata.id
|
|
@@ -1823,70 +1689,45 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1823
1689
|
queryingElements.push([shadowElements, shadowElementsAmount, shadowRoot]);
|
|
1824
1690
|
}
|
|
1825
1691
|
}
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
callId
|
|
1831
|
-
}]) => {
|
|
1832
|
-
const elements = injected.querySelectorAll(parsed, node);
|
|
1833
|
-
if (callId) injected.markTargetElements(new Set(elements), callId);
|
|
1834
|
-
return elements;
|
|
1692
|
+
const rootElements = await scope.evaluateHandleInUtility(([injected, node, { parsed: parsed2, callId }]) => {
|
|
1693
|
+
const elements2 = injected.querySelectorAll(parsed2, node);
|
|
1694
|
+
if (callId) injected.markTargetElements(new Set(elements2), callId);
|
|
1695
|
+
return elements2;
|
|
1835
1696
|
}, {
|
|
1836
1697
|
parsed: parsedEdits,
|
|
1837
1698
|
callId: progress.metadata.id
|
|
1838
1699
|
});
|
|
1839
1700
|
const rootElementsAmount = await rootElements.getProperty("length");
|
|
1840
1701
|
queryingElements.push([rootElements, rootElementsAmount, resolved.injected]);
|
|
1841
|
-
|
|
1842
|
-
// Querying and Sorting the elements by their backendNodeId
|
|
1843
1702
|
for (var queryedElement of queryingElements) {
|
|
1844
1703
|
var elementsToCheck = queryedElement[0];
|
|
1845
1704
|
var elementsAmount = await queryedElement[1].jsonValue();
|
|
1846
1705
|
var parentNode = queryedElement[2];
|
|
1847
1706
|
for (var i = 0; i < elementsAmount; i++) {
|
|
1848
1707
|
if (parentNode.constructor.name == "ElementHandle") {
|
|
1849
|
-
var elementToCheck = await parentNode.evaluateHandleInUtility(([injected, node, {
|
|
1850
|
-
index
|
|
1851
|
-
|
|
1852
|
-
}]) => {
|
|
1853
|
-
return elementsToCheck[index];
|
|
1854
|
-
}, {
|
|
1855
|
-
index: i,
|
|
1856
|
-
elementsToCheck: elementsToCheck
|
|
1857
|
-
});
|
|
1708
|
+
var elementToCheck = await parentNode.evaluateHandleInUtility(([injected, node, { index, elementsToCheck: elementsToCheck2 }]) => {
|
|
1709
|
+
return elementsToCheck2[index];
|
|
1710
|
+
}, { index: i, elementsToCheck });
|
|
1858
1711
|
} else {
|
|
1859
|
-
var elementToCheck = await parentNode.evaluateHandle((injected, {
|
|
1860
|
-
index
|
|
1861
|
-
|
|
1862
|
-
}) => {
|
|
1863
|
-
return elementsToCheck[index];
|
|
1864
|
-
}, {
|
|
1865
|
-
index: i,
|
|
1866
|
-
elementsToCheck: elementsToCheck
|
|
1867
|
-
});
|
|
1712
|
+
var elementToCheck = await parentNode.evaluateHandle((injected, { index, elementsToCheck: elementsToCheck2 }) => {
|
|
1713
|
+
return elementsToCheck2[index];
|
|
1714
|
+
}, { index: i, elementsToCheck });
|
|
1868
1715
|
}
|
|
1869
|
-
// For other Functions/Utilities
|
|
1870
1716
|
elementToCheck.parentNode = parentNode;
|
|
1871
|
-
var resolvedElement = await client.send(
|
|
1717
|
+
var resolvedElement = await client.send("DOM.describeNode", {
|
|
1872
1718
|
objectId: elementToCheck._objectId,
|
|
1873
1719
|
depth: -1
|
|
1874
1720
|
});
|
|
1875
|
-
// Note: Possible Bug, Maybe well actually have to check the Documents Node Position instead of using the backendNodeId
|
|
1876
1721
|
elementToCheck.backendNodeId = resolvedElement.node.backendNodeId;
|
|
1877
1722
|
elements.push(elementToCheck);
|
|
1878
1723
|
}
|
|
1879
1724
|
}
|
|
1880
1725
|
}
|
|
1881
1726
|
}
|
|
1882
|
-
// Setting currentScopingElements to the elements we just queried
|
|
1883
1727
|
currentScopingElements = [];
|
|
1884
1728
|
for (var element of elements) {
|
|
1885
1729
|
var elemIndex = element.backendNodeId;
|
|
1886
|
-
|
|
1887
|
-
var elemPos = elementsIndexes.findIndex(index => index > elemIndex);
|
|
1888
|
-
|
|
1889
|
-
// Sort the elements by their backendNodeId
|
|
1730
|
+
var elemPos = elementsIndexes.findIndex((index) => index > elemIndex);
|
|
1890
1731
|
if (elemPos === -1) {
|
|
1891
1732
|
currentScopingElements.push(element);
|
|
1892
1733
|
elementsIndexes.push(elemIndex);
|
|
@@ -1899,17 +1740,10 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1899
1740
|
return currentScopingElements;
|
|
1900
1741
|
}
|
|
1901
1742
|
}
|
|
1902
|
-
exports.Frame = Frame;
|
|
1903
|
-
Frame.Events = {
|
|
1904
|
-
InternalNavigation: 'internalnavigation',
|
|
1905
|
-
AddLifecycle: 'addlifecycle',
|
|
1906
|
-
RemoveLifecycle: 'removelifecycle'
|
|
1907
|
-
};
|
|
1908
1743
|
class SignalBarrier {
|
|
1909
1744
|
constructor(progress) {
|
|
1910
|
-
this._progress = void 0;
|
|
1911
1745
|
this._protectCount = 0;
|
|
1912
|
-
this._promise = new
|
|
1746
|
+
this._promise = new import_manualPromise.ManualPromise();
|
|
1913
1747
|
this._progress = progress;
|
|
1914
1748
|
this.retain();
|
|
1915
1749
|
}
|
|
@@ -1918,15 +1752,21 @@ class SignalBarrier {
|
|
|
1918
1752
|
return this._promise;
|
|
1919
1753
|
}
|
|
1920
1754
|
async addFrameNavigation(frame) {
|
|
1921
|
-
|
|
1922
|
-
|
|
1755
|
+
if (frame.parentFrame())
|
|
1756
|
+
return;
|
|
1923
1757
|
this.retain();
|
|
1924
|
-
const waiter =
|
|
1925
|
-
if (!e.isPublic)
|
|
1926
|
-
|
|
1758
|
+
const waiter = import_helper.helper.waitForEvent(null, frame, Frame.Events.InternalNavigation, (e) => {
|
|
1759
|
+
if (!e.isPublic)
|
|
1760
|
+
return false;
|
|
1761
|
+
if (!e.error && this._progress)
|
|
1762
|
+
this._progress.log(` navigated to "${frame._url}"`);
|
|
1927
1763
|
return true;
|
|
1928
1764
|
});
|
|
1929
|
-
await
|
|
1765
|
+
await import_utils.LongStandingScope.raceMultiple([
|
|
1766
|
+
frame._page.openScope,
|
|
1767
|
+
frame._detachedScope
|
|
1768
|
+
], waiter.promise).catch(() => {
|
|
1769
|
+
});
|
|
1930
1770
|
waiter.dispose();
|
|
1931
1771
|
this.release();
|
|
1932
1772
|
}
|
|
@@ -1935,15 +1775,25 @@ class SignalBarrier {
|
|
|
1935
1775
|
}
|
|
1936
1776
|
release() {
|
|
1937
1777
|
--this._protectCount;
|
|
1938
|
-
if (!this._protectCount)
|
|
1778
|
+
if (!this._protectCount)
|
|
1779
|
+
this._promise.resolve();
|
|
1939
1780
|
}
|
|
1940
1781
|
}
|
|
1941
1782
|
function verifyLifecycle(name, waitUntil) {
|
|
1942
|
-
if (waitUntil ===
|
|
1943
|
-
|
|
1783
|
+
if (waitUntil === "networkidle0")
|
|
1784
|
+
waitUntil = "networkidle";
|
|
1785
|
+
if (!types.kLifecycleEvents.has(waitUntil))
|
|
1786
|
+
throw new Error(`${name}: expected one of (load|domcontentloaded|networkidle|commit)`);
|
|
1944
1787
|
return waitUntil;
|
|
1945
1788
|
}
|
|
1946
1789
|
function renderUnexpectedValue(expression, received) {
|
|
1947
|
-
if (expression ===
|
|
1790
|
+
if (expression === "to.match.aria")
|
|
1791
|
+
return received ? received.raw : received;
|
|
1948
1792
|
return received;
|
|
1949
|
-
}
|
|
1793
|
+
}
|
|
1794
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1795
|
+
0 && (module.exports = {
|
|
1796
|
+
Frame,
|
|
1797
|
+
FrameManager,
|
|
1798
|
+
NavigationAbortedError
|
|
1799
|
+
});
|