rebrowser-playwright-core 1.49.0 → 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/ThirdPartyNotices.txt +381 -55
- package/bin/reinstall_msedge_beta_linux.sh +6 -0
- package/bin/reinstall_msedge_dev_linux.sh +6 -0
- package/bin/reinstall_msedge_stable_linux.sh +6 -0
- package/browsers.json +28 -13
- package/index.js +0 -1
- package/lib/androidServerImpl.js +42 -48
- package/lib/browserServerImpl.js +60 -64
- package/lib/cli/driver.js +71 -69
- package/lib/cli/program.js +314 -354
- package/lib/cli/programWithTestStub.js +51 -44
- package/lib/client/accessibility.js +31 -32
- package/lib/client/android.js +146 -254
- package/lib/client/api.js +135 -283
- package/lib/client/artifact.js +39 -39
- package/lib/client/browser.js +59 -68
- package/lib/client/browserContext.js +302 -322
- package/lib/client/browserType.js +95 -143
- package/lib/client/cdpSession.js +29 -31
- package/lib/client/channelOwner.js +109 -139
- package/lib/client/clientHelper.js +49 -42
- package/lib/client/clientInstrumentation.js +40 -35
- package/lib/client/clientStackTrace.js +69 -0
- package/lib/client/clock.js +36 -36
- package/lib/client/connection.js +203 -218
- package/lib/client/consoleMessage.js +33 -33
- 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 +74 -76
- package/lib/client/elementHandle.js +126 -163
- package/lib/client/errors.js +53 -53
- package/lib/client/eventEmitter.js +127 -127
- package/lib/client/events.js +72 -68
- package/lib/client/fetch.js +154 -178
- package/lib/client/fileChooser.js +25 -24
- package/lib/client/fileUtils.js +34 -0
- package/lib/client/frame.js +189 -307
- package/lib/client/harRouter.js +44 -56
- package/lib/client/input.js +40 -69
- package/lib/client/jsHandle.js +55 -71
- package/lib/client/jsonPipe.js +27 -23
- package/lib/client/localUtils.js +53 -28
- package/lib/client/locator.js +144 -230
- package/lib/client/network.js +285 -301
- package/lib/client/page.js +273 -312
- package/lib/client/platform.js +74 -0
- package/lib/client/playwright.js +62 -57
- package/lib/client/selectors.js +51 -43
- package/lib/client/stream.js +30 -45
- package/lib/client/timeoutSettings.js +75 -0
- package/lib/client/tracing.js +49 -82
- package/lib/client/types.js +26 -22
- package/lib/client/video.js +35 -27
- package/lib/client/waiter.js +71 -91
- package/lib/client/webError.js +25 -23
- package/lib/client/webSocket.js +111 -0
- package/lib/client/worker.js +48 -56
- package/lib/client/writableStream.js +28 -43
- 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 -48
- package/lib/inprocess.js +2 -19
- package/lib/outofprocess.js +53 -42
- package/lib/protocol/debug.js +209 -25
- package/lib/protocol/serializers.js +153 -134
- package/lib/protocol/validator.js +2712 -2667
- package/lib/protocol/validatorPrimitives.js +115 -75
- package/lib/remote/playwrightConnection.js +144 -152
- package/lib/remote/playwrightServer.js +106 -77
- package/lib/server/accessibility.js +44 -37
- package/lib/server/android/android.js +216 -206
- package/lib/server/android/backendAdb.js +89 -82
- package/lib/server/artifact.js +78 -55
- package/lib/server/bidi/bidiBrowser.js +227 -158
- package/lib/server/bidi/bidiChromium.js +106 -78
- package/lib/server/bidi/bidiConnection.js +66 -83
- package/lib/server/bidi/bidiExecutionContext.js +161 -97
- package/lib/server/bidi/bidiFirefox.js +76 -68
- package/lib/server/bidi/bidiInput.js +90 -102
- package/lib/server/bidi/bidiNetworkManager.js +141 -159
- package/lib/server/bidi/bidiOverCdp.js +57 -58
- package/lib/server/bidi/bidiPage.js +262 -261
- 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 +241 -223
- 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 +149 -111
- package/lib/server/browser.js +76 -84
- package/lib/server/browserContext.js +343 -360
- package/lib/server/browserType.js +169 -181
- package/lib/server/callLog.js +82 -0
- package/lib/server/chromium/chromium.js +212 -190
- package/lib/server/chromium/chromiumSwitches.js +99 -44
- package/lib/server/chromium/crAccessibility.js +157 -131
- package/lib/server/chromium/crBrowser.js +262 -280
- package/lib/server/chromium/crConnection.js +121 -178
- package/lib/server/chromium/crCoverage.js +113 -127
- package/lib/server/chromium/crDevTools.js +64 -55
- package/lib/server/chromium/crDragDrop.js +62 -79
- package/lib/server/chromium/crExecutionContext.js +100 -91
- package/lib/server/chromium/crInput.js +101 -88
- package/lib/server/chromium/crNetworkManager.js +269 -370
- package/lib/server/chromium/crPage.js +509 -595
- package/lib/server/chromium/crPdf.js +54 -86
- package/lib/server/chromium/crProtocolHelper.js +92 -80
- package/lib/server/chromium/crServiceWorker.js +85 -69
- 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 +58 -46
- package/lib/server/codegen/csharp.js +191 -156
- package/lib/server/codegen/java.js +163 -125
- package/lib/server/codegen/javascript.js +166 -143
- package/lib/server/codegen/jsonl.js +33 -29
- package/lib/server/codegen/language.js +75 -52
- package/lib/server/codegen/languages.js +65 -27
- package/lib/server/codegen/python.js +141 -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 +102 -154
- package/lib/server/debugger.js +82 -78
- package/lib/server/deviceDescriptors.js +37 -24
- package/lib/server/deviceDescriptorsSource.json +131 -131
- 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 +177 -217
- 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 -64
- package/lib/server/dispatchers/dialogDispatcher.js +30 -27
- package/lib/server/dispatchers/dispatcher.js +180 -229
- package/lib/server/dispatchers/electronDispatcher.js +54 -57
- package/lib/server/dispatchers/elementHandlerDispatcher.js +79 -116
- package/lib/server/dispatchers/frameDispatcher.js +93 -162
- package/lib/server/dispatchers/jsHandleDispatcher.js +49 -66
- package/lib/server/dispatchers/jsonPipeDispatcher.js +35 -36
- package/lib/server/dispatchers/localUtilsDispatcher.js +107 -365
- package/lib/server/dispatchers/networkDispatchers.js +92 -109
- package/lib/server/dispatchers/pageDispatcher.js +130 -169
- package/lib/server/dispatchers/playwrightDispatcher.js +69 -76
- package/lib/server/dispatchers/selectorsDispatcher.js +28 -24
- package/lib/server/dispatchers/streamDispatcher.js +42 -44
- package/lib/server/dispatchers/tracingDispatcher.js +36 -41
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +100 -135
- package/lib/server/dispatchers/writableStreamDispatcher.js +54 -39
- package/lib/server/dom.js +424 -443
- package/lib/server/download.js +45 -35
- package/lib/server/electron/electron.js +156 -175
- package/lib/server/electron/loader.js +8 -36
- package/lib/server/errors.js +47 -46
- package/lib/server/fetch.js +302 -331
- package/lib/server/fileChooser.js +25 -24
- package/lib/server/fileUploadUtils.js +66 -57
- package/lib/server/firefox/ffAccessibility.js +153 -131
- package/lib/server/firefox/ffBrowser.js +218 -274
- package/lib/server/firefox/ffConnection.js +63 -84
- package/lib/server/firefox/ffExecutionContext.js +103 -77
- package/lib/server/firefox/ffInput.js +72 -63
- package/lib/server/firefox/ffNetworkManager.js +131 -110
- package/lib/server/firefox/ffPage.js +244 -302
- package/lib/server/firefox/firefox.js +76 -69
- 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 +719 -855
- package/lib/server/har/harRecorder.js +85 -77
- package/lib/server/har/harTracer.js +288 -224
- package/lib/server/harBackend.js +157 -0
- package/lib/server/helper.js +56 -59
- package/lib/server/index.js +59 -106
- package/lib/server/input.js +136 -166
- package/lib/server/instrumentation.js +49 -44
- package/lib/server/javascript.js +157 -151
- package/lib/server/launchApp.js +92 -73
- package/lib/server/localUtils.js +211 -0
- package/lib/server/macEditingCommands.js +141 -137
- package/lib/server/network.js +263 -297
- package/lib/server/page.js +353 -432
- 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 +161 -0
- package/lib/server/recorder/contextRecorder.js +135 -148
- package/lib/server/recorder/recorderApp.js +129 -132
- package/lib/server/recorder/recorderCollection.js +57 -57
- package/lib/server/recorder/recorderFrontend.js +15 -4
- package/lib/server/recorder/recorderRunner.js +80 -100
- package/lib/server/recorder/recorderUtils.js +59 -72
- package/lib/server/recorder/throttledFile.js +42 -31
- package/lib/server/recorder.js +186 -190
- package/lib/server/registry/browserFetcher.js +107 -100
- package/lib/server/registry/dependencies.js +247 -198
- package/lib/server/registry/index.js +928 -709
- package/lib/server/registry/nativeDeps.js +1073 -461
- 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 -67
- package/lib/server/storageScript.js +154 -0
- package/lib/server/timeoutSettings.js +89 -0
- package/lib/server/trace/recorder/snapshotter.js +70 -88
- package/lib/server/trace/recorder/snapshotterInjected.js +246 -218
- package/lib/server/trace/recorder/tracing.js +324 -327
- package/lib/server/trace/test/inMemorySnapshotter.js +46 -52
- package/lib/server/trace/viewer/traceViewer.js +172 -137
- package/lib/server/transport.js +125 -133
- package/lib/server/types.js +26 -22
- package/lib/server/usKeyboardLayout.js +135 -545
- package/lib/server/utils/ascii.js +44 -0
- package/lib/server/utils/comparators.js +161 -0
- package/lib/server/utils/crypto.js +216 -0
- package/lib/server/utils/debug.js +47 -0
- package/lib/server/utils/debugLogger.js +114 -0
- package/lib/server/utils/env.js +68 -0
- package/lib/server/utils/eventsHelper.js +39 -0
- package/lib/server/utils/expectUtils.js +38 -0
- package/lib/server/utils/fileUtils.js +191 -0
- package/lib/server/utils/happyEyeballs.js +207 -0
- package/lib/server/utils/hostPlatform.js +109 -0
- package/lib/server/utils/httpServer.js +218 -0
- package/lib/server/utils/image_tools/colorUtils.js +89 -0
- package/lib/{image_tools → server/utils/image_tools}/compare.js +44 -43
- package/lib/server/utils/image_tools/imageChannel.js +78 -0
- package/lib/{image_tools → server/utils/image_tools}/stats.js +40 -40
- package/lib/server/utils/linuxUtils.js +71 -0
- package/lib/server/utils/network.js +217 -0
- package/lib/server/utils/nodePlatform.js +148 -0
- package/lib/server/utils/pipeTransport.js +84 -0
- package/lib/server/utils/processLauncher.js +238 -0
- package/lib/server/utils/profiler.js +65 -0
- package/lib/server/utils/socksProxy.js +511 -0
- package/lib/server/utils/spawnAsync.js +41 -0
- package/lib/server/utils/task.js +51 -0
- package/lib/server/utils/userAgent.js +98 -0
- package/lib/server/utils/wsServer.js +132 -0
- package/lib/server/utils/zipFile.js +74 -0
- package/lib/server/utils/zones.js +57 -0
- 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 +163 -180
- package/lib/server/webkit/wkConnection.js +59 -83
- package/lib/server/webkit/wkExecutionContext.js +96 -73
- package/lib/server/webkit/wkInput.js +87 -75
- package/lib/server/webkit/wkInterceptableRequest.js +102 -95
- package/lib/server/webkit/wkPage.js +536 -645
- package/lib/server/webkit/wkProvisionalPage.js +45 -56
- package/lib/server/webkit/wkWorkers.js +77 -77
- package/lib/utils/isomorphic/ariaSnapshot.js +245 -128
- package/lib/utils/isomorphic/assert.js +31 -0
- package/lib/utils/isomorphic/builtins.js +90 -0
- package/lib/utils/isomorphic/colors.js +72 -0
- package/lib/utils/isomorphic/cssParser.js +123 -127
- package/lib/utils/isomorphic/cssTokenizer.js +436 -364
- package/lib/utils/isomorphic/headers.js +53 -0
- package/lib/utils/isomorphic/locatorGenerators.js +344 -349
- package/lib/utils/isomorphic/locatorParser.js +103 -106
- package/lib/utils/isomorphic/locatorUtils.js +63 -44
- package/lib/utils/isomorphic/manualPromise.js +115 -0
- package/lib/utils/isomorphic/mimeType.js +453 -22
- package/lib/utils/isomorphic/multimap.js +81 -0
- package/lib/utils/isomorphic/rtti.js +43 -0
- package/lib/utils/isomorphic/selectorParser.js +183 -193
- package/lib/utils/isomorphic/semaphore.js +54 -0
- package/lib/utils/isomorphic/stackTrace.js +158 -0
- package/lib/utils/isomorphic/stringUtils.js +113 -106
- package/lib/utils/isomorphic/time.js +44 -0
- package/lib/utils/isomorphic/timeoutRunner.js +67 -0
- package/lib/utils/isomorphic/traceUtils.js +52 -32
- package/lib/utils/isomorphic/types.js +16 -0
- package/lib/utils/isomorphic/urlMatch.js +114 -71
- package/lib/utils/isomorphic/utilityScriptSerializers.js +248 -0
- package/lib/utils.js +101 -0
- package/lib/utilsBundle.js +101 -76
- package/lib/utilsBundleImpl/index.js +114 -116
- package/lib/vite/htmlReport/index.html +26 -20
- package/lib/vite/recorder/assets/codeMirrorModule-DVQi6prl.js +24 -0
- package/lib/vite/recorder/assets/index-97EUAAbk.js +184 -0
- package/lib/vite/recorder/assets/{index-iA1aAGZg.css → index-eHBmevrY.css} +1 -1
- package/lib/vite/recorder/index.html +2 -2
- package/lib/vite/traceViewer/assets/codeMirrorModule-DwAiTpyC.js +24 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-DkkRvn5X.js +265 -0
- package/lib/vite/traceViewer/assets/{xtermModule-BeNbaIVa.js → xtermModule-BoAIEibi.js} +7 -7
- package/lib/vite/traceViewer/defaultSettingsView.QdHITyLI.css +1 -0
- package/lib/vite/traceViewer/index.DvtSwn6E.js +2 -0
- package/lib/vite/traceViewer/index.html +4 -7
- package/lib/vite/traceViewer/sw.bundle.js +3 -3
- package/lib/vite/traceViewer/{uiMode.voC1ZiOQ.css → uiMode.BatfzHMG.css} +1 -1
- package/lib/vite/traceViewer/uiMode.Sdytl9wc.js +5 -0
- package/lib/vite/traceViewer/uiMode.html +4 -7
- package/lib/zipBundle.js +32 -23
- package/lib/zipBundleImpl.js +4 -4
- package/package.json +7 -7
- package/types/protocol.d.ts +819 -127
- package/types/types.d.ts +196 -75
- package/bin/PrintDeps.exe +0 -0
- package/bin/README.md +0 -2
- package/lib/common/socksProxy.js +0 -569
- package/lib/common/timeoutSettings.js +0 -73
- package/lib/common/types.js +0 -5
- package/lib/image_tools/colorUtils.js +0 -98
- package/lib/image_tools/imageChannel.js +0 -70
- package/lib/protocol/transport.js +0 -82
- package/lib/server/ariaSnapshot.js +0 -33
- package/lib/server/isomorphic/utilityScriptSerializers.js +0 -226
- package/lib/server/recorder/recorderInTraceViewer.js +0 -144
- package/lib/utils/ascii.js +0 -31
- package/lib/utils/comparators.js +0 -153
- package/lib/utils/crypto.js +0 -171
- package/lib/utils/debug.js +0 -46
- package/lib/utils/debugLogger.js +0 -91
- package/lib/utils/env.js +0 -49
- package/lib/utils/eventsHelper.js +0 -38
- package/lib/utils/expectUtils.js +0 -33
- package/lib/utils/fileUtils.js +0 -205
- package/lib/utils/happy-eyeballs.js +0 -194
- package/lib/utils/headers.js +0 -52
- package/lib/utils/hostPlatform.js +0 -139
- package/lib/utils/httpServer.js +0 -237
- package/lib/utils/index.js +0 -368
- package/lib/utils/isomorphic/recorderUtils.js +0 -227
- package/lib/utils/linuxUtils.js +0 -78
- package/lib/utils/manualPromise.js +0 -109
- package/lib/utils/multimap.js +0 -75
- package/lib/utils/network.js +0 -160
- package/lib/utils/processLauncher.js +0 -248
- package/lib/utils/profiler.js +0 -53
- package/lib/utils/rtti.js +0 -44
- package/lib/utils/semaphore.js +0 -51
- package/lib/utils/sequence.js +0 -64
- package/lib/utils/spawnAsync.js +0 -45
- package/lib/utils/stackTrace.js +0 -134
- package/lib/utils/task.js +0 -58
- package/lib/utils/time.js +0 -37
- package/lib/utils/timeoutRunner.js +0 -66
- package/lib/utils/traceUtils.js +0 -44
- package/lib/utils/userAgent.js +0 -105
- package/lib/utils/wsServer.js +0 -127
- package/lib/utils/zipFile.js +0 -75
- package/lib/utils/zones.js +0 -71
- package/lib/vite/recorder/assets/codeMirrorModule-AFvV6hAs.js +0 -24
- package/lib/vite/recorder/assets/index-_cTWgVuJ.js +0 -184
- package/lib/vite/traceViewer/assets/codeMirrorModule-KatbITLF.js +0 -24
- package/lib/vite/traceViewer/assets/inspectorTab-DdpLd2bb.js +0 -68
- package/lib/vite/traceViewer/assets/testServerConnection-DeE2kSzz.js +0 -1
- package/lib/vite/traceViewer/assets/workbench-CdYbzWFD.js +0 -9
- package/lib/vite/traceViewer/embedded.6m3UZh7r.js +0 -2
- package/lib/vite/traceViewer/embedded.html +0 -18
- package/lib/vite/traceViewer/embedded.w7WN2u1R.css +0 -1
- package/lib/vite/traceViewer/index.WUV-8boJ.js +0 -2
- package/lib/vite/traceViewer/inspectorTab.DEOUW62d.css +0 -1
- package/lib/vite/traceViewer/recorder.B_SY1GJM.css +0 -0
- package/lib/vite/traceViewer/recorder.OT2tVHgn.js +0 -2
- package/lib/vite/traceViewer/recorder.html +0 -17
- package/lib/vite/traceViewer/uiMode.BZBTyvGn.js +0 -5
- package/lib/vite/traceViewer/workbench.C-zR9ysA.css +0 -1
- /package/lib/vite/recorder/assets/{codeMirrorModule-ez37Vkbh.css → codeMirrorModule-C3UTv-Ge.css} +0 -0
- /package/lib/vite/traceViewer/{codeMirrorModule.ez37Vkbh.css → codeMirrorModule.C3UTv-Ge.css} +0 -0
- /package/lib/vite/traceViewer/{index.CrbWWHbf.css → index.CFOW-Ezb.css} +0 -0
- /package/lib/vite/traceViewer/{xtermModule.DSXBckUd.css → xtermModule.Beg8tuEN.css} +0 -0
|
@@ -1,127 +1,123 @@
|
|
|
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 wkPage_exports = {};
|
|
30
|
+
__export(wkPage_exports, {
|
|
31
|
+
WKPage: () => WKPage
|
|
5
32
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
|
-
/**
|
|
34
|
-
* Copyright 2017 Google Inc. All rights reserved.
|
|
35
|
-
* Modifications copyright (c) Microsoft Corporation.
|
|
36
|
-
*
|
|
37
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
38
|
-
* you may not use this file except in compliance with the License.
|
|
39
|
-
* You may obtain a copy of the License at
|
|
40
|
-
*
|
|
41
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
42
|
-
*
|
|
43
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
44
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
45
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
46
|
-
* See the License for the specific language governing permissions and
|
|
47
|
-
* limitations under the License.
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
const UTILITY_WORLD_NAME = '__playwright_utility_world__';
|
|
33
|
+
module.exports = __toCommonJS(wkPage_exports);
|
|
34
|
+
var import_path = __toESM(require("path"));
|
|
35
|
+
var import_utils = require("../../utils");
|
|
36
|
+
var import_headers = require("../../utils/isomorphic/headers");
|
|
37
|
+
var import_crypto = require("../utils/crypto");
|
|
38
|
+
var import_eventsHelper = require("../utils/eventsHelper");
|
|
39
|
+
var import_hostPlatform = require("../utils/hostPlatform");
|
|
40
|
+
var import_stackTrace = require("../../utils/isomorphic/stackTrace");
|
|
41
|
+
var import_utilsBundle = require("../../utilsBundle");
|
|
42
|
+
var import_browserContext = require("../browserContext");
|
|
43
|
+
var dialog = __toESM(require("../dialog"));
|
|
44
|
+
var dom = __toESM(require("../dom"));
|
|
45
|
+
var import_errors = require("../errors");
|
|
46
|
+
var import_helper = require("../helper");
|
|
47
|
+
var network = __toESM(require("../network"));
|
|
48
|
+
var import_page = require("../page");
|
|
49
|
+
var import_page2 = require("../page");
|
|
50
|
+
var import_wkAccessibility = require("./wkAccessibility");
|
|
51
|
+
var import_wkConnection = require("./wkConnection");
|
|
52
|
+
var import_wkExecutionContext = require("./wkExecutionContext");
|
|
53
|
+
var import_wkInput = require("./wkInput");
|
|
54
|
+
var import_wkInterceptableRequest = require("./wkInterceptableRequest");
|
|
55
|
+
var import_wkProvisionalPage = require("./wkProvisionalPage");
|
|
56
|
+
var import_wkWorkers = require("./wkWorkers");
|
|
57
|
+
var import_debugLogger = require("../utils/debugLogger");
|
|
58
|
+
const UTILITY_WORLD_NAME = "__playwright_utility_world__";
|
|
51
59
|
class WKPage {
|
|
52
60
|
constructor(browserContext, pageProxySession, opener) {
|
|
53
|
-
this.rawMouse = void 0;
|
|
54
|
-
this.rawKeyboard = void 0;
|
|
55
|
-
this.rawTouchscreen = void 0;
|
|
56
|
-
this._session = void 0;
|
|
57
61
|
this._provisionalPage = null;
|
|
58
|
-
this.
|
|
59
|
-
this.
|
|
60
|
-
this._pageProxySession = void 0;
|
|
61
|
-
this._opener = void 0;
|
|
62
|
-
this._requestIdToRequest = new Map();
|
|
63
|
-
this._requestIdToRequestWillBeSentEvent = new Map();
|
|
64
|
-
this._workers = void 0;
|
|
65
|
-
this._contextIdToContext = void 0;
|
|
62
|
+
this._requestIdToRequest = /* @__PURE__ */ new Map();
|
|
63
|
+
this._requestIdToRequestWillBeSentEvent = /* @__PURE__ */ new Map();
|
|
66
64
|
this._sessionListeners = [];
|
|
67
|
-
this.
|
|
68
|
-
|
|
69
|
-
this.
|
|
70
|
-
|
|
71
|
-
this._firstNonInitialNavigationCommittedFulfill = () => {};
|
|
72
|
-
this._firstNonInitialNavigationCommittedReject = e => {};
|
|
65
|
+
this._firstNonInitialNavigationCommittedFulfill = () => {
|
|
66
|
+
};
|
|
67
|
+
this._firstNonInitialNavigationCommittedReject = (e) => {
|
|
68
|
+
};
|
|
73
69
|
this._lastConsoleMessage = null;
|
|
74
|
-
this._requestIdToResponseReceivedPayloadEvent = new Map();
|
|
75
|
-
// Holds window features for the next popup being opened via window.open,
|
|
76
|
-
// until the popup page proxy arrives.
|
|
77
|
-
this._nextWindowOpenPopupFeatures = void 0;
|
|
70
|
+
this._requestIdToResponseReceivedPayloadEvent = /* @__PURE__ */ new Map();
|
|
78
71
|
this._recordingVideoFile = null;
|
|
79
72
|
this._screencastGeneration = 0;
|
|
80
73
|
this._pageProxySession = pageProxySession;
|
|
81
74
|
this._opener = opener;
|
|
82
|
-
this.rawKeyboard = new
|
|
83
|
-
this.rawMouse = new
|
|
84
|
-
this.rawTouchscreen = new
|
|
85
|
-
this._contextIdToContext = new Map();
|
|
86
|
-
this._page = new
|
|
75
|
+
this.rawKeyboard = new import_wkInput.RawKeyboardImpl(pageProxySession);
|
|
76
|
+
this.rawMouse = new import_wkInput.RawMouseImpl(pageProxySession);
|
|
77
|
+
this.rawTouchscreen = new import_wkInput.RawTouchscreenImpl(pageProxySession);
|
|
78
|
+
this._contextIdToContext = /* @__PURE__ */ new Map();
|
|
79
|
+
this._page = new import_page2.Page(this, browserContext);
|
|
87
80
|
this.rawMouse.setPage(this._page);
|
|
88
|
-
this._workers = new
|
|
89
|
-
this._session =
|
|
81
|
+
this._workers = new import_wkWorkers.WKWorkers(this._page);
|
|
82
|
+
this._session = void 0;
|
|
90
83
|
this._browserContext = browserContext;
|
|
91
|
-
this._page.on(
|
|
92
|
-
this._eventListeners = [
|
|
84
|
+
this._page.on(import_page2.Page.Events.FrameDetached, (frame) => this._removeContextsForFrame(frame, false));
|
|
85
|
+
this._eventListeners = [
|
|
86
|
+
import_eventsHelper.eventsHelper.addEventListener(this._pageProxySession, "Target.targetCreated", this._onTargetCreated.bind(this)),
|
|
87
|
+
import_eventsHelper.eventsHelper.addEventListener(this._pageProxySession, "Target.targetDestroyed", this._onTargetDestroyed.bind(this)),
|
|
88
|
+
import_eventsHelper.eventsHelper.addEventListener(this._pageProxySession, "Target.dispatchMessageFromTarget", this._onDispatchMessageFromTarget.bind(this)),
|
|
89
|
+
import_eventsHelper.eventsHelper.addEventListener(this._pageProxySession, "Target.didCommitProvisionalTarget", this._onDidCommitProvisionalTarget.bind(this)),
|
|
90
|
+
import_eventsHelper.eventsHelper.addEventListener(this._pageProxySession, "Screencast.screencastFrame", this._onScreencastFrame.bind(this))
|
|
91
|
+
];
|
|
93
92
|
this._firstNonInitialNavigationCommittedPromise = new Promise((f, r) => {
|
|
94
93
|
this._firstNonInitialNavigationCommittedFulfill = f;
|
|
95
94
|
this._firstNonInitialNavigationCommittedReject = r;
|
|
96
95
|
});
|
|
97
96
|
if (opener && !browserContext._options.noDefaultViewport && opener._nextWindowOpenPopupFeatures) {
|
|
98
|
-
const viewportSize =
|
|
99
|
-
opener._nextWindowOpenPopupFeatures =
|
|
100
|
-
if (viewportSize)
|
|
101
|
-
viewport: viewportSize,
|
|
102
|
-
screen: viewportSize
|
|
103
|
-
};
|
|
97
|
+
const viewportSize = import_helper.helper.getViewportSizeFromWindowFeatures(opener._nextWindowOpenPopupFeatures);
|
|
98
|
+
opener._nextWindowOpenPopupFeatures = void 0;
|
|
99
|
+
if (viewportSize)
|
|
100
|
+
this._page._emulatedSize = { viewport: viewportSize, screen: viewportSize };
|
|
104
101
|
}
|
|
105
102
|
}
|
|
106
|
-
potentiallyUninitializedPage() {
|
|
107
|
-
return this._page;
|
|
108
|
-
}
|
|
109
103
|
async _initializePageProxySession() {
|
|
110
|
-
if (this._page._browserContext.isSettingStorageState())
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
104
|
+
if (this._page._browserContext.isSettingStorageState())
|
|
105
|
+
return;
|
|
106
|
+
const promises = [
|
|
107
|
+
this._pageProxySession.send("Dialog.enable"),
|
|
108
|
+
this._pageProxySession.send("Emulation.setActiveAndFocused", { active: true })
|
|
109
|
+
];
|
|
114
110
|
const contextOptions = this._browserContext._options;
|
|
115
|
-
if (contextOptions.javaScriptEnabled === false)
|
|
116
|
-
enabled: false
|
|
117
|
-
}));
|
|
111
|
+
if (contextOptions.javaScriptEnabled === false)
|
|
112
|
+
promises.push(this._pageProxySession.send("Emulation.setJavaScriptEnabled", { enabled: false }));
|
|
118
113
|
promises.push(this._updateViewport());
|
|
119
114
|
promises.push(this.updateHttpCredentials());
|
|
120
115
|
if (this._browserContext._permissions.size) {
|
|
121
|
-
for (const [key, value] of this._browserContext._permissions)
|
|
116
|
+
for (const [key, value] of this._browserContext._permissions)
|
|
117
|
+
promises.push(this._grantPermissions(key, value));
|
|
122
118
|
}
|
|
123
119
|
if (this._browserContext._options.recordVideo) {
|
|
124
|
-
const outputFile =
|
|
120
|
+
const outputFile = import_path.default.join(this._browserContext._options.recordVideo.dir, (0, import_crypto.createGuid)() + ".webm");
|
|
125
121
|
promises.push(this._browserContext._ensureVideosPath().then(() => {
|
|
126
122
|
return this._startVideo({
|
|
127
123
|
// validateBrowserContextOptions ensures correct video size.
|
|
@@ -133,134 +129,100 @@ class WKPage {
|
|
|
133
129
|
await Promise.all(promises);
|
|
134
130
|
}
|
|
135
131
|
_setSession(session) {
|
|
136
|
-
|
|
132
|
+
import_eventsHelper.eventsHelper.removeEventListeners(this._sessionListeners);
|
|
137
133
|
this._session = session;
|
|
138
134
|
this.rawKeyboard.setSession(session);
|
|
139
135
|
this.rawMouse.setSession(session);
|
|
140
136
|
this._addSessionListeners();
|
|
141
137
|
this._workers.setSession(session);
|
|
142
138
|
}
|
|
143
|
-
|
|
144
139
|
// This method is called for provisional targets as well. The session passed as the parameter
|
|
145
140
|
// may be different from the current session and may be destroyed without becoming current.
|
|
146
141
|
async _initializeSession(session, provisional, resourceTreeHandler) {
|
|
147
|
-
await this._initializeSessionMayThrow(session, resourceTreeHandler).catch(e => {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (
|
|
151
|
-
|
|
152
|
-
// since we will reinitialize again.
|
|
153
|
-
if (this._session === session) throw e;
|
|
142
|
+
await this._initializeSessionMayThrow(session, resourceTreeHandler).catch((e) => {
|
|
143
|
+
if (provisional && session.isDisposed())
|
|
144
|
+
return;
|
|
145
|
+
if (this._session === session)
|
|
146
|
+
throw e;
|
|
154
147
|
});
|
|
155
148
|
}
|
|
156
149
|
async _initializeSessionMayThrow(session, resourceTreeHandler) {
|
|
157
150
|
const [, frameTree] = await Promise.all([
|
|
158
|
-
|
|
159
|
-
|
|
151
|
+
// Page agent must be enabled before Runtime.
|
|
152
|
+
session.send("Page.enable"),
|
|
153
|
+
session.send("Page.getResourceTree")
|
|
154
|
+
]);
|
|
160
155
|
resourceTreeHandler(frameTree);
|
|
161
156
|
const promises = [
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
name:
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
157
|
+
// Resource tree should be received before first execution context.
|
|
158
|
+
session.send("Runtime.enable"),
|
|
159
|
+
session.send("Runtime.addBinding", { name: import_page.PageBinding.kPlaywrightBinding }),
|
|
160
|
+
session.send("Page.createUserWorld", { name: UTILITY_WORLD_NAME }).catch((_) => {
|
|
161
|
+
}),
|
|
162
|
+
// Worlds are per-process
|
|
163
|
+
session.send("Console.enable"),
|
|
164
|
+
session.send("Network.enable"),
|
|
165
|
+
this._workers.initializeSession(session)
|
|
166
|
+
];
|
|
170
167
|
if (this._page.needsRequestInterception()) {
|
|
171
|
-
promises.push(session.send(
|
|
172
|
-
|
|
173
|
-
}));
|
|
174
|
-
promises.push(session.send('Network.setResourceCachingDisabled', {
|
|
175
|
-
disabled: true
|
|
176
|
-
}));
|
|
177
|
-
promises.push(session.send('Network.addInterception', {
|
|
178
|
-
url: '.*',
|
|
179
|
-
stage: 'request',
|
|
180
|
-
isRegex: true
|
|
181
|
-
}));
|
|
168
|
+
promises.push(session.send("Network.setInterceptionEnabled", { enabled: true }));
|
|
169
|
+
promises.push(session.send("Network.setResourceCachingDisabled", { disabled: true }));
|
|
170
|
+
promises.push(session.send("Network.addInterception", { url: ".*", stage: "request", isRegex: true }));
|
|
182
171
|
}
|
|
183
172
|
if (this._page._browserContext.isSettingStorageState()) {
|
|
184
173
|
await Promise.all(promises);
|
|
185
174
|
return;
|
|
186
175
|
}
|
|
187
176
|
const contextOptions = this._browserContext._options;
|
|
188
|
-
if (contextOptions.userAgent)
|
|
177
|
+
if (contextOptions.userAgent)
|
|
178
|
+
promises.push(this.updateUserAgent());
|
|
189
179
|
const emulatedMedia = this._page.emulatedMedia();
|
|
190
|
-
if (emulatedMedia.media || emulatedMedia.colorScheme || emulatedMedia.reducedMotion || emulatedMedia.forcedColors
|
|
180
|
+
if (emulatedMedia.media || emulatedMedia.colorScheme || emulatedMedia.reducedMotion || emulatedMedia.forcedColors || emulatedMedia.contrast)
|
|
181
|
+
promises.push(WKPage._setEmulateMedia(session, emulatedMedia.media, emulatedMedia.colorScheme, emulatedMedia.reducedMotion, emulatedMedia.forcedColors, emulatedMedia.contrast));
|
|
191
182
|
const bootstrapScript = this._calculateBootstrapScript();
|
|
192
|
-
if (bootstrapScript.length)
|
|
193
|
-
source: bootstrapScript
|
|
194
|
-
|
|
195
|
-
this._page.frames().map(frame => frame.evaluateExpression(bootstrapScript).catch(e => {}));
|
|
196
|
-
if (contextOptions.bypassCSP) promises.push(session.send('Page.setBypassCSP', {
|
|
197
|
-
enabled: true
|
|
183
|
+
if (bootstrapScript.length)
|
|
184
|
+
promises.push(session.send("Page.setBootstrapScript", { source: bootstrapScript }));
|
|
185
|
+
this._page.frames().map((frame) => frame.evaluateExpression(bootstrapScript).catch((e) => {
|
|
198
186
|
}));
|
|
187
|
+
if (contextOptions.bypassCSP)
|
|
188
|
+
promises.push(session.send("Page.setBypassCSP", { enabled: true }));
|
|
199
189
|
const emulatedSize = this._page.emulatedSize();
|
|
200
190
|
if (emulatedSize) {
|
|
201
|
-
promises.push(session.send(
|
|
191
|
+
promises.push(session.send("Page.setScreenSizeOverride", {
|
|
202
192
|
width: emulatedSize.screen.width,
|
|
203
193
|
height: emulatedSize.screen.height
|
|
204
194
|
}));
|
|
205
195
|
}
|
|
206
196
|
promises.push(this.updateEmulateMedia());
|
|
207
|
-
promises.push(session.send(
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}));
|
|
197
|
+
promises.push(session.send("Network.setExtraHTTPHeaders", { headers: (0, import_headers.headersArrayToObject)(
|
|
198
|
+
this._calculateExtraHTTPHeaders(),
|
|
199
|
+
false
|
|
200
|
+
/* lowerCase */
|
|
201
|
+
) }));
|
|
202
|
+
if (contextOptions.offline)
|
|
203
|
+
promises.push(session.send("Network.setEmulateOfflineState", { offline: true }));
|
|
204
|
+
promises.push(session.send("Page.setTouchEmulationEnabled", { enabled: !!contextOptions.hasTouch }));
|
|
216
205
|
if (contextOptions.timezoneId) {
|
|
217
|
-
promises.push(session.send(
|
|
218
|
-
timeZone: contextOptions.timezoneId
|
|
219
|
-
}).catch(e => {
|
|
206
|
+
promises.push(session.send("Page.setTimeZone", { timeZone: contextOptions.timezoneId }).catch((e) => {
|
|
220
207
|
throw new Error(`Invalid timezone ID: ${contextOptions.timezoneId}`);
|
|
221
208
|
}));
|
|
222
209
|
}
|
|
223
|
-
if (this._page.fileChooserIntercepted())
|
|
224
|
-
enabled: true
|
|
225
|
-
}));
|
|
226
|
-
promises.push(session.send(
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}));
|
|
230
|
-
promises.push(session.send(
|
|
231
|
-
|
|
232
|
-
value: !contextOptions.isMobile
|
|
233
|
-
}));
|
|
234
|
-
promises.push(session.send('Page.overrideSetting', {
|
|
235
|
-
setting: 'NotificationsEnabled',
|
|
236
|
-
value: !contextOptions.isMobile
|
|
237
|
-
}));
|
|
238
|
-
promises.push(session.send('Page.overrideSetting', {
|
|
239
|
-
setting: 'PointerLockEnabled',
|
|
240
|
-
value: !contextOptions.isMobile
|
|
241
|
-
}));
|
|
242
|
-
promises.push(session.send('Page.overrideSetting', {
|
|
243
|
-
setting: 'InputTypeMonthEnabled',
|
|
244
|
-
value: contextOptions.isMobile
|
|
245
|
-
}));
|
|
246
|
-
promises.push(session.send('Page.overrideSetting', {
|
|
247
|
-
setting: 'InputTypeWeekEnabled',
|
|
248
|
-
value: contextOptions.isMobile
|
|
249
|
-
}));
|
|
250
|
-
promises.push(session.send('Page.overrideSetting', {
|
|
251
|
-
setting: 'FixedBackgroundsPaintRelativeToDocument',
|
|
252
|
-
value: contextOptions.isMobile
|
|
253
|
-
}));
|
|
210
|
+
if (this._page.fileChooserIntercepted())
|
|
211
|
+
promises.push(session.send("Page.setInterceptFileChooserDialog", { enabled: true }));
|
|
212
|
+
promises.push(session.send("Page.overrideSetting", { setting: "DeviceOrientationEventEnabled", value: contextOptions.isMobile }));
|
|
213
|
+
promises.push(session.send("Page.overrideSetting", { setting: "FullScreenEnabled", value: !contextOptions.isMobile }));
|
|
214
|
+
promises.push(session.send("Page.overrideSetting", { setting: "NotificationsEnabled", value: !contextOptions.isMobile }));
|
|
215
|
+
promises.push(session.send("Page.overrideSetting", { setting: "PointerLockEnabled", value: !contextOptions.isMobile }));
|
|
216
|
+
promises.push(session.send("Page.overrideSetting", { setting: "InputTypeMonthEnabled", value: contextOptions.isMobile }));
|
|
217
|
+
promises.push(session.send("Page.overrideSetting", { setting: "InputTypeWeekEnabled", value: contextOptions.isMobile }));
|
|
218
|
+
promises.push(session.send("Page.overrideSetting", { setting: "FixedBackgroundsPaintRelativeToDocument", value: contextOptions.isMobile }));
|
|
254
219
|
await Promise.all(promises);
|
|
255
220
|
}
|
|
256
221
|
_onDidCommitProvisionalTarget(event) {
|
|
257
|
-
const {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
(0, _utils.assert)(this._provisionalPage);
|
|
262
|
-
(0, _utils.assert)(this._provisionalPage._session.sessionId === newTargetId, 'Unknown new target: ' + newTargetId);
|
|
263
|
-
(0, _utils.assert)(this._session.sessionId === oldTargetId, 'Unknown old target: ' + oldTargetId);
|
|
222
|
+
const { oldTargetId, newTargetId } = event;
|
|
223
|
+
(0, import_utils.assert)(this._provisionalPage);
|
|
224
|
+
(0, import_utils.assert)(this._provisionalPage._session.sessionId === newTargetId, "Unknown new target: " + newTargetId);
|
|
225
|
+
(0, import_utils.assert)(this._session.sessionId === oldTargetId, "Unknown old target: " + oldTargetId);
|
|
264
226
|
const newSession = this._provisionalPage._session;
|
|
265
227
|
this._provisionalPage.commit();
|
|
266
228
|
this._provisionalPage.dispose();
|
|
@@ -268,10 +230,7 @@ class WKPage {
|
|
|
268
230
|
this._setSession(newSession);
|
|
269
231
|
}
|
|
270
232
|
_onTargetDestroyed(event) {
|
|
271
|
-
const {
|
|
272
|
-
targetId,
|
|
273
|
-
crashed
|
|
274
|
-
} = event;
|
|
233
|
+
const { targetId, crashed } = event;
|
|
275
234
|
if (this._provisionalPage && this._provisionalPage._session.sessionId === targetId) {
|
|
276
235
|
this._maybeCancelCoopNavigationRequest(this._provisionalPage);
|
|
277
236
|
this._provisionalPage._session.dispose();
|
|
@@ -279,7 +238,7 @@ class WKPage {
|
|
|
279
238
|
this._provisionalPage = null;
|
|
280
239
|
} else if (this._session.sessionId === targetId) {
|
|
281
240
|
this._session.dispose();
|
|
282
|
-
|
|
241
|
+
import_eventsHelper.eventsHelper.removeEventListeners(this._sessionListeners);
|
|
283
242
|
if (crashed) {
|
|
284
243
|
this._session.markAsCrashed();
|
|
285
244
|
this._page._didCrash();
|
|
@@ -288,163 +247,174 @@ class WKPage {
|
|
|
288
247
|
}
|
|
289
248
|
didClose() {
|
|
290
249
|
this._pageProxySession.dispose();
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
if (this._session)
|
|
250
|
+
import_eventsHelper.eventsHelper.removeEventListeners(this._sessionListeners);
|
|
251
|
+
import_eventsHelper.eventsHelper.removeEventListeners(this._eventListeners);
|
|
252
|
+
if (this._session)
|
|
253
|
+
this._session.dispose();
|
|
294
254
|
if (this._provisionalPage) {
|
|
295
255
|
this._provisionalPage._session.dispose();
|
|
296
256
|
this._provisionalPage.dispose();
|
|
297
257
|
this._provisionalPage = null;
|
|
298
258
|
}
|
|
299
|
-
this._firstNonInitialNavigationCommittedReject(new
|
|
259
|
+
this._firstNonInitialNavigationCommittedReject(new import_errors.TargetClosedError());
|
|
300
260
|
this._page._didClose();
|
|
301
261
|
}
|
|
302
262
|
dispatchMessageToSession(message) {
|
|
303
263
|
this._pageProxySession.dispatchMessage(message);
|
|
304
264
|
}
|
|
305
265
|
handleProvisionalLoadFailed(event) {
|
|
306
|
-
if (!this.
|
|
307
|
-
this._firstNonInitialNavigationCommittedReject(new Error(
|
|
266
|
+
if (!this._page.initializedOrUndefined()) {
|
|
267
|
+
this._firstNonInitialNavigationCommittedReject(new Error("Initial load failed"));
|
|
308
268
|
return;
|
|
309
269
|
}
|
|
310
|
-
if (!this._provisionalPage)
|
|
270
|
+
if (!this._provisionalPage)
|
|
271
|
+
return;
|
|
311
272
|
let errorText = event.error;
|
|
312
|
-
if (errorText.includes(
|
|
273
|
+
if (errorText.includes("cancelled"))
|
|
274
|
+
errorText += "; maybe frame was detached?";
|
|
313
275
|
this._page._frameManager.frameAbortedNavigation(this._page.mainFrame()._id, errorText, event.loaderId);
|
|
314
276
|
}
|
|
315
277
|
handleWindowOpen(event) {
|
|
316
|
-
(0, _utils.debugAssert)(!this._nextWindowOpenPopupFeatures);
|
|
317
278
|
this._nextWindowOpenPopupFeatures = event.windowFeatures;
|
|
318
279
|
}
|
|
319
|
-
async pageOrError() {
|
|
320
|
-
return this._pagePromise;
|
|
321
|
-
}
|
|
322
280
|
async _onTargetCreated(event) {
|
|
323
|
-
const {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
const session = new _wkConnection.WKSession(this._pageProxySession.connection, targetInfo.targetId, message => {
|
|
327
|
-
this._pageProxySession.send('Target.sendMessageToTarget', {
|
|
281
|
+
const { targetInfo } = event;
|
|
282
|
+
const session = new import_wkConnection.WKSession(this._pageProxySession.connection, targetInfo.targetId, (message) => {
|
|
283
|
+
this._pageProxySession.send("Target.sendMessageToTarget", {
|
|
328
284
|
message: JSON.stringify(message),
|
|
329
285
|
targetId: targetInfo.targetId
|
|
330
|
-
}).catch(e => {
|
|
331
|
-
session.dispatchMessage({
|
|
332
|
-
id: message.id,
|
|
333
|
-
error: {
|
|
334
|
-
message: e.message
|
|
335
|
-
}
|
|
336
|
-
});
|
|
286
|
+
}).catch((e) => {
|
|
287
|
+
session.dispatchMessage({ id: message.id, error: { message: e.message } });
|
|
337
288
|
});
|
|
338
289
|
});
|
|
339
|
-
(0,
|
|
290
|
+
(0, import_utils.assert)(targetInfo.type === "page", "Only page targets are expected in WebKit, received: " + targetInfo.type);
|
|
340
291
|
if (!targetInfo.isProvisional) {
|
|
341
|
-
(0,
|
|
292
|
+
(0, import_utils.assert)(!this._page.initializedOrUndefined());
|
|
342
293
|
let pageOrError;
|
|
343
294
|
try {
|
|
344
295
|
this._setSession(session);
|
|
345
|
-
await Promise.all([
|
|
346
|
-
|
|
347
|
-
|
|
296
|
+
await Promise.all([
|
|
297
|
+
this._initializePageProxySession(),
|
|
298
|
+
this._initializeSession(session, false, ({ frameTree }) => this._handleFrameTree(frameTree))
|
|
299
|
+
]);
|
|
348
300
|
pageOrError = this._page;
|
|
349
301
|
} catch (e) {
|
|
350
302
|
pageOrError = e;
|
|
351
303
|
}
|
|
352
|
-
if (targetInfo.isPaused)
|
|
353
|
-
targetId: targetInfo.targetId
|
|
354
|
-
|
|
355
|
-
if (pageOrError instanceof _page.Page && this._page.mainFrame().url() === '') {
|
|
304
|
+
if (targetInfo.isPaused)
|
|
305
|
+
this._pageProxySession.sendMayFail("Target.resume", { targetId: targetInfo.targetId });
|
|
306
|
+
if (pageOrError instanceof import_page2.Page && this._page.mainFrame().url() === "") {
|
|
356
307
|
try {
|
|
357
|
-
// Initial empty page has an empty url. We should wait until the first real url has been loaded,
|
|
358
|
-
// even if that url is about:blank. This is especially important for popups, where we need the
|
|
359
|
-
// actual url before interacting with it.
|
|
360
308
|
await this._firstNonInitialNavigationCommittedPromise;
|
|
361
309
|
} catch (e) {
|
|
362
310
|
pageOrError = e;
|
|
363
311
|
}
|
|
364
312
|
} else {
|
|
365
|
-
|
|
366
|
-
|
|
313
|
+
this._firstNonInitialNavigationCommittedPromise.catch(() => {
|
|
314
|
+
});
|
|
367
315
|
}
|
|
368
|
-
|
|
369
|
-
// Note: it is important to call |reportAsNew| before resolving pageOrError promise,
|
|
370
|
-
// so that anyone who awaits pageOrError got a ready and reported page.
|
|
371
|
-
this._initializedPage = pageOrError instanceof _page.Page ? pageOrError : null;
|
|
372
|
-
this._page.reportAsNew(pageOrError instanceof _page.Page ? undefined : pageOrError);
|
|
373
|
-
this._pagePromise.resolve(pageOrError);
|
|
316
|
+
this._page.reportAsNew(this._opener?._page, pageOrError instanceof import_page2.Page ? void 0 : pageOrError);
|
|
374
317
|
} else {
|
|
375
|
-
(0,
|
|
376
|
-
(0,
|
|
377
|
-
this._provisionalPage = new
|
|
318
|
+
(0, import_utils.assert)(targetInfo.isProvisional);
|
|
319
|
+
(0, import_utils.assert)(!this._provisionalPage);
|
|
320
|
+
this._provisionalPage = new import_wkProvisionalPage.WKProvisionalPage(session, this);
|
|
378
321
|
if (targetInfo.isPaused) {
|
|
379
322
|
this._provisionalPage.initializationPromise.then(() => {
|
|
380
|
-
this._pageProxySession.sendMayFail(
|
|
381
|
-
targetId: targetInfo.targetId
|
|
382
|
-
});
|
|
323
|
+
this._pageProxySession.sendMayFail("Target.resume", { targetId: targetInfo.targetId });
|
|
383
324
|
});
|
|
384
325
|
}
|
|
385
326
|
}
|
|
386
327
|
}
|
|
387
328
|
_onDispatchMessageFromTarget(event) {
|
|
388
|
-
const {
|
|
389
|
-
|
|
390
|
-
message
|
|
391
|
-
|
|
392
|
-
|
|
329
|
+
const { targetId, message } = event;
|
|
330
|
+
if (this._provisionalPage && this._provisionalPage._session.sessionId === targetId)
|
|
331
|
+
this._provisionalPage._session.dispatchMessage(JSON.parse(message));
|
|
332
|
+
else if (this._session.sessionId === targetId)
|
|
333
|
+
this._session.dispatchMessage(JSON.parse(message));
|
|
334
|
+
else
|
|
335
|
+
throw new Error("Unknown target: " + targetId);
|
|
393
336
|
}
|
|
394
337
|
_addSessionListeners() {
|
|
395
|
-
this._sessionListeners = [
|
|
338
|
+
this._sessionListeners = [
|
|
339
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.frameNavigated", (event) => this._onFrameNavigated(event.frame, false)),
|
|
340
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.navigatedWithinDocument", (event) => this._onFrameNavigatedWithinDocument(event.frameId, event.url)),
|
|
341
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.frameAttached", (event) => this._onFrameAttached(event.frameId, event.parentFrameId)),
|
|
342
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.frameDetached", (event) => this._onFrameDetached(event.frameId)),
|
|
343
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.willCheckNavigationPolicy", (event) => this._onWillCheckNavigationPolicy(event.frameId)),
|
|
344
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.didCheckNavigationPolicy", (event) => this._onDidCheckNavigationPolicy(event.frameId, event.cancel)),
|
|
345
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.frameScheduledNavigation", (event) => this._onFrameScheduledNavigation(event.frameId, event.delay, event.targetIsCurrentFrame)),
|
|
346
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.loadEventFired", (event) => this._page._frameManager.frameLifecycleEvent(event.frameId, "load")),
|
|
347
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.domContentEventFired", (event) => this._page._frameManager.frameLifecycleEvent(event.frameId, "domcontentloaded")),
|
|
348
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Runtime.executionContextCreated", (event) => this._onExecutionContextCreated(event.context)),
|
|
349
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Runtime.bindingCalled", (event) => this._onBindingCalled(event.contextId, event.argument)),
|
|
350
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Console.messageAdded", (event) => this._onConsoleMessage(event)),
|
|
351
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Console.messageRepeatCountUpdated", (event) => this._onConsoleRepeatCountUpdated(event)),
|
|
352
|
+
import_eventsHelper.eventsHelper.addEventListener(this._pageProxySession, "Dialog.javascriptDialogOpening", (event) => this._onDialog(event)),
|
|
353
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.fileChooserOpened", (event) => this._onFileChooserOpened(event)),
|
|
354
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.requestWillBeSent", (e) => this._onRequestWillBeSent(this._session, e)),
|
|
355
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.requestIntercepted", (e) => this._onRequestIntercepted(this._session, e)),
|
|
356
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.responseReceived", (e) => this._onResponseReceived(this._session, e)),
|
|
357
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.loadingFinished", (e) => this._onLoadingFinished(e)),
|
|
358
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.loadingFailed", (e) => this._onLoadingFailed(this._session, e)),
|
|
359
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.webSocketCreated", (e) => this._page._frameManager.onWebSocketCreated(e.requestId, e.url)),
|
|
360
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.webSocketWillSendHandshakeRequest", (e) => this._page._frameManager.onWebSocketRequest(e.requestId)),
|
|
361
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.webSocketHandshakeResponseReceived", (e) => this._page._frameManager.onWebSocketResponse(e.requestId, e.response.status, e.response.statusText)),
|
|
362
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.webSocketFrameSent", (e) => e.response.payloadData && this._page._frameManager.onWebSocketFrameSent(e.requestId, e.response.opcode, e.response.payloadData)),
|
|
363
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.webSocketFrameReceived", (e) => e.response.payloadData && this._page._frameManager.webSocketFrameReceived(e.requestId, e.response.opcode, e.response.payloadData)),
|
|
364
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.webSocketClosed", (e) => this._page._frameManager.webSocketClosed(e.requestId)),
|
|
365
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Network.webSocketFrameError", (e) => this._page._frameManager.webSocketError(e.requestId, e.errorMessage))
|
|
366
|
+
];
|
|
396
367
|
}
|
|
397
368
|
async _updateState(method, params) {
|
|
398
|
-
await this._forAllSessions(session => session.send(method, params).then());
|
|
369
|
+
await this._forAllSessions((session) => session.send(method, params).then());
|
|
399
370
|
}
|
|
400
371
|
async _forAllSessions(callback) {
|
|
401
|
-
const sessions = [
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
if (this._provisionalPage)
|
|
405
|
-
|
|
372
|
+
const sessions = [
|
|
373
|
+
this._session
|
|
374
|
+
];
|
|
375
|
+
if (this._provisionalPage)
|
|
376
|
+
sessions.push(this._provisionalPage._session);
|
|
377
|
+
await Promise.all(sessions.map((session) => callback(session).catch((e) => {
|
|
378
|
+
})));
|
|
406
379
|
}
|
|
407
380
|
_onWillCheckNavigationPolicy(frameId) {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
// either:
|
|
411
|
-
// - end up canceled, e.g. ctrl+click opening link in new tab, having no effect
|
|
412
|
-
// on this page
|
|
413
|
-
// - start new provisional load which we will miss in our signal trackers but
|
|
414
|
-
// we certainly won't hang waiting for it to finish and there is high chance
|
|
415
|
-
// that the current provisional page will commit navigation canceling the new
|
|
416
|
-
// one.
|
|
417
|
-
if (this._provisionalPage) return;
|
|
381
|
+
if (this._provisionalPage)
|
|
382
|
+
return;
|
|
418
383
|
this._page._frameManager.frameRequestedNavigation(frameId);
|
|
419
384
|
}
|
|
420
385
|
_onDidCheckNavigationPolicy(frameId, cancel) {
|
|
421
|
-
if (!cancel)
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
this._page._frameManager.frameAbortedNavigation(frameId,
|
|
386
|
+
if (!cancel)
|
|
387
|
+
return;
|
|
388
|
+
if (this._provisionalPage)
|
|
389
|
+
return;
|
|
390
|
+
this._page._frameManager.frameAbortedNavigation(frameId, "Navigation canceled by policy check");
|
|
426
391
|
}
|
|
427
392
|
_onFrameScheduledNavigation(frameId, delay, targetIsCurrentFrame) {
|
|
428
|
-
if (targetIsCurrentFrame)
|
|
393
|
+
if (targetIsCurrentFrame)
|
|
394
|
+
this._page._frameManager.frameRequestedNavigation(frameId);
|
|
429
395
|
}
|
|
430
396
|
_handleFrameTree(frameTree) {
|
|
431
397
|
this._onFrameAttached(frameTree.frame.id, frameTree.frame.parentId || null);
|
|
432
398
|
this._onFrameNavigated(frameTree.frame, true);
|
|
433
|
-
this._page._frameManager.frameLifecycleEvent(frameTree.frame.id,
|
|
434
|
-
this._page._frameManager.frameLifecycleEvent(frameTree.frame.id,
|
|
435
|
-
if (!frameTree.childFrames)
|
|
436
|
-
|
|
399
|
+
this._page._frameManager.frameLifecycleEvent(frameTree.frame.id, "domcontentloaded");
|
|
400
|
+
this._page._frameManager.frameLifecycleEvent(frameTree.frame.id, "load");
|
|
401
|
+
if (!frameTree.childFrames)
|
|
402
|
+
return;
|
|
403
|
+
for (const child of frameTree.childFrames)
|
|
404
|
+
this._handleFrameTree(child);
|
|
437
405
|
}
|
|
438
406
|
_onFrameAttached(frameId, parentFrameId) {
|
|
439
407
|
return this._page._frameManager.frameAttached(frameId, parentFrameId);
|
|
440
408
|
}
|
|
441
409
|
_onFrameNavigated(framePayload, initial) {
|
|
442
410
|
const frame = this._page._frameManager.frame(framePayload.id);
|
|
443
|
-
(0,
|
|
411
|
+
(0, import_utils.assert)(frame);
|
|
444
412
|
this._removeContextsForFrame(frame, true);
|
|
445
|
-
if (!framePayload.parentId)
|
|
446
|
-
|
|
447
|
-
|
|
413
|
+
if (!framePayload.parentId)
|
|
414
|
+
this._workers.clear();
|
|
415
|
+
this._page._frameManager.frameCommittedNewDocumentNavigation(framePayload.id, framePayload.url, framePayload.name || "", framePayload.loaderId, initial);
|
|
416
|
+
if (!initial)
|
|
417
|
+
this._firstNonInitialNavigationCommittedFulfill();
|
|
448
418
|
}
|
|
449
419
|
_onFrameNavigatedWithinDocument(frameId, url) {
|
|
450
420
|
this._page._frameManager.frameCommittedSameDocumentNavigation(frameId, url);
|
|
@@ -456,77 +426,67 @@ class WKPage {
|
|
|
456
426
|
for (const [contextId, context] of this._contextIdToContext) {
|
|
457
427
|
if (context.frame === frame) {
|
|
458
428
|
this._contextIdToContext.delete(contextId);
|
|
459
|
-
if (notifyFrame)
|
|
429
|
+
if (notifyFrame)
|
|
430
|
+
frame._contextDestroyed(context);
|
|
460
431
|
}
|
|
461
432
|
}
|
|
462
433
|
}
|
|
463
434
|
_onExecutionContextCreated(contextPayload) {
|
|
464
|
-
if (this._contextIdToContext.has(contextPayload.id))
|
|
435
|
+
if (this._contextIdToContext.has(contextPayload.id))
|
|
436
|
+
return;
|
|
465
437
|
const frame = this._page._frameManager.frame(contextPayload.frameId);
|
|
466
|
-
if (!frame)
|
|
467
|
-
|
|
438
|
+
if (!frame)
|
|
439
|
+
return;
|
|
440
|
+
const delegate = new import_wkExecutionContext.WKExecutionContext(this._session, contextPayload.id);
|
|
468
441
|
let worldName = null;
|
|
469
|
-
if (contextPayload.type ===
|
|
442
|
+
if (contextPayload.type === "normal")
|
|
443
|
+
worldName = "main";
|
|
444
|
+
else if (contextPayload.type === "user" && contextPayload.name === UTILITY_WORLD_NAME)
|
|
445
|
+
worldName = "utility";
|
|
470
446
|
const context = new dom.FrameExecutionContext(delegate, frame, worldName);
|
|
471
|
-
|
|
472
|
-
|
|
447
|
+
if (worldName)
|
|
448
|
+
frame._contextCreated(worldName, context);
|
|
473
449
|
this._contextIdToContext.set(contextPayload.id, context);
|
|
474
450
|
}
|
|
475
451
|
async _onBindingCalled(contextId, argument) {
|
|
476
|
-
const pageOrError = await this.
|
|
452
|
+
const pageOrError = await this._page.waitForInitializedOrError();
|
|
477
453
|
if (!(pageOrError instanceof Error)) {
|
|
478
454
|
const context = this._contextIdToContext.get(contextId);
|
|
479
|
-
if (context)
|
|
455
|
+
if (context)
|
|
456
|
+
await this._page._onBindingCalled(argument, context);
|
|
480
457
|
}
|
|
481
458
|
}
|
|
482
459
|
async navigateFrame(frame, url, referrer) {
|
|
483
|
-
if (this._pageProxySession.isDisposed())
|
|
460
|
+
if (this._pageProxySession.isDisposed())
|
|
461
|
+
throw new import_errors.TargetClosedError();
|
|
484
462
|
const pageProxyId = this._pageProxySession.sessionId;
|
|
485
|
-
const result = await this._pageProxySession.connection.browserSession.send(
|
|
486
|
-
|
|
487
|
-
pageProxyId,
|
|
488
|
-
frameId: frame._id,
|
|
489
|
-
referrer
|
|
490
|
-
});
|
|
491
|
-
return {
|
|
492
|
-
newDocumentId: result.loaderId
|
|
493
|
-
};
|
|
463
|
+
const result = await this._pageProxySession.connection.browserSession.send("Playwright.navigate", { url, pageProxyId, frameId: frame._id, referrer });
|
|
464
|
+
return { newDocumentId: result.loaderId };
|
|
494
465
|
}
|
|
495
466
|
_onConsoleMessage(event) {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
type,
|
|
500
|
-
level,
|
|
501
|
-
text,
|
|
502
|
-
parameters,
|
|
503
|
-
url,
|
|
504
|
-
line: lineNumber,
|
|
505
|
-
column: columnNumber,
|
|
506
|
-
source
|
|
507
|
-
} = event.message;
|
|
508
|
-
if (level === 'error' && source === 'javascript') {
|
|
509
|
-
const {
|
|
510
|
-
name,
|
|
511
|
-
message
|
|
512
|
-
} = (0, _stackTrace.splitErrorMessage)(text);
|
|
467
|
+
const { type, level, text, parameters, url, line: lineNumber, column: columnNumber, source } = event.message;
|
|
468
|
+
if (level === "error" && source === "javascript") {
|
|
469
|
+
const { name, message } = (0, import_stackTrace.splitErrorMessage)(text);
|
|
513
470
|
let stack;
|
|
514
471
|
if (event.message.stackTrace) {
|
|
515
|
-
stack = text +
|
|
516
|
-
return ` at ${callFrame.functionName ||
|
|
517
|
-
}).join(
|
|
472
|
+
stack = text + "\n" + event.message.stackTrace.callFrames.map((callFrame) => {
|
|
473
|
+
return ` at ${callFrame.functionName || "unknown"} (${callFrame.url}:${callFrame.lineNumber}:${callFrame.columnNumber})`;
|
|
474
|
+
}).join("\n");
|
|
518
475
|
} else {
|
|
519
|
-
stack =
|
|
476
|
+
stack = "";
|
|
520
477
|
}
|
|
521
478
|
this._lastConsoleMessage = null;
|
|
522
479
|
const error = new Error(message);
|
|
523
480
|
error.stack = stack;
|
|
524
481
|
error.name = name;
|
|
525
|
-
this._page.emitOnContextOnceInitialized(
|
|
482
|
+
this._page.emitOnContextOnceInitialized(import_browserContext.BrowserContext.Events.PageError, error, this._page);
|
|
526
483
|
return;
|
|
527
484
|
}
|
|
528
|
-
let derivedType = type ||
|
|
529
|
-
if (type ===
|
|
485
|
+
let derivedType = type || "";
|
|
486
|
+
if (type === "log")
|
|
487
|
+
derivedType = level;
|
|
488
|
+
else if (type === "timing")
|
|
489
|
+
derivedType = "timeEnd";
|
|
530
490
|
const handles = [];
|
|
531
491
|
for (const p of parameters || []) {
|
|
532
492
|
let context;
|
|
@@ -534,11 +494,11 @@ class WKPage {
|
|
|
534
494
|
const objectId = JSON.parse(p.objectId);
|
|
535
495
|
context = this._contextIdToContext.get(objectId.injectedScriptId);
|
|
536
496
|
} else {
|
|
537
|
-
|
|
538
|
-
context = [...this._contextIdToContext.values()].find(c => c.frame === this._page.mainFrame());
|
|
497
|
+
context = [...this._contextIdToContext.values()].find((c) => c.frame === this._page.mainFrame());
|
|
539
498
|
}
|
|
540
|
-
if (!context)
|
|
541
|
-
|
|
499
|
+
if (!context)
|
|
500
|
+
return;
|
|
501
|
+
handles.push((0, import_wkExecutionContext.createHandle)(context, p));
|
|
542
502
|
}
|
|
543
503
|
this._lastConsoleMessage = {
|
|
544
504
|
derivedType,
|
|
@@ -546,14 +506,12 @@ class WKPage {
|
|
|
546
506
|
handles,
|
|
547
507
|
count: 0,
|
|
548
508
|
location: {
|
|
549
|
-
url: url ||
|
|
509
|
+
url: url || "",
|
|
550
510
|
lineNumber: (lineNumber || 1) - 1,
|
|
551
511
|
columnNumber: (columnNumber || 1) - 1
|
|
552
512
|
}
|
|
553
513
|
};
|
|
554
|
-
this._onConsoleRepeatCountUpdated({
|
|
555
|
-
count: 1
|
|
556
|
-
});
|
|
514
|
+
this._onConsoleRepeatCountUpdated({ count: 1 });
|
|
557
515
|
}
|
|
558
516
|
_onConsoleRepeatCountUpdated(event) {
|
|
559
517
|
if (this._lastConsoleMessage) {
|
|
@@ -564,91 +522,105 @@ class WKPage {
|
|
|
564
522
|
count,
|
|
565
523
|
location
|
|
566
524
|
} = this._lastConsoleMessage;
|
|
567
|
-
for (let i = count; i < event.count; ++i)
|
|
525
|
+
for (let i = count; i < event.count; ++i)
|
|
526
|
+
this._page._addConsoleMessage(derivedType, handles, location, handles.length ? void 0 : text);
|
|
568
527
|
this._lastConsoleMessage.count = event.count;
|
|
569
528
|
}
|
|
570
529
|
}
|
|
571
530
|
_onDialog(event) {
|
|
572
|
-
this._page.emitOnContext(
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
531
|
+
this._page.emitOnContext(import_browserContext.BrowserContext.Events.Dialog, new dialog.Dialog(
|
|
532
|
+
this._page,
|
|
533
|
+
event.type,
|
|
534
|
+
event.message,
|
|
535
|
+
async (accept, promptText) => {
|
|
536
|
+
if (event.type === "beforeunload" && !accept)
|
|
537
|
+
this._page._frameManager.frameAbortedNavigation(this._page.mainFrame()._id, "navigation cancelled by beforeunload dialog");
|
|
538
|
+
await this._pageProxySession.send("Dialog.handleJavaScriptDialog", { accept, promptText });
|
|
539
|
+
},
|
|
540
|
+
event.defaultPrompt
|
|
541
|
+
));
|
|
578
542
|
}
|
|
579
543
|
async _onFileChooserOpened(event) {
|
|
580
544
|
let handle;
|
|
581
545
|
try {
|
|
582
546
|
const context = await this._page._frameManager.frame(event.frameId)._mainContext();
|
|
583
|
-
handle =
|
|
547
|
+
handle = (0, import_wkExecutionContext.createHandle)(context, event.element).asElement();
|
|
584
548
|
} catch (e) {
|
|
585
|
-
// During async processing, frame/context may go away. We should not throw.
|
|
586
549
|
return;
|
|
587
550
|
}
|
|
588
551
|
await this._page._onFileChooserOpened(handle);
|
|
589
552
|
}
|
|
590
|
-
static async _setEmulateMedia(session, mediaType, colorScheme, reducedMotion, forcedColors) {
|
|
553
|
+
static async _setEmulateMedia(session, mediaType, colorScheme, reducedMotion, forcedColors, contrast) {
|
|
591
554
|
const promises = [];
|
|
592
|
-
promises.push(session.send(
|
|
593
|
-
|
|
594
|
-
}));
|
|
595
|
-
let appearance = undefined;
|
|
555
|
+
promises.push(session.send("Page.setEmulatedMedia", { media: mediaType === "no-override" ? "" : mediaType }));
|
|
556
|
+
let appearance = void 0;
|
|
596
557
|
switch (colorScheme) {
|
|
597
|
-
case
|
|
598
|
-
appearance =
|
|
558
|
+
case "light":
|
|
559
|
+
appearance = "Light";
|
|
599
560
|
break;
|
|
600
|
-
case
|
|
601
|
-
appearance =
|
|
561
|
+
case "dark":
|
|
562
|
+
appearance = "Dark";
|
|
602
563
|
break;
|
|
603
|
-
case
|
|
604
|
-
appearance =
|
|
564
|
+
case "no-override":
|
|
565
|
+
appearance = void 0;
|
|
605
566
|
break;
|
|
606
567
|
}
|
|
607
|
-
promises.push(session.send(
|
|
608
|
-
|
|
609
|
-
value: appearance
|
|
610
|
-
}));
|
|
611
|
-
let reducedMotionWk = undefined;
|
|
568
|
+
promises.push(session.send("Page.overrideUserPreference", { name: "PrefersColorScheme", value: appearance }));
|
|
569
|
+
let reducedMotionWk = void 0;
|
|
612
570
|
switch (reducedMotion) {
|
|
613
|
-
case
|
|
614
|
-
reducedMotionWk =
|
|
571
|
+
case "reduce":
|
|
572
|
+
reducedMotionWk = "Reduce";
|
|
615
573
|
break;
|
|
616
|
-
case
|
|
617
|
-
reducedMotionWk =
|
|
574
|
+
case "no-preference":
|
|
575
|
+
reducedMotionWk = "NoPreference";
|
|
618
576
|
break;
|
|
619
|
-
case
|
|
620
|
-
reducedMotionWk =
|
|
577
|
+
case "no-override":
|
|
578
|
+
reducedMotionWk = void 0;
|
|
621
579
|
break;
|
|
622
580
|
}
|
|
623
|
-
promises.push(session.send(
|
|
624
|
-
|
|
625
|
-
value: reducedMotionWk
|
|
626
|
-
}));
|
|
627
|
-
let forcedColorsWk = undefined;
|
|
581
|
+
promises.push(session.send("Page.overrideUserPreference", { name: "PrefersReducedMotion", value: reducedMotionWk }));
|
|
582
|
+
let forcedColorsWk = void 0;
|
|
628
583
|
switch (forcedColors) {
|
|
629
|
-
case
|
|
630
|
-
forcedColorsWk =
|
|
584
|
+
case "active":
|
|
585
|
+
forcedColorsWk = "Active";
|
|
631
586
|
break;
|
|
632
|
-
case
|
|
633
|
-
forcedColorsWk =
|
|
587
|
+
case "none":
|
|
588
|
+
forcedColorsWk = "None";
|
|
634
589
|
break;
|
|
635
|
-
case
|
|
636
|
-
forcedColorsWk =
|
|
590
|
+
case "no-override":
|
|
591
|
+
forcedColorsWk = void 0;
|
|
637
592
|
break;
|
|
638
593
|
}
|
|
639
|
-
promises.push(session.send(
|
|
640
|
-
|
|
641
|
-
|
|
594
|
+
promises.push(session.send("Page.setForcedColors", { forcedColors: forcedColorsWk }));
|
|
595
|
+
let contrastWk = void 0;
|
|
596
|
+
switch (contrast) {
|
|
597
|
+
case "more":
|
|
598
|
+
contrastWk = "More";
|
|
599
|
+
break;
|
|
600
|
+
case "no-preference":
|
|
601
|
+
contrastWk = "NoPreference";
|
|
602
|
+
break;
|
|
603
|
+
case "no-override":
|
|
604
|
+
contrastWk = void 0;
|
|
605
|
+
break;
|
|
606
|
+
}
|
|
607
|
+
promises.push(session.send("Page.overrideUserPreference", { name: "PrefersContrast", value: contrastWk }));
|
|
642
608
|
await Promise.all(promises);
|
|
643
609
|
}
|
|
644
610
|
async updateExtraHTTPHeaders() {
|
|
645
|
-
await this._updateState(
|
|
646
|
-
|
|
647
|
-
|
|
611
|
+
await this._updateState("Network.setExtraHTTPHeaders", { headers: (0, import_headers.headersArrayToObject)(
|
|
612
|
+
this._calculateExtraHTTPHeaders(),
|
|
613
|
+
false
|
|
614
|
+
/* lowerCase */
|
|
615
|
+
) });
|
|
648
616
|
}
|
|
649
617
|
_calculateExtraHTTPHeaders() {
|
|
650
618
|
const locale = this._browserContext._options.locale;
|
|
651
|
-
const headers = network.mergeHeaders([
|
|
619
|
+
const headers = network.mergeHeaders([
|
|
620
|
+
this._browserContext._options.extraHTTPHeaders,
|
|
621
|
+
this._page.extraHTTPHeaders(),
|
|
622
|
+
locale ? network.singleHeader("Accept-Language", locale) : void 0
|
|
623
|
+
]);
|
|
652
624
|
return headers;
|
|
653
625
|
}
|
|
654
626
|
async updateEmulateMedia() {
|
|
@@ -656,7 +628,8 @@ class WKPage {
|
|
|
656
628
|
const colorScheme = emulatedMedia.colorScheme;
|
|
657
629
|
const reducedMotion = emulatedMedia.reducedMotion;
|
|
658
630
|
const forcedColors = emulatedMedia.forcedColors;
|
|
659
|
-
|
|
631
|
+
const contrast = emulatedMedia.contrast;
|
|
632
|
+
await this._forAllSessions((session) => WKPage._setEmulateMedia(session, emulatedMedia.media, colorScheme, reducedMotion, forcedColors, contrast));
|
|
660
633
|
}
|
|
661
634
|
async updateEmulatedViewportSize() {
|
|
662
635
|
this._browserContext._validateEmulatedViewport(this._page.viewportSize());
|
|
@@ -664,94 +637,77 @@ class WKPage {
|
|
|
664
637
|
}
|
|
665
638
|
async updateUserAgent() {
|
|
666
639
|
const contextOptions = this._browserContext._options;
|
|
667
|
-
this._updateState(
|
|
668
|
-
value: contextOptions.userAgent
|
|
669
|
-
});
|
|
640
|
+
this._updateState("Page.overrideUserAgent", { value: contextOptions.userAgent });
|
|
670
641
|
}
|
|
671
642
|
async bringToFront() {
|
|
672
|
-
this._pageProxySession.send(
|
|
643
|
+
this._pageProxySession.send("Target.activate", {
|
|
673
644
|
targetId: this._session.sessionId
|
|
674
645
|
});
|
|
675
646
|
}
|
|
676
647
|
async _updateViewport() {
|
|
677
648
|
const options = this._browserContext._options;
|
|
678
649
|
const deviceSize = this._page.emulatedSize();
|
|
679
|
-
if (deviceSize === null)
|
|
650
|
+
if (deviceSize === null)
|
|
651
|
+
return;
|
|
680
652
|
const viewportSize = deviceSize.viewport;
|
|
681
653
|
const screenSize = deviceSize.screen;
|
|
682
|
-
const promises = [
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
654
|
+
const promises = [
|
|
655
|
+
this._pageProxySession.send("Emulation.setDeviceMetricsOverride", {
|
|
656
|
+
width: viewportSize.width,
|
|
657
|
+
height: viewportSize.height,
|
|
658
|
+
fixedLayout: !!options.isMobile,
|
|
659
|
+
deviceScaleFactor: options.deviceScaleFactor || 1
|
|
660
|
+
}),
|
|
661
|
+
this._session.send("Page.setScreenSizeOverride", {
|
|
662
|
+
width: screenSize.width,
|
|
663
|
+
height: screenSize.height
|
|
664
|
+
})
|
|
665
|
+
];
|
|
691
666
|
if (options.isMobile) {
|
|
692
667
|
const angle = viewportSize.width > viewportSize.height ? 90 : 0;
|
|
693
|
-
|
|
694
|
-
const useLegacySetOrientationOverrideMethod = _os.default.platform() === 'darwin' && parseInt(_os.default.release().split('.')[0], 10) <= 21;
|
|
695
|
-
if (useLegacySetOrientationOverrideMethod) promises.push(this._session.send('Page.setOrientationOverride', {
|
|
696
|
-
angle
|
|
697
|
-
}));else promises.push(this._pageProxySession.send('Emulation.setOrientationOverride', {
|
|
698
|
-
angle
|
|
699
|
-
}));
|
|
668
|
+
promises.push(this._pageProxySession.send("Emulation.setOrientationOverride", { angle }));
|
|
700
669
|
}
|
|
701
670
|
await Promise.all(promises);
|
|
702
671
|
}
|
|
703
672
|
async updateRequestInterception() {
|
|
704
673
|
const enabled = this._page.needsRequestInterception();
|
|
705
|
-
await Promise.all([
|
|
706
|
-
enabled
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
url: '.*',
|
|
711
|
-
stage: 'request',
|
|
712
|
-
isRegex: true
|
|
713
|
-
})]);
|
|
674
|
+
await Promise.all([
|
|
675
|
+
this._updateState("Network.setInterceptionEnabled", { enabled }),
|
|
676
|
+
this._updateState("Network.setResourceCachingDisabled", { disabled: enabled }),
|
|
677
|
+
this._updateState("Network.addInterception", { url: ".*", stage: "request", isRegex: true })
|
|
678
|
+
]);
|
|
714
679
|
}
|
|
715
680
|
async updateOffline() {
|
|
716
|
-
await this._updateState(
|
|
717
|
-
offline: !!this._browserContext._options.offline
|
|
718
|
-
});
|
|
681
|
+
await this._updateState("Network.setEmulateOfflineState", { offline: !!this._browserContext._options.offline });
|
|
719
682
|
}
|
|
720
683
|
async updateHttpCredentials() {
|
|
721
|
-
const credentials = this._browserContext._options.httpCredentials || {
|
|
722
|
-
|
|
723
|
-
password: '',
|
|
724
|
-
origin: ''
|
|
725
|
-
};
|
|
726
|
-
await this._pageProxySession.send('Emulation.setAuthCredentials', {
|
|
727
|
-
username: credentials.username,
|
|
728
|
-
password: credentials.password,
|
|
729
|
-
origin: credentials.origin
|
|
730
|
-
});
|
|
684
|
+
const credentials = this._browserContext._options.httpCredentials || { username: "", password: "", origin: "" };
|
|
685
|
+
await this._pageProxySession.send("Emulation.setAuthCredentials", { username: credentials.username, password: credentials.password, origin: credentials.origin });
|
|
731
686
|
}
|
|
732
687
|
async updateFileChooserInterception() {
|
|
733
688
|
const enabled = this._page.fileChooserIntercepted();
|
|
734
|
-
await this._session.send(
|
|
735
|
-
|
|
736
|
-
}).catch(() => {}); // target can be closed.
|
|
689
|
+
await this._session.send("Page.setInterceptFileChooserDialog", { enabled }).catch(() => {
|
|
690
|
+
});
|
|
737
691
|
}
|
|
738
692
|
async reload() {
|
|
739
|
-
await this._session.send(
|
|
693
|
+
await this._session.send("Page.reload");
|
|
740
694
|
}
|
|
741
695
|
goBack() {
|
|
742
|
-
return this._session.send(
|
|
743
|
-
if (error instanceof Error && error.message.includes(`Protocol error (Page.goBack): Failed to go`))
|
|
696
|
+
return this._session.send("Page.goBack").then(() => true).catch((error) => {
|
|
697
|
+
if (error instanceof Error && error.message.includes(`Protocol error (Page.goBack): Failed to go`))
|
|
698
|
+
return false;
|
|
744
699
|
throw error;
|
|
745
700
|
});
|
|
746
701
|
}
|
|
747
702
|
goForward() {
|
|
748
|
-
return this._session.send(
|
|
749
|
-
if (error instanceof Error && error.message.includes(`Protocol error (Page.goForward): Failed to go`))
|
|
703
|
+
return this._session.send("Page.goForward").then(() => true).catch((error) => {
|
|
704
|
+
if (error instanceof Error && error.message.includes(`Protocol error (Page.goForward): Failed to go`))
|
|
705
|
+
return false;
|
|
750
706
|
throw error;
|
|
751
707
|
});
|
|
752
708
|
}
|
|
753
709
|
async requestGC() {
|
|
754
|
-
await this._session.send(
|
|
710
|
+
await this._session.send("Heap.gc");
|
|
755
711
|
}
|
|
756
712
|
async addInitScript(initScript) {
|
|
757
713
|
await this._updateBootstrapScript();
|
|
@@ -762,97 +718,90 @@ class WKPage {
|
|
|
762
718
|
_calculateBootstrapScript() {
|
|
763
719
|
const scripts = [];
|
|
764
720
|
if (!this._page.context()._options.isMobile) {
|
|
765
|
-
scripts.push(
|
|
766
|
-
scripts.push(
|
|
767
|
-
scripts.push(
|
|
721
|
+
scripts.push("delete window.orientation");
|
|
722
|
+
scripts.push("delete window.ondevicemotion");
|
|
723
|
+
scripts.push("delete window.ondeviceorientation");
|
|
768
724
|
}
|
|
769
725
|
scripts.push('if (!window.safari) window.safari = { pushNotification: { toString() { return "[object SafariRemoteNotification]"; } } };');
|
|
770
|
-
scripts.push(
|
|
771
|
-
scripts.push(...this._page.allInitScripts().map(script => script.source));
|
|
772
|
-
return scripts.join(
|
|
726
|
+
scripts.push("if (!window.GestureEvent) window.GestureEvent = function GestureEvent() {};");
|
|
727
|
+
scripts.push(...this._page.allInitScripts().map((script) => script.source));
|
|
728
|
+
return scripts.join(";\n");
|
|
773
729
|
}
|
|
774
730
|
async _updateBootstrapScript() {
|
|
775
|
-
await this._updateState(
|
|
776
|
-
source: this._calculateBootstrapScript()
|
|
777
|
-
});
|
|
731
|
+
await this._updateState("Page.setBootstrapScript", { source: this._calculateBootstrapScript() });
|
|
778
732
|
}
|
|
779
733
|
async closePage(runBeforeUnload) {
|
|
780
734
|
await this._stopVideo();
|
|
781
|
-
await this._pageProxySession.sendMayFail(
|
|
735
|
+
await this._pageProxySession.sendMayFail("Target.close", {
|
|
782
736
|
targetId: this._session.sessionId,
|
|
783
737
|
runBeforeUnload
|
|
784
738
|
});
|
|
785
739
|
}
|
|
786
740
|
async setBackgroundColor(color) {
|
|
787
|
-
await this._session.send(
|
|
788
|
-
color
|
|
789
|
-
});
|
|
741
|
+
await this._session.send("Page.setDefaultBackgroundColorOverride", { color });
|
|
790
742
|
}
|
|
791
743
|
_toolbarHeight() {
|
|
792
|
-
|
|
793
|
-
|
|
744
|
+
if (this._page._browserContext._browser?.options.headful)
|
|
745
|
+
return import_hostPlatform.hostPlatform === "mac10.15" ? 55 : 59;
|
|
794
746
|
return 0;
|
|
795
747
|
}
|
|
796
748
|
async _startVideo(options) {
|
|
797
|
-
(0,
|
|
798
|
-
const {
|
|
799
|
-
screencastId
|
|
800
|
-
} = await this._pageProxySession.send('Screencast.startVideo', {
|
|
749
|
+
(0, import_utils.assert)(!this._recordingVideoFile);
|
|
750
|
+
const { screencastId } = await this._pageProxySession.send("Screencast.startVideo", {
|
|
801
751
|
file: options.outputFile,
|
|
802
752
|
width: options.width,
|
|
803
753
|
height: options.height,
|
|
804
754
|
toolbarHeight: this._toolbarHeight()
|
|
805
755
|
});
|
|
806
756
|
this._recordingVideoFile = options.outputFile;
|
|
807
|
-
this._browserContext._browser._videoStarted(this._browserContext, screencastId, options.outputFile, this.
|
|
757
|
+
this._browserContext._browser._videoStarted(this._browserContext, screencastId, options.outputFile, this._page.waitForInitializedOrError());
|
|
808
758
|
}
|
|
809
759
|
async _stopVideo() {
|
|
810
|
-
if (!this._recordingVideoFile)
|
|
811
|
-
|
|
760
|
+
if (!this._recordingVideoFile)
|
|
761
|
+
return;
|
|
762
|
+
await this._pageProxySession.sendMayFail("Screencast.stopVideo");
|
|
812
763
|
this._recordingVideoFile = null;
|
|
813
764
|
}
|
|
814
765
|
validateScreenshotDimension(side, omitDeviceScaleFactor) {
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
if (
|
|
818
|
-
|
|
819
|
-
if (side > 32767)
|
|
766
|
+
if (process.platform === "darwin")
|
|
767
|
+
return;
|
|
768
|
+
if (!omitDeviceScaleFactor && this._page._browserContext._options.deviceScaleFactor)
|
|
769
|
+
side = Math.ceil(side * this._page._browserContext._options.deviceScaleFactor);
|
|
770
|
+
if (side > 32767)
|
|
771
|
+
throw new Error("Cannot take screenshot larger than 32767 pixels on any dimension");
|
|
820
772
|
}
|
|
821
773
|
async takeScreenshot(progress, format, documentRect, viewportRect, quality, fitsViewport, scale) {
|
|
822
774
|
const rect = documentRect || viewportRect;
|
|
823
|
-
const omitDeviceScaleFactor = scale ===
|
|
775
|
+
const omitDeviceScaleFactor = scale === "css";
|
|
824
776
|
this.validateScreenshotDimension(rect.width, omitDeviceScaleFactor);
|
|
825
777
|
this.validateScreenshotDimension(rect.height, omitDeviceScaleFactor);
|
|
826
|
-
const result = await this._session.send(
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
const prefix = 'data:image/png;base64,';
|
|
832
|
-
let buffer = Buffer.from(result.dataURL.substr(prefix.length), 'base64');
|
|
833
|
-
if (format === 'jpeg') buffer = _utilsBundle.jpegjs.encode(_utilsBundle.PNG.sync.read(buffer), quality).data;
|
|
778
|
+
const result = await this._session.send("Page.snapshotRect", { ...rect, coordinateSystem: documentRect ? "Page" : "Viewport", omitDeviceScaleFactor });
|
|
779
|
+
const prefix = "data:image/png;base64,";
|
|
780
|
+
let buffer = Buffer.from(result.dataURL.substr(prefix.length), "base64");
|
|
781
|
+
if (format === "jpeg")
|
|
782
|
+
buffer = import_utilsBundle.jpegjs.encode(import_utilsBundle.PNG.sync.read(buffer), quality).data;
|
|
834
783
|
return buffer;
|
|
835
784
|
}
|
|
836
785
|
async getContentFrame(handle) {
|
|
837
|
-
const nodeInfo = await this._session.send(
|
|
786
|
+
const nodeInfo = await this._session.send("DOM.describeNode", {
|
|
838
787
|
objectId: handle._objectId
|
|
839
788
|
});
|
|
840
|
-
if (!nodeInfo.contentFrameId)
|
|
789
|
+
if (!nodeInfo.contentFrameId)
|
|
790
|
+
return null;
|
|
841
791
|
return this._page._frameManager.frame(nodeInfo.contentFrameId);
|
|
842
792
|
}
|
|
843
793
|
async getOwnerFrame(handle) {
|
|
844
|
-
if (!handle._objectId)
|
|
845
|
-
|
|
794
|
+
if (!handle._objectId)
|
|
795
|
+
return null;
|
|
796
|
+
const nodeInfo = await this._session.send("DOM.describeNode", {
|
|
846
797
|
objectId: handle._objectId
|
|
847
798
|
});
|
|
848
799
|
return nodeInfo.ownerFrameId || null;
|
|
849
800
|
}
|
|
850
|
-
isElementHandle(remoteObject) {
|
|
851
|
-
return remoteObject.subtype === 'node';
|
|
852
|
-
}
|
|
853
801
|
async getBoundingBox(handle) {
|
|
854
802
|
const quads = await this.getContentQuads(handle);
|
|
855
|
-
if (!quads || !quads.length)
|
|
803
|
+
if (!quads || !quads.length)
|
|
804
|
+
return null;
|
|
856
805
|
let minX = Infinity;
|
|
857
806
|
let maxX = -Infinity;
|
|
858
807
|
let minY = Infinity;
|
|
@@ -865,128 +814,101 @@ class WKPage {
|
|
|
865
814
|
maxY = Math.max(maxY, point.y);
|
|
866
815
|
}
|
|
867
816
|
}
|
|
868
|
-
return {
|
|
869
|
-
x: minX,
|
|
870
|
-
y: minY,
|
|
871
|
-
width: maxX - minX,
|
|
872
|
-
height: maxY - minY
|
|
873
|
-
};
|
|
817
|
+
return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
874
818
|
}
|
|
875
819
|
async scrollRectIntoViewIfNeeded(handle, rect) {
|
|
876
|
-
return await this._session.send(
|
|
820
|
+
return await this._session.send("DOM.scrollIntoViewIfNeeded", {
|
|
877
821
|
objectId: handle._objectId,
|
|
878
822
|
rect
|
|
879
|
-
}).then(() =>
|
|
880
|
-
if (e instanceof Error && e.message.includes(
|
|
881
|
-
|
|
823
|
+
}).then(() => "done").catch((e) => {
|
|
824
|
+
if (e instanceof Error && e.message.includes("Node does not have a layout object"))
|
|
825
|
+
return "error:notvisible";
|
|
826
|
+
if (e instanceof Error && e.message.includes("Node is detached from document"))
|
|
827
|
+
return "error:notconnected";
|
|
882
828
|
throw e;
|
|
883
829
|
});
|
|
884
830
|
}
|
|
885
831
|
async setScreencastOptions(options) {
|
|
886
832
|
if (options) {
|
|
887
|
-
const so = {
|
|
888
|
-
|
|
889
|
-
toolbarHeight: this._toolbarHeight()
|
|
890
|
-
};
|
|
891
|
-
const {
|
|
892
|
-
generation
|
|
893
|
-
} = await this._pageProxySession.send('Screencast.startScreencast', so);
|
|
833
|
+
const so = { ...options, toolbarHeight: this._toolbarHeight() };
|
|
834
|
+
const { generation } = await this._pageProxySession.send("Screencast.startScreencast", so);
|
|
894
835
|
this._screencastGeneration = generation;
|
|
895
836
|
} else {
|
|
896
|
-
await this._pageProxySession.send(
|
|
837
|
+
await this._pageProxySession.send("Screencast.stopScreencast");
|
|
897
838
|
}
|
|
898
839
|
}
|
|
899
840
|
_onScreencastFrame(event) {
|
|
900
841
|
const generation = this._screencastGeneration;
|
|
901
842
|
this._page.throttleScreencastFrameAck(() => {
|
|
902
|
-
this._pageProxySession.send(
|
|
903
|
-
generation
|
|
904
|
-
}).catch(e => _debugLogger.debugLogger.log('error', e));
|
|
843
|
+
this._pageProxySession.send("Screencast.screencastFrameAck", { generation }).catch((e) => import_debugLogger.debugLogger.log("error", e));
|
|
905
844
|
});
|
|
906
|
-
const buffer = Buffer.from(event.data,
|
|
907
|
-
this._page.emit(
|
|
845
|
+
const buffer = Buffer.from(event.data, "base64");
|
|
846
|
+
this._page.emit(import_page2.Page.Events.ScreencastFrame, {
|
|
908
847
|
buffer,
|
|
909
848
|
width: event.deviceWidth,
|
|
910
849
|
height: event.deviceHeight
|
|
911
850
|
});
|
|
912
851
|
}
|
|
913
852
|
rafCountForStablePosition() {
|
|
914
|
-
return process.platform ===
|
|
853
|
+
return process.platform === "win32" ? 5 : 1;
|
|
915
854
|
}
|
|
916
855
|
async getContentQuads(handle) {
|
|
917
|
-
const result = await this._session.sendMayFail(
|
|
856
|
+
const result = await this._session.sendMayFail("DOM.getContentQuads", {
|
|
918
857
|
objectId: handle._objectId
|
|
919
858
|
});
|
|
920
|
-
if (!result)
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
y: quad[1]
|
|
924
|
-
|
|
925
|
-
x: quad[
|
|
926
|
-
y: quad[
|
|
927
|
-
|
|
928
|
-
x: quad[4],
|
|
929
|
-
y: quad[5]
|
|
930
|
-
}, {
|
|
931
|
-
x: quad[6],
|
|
932
|
-
y: quad[7]
|
|
933
|
-
}]);
|
|
934
|
-
}
|
|
935
|
-
async setInputFiles(handle, files) {
|
|
936
|
-
const objectId = handle._objectId;
|
|
937
|
-
const protocolFiles = files.map(file => ({
|
|
938
|
-
name: file.name,
|
|
939
|
-
type: file.mimeType,
|
|
940
|
-
data: file.buffer
|
|
941
|
-
}));
|
|
942
|
-
await this._session.send('DOM.setInputFiles', {
|
|
943
|
-
objectId,
|
|
944
|
-
files: protocolFiles
|
|
945
|
-
});
|
|
859
|
+
if (!result)
|
|
860
|
+
return null;
|
|
861
|
+
return result.quads.map((quad) => [
|
|
862
|
+
{ x: quad[0], y: quad[1] },
|
|
863
|
+
{ x: quad[2], y: quad[3] },
|
|
864
|
+
{ x: quad[4], y: quad[5] },
|
|
865
|
+
{ x: quad[6], y: quad[7] }
|
|
866
|
+
]);
|
|
946
867
|
}
|
|
947
868
|
async setInputFilePaths(handle, paths) {
|
|
948
869
|
const pageProxyId = this._pageProxySession.sessionId;
|
|
949
870
|
const objectId = handle._objectId;
|
|
950
|
-
await Promise.all([
|
|
951
|
-
pageProxyId,
|
|
952
|
-
paths
|
|
953
|
-
|
|
954
|
-
objectId,
|
|
955
|
-
paths
|
|
956
|
-
})]);
|
|
871
|
+
await Promise.all([
|
|
872
|
+
this._pageProxySession.connection.browserSession.send("Playwright.grantFileReadAccess", { pageProxyId, paths }),
|
|
873
|
+
this._session.send("DOM.setInputFiles", { objectId, paths })
|
|
874
|
+
]);
|
|
957
875
|
}
|
|
958
876
|
async adoptElementHandle(handle, to) {
|
|
959
|
-
const result = await this._session.sendMayFail(
|
|
877
|
+
const result = await this._session.sendMayFail("DOM.resolveNode", {
|
|
960
878
|
objectId: handle._objectId,
|
|
961
|
-
executionContextId: to
|
|
879
|
+
executionContextId: to.delegate._contextId
|
|
962
880
|
});
|
|
963
|
-
if (!result || result.object.subtype ===
|
|
964
|
-
|
|
881
|
+
if (!result || result.object.subtype === "null")
|
|
882
|
+
throw new Error(dom.kUnableToAdoptErrorMessage);
|
|
883
|
+
return (0, import_wkExecutionContext.createHandle)(to, result.object);
|
|
965
884
|
}
|
|
966
885
|
async getAccessibilityTree(needle) {
|
|
967
|
-
return (0,
|
|
886
|
+
return (0, import_wkAccessibility.getAccessibilityTree)(this._session, needle);
|
|
887
|
+
}
|
|
888
|
+
async inputActionEpilogue() {
|
|
889
|
+
}
|
|
890
|
+
async resetForReuse() {
|
|
968
891
|
}
|
|
969
|
-
async inputActionEpilogue() {}
|
|
970
|
-
async resetForReuse() {}
|
|
971
892
|
async getFrameElement(frame) {
|
|
972
893
|
const parent = frame.parentFrame();
|
|
973
|
-
if (!parent)
|
|
894
|
+
if (!parent)
|
|
895
|
+
throw new Error("Frame has been detached.");
|
|
974
896
|
const context = await parent._mainContext();
|
|
975
|
-
const result = await this._session.send(
|
|
897
|
+
const result = await this._session.send("DOM.resolveNode", {
|
|
976
898
|
frameId: frame._id,
|
|
977
|
-
executionContextId: context
|
|
899
|
+
executionContextId: context.delegate._contextId
|
|
978
900
|
});
|
|
979
|
-
if (!result || result.object.subtype ===
|
|
980
|
-
|
|
901
|
+
if (!result || result.object.subtype === "null")
|
|
902
|
+
throw new Error("Frame has been detached.");
|
|
903
|
+
return (0, import_wkExecutionContext.createHandle)(context, result.object);
|
|
981
904
|
}
|
|
982
905
|
_maybeCancelCoopNavigationRequest(provisionalPage) {
|
|
983
906
|
const navigationRequest = provisionalPage.coopNavigationRequest();
|
|
984
907
|
for (const [requestId, request] of this._requestIdToRequest) {
|
|
985
908
|
if (request.request === navigationRequest) {
|
|
986
|
-
// Make sure the request completes if the provisional navigation is canceled.
|
|
987
909
|
this._onLoadingFailed(provisionalPage._session, {
|
|
988
|
-
requestId
|
|
989
|
-
errorText:
|
|
910
|
+
requestId,
|
|
911
|
+
errorText: "Provisiolal navigation canceled.",
|
|
990
912
|
timestamp: request._timestamp,
|
|
991
913
|
canceled: true
|
|
992
914
|
});
|
|
@@ -1005,35 +927,33 @@ class WKPage {
|
|
|
1005
927
|
}
|
|
1006
928
|
}
|
|
1007
929
|
_onRequestWillBeSent(session, event) {
|
|
1008
|
-
if (event.request.url.startsWith(
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
930
|
+
if (event.request.url.startsWith("data:"))
|
|
931
|
+
return;
|
|
932
|
+
if (event.request.url.startsWith("about:"))
|
|
933
|
+
return;
|
|
934
|
+
if (this._page.needsRequestInterception() && !event.redirectResponse)
|
|
935
|
+
this._requestIdToRequestWillBeSentEvent.set(event.requestId, event);
|
|
936
|
+
else
|
|
937
|
+
this._onRequest(session, event, false);
|
|
1012
938
|
}
|
|
1013
939
|
_onRequest(session, event, intercepted) {
|
|
1014
940
|
let redirectedFrom = null;
|
|
1015
941
|
if (event.redirectResponse) {
|
|
1016
|
-
const
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
redirectedFrom = request;
|
|
942
|
+
const request2 = this._requestIdToRequest.get(event.requestId);
|
|
943
|
+
if (request2) {
|
|
944
|
+
this._handleRequestRedirect(request2, event.requestId, event.redirectResponse, event.timestamp);
|
|
945
|
+
redirectedFrom = request2;
|
|
1021
946
|
}
|
|
1022
947
|
}
|
|
1023
948
|
const frame = redirectedFrom ? redirectedFrom.request.frame() : this._page._frameManager.frame(event.frameId);
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
const isNavigationRequest = event.type === 'Document';
|
|
1030
|
-
const documentId = isNavigationRequest ? event.loaderId : undefined;
|
|
1031
|
-
const request = new _wkInterceptableRequest.WKInterceptableRequest(session, frame, event, redirectedFrom, documentId);
|
|
949
|
+
if (!frame)
|
|
950
|
+
return;
|
|
951
|
+
const isNavigationRequest = event.type === "Document";
|
|
952
|
+
const documentId = isNavigationRequest ? event.loaderId : void 0;
|
|
953
|
+
const request = new import_wkInterceptableRequest.WKInterceptableRequest(session, frame, event, redirectedFrom, documentId);
|
|
1032
954
|
let route;
|
|
1033
955
|
if (intercepted) {
|
|
1034
|
-
route = new
|
|
1035
|
-
// There is no point in waiting for the raw headers in Network.responseReceived when intercepting.
|
|
1036
|
-
// Use provisional headers as raw headers, so that client can call allHeaders() from the route handler.
|
|
956
|
+
route = new import_wkInterceptableRequest.WKRouteImpl(session, event.requestId);
|
|
1037
957
|
request.request.setRawRequestHeaders(null);
|
|
1038
958
|
}
|
|
1039
959
|
this._requestIdToRequest.set(event.requestId, request);
|
|
@@ -1045,7 +965,7 @@ class WKPage {
|
|
|
1045
965
|
response._serverAddrFinished();
|
|
1046
966
|
response.setResponseHeadersSize(null);
|
|
1047
967
|
response.setEncodedBodySize(null);
|
|
1048
|
-
response._requestFinished(responsePayload.timing ?
|
|
968
|
+
response._requestFinished(responsePayload.timing ? import_helper.helper.secondsToRoundishMillis(timestamp - request._timestamp) : -1);
|
|
1049
969
|
this._requestIdToRequest.delete(requestId);
|
|
1050
970
|
this._page._frameManager.requestReceivedResponse(response);
|
|
1051
971
|
this._page._frameManager.reportRequestFinished(request.request, response);
|
|
@@ -1053,11 +973,7 @@ class WKPage {
|
|
|
1053
973
|
_onRequestIntercepted(session, event) {
|
|
1054
974
|
const requestWillBeSentEvent = this._requestIdToRequestWillBeSentEvent.get(event.requestId);
|
|
1055
975
|
if (!requestWillBeSentEvent) {
|
|
1056
|
-
|
|
1057
|
-
// Just continue.
|
|
1058
|
-
session.sendMayFail('Network.interceptWithRequest', {
|
|
1059
|
-
requestId: event.requestId
|
|
1060
|
-
});
|
|
976
|
+
session.sendMayFail("Network.interceptWithRequest", { requestId: event.requestId });
|
|
1061
977
|
return;
|
|
1062
978
|
}
|
|
1063
979
|
this._requestIdToRequestWillBeSentEvent.delete(event.requestId);
|
|
@@ -1067,49 +983,42 @@ class WKPage {
|
|
|
1067
983
|
const requestWillBeSentEvent = this._requestIdToRequestWillBeSentEvent.get(event.requestId);
|
|
1068
984
|
if (requestWillBeSentEvent) {
|
|
1069
985
|
this._requestIdToRequestWillBeSentEvent.delete(event.requestId);
|
|
1070
|
-
// We received a response, so the request won't be intercepted (e.g. it was handled by a
|
|
1071
|
-
// service worker and we don't intercept service workers).
|
|
1072
986
|
this._onRequest(session, requestWillBeSentEvent, false);
|
|
1073
987
|
}
|
|
1074
988
|
const request = this._requestIdToRequest.get(event.requestId);
|
|
1075
|
-
|
|
1076
|
-
|
|
989
|
+
if (!request)
|
|
990
|
+
return;
|
|
1077
991
|
this._requestIdToResponseReceivedPayloadEvent.set(event.requestId, event);
|
|
1078
992
|
const response = request.createResponse(event.response);
|
|
1079
993
|
this._page._frameManager.requestReceivedResponse(response);
|
|
1080
994
|
if (response.status() === 204 && request.request.isNavigationRequest()) {
|
|
1081
995
|
this._onLoadingFailed(session, {
|
|
1082
996
|
requestId: event.requestId,
|
|
1083
|
-
errorText:
|
|
997
|
+
errorText: "Aborted: 204 No Content",
|
|
1084
998
|
timestamp: event.timestamp
|
|
1085
999
|
});
|
|
1086
1000
|
}
|
|
1087
1001
|
}
|
|
1088
1002
|
_onLoadingFinished(event) {
|
|
1089
1003
|
const request = this._requestIdToRequest.get(event.requestId);
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
if (!request) return;
|
|
1093
|
-
|
|
1094
|
-
// Under certain conditions we never get the Network.responseReceived
|
|
1095
|
-
// event from protocol. @see https://crbug.com/883475
|
|
1004
|
+
if (!request)
|
|
1005
|
+
return;
|
|
1096
1006
|
const response = request.request._existingResponse();
|
|
1097
1007
|
if (response) {
|
|
1098
|
-
var _event$metrics, _event$metrics2, _responseReceivedPayl, _responseReceivedPayl2, _responseReceivedPayl3, _event$metrics3, _event$metrics$respon, _event$metrics4, _event$metrics$respon2, _event$metrics5;
|
|
1099
1008
|
const responseReceivedPayload = this._requestIdToResponseReceivedPayloadEvent.get(event.requestId);
|
|
1100
|
-
response._serverAddrFinished(parseRemoteAddress(event
|
|
1009
|
+
response._serverAddrFinished(parseRemoteAddress(event?.metrics?.remoteAddress));
|
|
1101
1010
|
response._securityDetailsFinished({
|
|
1102
|
-
protocol: isLoadedSecurely(response.url(), response.timing()) ?
|
|
1103
|
-
subjectName: responseReceivedPayload
|
|
1104
|
-
validFrom: responseReceivedPayload
|
|
1105
|
-
validTo: responseReceivedPayload
|
|
1011
|
+
protocol: isLoadedSecurely(response.url(), response.timing()) ? event.metrics?.securityConnection?.protocol : void 0,
|
|
1012
|
+
subjectName: responseReceivedPayload?.response.security?.certificate?.subject,
|
|
1013
|
+
validFrom: responseReceivedPayload?.response.security?.certificate?.validFrom,
|
|
1014
|
+
validTo: responseReceivedPayload?.response.security?.certificate?.validUntil
|
|
1106
1015
|
});
|
|
1107
|
-
if (
|
|
1108
|
-
|
|
1109
|
-
response.
|
|
1110
|
-
response.
|
|
1016
|
+
if (event.metrics?.protocol)
|
|
1017
|
+
response._setHttpVersion(event.metrics.protocol);
|
|
1018
|
+
response.setEncodedBodySize(event.metrics?.responseBodyBytesReceived ?? null);
|
|
1019
|
+
response.setResponseHeadersSize(event.metrics?.responseHeaderBytesReceived ?? null);
|
|
1020
|
+
response._requestFinished(import_helper.helper.secondsToRoundishMillis(event.timestamp - request._timestamp));
|
|
1111
1021
|
} else {
|
|
1112
|
-
// Use provisional headers if we didn't have the response with raw headers.
|
|
1113
1022
|
request.request.setRawRequestHeaders(null);
|
|
1114
1023
|
}
|
|
1115
1024
|
this._requestIdToResponseReceivedPayloadEvent.delete(event.requestId);
|
|
@@ -1120,104 +1029,86 @@ class WKPage {
|
|
|
1120
1029
|
const requestWillBeSentEvent = this._requestIdToRequestWillBeSentEvent.get(event.requestId);
|
|
1121
1030
|
if (requestWillBeSentEvent) {
|
|
1122
1031
|
this._requestIdToRequestWillBeSentEvent.delete(event.requestId);
|
|
1123
|
-
// If loading failed, the request won't be intercepted (e.g. it was handled by a
|
|
1124
|
-
// service worker and we don't intercept service workers).
|
|
1125
1032
|
this._onRequest(session, requestWillBeSentEvent, false);
|
|
1126
1033
|
}
|
|
1127
1034
|
const request = this._requestIdToRequest.get(event.requestId);
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
if (!request) return;
|
|
1035
|
+
if (!request)
|
|
1036
|
+
return;
|
|
1131
1037
|
const response = request.request._existingResponse();
|
|
1132
1038
|
if (response) {
|
|
1133
1039
|
response._serverAddrFinished();
|
|
1134
1040
|
response._securityDetailsFinished();
|
|
1135
1041
|
response.setResponseHeadersSize(null);
|
|
1136
1042
|
response.setEncodedBodySize(null);
|
|
1137
|
-
response._requestFinished(
|
|
1043
|
+
response._requestFinished(import_helper.helper.secondsToRoundishMillis(event.timestamp - request._timestamp));
|
|
1138
1044
|
} else {
|
|
1139
|
-
// Use provisional headers if we didn't have the response with raw headers.
|
|
1140
1045
|
request.request.setRawRequestHeaders(null);
|
|
1141
1046
|
}
|
|
1142
1047
|
this._requestIdToRequest.delete(event.requestId);
|
|
1143
1048
|
request.request._setFailureText(event.errorText);
|
|
1144
|
-
this._page._frameManager.requestFailed(request.request, event.errorText.includes(
|
|
1049
|
+
this._page._frameManager.requestFailed(request.request, event.errorText.includes("cancelled"));
|
|
1145
1050
|
}
|
|
1146
1051
|
async _grantPermissions(origin, permissions) {
|
|
1147
|
-
const webPermissionToProtocol = new Map([
|
|
1148
|
-
|
|
1052
|
+
const webPermissionToProtocol = /* @__PURE__ */ new Map([
|
|
1053
|
+
["geolocation", "geolocation"],
|
|
1054
|
+
["notifications", "notifications"],
|
|
1055
|
+
["clipboard-read", "clipboard-read"]
|
|
1056
|
+
]);
|
|
1057
|
+
const filtered = permissions.map((permission) => {
|
|
1149
1058
|
const protocolPermission = webPermissionToProtocol.get(permission);
|
|
1150
|
-
if (!protocolPermission)
|
|
1059
|
+
if (!protocolPermission)
|
|
1060
|
+
throw new Error("Unknown permission: " + permission);
|
|
1151
1061
|
return protocolPermission;
|
|
1152
1062
|
});
|
|
1153
|
-
await this._pageProxySession.send(
|
|
1154
|
-
origin,
|
|
1155
|
-
permissions: filtered
|
|
1156
|
-
});
|
|
1063
|
+
await this._pageProxySession.send("Emulation.grantPermissions", { origin, permissions: filtered });
|
|
1157
1064
|
}
|
|
1158
1065
|
async _clearPermissions() {
|
|
1159
|
-
await this._pageProxySession.send(
|
|
1066
|
+
await this._pageProxySession.send("Emulation.resetPermissions", {});
|
|
1160
1067
|
}
|
|
1161
1068
|
shouldToggleStyleSheetToSyncAnimations() {
|
|
1162
1069
|
return true;
|
|
1163
1070
|
}
|
|
1164
1071
|
}
|
|
1165
|
-
|
|
1166
|
-
/**
|
|
1167
|
-
* WebKit Remote Addresses look like:
|
|
1168
|
-
*
|
|
1169
|
-
* macOS:
|
|
1170
|
-
* ::1.8911
|
|
1171
|
-
* 2606:2800:220:1:248:1893:25c8:1946.443
|
|
1172
|
-
* 127.0.0.1:8000
|
|
1173
|
-
*
|
|
1174
|
-
* ubuntu:
|
|
1175
|
-
* ::1:8907
|
|
1176
|
-
* 127.0.0.1:8000
|
|
1177
|
-
*
|
|
1178
|
-
* NB: They look IPv4 and IPv6's with ports but use an alternative notation.
|
|
1179
|
-
*/
|
|
1180
|
-
exports.WKPage = WKPage;
|
|
1181
1072
|
function parseRemoteAddress(value) {
|
|
1182
|
-
if (!value)
|
|
1073
|
+
if (!value)
|
|
1074
|
+
return;
|
|
1183
1075
|
try {
|
|
1184
|
-
const colon = value.lastIndexOf(
|
|
1185
|
-
const dot = value.lastIndexOf(
|
|
1076
|
+
const colon = value.lastIndexOf(":");
|
|
1077
|
+
const dot = value.lastIndexOf(".");
|
|
1186
1078
|
if (dot < 0) {
|
|
1187
|
-
// IPv6ish:port
|
|
1188
1079
|
return {
|
|
1189
1080
|
ipAddress: `[${value.slice(0, colon)}]`,
|
|
1190
1081
|
port: +value.slice(colon + 1)
|
|
1191
1082
|
};
|
|
1192
1083
|
}
|
|
1193
1084
|
if (colon > dot) {
|
|
1194
|
-
|
|
1195
|
-
const [address, port] = value.split(':');
|
|
1085
|
+
const [address, port] = value.split(":");
|
|
1196
1086
|
return {
|
|
1197
1087
|
ipAddress: address,
|
|
1198
1088
|
port: +port
|
|
1199
1089
|
};
|
|
1200
1090
|
} else {
|
|
1201
|
-
|
|
1202
|
-
const [address, port] = value.split('.');
|
|
1091
|
+
const [address, port] = value.split(".");
|
|
1203
1092
|
return {
|
|
1204
1093
|
ipAddress: `[${address}]`,
|
|
1205
1094
|
port: +port
|
|
1206
1095
|
};
|
|
1207
1096
|
}
|
|
1208
|
-
} catch (_) {
|
|
1097
|
+
} catch (_) {
|
|
1098
|
+
}
|
|
1209
1099
|
}
|
|
1210
|
-
|
|
1211
|
-
/**
|
|
1212
|
-
* Adapted from Source/WebInspectorUI/UserInterface/Models/Resource.js in
|
|
1213
|
-
* WebKit codebase.
|
|
1214
|
-
*/
|
|
1215
1100
|
function isLoadedSecurely(url, timing) {
|
|
1216
1101
|
try {
|
|
1217
1102
|
const u = new URL(url);
|
|
1218
|
-
if (u.protocol !==
|
|
1219
|
-
|
|
1103
|
+
if (u.protocol !== "https:" && u.protocol !== "wss:" && u.protocol !== "sftp:")
|
|
1104
|
+
return false;
|
|
1105
|
+
if (timing.secureConnectionStart === -1 && timing.connectStart !== -1)
|
|
1106
|
+
return false;
|
|
1220
1107
|
return true;
|
|
1221
|
-
} catch (_) {
|
|
1108
|
+
} catch (_) {
|
|
1109
|
+
}
|
|
1222
1110
|
}
|
|
1223
|
-
|
|
1111
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1112
|
+
0 && (module.exports = {
|
|
1113
|
+
WKPage
|
|
1114
|
+
});
|