rebrowser-playwright-core 1.49.1 → 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 -597
- 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 +351 -434
- 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 -647
- 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-C5j27SYZ.js → codeMirrorModule-DVQi6prl.js} +13 -13
- 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 +181 -69
- 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/index-m0XdVJHe.js +0 -184
- package/lib/vite/traceViewer/assets/codeMirrorModule-BBCX0spr.js +0 -24
- package/lib/vite/traceViewer/assets/inspectorTab-B4Iw34Ow.js +0 -68
- package/lib/vite/traceViewer/assets/testServerConnection-DeE2kSzz.js +0 -1
- package/lib/vite/traceViewer/assets/workbench-DFlGYqou.js +0 -9
- package/lib/vite/traceViewer/embedded.CmarehFk.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.FBucu_gE.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.CW_rzcEp.js +0 -2
- package/lib/vite/traceViewer/recorder.html +0 -17
- package/lib/vite/traceViewer/uiMode.CDUVjusr.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,93 +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
|
-
|
|
578
|
-
|
|
579
|
-
|
|
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
|
+
));
|
|
580
542
|
}
|
|
581
543
|
async _onFileChooserOpened(event) {
|
|
582
544
|
let handle;
|
|
583
545
|
try {
|
|
584
546
|
const context = await this._page._frameManager.frame(event.frameId)._mainContext();
|
|
585
|
-
handle =
|
|
547
|
+
handle = (0, import_wkExecutionContext.createHandle)(context, event.element).asElement();
|
|
586
548
|
} catch (e) {
|
|
587
|
-
// During async processing, frame/context may go away. We should not throw.
|
|
588
549
|
return;
|
|
589
550
|
}
|
|
590
551
|
await this._page._onFileChooserOpened(handle);
|
|
591
552
|
}
|
|
592
|
-
static async _setEmulateMedia(session, mediaType, colorScheme, reducedMotion, forcedColors) {
|
|
553
|
+
static async _setEmulateMedia(session, mediaType, colorScheme, reducedMotion, forcedColors, contrast) {
|
|
593
554
|
const promises = [];
|
|
594
|
-
promises.push(session.send(
|
|
595
|
-
|
|
596
|
-
}));
|
|
597
|
-
let appearance = undefined;
|
|
555
|
+
promises.push(session.send("Page.setEmulatedMedia", { media: mediaType === "no-override" ? "" : mediaType }));
|
|
556
|
+
let appearance = void 0;
|
|
598
557
|
switch (colorScheme) {
|
|
599
|
-
case
|
|
600
|
-
appearance =
|
|
558
|
+
case "light":
|
|
559
|
+
appearance = "Light";
|
|
601
560
|
break;
|
|
602
|
-
case
|
|
603
|
-
appearance =
|
|
561
|
+
case "dark":
|
|
562
|
+
appearance = "Dark";
|
|
604
563
|
break;
|
|
605
|
-
case
|
|
606
|
-
appearance =
|
|
564
|
+
case "no-override":
|
|
565
|
+
appearance = void 0;
|
|
607
566
|
break;
|
|
608
567
|
}
|
|
609
|
-
promises.push(session.send(
|
|
610
|
-
|
|
611
|
-
value: appearance
|
|
612
|
-
}));
|
|
613
|
-
let reducedMotionWk = undefined;
|
|
568
|
+
promises.push(session.send("Page.overrideUserPreference", { name: "PrefersColorScheme", value: appearance }));
|
|
569
|
+
let reducedMotionWk = void 0;
|
|
614
570
|
switch (reducedMotion) {
|
|
615
|
-
case
|
|
616
|
-
reducedMotionWk =
|
|
571
|
+
case "reduce":
|
|
572
|
+
reducedMotionWk = "Reduce";
|
|
617
573
|
break;
|
|
618
|
-
case
|
|
619
|
-
reducedMotionWk =
|
|
574
|
+
case "no-preference":
|
|
575
|
+
reducedMotionWk = "NoPreference";
|
|
620
576
|
break;
|
|
621
|
-
case
|
|
622
|
-
reducedMotionWk =
|
|
577
|
+
case "no-override":
|
|
578
|
+
reducedMotionWk = void 0;
|
|
623
579
|
break;
|
|
624
580
|
}
|
|
625
|
-
promises.push(session.send(
|
|
626
|
-
|
|
627
|
-
value: reducedMotionWk
|
|
628
|
-
}));
|
|
629
|
-
let forcedColorsWk = undefined;
|
|
581
|
+
promises.push(session.send("Page.overrideUserPreference", { name: "PrefersReducedMotion", value: reducedMotionWk }));
|
|
582
|
+
let forcedColorsWk = void 0;
|
|
630
583
|
switch (forcedColors) {
|
|
631
|
-
case
|
|
632
|
-
forcedColorsWk =
|
|
584
|
+
case "active":
|
|
585
|
+
forcedColorsWk = "Active";
|
|
633
586
|
break;
|
|
634
|
-
case
|
|
635
|
-
forcedColorsWk =
|
|
587
|
+
case "none":
|
|
588
|
+
forcedColorsWk = "None";
|
|
636
589
|
break;
|
|
637
|
-
case
|
|
638
|
-
forcedColorsWk =
|
|
590
|
+
case "no-override":
|
|
591
|
+
forcedColorsWk = void 0;
|
|
639
592
|
break;
|
|
640
593
|
}
|
|
641
|
-
promises.push(session.send(
|
|
642
|
-
|
|
643
|
-
|
|
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 }));
|
|
644
608
|
await Promise.all(promises);
|
|
645
609
|
}
|
|
646
610
|
async updateExtraHTTPHeaders() {
|
|
647
|
-
await this._updateState(
|
|
648
|
-
|
|
649
|
-
|
|
611
|
+
await this._updateState("Network.setExtraHTTPHeaders", { headers: (0, import_headers.headersArrayToObject)(
|
|
612
|
+
this._calculateExtraHTTPHeaders(),
|
|
613
|
+
false
|
|
614
|
+
/* lowerCase */
|
|
615
|
+
) });
|
|
650
616
|
}
|
|
651
617
|
_calculateExtraHTTPHeaders() {
|
|
652
618
|
const locale = this._browserContext._options.locale;
|
|
653
|
-
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
|
+
]);
|
|
654
624
|
return headers;
|
|
655
625
|
}
|
|
656
626
|
async updateEmulateMedia() {
|
|
@@ -658,7 +628,8 @@ class WKPage {
|
|
|
658
628
|
const colorScheme = emulatedMedia.colorScheme;
|
|
659
629
|
const reducedMotion = emulatedMedia.reducedMotion;
|
|
660
630
|
const forcedColors = emulatedMedia.forcedColors;
|
|
661
|
-
|
|
631
|
+
const contrast = emulatedMedia.contrast;
|
|
632
|
+
await this._forAllSessions((session) => WKPage._setEmulateMedia(session, emulatedMedia.media, colorScheme, reducedMotion, forcedColors, contrast));
|
|
662
633
|
}
|
|
663
634
|
async updateEmulatedViewportSize() {
|
|
664
635
|
this._browserContext._validateEmulatedViewport(this._page.viewportSize());
|
|
@@ -666,94 +637,77 @@ class WKPage {
|
|
|
666
637
|
}
|
|
667
638
|
async updateUserAgent() {
|
|
668
639
|
const contextOptions = this._browserContext._options;
|
|
669
|
-
this._updateState(
|
|
670
|
-
value: contextOptions.userAgent
|
|
671
|
-
});
|
|
640
|
+
this._updateState("Page.overrideUserAgent", { value: contextOptions.userAgent });
|
|
672
641
|
}
|
|
673
642
|
async bringToFront() {
|
|
674
|
-
this._pageProxySession.send(
|
|
643
|
+
this._pageProxySession.send("Target.activate", {
|
|
675
644
|
targetId: this._session.sessionId
|
|
676
645
|
});
|
|
677
646
|
}
|
|
678
647
|
async _updateViewport() {
|
|
679
648
|
const options = this._browserContext._options;
|
|
680
649
|
const deviceSize = this._page.emulatedSize();
|
|
681
|
-
if (deviceSize === null)
|
|
650
|
+
if (deviceSize === null)
|
|
651
|
+
return;
|
|
682
652
|
const viewportSize = deviceSize.viewport;
|
|
683
653
|
const screenSize = deviceSize.screen;
|
|
684
|
-
const promises = [
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
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
|
+
];
|
|
693
666
|
if (options.isMobile) {
|
|
694
667
|
const angle = viewportSize.width > viewportSize.height ? 90 : 0;
|
|
695
|
-
|
|
696
|
-
const useLegacySetOrientationOverrideMethod = _os.default.platform() === 'darwin' && parseInt(_os.default.release().split('.')[0], 10) <= 21;
|
|
697
|
-
if (useLegacySetOrientationOverrideMethod) promises.push(this._session.send('Page.setOrientationOverride', {
|
|
698
|
-
angle
|
|
699
|
-
}));else promises.push(this._pageProxySession.send('Emulation.setOrientationOverride', {
|
|
700
|
-
angle
|
|
701
|
-
}));
|
|
668
|
+
promises.push(this._pageProxySession.send("Emulation.setOrientationOverride", { angle }));
|
|
702
669
|
}
|
|
703
670
|
await Promise.all(promises);
|
|
704
671
|
}
|
|
705
672
|
async updateRequestInterception() {
|
|
706
673
|
const enabled = this._page.needsRequestInterception();
|
|
707
|
-
await Promise.all([
|
|
708
|
-
enabled
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
url: '.*',
|
|
713
|
-
stage: 'request',
|
|
714
|
-
isRegex: true
|
|
715
|
-
})]);
|
|
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
|
+
]);
|
|
716
679
|
}
|
|
717
680
|
async updateOffline() {
|
|
718
|
-
await this._updateState(
|
|
719
|
-
offline: !!this._browserContext._options.offline
|
|
720
|
-
});
|
|
681
|
+
await this._updateState("Network.setEmulateOfflineState", { offline: !!this._browserContext._options.offline });
|
|
721
682
|
}
|
|
722
683
|
async updateHttpCredentials() {
|
|
723
|
-
const credentials = this._browserContext._options.httpCredentials || {
|
|
724
|
-
|
|
725
|
-
password: '',
|
|
726
|
-
origin: ''
|
|
727
|
-
};
|
|
728
|
-
await this._pageProxySession.send('Emulation.setAuthCredentials', {
|
|
729
|
-
username: credentials.username,
|
|
730
|
-
password: credentials.password,
|
|
731
|
-
origin: credentials.origin
|
|
732
|
-
});
|
|
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 });
|
|
733
686
|
}
|
|
734
687
|
async updateFileChooserInterception() {
|
|
735
688
|
const enabled = this._page.fileChooserIntercepted();
|
|
736
|
-
await this._session.send(
|
|
737
|
-
|
|
738
|
-
}).catch(() => {}); // target can be closed.
|
|
689
|
+
await this._session.send("Page.setInterceptFileChooserDialog", { enabled }).catch(() => {
|
|
690
|
+
});
|
|
739
691
|
}
|
|
740
692
|
async reload() {
|
|
741
|
-
await this._session.send(
|
|
693
|
+
await this._session.send("Page.reload");
|
|
742
694
|
}
|
|
743
695
|
goBack() {
|
|
744
|
-
return this._session.send(
|
|
745
|
-
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;
|
|
746
699
|
throw error;
|
|
747
700
|
});
|
|
748
701
|
}
|
|
749
702
|
goForward() {
|
|
750
|
-
return this._session.send(
|
|
751
|
-
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;
|
|
752
706
|
throw error;
|
|
753
707
|
});
|
|
754
708
|
}
|
|
755
709
|
async requestGC() {
|
|
756
|
-
await this._session.send(
|
|
710
|
+
await this._session.send("Heap.gc");
|
|
757
711
|
}
|
|
758
712
|
async addInitScript(initScript) {
|
|
759
713
|
await this._updateBootstrapScript();
|
|
@@ -764,97 +718,90 @@ class WKPage {
|
|
|
764
718
|
_calculateBootstrapScript() {
|
|
765
719
|
const scripts = [];
|
|
766
720
|
if (!this._page.context()._options.isMobile) {
|
|
767
|
-
scripts.push(
|
|
768
|
-
scripts.push(
|
|
769
|
-
scripts.push(
|
|
721
|
+
scripts.push("delete window.orientation");
|
|
722
|
+
scripts.push("delete window.ondevicemotion");
|
|
723
|
+
scripts.push("delete window.ondeviceorientation");
|
|
770
724
|
}
|
|
771
725
|
scripts.push('if (!window.safari) window.safari = { pushNotification: { toString() { return "[object SafariRemoteNotification]"; } } };');
|
|
772
|
-
scripts.push(
|
|
773
|
-
scripts.push(...this._page.allInitScripts().map(script => script.source));
|
|
774
|
-
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");
|
|
775
729
|
}
|
|
776
730
|
async _updateBootstrapScript() {
|
|
777
|
-
await this._updateState(
|
|
778
|
-
source: this._calculateBootstrapScript()
|
|
779
|
-
});
|
|
731
|
+
await this._updateState("Page.setBootstrapScript", { source: this._calculateBootstrapScript() });
|
|
780
732
|
}
|
|
781
733
|
async closePage(runBeforeUnload) {
|
|
782
734
|
await this._stopVideo();
|
|
783
|
-
await this._pageProxySession.sendMayFail(
|
|
735
|
+
await this._pageProxySession.sendMayFail("Target.close", {
|
|
784
736
|
targetId: this._session.sessionId,
|
|
785
737
|
runBeforeUnload
|
|
786
738
|
});
|
|
787
739
|
}
|
|
788
740
|
async setBackgroundColor(color) {
|
|
789
|
-
await this._session.send(
|
|
790
|
-
color
|
|
791
|
-
});
|
|
741
|
+
await this._session.send("Page.setDefaultBackgroundColorOverride", { color });
|
|
792
742
|
}
|
|
793
743
|
_toolbarHeight() {
|
|
794
|
-
|
|
795
|
-
|
|
744
|
+
if (this._page._browserContext._browser?.options.headful)
|
|
745
|
+
return import_hostPlatform.hostPlatform === "mac10.15" ? 55 : 59;
|
|
796
746
|
return 0;
|
|
797
747
|
}
|
|
798
748
|
async _startVideo(options) {
|
|
799
|
-
(0,
|
|
800
|
-
const {
|
|
801
|
-
screencastId
|
|
802
|
-
} = await this._pageProxySession.send('Screencast.startVideo', {
|
|
749
|
+
(0, import_utils.assert)(!this._recordingVideoFile);
|
|
750
|
+
const { screencastId } = await this._pageProxySession.send("Screencast.startVideo", {
|
|
803
751
|
file: options.outputFile,
|
|
804
752
|
width: options.width,
|
|
805
753
|
height: options.height,
|
|
806
754
|
toolbarHeight: this._toolbarHeight()
|
|
807
755
|
});
|
|
808
756
|
this._recordingVideoFile = options.outputFile;
|
|
809
|
-
this._browserContext._browser._videoStarted(this._browserContext, screencastId, options.outputFile, this.
|
|
757
|
+
this._browserContext._browser._videoStarted(this._browserContext, screencastId, options.outputFile, this._page.waitForInitializedOrError());
|
|
810
758
|
}
|
|
811
759
|
async _stopVideo() {
|
|
812
|
-
if (!this._recordingVideoFile)
|
|
813
|
-
|
|
760
|
+
if (!this._recordingVideoFile)
|
|
761
|
+
return;
|
|
762
|
+
await this._pageProxySession.sendMayFail("Screencast.stopVideo");
|
|
814
763
|
this._recordingVideoFile = null;
|
|
815
764
|
}
|
|
816
765
|
validateScreenshotDimension(side, omitDeviceScaleFactor) {
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
if (
|
|
820
|
-
|
|
821
|
-
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");
|
|
822
772
|
}
|
|
823
773
|
async takeScreenshot(progress, format, documentRect, viewportRect, quality, fitsViewport, scale) {
|
|
824
774
|
const rect = documentRect || viewportRect;
|
|
825
|
-
const omitDeviceScaleFactor = scale ===
|
|
775
|
+
const omitDeviceScaleFactor = scale === "css";
|
|
826
776
|
this.validateScreenshotDimension(rect.width, omitDeviceScaleFactor);
|
|
827
777
|
this.validateScreenshotDimension(rect.height, omitDeviceScaleFactor);
|
|
828
|
-
const result = await this._session.send(
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
const prefix = 'data:image/png;base64,';
|
|
834
|
-
let buffer = Buffer.from(result.dataURL.substr(prefix.length), 'base64');
|
|
835
|
-
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;
|
|
836
783
|
return buffer;
|
|
837
784
|
}
|
|
838
785
|
async getContentFrame(handle) {
|
|
839
|
-
const nodeInfo = await this._session.send(
|
|
786
|
+
const nodeInfo = await this._session.send("DOM.describeNode", {
|
|
840
787
|
objectId: handle._objectId
|
|
841
788
|
});
|
|
842
|
-
if (!nodeInfo.contentFrameId)
|
|
789
|
+
if (!nodeInfo.contentFrameId)
|
|
790
|
+
return null;
|
|
843
791
|
return this._page._frameManager.frame(nodeInfo.contentFrameId);
|
|
844
792
|
}
|
|
845
793
|
async getOwnerFrame(handle) {
|
|
846
|
-
if (!handle._objectId)
|
|
847
|
-
|
|
794
|
+
if (!handle._objectId)
|
|
795
|
+
return null;
|
|
796
|
+
const nodeInfo = await this._session.send("DOM.describeNode", {
|
|
848
797
|
objectId: handle._objectId
|
|
849
798
|
});
|
|
850
799
|
return nodeInfo.ownerFrameId || null;
|
|
851
800
|
}
|
|
852
|
-
isElementHandle(remoteObject) {
|
|
853
|
-
return remoteObject.subtype === 'node';
|
|
854
|
-
}
|
|
855
801
|
async getBoundingBox(handle) {
|
|
856
802
|
const quads = await this.getContentQuads(handle);
|
|
857
|
-
if (!quads || !quads.length)
|
|
803
|
+
if (!quads || !quads.length)
|
|
804
|
+
return null;
|
|
858
805
|
let minX = Infinity;
|
|
859
806
|
let maxX = -Infinity;
|
|
860
807
|
let minY = Infinity;
|
|
@@ -867,128 +814,101 @@ class WKPage {
|
|
|
867
814
|
maxY = Math.max(maxY, point.y);
|
|
868
815
|
}
|
|
869
816
|
}
|
|
870
|
-
return {
|
|
871
|
-
x: minX,
|
|
872
|
-
y: minY,
|
|
873
|
-
width: maxX - minX,
|
|
874
|
-
height: maxY - minY
|
|
875
|
-
};
|
|
817
|
+
return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
876
818
|
}
|
|
877
819
|
async scrollRectIntoViewIfNeeded(handle, rect) {
|
|
878
|
-
return await this._session.send(
|
|
820
|
+
return await this._session.send("DOM.scrollIntoViewIfNeeded", {
|
|
879
821
|
objectId: handle._objectId,
|
|
880
822
|
rect
|
|
881
|
-
}).then(() =>
|
|
882
|
-
if (e instanceof Error && e.message.includes(
|
|
883
|
-
|
|
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";
|
|
884
828
|
throw e;
|
|
885
829
|
});
|
|
886
830
|
}
|
|
887
831
|
async setScreencastOptions(options) {
|
|
888
832
|
if (options) {
|
|
889
|
-
const so = {
|
|
890
|
-
|
|
891
|
-
toolbarHeight: this._toolbarHeight()
|
|
892
|
-
};
|
|
893
|
-
const {
|
|
894
|
-
generation
|
|
895
|
-
} = await this._pageProxySession.send('Screencast.startScreencast', so);
|
|
833
|
+
const so = { ...options, toolbarHeight: this._toolbarHeight() };
|
|
834
|
+
const { generation } = await this._pageProxySession.send("Screencast.startScreencast", so);
|
|
896
835
|
this._screencastGeneration = generation;
|
|
897
836
|
} else {
|
|
898
|
-
await this._pageProxySession.send(
|
|
837
|
+
await this._pageProxySession.send("Screencast.stopScreencast");
|
|
899
838
|
}
|
|
900
839
|
}
|
|
901
840
|
_onScreencastFrame(event) {
|
|
902
841
|
const generation = this._screencastGeneration;
|
|
903
842
|
this._page.throttleScreencastFrameAck(() => {
|
|
904
|
-
this._pageProxySession.send(
|
|
905
|
-
generation
|
|
906
|
-
}).catch(e => _debugLogger.debugLogger.log('error', e));
|
|
843
|
+
this._pageProxySession.send("Screencast.screencastFrameAck", { generation }).catch((e) => import_debugLogger.debugLogger.log("error", e));
|
|
907
844
|
});
|
|
908
|
-
const buffer = Buffer.from(event.data,
|
|
909
|
-
this._page.emit(
|
|
845
|
+
const buffer = Buffer.from(event.data, "base64");
|
|
846
|
+
this._page.emit(import_page2.Page.Events.ScreencastFrame, {
|
|
910
847
|
buffer,
|
|
911
848
|
width: event.deviceWidth,
|
|
912
849
|
height: event.deviceHeight
|
|
913
850
|
});
|
|
914
851
|
}
|
|
915
852
|
rafCountForStablePosition() {
|
|
916
|
-
return process.platform ===
|
|
853
|
+
return process.platform === "win32" ? 5 : 1;
|
|
917
854
|
}
|
|
918
855
|
async getContentQuads(handle) {
|
|
919
|
-
const result = await this._session.sendMayFail(
|
|
856
|
+
const result = await this._session.sendMayFail("DOM.getContentQuads", {
|
|
920
857
|
objectId: handle._objectId
|
|
921
858
|
});
|
|
922
|
-
if (!result)
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
y: quad[1]
|
|
926
|
-
|
|
927
|
-
x: quad[
|
|
928
|
-
y: quad[
|
|
929
|
-
|
|
930
|
-
x: quad[4],
|
|
931
|
-
y: quad[5]
|
|
932
|
-
}, {
|
|
933
|
-
x: quad[6],
|
|
934
|
-
y: quad[7]
|
|
935
|
-
}]);
|
|
936
|
-
}
|
|
937
|
-
async setInputFiles(handle, files) {
|
|
938
|
-
const objectId = handle._objectId;
|
|
939
|
-
const protocolFiles = files.map(file => ({
|
|
940
|
-
name: file.name,
|
|
941
|
-
type: file.mimeType,
|
|
942
|
-
data: file.buffer
|
|
943
|
-
}));
|
|
944
|
-
await this._session.send('DOM.setInputFiles', {
|
|
945
|
-
objectId,
|
|
946
|
-
files: protocolFiles
|
|
947
|
-
});
|
|
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
|
+
]);
|
|
948
867
|
}
|
|
949
868
|
async setInputFilePaths(handle, paths) {
|
|
950
869
|
const pageProxyId = this._pageProxySession.sessionId;
|
|
951
870
|
const objectId = handle._objectId;
|
|
952
|
-
await Promise.all([
|
|
953
|
-
pageProxyId,
|
|
954
|
-
paths
|
|
955
|
-
|
|
956
|
-
objectId,
|
|
957
|
-
paths
|
|
958
|
-
})]);
|
|
871
|
+
await Promise.all([
|
|
872
|
+
this._pageProxySession.connection.browserSession.send("Playwright.grantFileReadAccess", { pageProxyId, paths }),
|
|
873
|
+
this._session.send("DOM.setInputFiles", { objectId, paths })
|
|
874
|
+
]);
|
|
959
875
|
}
|
|
960
876
|
async adoptElementHandle(handle, to) {
|
|
961
|
-
const result = await this._session.sendMayFail(
|
|
877
|
+
const result = await this._session.sendMayFail("DOM.resolveNode", {
|
|
962
878
|
objectId: handle._objectId,
|
|
963
|
-
executionContextId: to
|
|
879
|
+
executionContextId: to.delegate._contextId
|
|
964
880
|
});
|
|
965
|
-
if (!result || result.object.subtype ===
|
|
966
|
-
|
|
881
|
+
if (!result || result.object.subtype === "null")
|
|
882
|
+
throw new Error(dom.kUnableToAdoptErrorMessage);
|
|
883
|
+
return (0, import_wkExecutionContext.createHandle)(to, result.object);
|
|
967
884
|
}
|
|
968
885
|
async getAccessibilityTree(needle) {
|
|
969
|
-
return (0,
|
|
886
|
+
return (0, import_wkAccessibility.getAccessibilityTree)(this._session, needle);
|
|
887
|
+
}
|
|
888
|
+
async inputActionEpilogue() {
|
|
889
|
+
}
|
|
890
|
+
async resetForReuse() {
|
|
970
891
|
}
|
|
971
|
-
async inputActionEpilogue() {}
|
|
972
|
-
async resetForReuse() {}
|
|
973
892
|
async getFrameElement(frame) {
|
|
974
893
|
const parent = frame.parentFrame();
|
|
975
|
-
if (!parent)
|
|
894
|
+
if (!parent)
|
|
895
|
+
throw new Error("Frame has been detached.");
|
|
976
896
|
const context = await parent._mainContext();
|
|
977
|
-
const result = await this._session.send(
|
|
897
|
+
const result = await this._session.send("DOM.resolveNode", {
|
|
978
898
|
frameId: frame._id,
|
|
979
|
-
executionContextId: context
|
|
899
|
+
executionContextId: context.delegate._contextId
|
|
980
900
|
});
|
|
981
|
-
if (!result || result.object.subtype ===
|
|
982
|
-
|
|
901
|
+
if (!result || result.object.subtype === "null")
|
|
902
|
+
throw new Error("Frame has been detached.");
|
|
903
|
+
return (0, import_wkExecutionContext.createHandle)(context, result.object);
|
|
983
904
|
}
|
|
984
905
|
_maybeCancelCoopNavigationRequest(provisionalPage) {
|
|
985
906
|
const navigationRequest = provisionalPage.coopNavigationRequest();
|
|
986
907
|
for (const [requestId, request] of this._requestIdToRequest) {
|
|
987
908
|
if (request.request === navigationRequest) {
|
|
988
|
-
// Make sure the request completes if the provisional navigation is canceled.
|
|
989
909
|
this._onLoadingFailed(provisionalPage._session, {
|
|
990
|
-
requestId
|
|
991
|
-
errorText:
|
|
910
|
+
requestId,
|
|
911
|
+
errorText: "Provisiolal navigation canceled.",
|
|
992
912
|
timestamp: request._timestamp,
|
|
993
913
|
canceled: true
|
|
994
914
|
});
|
|
@@ -1007,35 +927,33 @@ class WKPage {
|
|
|
1007
927
|
}
|
|
1008
928
|
}
|
|
1009
929
|
_onRequestWillBeSent(session, event) {
|
|
1010
|
-
if (event.request.url.startsWith(
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
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);
|
|
1014
938
|
}
|
|
1015
939
|
_onRequest(session, event, intercepted) {
|
|
1016
940
|
let redirectedFrom = null;
|
|
1017
941
|
if (event.redirectResponse) {
|
|
1018
|
-
const
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
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;
|
|
1023
946
|
}
|
|
1024
947
|
}
|
|
1025
948
|
const frame = redirectedFrom ? redirectedFrom.request.frame() : this._page._frameManager.frame(event.frameId);
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
const isNavigationRequest = event.type === 'Document';
|
|
1032
|
-
const documentId = isNavigationRequest ? event.loaderId : undefined;
|
|
1033
|
-
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);
|
|
1034
954
|
let route;
|
|
1035
955
|
if (intercepted) {
|
|
1036
|
-
route = new
|
|
1037
|
-
// There is no point in waiting for the raw headers in Network.responseReceived when intercepting.
|
|
1038
|
-
// 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);
|
|
1039
957
|
request.request.setRawRequestHeaders(null);
|
|
1040
958
|
}
|
|
1041
959
|
this._requestIdToRequest.set(event.requestId, request);
|
|
@@ -1047,7 +965,7 @@ class WKPage {
|
|
|
1047
965
|
response._serverAddrFinished();
|
|
1048
966
|
response.setResponseHeadersSize(null);
|
|
1049
967
|
response.setEncodedBodySize(null);
|
|
1050
|
-
response._requestFinished(responsePayload.timing ?
|
|
968
|
+
response._requestFinished(responsePayload.timing ? import_helper.helper.secondsToRoundishMillis(timestamp - request._timestamp) : -1);
|
|
1051
969
|
this._requestIdToRequest.delete(requestId);
|
|
1052
970
|
this._page._frameManager.requestReceivedResponse(response);
|
|
1053
971
|
this._page._frameManager.reportRequestFinished(request.request, response);
|
|
@@ -1055,11 +973,7 @@ class WKPage {
|
|
|
1055
973
|
_onRequestIntercepted(session, event) {
|
|
1056
974
|
const requestWillBeSentEvent = this._requestIdToRequestWillBeSentEvent.get(event.requestId);
|
|
1057
975
|
if (!requestWillBeSentEvent) {
|
|
1058
|
-
|
|
1059
|
-
// Just continue.
|
|
1060
|
-
session.sendMayFail('Network.interceptWithRequest', {
|
|
1061
|
-
requestId: event.requestId
|
|
1062
|
-
});
|
|
976
|
+
session.sendMayFail("Network.interceptWithRequest", { requestId: event.requestId });
|
|
1063
977
|
return;
|
|
1064
978
|
}
|
|
1065
979
|
this._requestIdToRequestWillBeSentEvent.delete(event.requestId);
|
|
@@ -1069,49 +983,42 @@ class WKPage {
|
|
|
1069
983
|
const requestWillBeSentEvent = this._requestIdToRequestWillBeSentEvent.get(event.requestId);
|
|
1070
984
|
if (requestWillBeSentEvent) {
|
|
1071
985
|
this._requestIdToRequestWillBeSentEvent.delete(event.requestId);
|
|
1072
|
-
// We received a response, so the request won't be intercepted (e.g. it was handled by a
|
|
1073
|
-
// service worker and we don't intercept service workers).
|
|
1074
986
|
this._onRequest(session, requestWillBeSentEvent, false);
|
|
1075
987
|
}
|
|
1076
988
|
const request = this._requestIdToRequest.get(event.requestId);
|
|
1077
|
-
|
|
1078
|
-
|
|
989
|
+
if (!request)
|
|
990
|
+
return;
|
|
1079
991
|
this._requestIdToResponseReceivedPayloadEvent.set(event.requestId, event);
|
|
1080
992
|
const response = request.createResponse(event.response);
|
|
1081
993
|
this._page._frameManager.requestReceivedResponse(response);
|
|
1082
994
|
if (response.status() === 204 && request.request.isNavigationRequest()) {
|
|
1083
995
|
this._onLoadingFailed(session, {
|
|
1084
996
|
requestId: event.requestId,
|
|
1085
|
-
errorText:
|
|
997
|
+
errorText: "Aborted: 204 No Content",
|
|
1086
998
|
timestamp: event.timestamp
|
|
1087
999
|
});
|
|
1088
1000
|
}
|
|
1089
1001
|
}
|
|
1090
1002
|
_onLoadingFinished(event) {
|
|
1091
1003
|
const request = this._requestIdToRequest.get(event.requestId);
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
if (!request) return;
|
|
1095
|
-
|
|
1096
|
-
// Under certain conditions we never get the Network.responseReceived
|
|
1097
|
-
// event from protocol. @see https://crbug.com/883475
|
|
1004
|
+
if (!request)
|
|
1005
|
+
return;
|
|
1098
1006
|
const response = request.request._existingResponse();
|
|
1099
1007
|
if (response) {
|
|
1100
|
-
var _event$metrics, _event$metrics2, _responseReceivedPayl, _responseReceivedPayl2, _responseReceivedPayl3, _event$metrics3, _event$metrics$respon, _event$metrics4, _event$metrics$respon2, _event$metrics5;
|
|
1101
1008
|
const responseReceivedPayload = this._requestIdToResponseReceivedPayloadEvent.get(event.requestId);
|
|
1102
|
-
response._serverAddrFinished(parseRemoteAddress(event
|
|
1009
|
+
response._serverAddrFinished(parseRemoteAddress(event?.metrics?.remoteAddress));
|
|
1103
1010
|
response._securityDetailsFinished({
|
|
1104
|
-
protocol: isLoadedSecurely(response.url(), response.timing()) ?
|
|
1105
|
-
subjectName: responseReceivedPayload
|
|
1106
|
-
validFrom: responseReceivedPayload
|
|
1107
|
-
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
|
|
1108
1015
|
});
|
|
1109
|
-
if (
|
|
1110
|
-
|
|
1111
|
-
response.
|
|
1112
|
-
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));
|
|
1113
1021
|
} else {
|
|
1114
|
-
// Use provisional headers if we didn't have the response with raw headers.
|
|
1115
1022
|
request.request.setRawRequestHeaders(null);
|
|
1116
1023
|
}
|
|
1117
1024
|
this._requestIdToResponseReceivedPayloadEvent.delete(event.requestId);
|
|
@@ -1122,104 +1029,86 @@ class WKPage {
|
|
|
1122
1029
|
const requestWillBeSentEvent = this._requestIdToRequestWillBeSentEvent.get(event.requestId);
|
|
1123
1030
|
if (requestWillBeSentEvent) {
|
|
1124
1031
|
this._requestIdToRequestWillBeSentEvent.delete(event.requestId);
|
|
1125
|
-
// If loading failed, the request won't be intercepted (e.g. it was handled by a
|
|
1126
|
-
// service worker and we don't intercept service workers).
|
|
1127
1032
|
this._onRequest(session, requestWillBeSentEvent, false);
|
|
1128
1033
|
}
|
|
1129
1034
|
const request = this._requestIdToRequest.get(event.requestId);
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
if (!request) return;
|
|
1035
|
+
if (!request)
|
|
1036
|
+
return;
|
|
1133
1037
|
const response = request.request._existingResponse();
|
|
1134
1038
|
if (response) {
|
|
1135
1039
|
response._serverAddrFinished();
|
|
1136
1040
|
response._securityDetailsFinished();
|
|
1137
1041
|
response.setResponseHeadersSize(null);
|
|
1138
1042
|
response.setEncodedBodySize(null);
|
|
1139
|
-
response._requestFinished(
|
|
1043
|
+
response._requestFinished(import_helper.helper.secondsToRoundishMillis(event.timestamp - request._timestamp));
|
|
1140
1044
|
} else {
|
|
1141
|
-
// Use provisional headers if we didn't have the response with raw headers.
|
|
1142
1045
|
request.request.setRawRequestHeaders(null);
|
|
1143
1046
|
}
|
|
1144
1047
|
this._requestIdToRequest.delete(event.requestId);
|
|
1145
1048
|
request.request._setFailureText(event.errorText);
|
|
1146
|
-
this._page._frameManager.requestFailed(request.request, event.errorText.includes(
|
|
1049
|
+
this._page._frameManager.requestFailed(request.request, event.errorText.includes("cancelled"));
|
|
1147
1050
|
}
|
|
1148
1051
|
async _grantPermissions(origin, permissions) {
|
|
1149
|
-
const webPermissionToProtocol = new Map([
|
|
1150
|
-
|
|
1052
|
+
const webPermissionToProtocol = /* @__PURE__ */ new Map([
|
|
1053
|
+
["geolocation", "geolocation"],
|
|
1054
|
+
["notifications", "notifications"],
|
|
1055
|
+
["clipboard-read", "clipboard-read"]
|
|
1056
|
+
]);
|
|
1057
|
+
const filtered = permissions.map((permission) => {
|
|
1151
1058
|
const protocolPermission = webPermissionToProtocol.get(permission);
|
|
1152
|
-
if (!protocolPermission)
|
|
1059
|
+
if (!protocolPermission)
|
|
1060
|
+
throw new Error("Unknown permission: " + permission);
|
|
1153
1061
|
return protocolPermission;
|
|
1154
1062
|
});
|
|
1155
|
-
await this._pageProxySession.send(
|
|
1156
|
-
origin,
|
|
1157
|
-
permissions: filtered
|
|
1158
|
-
});
|
|
1063
|
+
await this._pageProxySession.send("Emulation.grantPermissions", { origin, permissions: filtered });
|
|
1159
1064
|
}
|
|
1160
1065
|
async _clearPermissions() {
|
|
1161
|
-
await this._pageProxySession.send(
|
|
1066
|
+
await this._pageProxySession.send("Emulation.resetPermissions", {});
|
|
1162
1067
|
}
|
|
1163
1068
|
shouldToggleStyleSheetToSyncAnimations() {
|
|
1164
1069
|
return true;
|
|
1165
1070
|
}
|
|
1166
1071
|
}
|
|
1167
|
-
|
|
1168
|
-
/**
|
|
1169
|
-
* WebKit Remote Addresses look like:
|
|
1170
|
-
*
|
|
1171
|
-
* macOS:
|
|
1172
|
-
* ::1.8911
|
|
1173
|
-
* 2606:2800:220:1:248:1893:25c8:1946.443
|
|
1174
|
-
* 127.0.0.1:8000
|
|
1175
|
-
*
|
|
1176
|
-
* ubuntu:
|
|
1177
|
-
* ::1:8907
|
|
1178
|
-
* 127.0.0.1:8000
|
|
1179
|
-
*
|
|
1180
|
-
* NB: They look IPv4 and IPv6's with ports but use an alternative notation.
|
|
1181
|
-
*/
|
|
1182
|
-
exports.WKPage = WKPage;
|
|
1183
1072
|
function parseRemoteAddress(value) {
|
|
1184
|
-
if (!value)
|
|
1073
|
+
if (!value)
|
|
1074
|
+
return;
|
|
1185
1075
|
try {
|
|
1186
|
-
const colon = value.lastIndexOf(
|
|
1187
|
-
const dot = value.lastIndexOf(
|
|
1076
|
+
const colon = value.lastIndexOf(":");
|
|
1077
|
+
const dot = value.lastIndexOf(".");
|
|
1188
1078
|
if (dot < 0) {
|
|
1189
|
-
// IPv6ish:port
|
|
1190
1079
|
return {
|
|
1191
1080
|
ipAddress: `[${value.slice(0, colon)}]`,
|
|
1192
1081
|
port: +value.slice(colon + 1)
|
|
1193
1082
|
};
|
|
1194
1083
|
}
|
|
1195
1084
|
if (colon > dot) {
|
|
1196
|
-
|
|
1197
|
-
const [address, port] = value.split(':');
|
|
1085
|
+
const [address, port] = value.split(":");
|
|
1198
1086
|
return {
|
|
1199
1087
|
ipAddress: address,
|
|
1200
1088
|
port: +port
|
|
1201
1089
|
};
|
|
1202
1090
|
} else {
|
|
1203
|
-
|
|
1204
|
-
const [address, port] = value.split('.');
|
|
1091
|
+
const [address, port] = value.split(".");
|
|
1205
1092
|
return {
|
|
1206
1093
|
ipAddress: `[${address}]`,
|
|
1207
1094
|
port: +port
|
|
1208
1095
|
};
|
|
1209
1096
|
}
|
|
1210
|
-
} catch (_) {
|
|
1097
|
+
} catch (_) {
|
|
1098
|
+
}
|
|
1211
1099
|
}
|
|
1212
|
-
|
|
1213
|
-
/**
|
|
1214
|
-
* Adapted from Source/WebInspectorUI/UserInterface/Models/Resource.js in
|
|
1215
|
-
* WebKit codebase.
|
|
1216
|
-
*/
|
|
1217
1100
|
function isLoadedSecurely(url, timing) {
|
|
1218
1101
|
try {
|
|
1219
1102
|
const u = new URL(url);
|
|
1220
|
-
if (u.protocol !==
|
|
1221
|
-
|
|
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;
|
|
1222
1107
|
return true;
|
|
1223
|
-
} catch (_) {
|
|
1108
|
+
} catch (_) {
|
|
1109
|
+
}
|
|
1224
1110
|
}
|
|
1225
|
-
|
|
1111
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1112
|
+
0 && (module.exports = {
|
|
1113
|
+
WKPage
|
|
1114
|
+
});
|