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,222 +1,205 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var playwrightConnection_exports = {};
|
|
20
|
+
__export(playwrightConnection_exports, {
|
|
21
|
+
PlaywrightConnection: () => PlaywrightConnection
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
19
|
-
* you may not use this file except in compliance with the License.
|
|
20
|
-
* You may obtain a copy of the License at
|
|
21
|
-
*
|
|
22
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
23
|
-
*
|
|
24
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
25
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
26
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
27
|
-
* See the License for the specific language governing permissions and
|
|
28
|
-
* limitations under the License.
|
|
29
|
-
*/
|
|
30
|
-
|
|
23
|
+
module.exports = __toCommonJS(playwrightConnection_exports);
|
|
24
|
+
var import_socksProxy = require("../server/utils/socksProxy");
|
|
25
|
+
var import_server = require("../server");
|
|
26
|
+
var import_android = require("../server/android/android");
|
|
27
|
+
var import_browser = require("../server/browser");
|
|
28
|
+
var import_debugControllerDispatcher = require("../server/dispatchers/debugControllerDispatcher");
|
|
29
|
+
var import_instrumentation = require("../server/instrumentation");
|
|
30
|
+
var import_assert = require("../utils/isomorphic/assert");
|
|
31
|
+
var import_debug = require("../server/utils/debug");
|
|
32
|
+
var import_profiler = require("../server/utils/profiler");
|
|
33
|
+
var import_utils = require("../utils");
|
|
34
|
+
var import_debugLogger = require("../server/utils/debugLogger");
|
|
31
35
|
class PlaywrightConnection {
|
|
32
36
|
constructor(lock, clientType, ws, options, preLaunched, id, onClose) {
|
|
33
|
-
this._ws = void 0;
|
|
34
|
-
this._onClose = void 0;
|
|
35
|
-
this._dispatcherConnection = void 0;
|
|
36
37
|
this._cleanups = [];
|
|
37
|
-
this._id = void 0;
|
|
38
38
|
this._disconnected = false;
|
|
39
|
-
this._preLaunched = void 0;
|
|
40
|
-
this._options = void 0;
|
|
41
|
-
this._root = void 0;
|
|
42
|
-
this._profileName = void 0;
|
|
43
39
|
this._ws = ws;
|
|
44
40
|
this._preLaunched = preLaunched;
|
|
45
41
|
this._options = options;
|
|
46
|
-
options.launchOptions = filterLaunchOptions(options.launchOptions);
|
|
47
|
-
if (clientType ===
|
|
48
|
-
|
|
42
|
+
options.launchOptions = filterLaunchOptions(options.launchOptions, options.allowFSPaths);
|
|
43
|
+
if (clientType === "reuse-browser" || clientType === "pre-launched-browser-or-android")
|
|
44
|
+
(0, import_assert.assert)(preLaunched.playwright);
|
|
45
|
+
if (clientType === "pre-launched-browser-or-android")
|
|
46
|
+
(0, import_assert.assert)(preLaunched.browser || preLaunched.androidDevice);
|
|
49
47
|
this._onClose = onClose;
|
|
50
48
|
this._id = id;
|
|
51
|
-
this._profileName = `${new Date().toISOString()}-${clientType}`;
|
|
52
|
-
this._dispatcherConnection = new
|
|
53
|
-
this._dispatcherConnection.onmessage = async message => {
|
|
49
|
+
this._profileName = `${(/* @__PURE__ */ new Date()).toISOString()}-${clientType}`;
|
|
50
|
+
this._dispatcherConnection = new import_server.DispatcherConnection();
|
|
51
|
+
this._dispatcherConnection.onmessage = async (message) => {
|
|
54
52
|
await lock;
|
|
55
53
|
if (ws.readyState !== ws.CLOSING) {
|
|
56
54
|
const messageString = JSON.stringify(message);
|
|
57
|
-
if (
|
|
58
|
-
|
|
55
|
+
if (import_debugLogger.debugLogger.isEnabled("server:channel"))
|
|
56
|
+
import_debugLogger.debugLogger.log("server:channel", `[${this._id}] ${(0, import_utils.monotonicTime)() * 1e3} SEND \u25BA ${messageString}`);
|
|
57
|
+
if (import_debugLogger.debugLogger.isEnabled("server:metadata"))
|
|
58
|
+
this.logServerMetadata(message, messageString, "SEND");
|
|
59
59
|
ws.send(messageString);
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
-
ws.on(
|
|
62
|
+
ws.on("message", async (message) => {
|
|
63
63
|
await lock;
|
|
64
64
|
const messageString = Buffer.from(message).toString();
|
|
65
65
|
const jsonMessage = JSON.parse(messageString);
|
|
66
|
-
if (
|
|
67
|
-
|
|
66
|
+
if (import_debugLogger.debugLogger.isEnabled("server:channel"))
|
|
67
|
+
import_debugLogger.debugLogger.log("server:channel", `[${this._id}] ${(0, import_utils.monotonicTime)() * 1e3} \u25C0 RECV ${messageString}`);
|
|
68
|
+
if (import_debugLogger.debugLogger.isEnabled("server:metadata"))
|
|
69
|
+
this.logServerMetadata(jsonMessage, messageString, "RECV");
|
|
68
70
|
this._dispatcherConnection.dispatch(jsonMessage);
|
|
69
71
|
});
|
|
70
|
-
ws.on(
|
|
71
|
-
ws.on(
|
|
72
|
-
if (clientType ===
|
|
72
|
+
ws.on("close", () => this._onDisconnect());
|
|
73
|
+
ws.on("error", (error) => this._onDisconnect(error));
|
|
74
|
+
if (clientType === "controller") {
|
|
73
75
|
this._root = this._initDebugControllerMode();
|
|
74
76
|
return;
|
|
75
77
|
}
|
|
76
|
-
this._root = new
|
|
77
|
-
await (0,
|
|
78
|
-
if (clientType ===
|
|
79
|
-
|
|
80
|
-
if (clientType ===
|
|
81
|
-
|
|
78
|
+
this._root = new import_server.RootDispatcher(this._dispatcherConnection, async (scope, options2) => {
|
|
79
|
+
await (0, import_profiler.startProfiling)();
|
|
80
|
+
if (clientType === "reuse-browser")
|
|
81
|
+
return await this._initReuseBrowsersMode(scope);
|
|
82
|
+
if (clientType === "pre-launched-browser-or-android")
|
|
83
|
+
return this._preLaunched.browser ? await this._initPreLaunchedBrowserMode(scope) : await this._initPreLaunchedAndroidMode(scope);
|
|
84
|
+
if (clientType === "launch-browser")
|
|
85
|
+
return await this._initLaunchBrowserMode(scope, options2);
|
|
86
|
+
throw new Error("Unsupported client type: " + clientType);
|
|
82
87
|
});
|
|
83
88
|
}
|
|
84
89
|
async _initLaunchBrowserMode(scope, options) {
|
|
85
|
-
|
|
86
|
-
const playwright = (0,
|
|
87
|
-
sdkLanguage: options.sdkLanguage,
|
|
88
|
-
isServer: true
|
|
89
|
-
});
|
|
90
|
+
import_debugLogger.debugLogger.log("server", `[${this._id}] engaged launch mode for "${this._options.browserName}"`);
|
|
91
|
+
const playwright = (0, import_server.createPlaywright)({ sdkLanguage: options.sdkLanguage, isServer: true });
|
|
90
92
|
const ownedSocksProxy = await this._createOwnedSocksProxy(playwright);
|
|
91
|
-
|
|
93
|
+
let browserName = this._options.browserName;
|
|
94
|
+
if ("bidi" === browserName) {
|
|
95
|
+
if (this._options.launchOptions?.channel?.toLocaleLowerCase().includes("firefox"))
|
|
96
|
+
browserName = "bidiFirefox";
|
|
97
|
+
else
|
|
98
|
+
browserName = "bidiChromium";
|
|
99
|
+
}
|
|
100
|
+
const browser = await playwright[browserName].launch((0, import_instrumentation.serverSideCallMetadata)(), this._options.launchOptions);
|
|
92
101
|
this._cleanups.push(async () => {
|
|
93
|
-
for (const
|
|
94
|
-
reason:
|
|
95
|
-
});
|
|
102
|
+
for (const browser2 of playwright.allBrowsers())
|
|
103
|
+
await browser2.close({ reason: "Connection terminated" });
|
|
96
104
|
});
|
|
97
|
-
browser.on(
|
|
98
|
-
|
|
99
|
-
this.close({
|
|
100
|
-
code: 1001,
|
|
101
|
-
reason: 'Browser closed'
|
|
102
|
-
});
|
|
105
|
+
browser.on(import_browser.Browser.Events.Disconnected, () => {
|
|
106
|
+
this.close({ code: 1001, reason: "Browser closed" });
|
|
103
107
|
});
|
|
104
|
-
return new
|
|
108
|
+
return new import_server.PlaywrightDispatcher(scope, playwright, ownedSocksProxy, browser);
|
|
105
109
|
}
|
|
106
110
|
async _initPreLaunchedBrowserMode(scope) {
|
|
107
|
-
|
|
108
|
-
_debugLogger.debugLogger.log('server', `[${this._id}] engaged pre-launched (browser) mode`);
|
|
111
|
+
import_debugLogger.debugLogger.log("server", `[${this._id}] engaged pre-launched (browser) mode`);
|
|
109
112
|
const playwright = this._preLaunched.playwright;
|
|
110
|
-
|
|
111
|
-
// Note: connected client owns the socks proxy and configures the pattern.
|
|
112
|
-
(_this$_preLaunched$so = this._preLaunched.socksProxy) === null || _this$_preLaunched$so === void 0 || _this$_preLaunched$so.setPattern(this._options.socksProxyPattern);
|
|
113
|
+
this._preLaunched.socksProxy?.setPattern(this._options.socksProxyPattern);
|
|
113
114
|
const browser = this._preLaunched.browser;
|
|
114
|
-
browser.on(
|
|
115
|
-
|
|
116
|
-
this.close({
|
|
117
|
-
code: 1001,
|
|
118
|
-
reason: 'Browser closed'
|
|
119
|
-
});
|
|
115
|
+
browser.on(import_browser.Browser.Events.Disconnected, () => {
|
|
116
|
+
this.close({ code: 1001, reason: "Browser closed" });
|
|
120
117
|
});
|
|
121
|
-
const playwrightDispatcher = new
|
|
122
|
-
// In pre-launched mode, keep only the pre-launched browser.
|
|
118
|
+
const playwrightDispatcher = new import_server.PlaywrightDispatcher(scope, playwright, this._preLaunched.socksProxy, browser);
|
|
123
119
|
for (const b of playwright.allBrowsers()) {
|
|
124
|
-
if (b !== browser)
|
|
125
|
-
reason:
|
|
126
|
-
});
|
|
120
|
+
if (b !== browser)
|
|
121
|
+
await b.close({ reason: "Connection terminated" });
|
|
127
122
|
}
|
|
128
123
|
this._cleanups.push(() => playwrightDispatcher.cleanup());
|
|
129
124
|
return playwrightDispatcher;
|
|
130
125
|
}
|
|
131
126
|
async _initPreLaunchedAndroidMode(scope) {
|
|
132
|
-
|
|
127
|
+
import_debugLogger.debugLogger.log("server", `[${this._id}] engaged pre-launched (Android) mode`);
|
|
133
128
|
const playwright = this._preLaunched.playwright;
|
|
134
129
|
const androidDevice = this._preLaunched.androidDevice;
|
|
135
|
-
androidDevice.on(
|
|
136
|
-
|
|
137
|
-
this.close({
|
|
138
|
-
code: 1001,
|
|
139
|
-
reason: 'Android device disconnected'
|
|
140
|
-
});
|
|
130
|
+
androidDevice.on(import_android.AndroidDevice.Events.Close, () => {
|
|
131
|
+
this.close({ code: 1001, reason: "Android device disconnected" });
|
|
141
132
|
});
|
|
142
|
-
const playwrightDispatcher = new
|
|
133
|
+
const playwrightDispatcher = new import_server.PlaywrightDispatcher(scope, playwright, void 0, void 0, androidDevice);
|
|
143
134
|
this._cleanups.push(() => playwrightDispatcher.cleanup());
|
|
144
135
|
return playwrightDispatcher;
|
|
145
136
|
}
|
|
146
137
|
_initDebugControllerMode() {
|
|
147
|
-
|
|
138
|
+
import_debugLogger.debugLogger.log("server", `[${this._id}] engaged reuse controller mode`);
|
|
148
139
|
const playwright = this._preLaunched.playwright;
|
|
149
|
-
|
|
150
|
-
return new _debugControllerDispatcher.DebugControllerDispatcher(this._dispatcherConnection, playwright.debugController);
|
|
140
|
+
return new import_debugControllerDispatcher.DebugControllerDispatcher(this._dispatcherConnection, playwright.debugController);
|
|
151
141
|
}
|
|
152
142
|
async _initReuseBrowsersMode(scope) {
|
|
153
|
-
|
|
154
|
-
// clients come and go, while the browser stays the same.
|
|
155
|
-
|
|
156
|
-
_debugLogger.debugLogger.log('server', `[${this._id}] engaged reuse browsers mode for ${this._options.browserName}`);
|
|
143
|
+
import_debugLogger.debugLogger.log("server", `[${this._id}] engaged reuse browsers mode for ${this._options.browserName}`);
|
|
157
144
|
const playwright = this._preLaunched.playwright;
|
|
158
145
|
const requestedOptions = launchOptionsHash(this._options.launchOptions);
|
|
159
|
-
let browser = playwright.allBrowsers().find(b => {
|
|
160
|
-
if (b.options.name !== this._options.browserName)
|
|
146
|
+
let browser = playwright.allBrowsers().find((b) => {
|
|
147
|
+
if (b.options.name !== this._options.browserName)
|
|
148
|
+
return false;
|
|
161
149
|
const existingOptions = launchOptionsHash(b.options.originalLaunchOptions);
|
|
162
150
|
return existingOptions === requestedOptions;
|
|
163
151
|
});
|
|
164
|
-
|
|
165
|
-
// Close remaining browsers of this type+channel. Keep different browser types for the speed.
|
|
166
152
|
for (const b of playwright.allBrowsers()) {
|
|
167
|
-
if (b === browser)
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
153
|
+
if (b === browser)
|
|
154
|
+
continue;
|
|
155
|
+
if (b.options.name === this._options.browserName && b.options.channel === this._options.launchOptions.channel)
|
|
156
|
+
await b.close({ reason: "Connection terminated" });
|
|
171
157
|
}
|
|
172
158
|
if (!browser) {
|
|
173
|
-
browser = await playwright[this._options.browserName ||
|
|
159
|
+
browser = await playwright[this._options.browserName || "chromium"].launch((0, import_instrumentation.serverSideCallMetadata)(), {
|
|
174
160
|
...this._options.launchOptions,
|
|
175
161
|
headless: !!process.env.PW_DEBUG_CONTROLLER_HEADLESS
|
|
176
162
|
});
|
|
177
|
-
browser.on(
|
|
178
|
-
|
|
179
|
-
this.close({
|
|
180
|
-
code: 1001,
|
|
181
|
-
reason: 'Browser closed'
|
|
182
|
-
});
|
|
163
|
+
browser.on(import_browser.Browser.Events.Disconnected, () => {
|
|
164
|
+
this.close({ code: 1001, reason: "Browser closed" });
|
|
183
165
|
});
|
|
184
166
|
}
|
|
185
167
|
this._cleanups.push(async () => {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
});else await context.stopPendingOperations('Connection closed');
|
|
168
|
+
for (const browser2 of playwright.allBrowsers()) {
|
|
169
|
+
for (const context of browser2.contexts()) {
|
|
170
|
+
if (!context.pages().length)
|
|
171
|
+
await context.close({ reason: "Connection terminated" });
|
|
172
|
+
else
|
|
173
|
+
await context.stopPendingOperations("Connection closed");
|
|
193
174
|
}
|
|
194
|
-
if (!
|
|
195
|
-
reason:
|
|
196
|
-
});
|
|
175
|
+
if (!browser2.contexts())
|
|
176
|
+
await browser2.close({ reason: "Connection terminated" });
|
|
197
177
|
}
|
|
198
178
|
});
|
|
199
|
-
const playwrightDispatcher = new
|
|
179
|
+
const playwrightDispatcher = new import_server.PlaywrightDispatcher(scope, playwright, void 0, browser);
|
|
200
180
|
return playwrightDispatcher;
|
|
201
181
|
}
|
|
202
182
|
async _createOwnedSocksProxy(playwright) {
|
|
203
|
-
if (!this._options.socksProxyPattern)
|
|
204
|
-
|
|
183
|
+
if (!this._options.socksProxyPattern)
|
|
184
|
+
return;
|
|
185
|
+
const socksProxy = new import_socksProxy.SocksProxy();
|
|
205
186
|
socksProxy.setPattern(this._options.socksProxyPattern);
|
|
206
187
|
playwright.options.socksProxyPort = await socksProxy.listen(0);
|
|
207
|
-
|
|
188
|
+
import_debugLogger.debugLogger.log("server", `[${this._id}] started socks proxy on port ${playwright.options.socksProxyPort}`);
|
|
208
189
|
this._cleanups.push(() => socksProxy.close());
|
|
209
190
|
return socksProxy;
|
|
210
191
|
}
|
|
211
192
|
async _onDisconnect(error) {
|
|
212
193
|
this._disconnected = true;
|
|
213
|
-
|
|
194
|
+
import_debugLogger.debugLogger.log("server", `[${this._id}] disconnected. error: ${error}`);
|
|
214
195
|
this._root._dispose();
|
|
215
|
-
|
|
216
|
-
for (const cleanup of this._cleanups)
|
|
217
|
-
|
|
196
|
+
import_debugLogger.debugLogger.log("server", `[${this._id}] starting cleanup`);
|
|
197
|
+
for (const cleanup of this._cleanups)
|
|
198
|
+
await cleanup().catch(() => {
|
|
199
|
+
});
|
|
200
|
+
await (0, import_profiler.stopProfiling)(this._profileName);
|
|
218
201
|
this._onClose();
|
|
219
|
-
|
|
202
|
+
import_debugLogger.debugLogger.log("server", `[${this._id}] finished cleanup`);
|
|
220
203
|
}
|
|
221
204
|
logServerMetadata(message, messageString, direction) {
|
|
222
205
|
const serverLogMetadata = {
|
|
@@ -224,31 +207,32 @@ class PlaywrightConnection {
|
|
|
224
207
|
id: message.id,
|
|
225
208
|
guid: message.guid,
|
|
226
209
|
method: message.method,
|
|
227
|
-
payloadSizeInBytes: Buffer.byteLength(messageString,
|
|
210
|
+
payloadSizeInBytes: Buffer.byteLength(messageString, "utf-8")
|
|
228
211
|
};
|
|
229
|
-
|
|
212
|
+
import_debugLogger.debugLogger.log("server:metadata", (direction === "SEND" ? "SEND \u25BA " : "\u25C0 RECV ") + JSON.stringify(serverLogMetadata));
|
|
230
213
|
}
|
|
231
214
|
async close(reason) {
|
|
232
|
-
if (this._disconnected)
|
|
233
|
-
|
|
215
|
+
if (this._disconnected)
|
|
216
|
+
return;
|
|
217
|
+
import_debugLogger.debugLogger.log("server", `[${this._id}] force closing connection: ${reason?.reason || ""} (${reason?.code || 0})`);
|
|
234
218
|
try {
|
|
235
|
-
this._ws.close(reason
|
|
236
|
-
} catch (e) {
|
|
219
|
+
this._ws.close(reason?.code, reason?.reason);
|
|
220
|
+
} catch (e) {
|
|
221
|
+
}
|
|
237
222
|
}
|
|
238
223
|
}
|
|
239
|
-
exports.PlaywrightConnection = PlaywrightConnection;
|
|
240
224
|
function launchOptionsHash(options) {
|
|
241
|
-
const copy = {
|
|
242
|
-
...options
|
|
243
|
-
};
|
|
225
|
+
const copy = { ...options };
|
|
244
226
|
for (const k of Object.keys(copy)) {
|
|
245
227
|
const key = k;
|
|
246
|
-
if (copy[key] === defaultLaunchOptions[key])
|
|
228
|
+
if (copy[key] === defaultLaunchOptions[key])
|
|
229
|
+
delete copy[key];
|
|
247
230
|
}
|
|
248
|
-
for (const key of optionsThatAllowBrowserReuse)
|
|
231
|
+
for (const key of optionsThatAllowBrowserReuse)
|
|
232
|
+
delete copy[key];
|
|
249
233
|
return JSON.stringify(copy);
|
|
250
234
|
}
|
|
251
|
-
function filterLaunchOptions(options) {
|
|
235
|
+
function filterLaunchOptions(options, allowFSPaths) {
|
|
252
236
|
return {
|
|
253
237
|
channel: options.channel,
|
|
254
238
|
args: options.args,
|
|
@@ -260,7 +244,8 @@ function filterLaunchOptions(options) {
|
|
|
260
244
|
chromiumSandbox: options.chromiumSandbox,
|
|
261
245
|
firefoxUserPrefs: options.firefoxUserPrefs,
|
|
262
246
|
slowMo: options.slowMo,
|
|
263
|
-
executablePath: (0,
|
|
247
|
+
executablePath: (0, import_debug.isUnderTest)() || allowFSPaths ? options.executablePath : void 0,
|
|
248
|
+
downloadsPath: allowFSPaths ? options.downloadsPath : void 0
|
|
264
249
|
};
|
|
265
250
|
}
|
|
266
251
|
const defaultLaunchOptions = {
|
|
@@ -271,4 +256,11 @@ const defaultLaunchOptions = {
|
|
|
271
256
|
headless: true,
|
|
272
257
|
devtools: false
|
|
273
258
|
};
|
|
274
|
-
const optionsThatAllowBrowserReuse = [
|
|
259
|
+
const optionsThatAllowBrowserReuse = [
|
|
260
|
+
"headless",
|
|
261
|
+
"tracesDir"
|
|
262
|
+
];
|
|
263
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
264
|
+
0 && (module.exports = {
|
|
265
|
+
PlaywrightConnection
|
|
266
|
+
});
|
|
@@ -1,102 +1,105 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var playwrightServer_exports = {};
|
|
20
|
+
__export(playwrightServer_exports, {
|
|
21
|
+
PlaywrightServer: () => PlaywrightServer
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
* Copyright (c) Microsoft Corporation.
|
|
15
|
-
*
|
|
16
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
17
|
-
* you may not use this file except in compliance with the License.
|
|
18
|
-
* You may obtain a copy of the License at
|
|
19
|
-
*
|
|
20
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
21
|
-
*
|
|
22
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
23
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
24
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
25
|
-
* See the License for the specific language governing permissions and
|
|
26
|
-
* limitations under the License.
|
|
27
|
-
*/
|
|
28
|
-
|
|
23
|
+
module.exports = __toCommonJS(playwrightServer_exports);
|
|
24
|
+
var import_playwrightConnection = require("./playwrightConnection");
|
|
25
|
+
var import_playwright = require("../server/playwright");
|
|
26
|
+
var import_debugLogger = require("../server/utils/debugLogger");
|
|
27
|
+
var import_semaphore = require("../utils/isomorphic/semaphore");
|
|
28
|
+
var import_wsServer = require("../server/utils/wsServer");
|
|
29
|
+
var import_ascii = require("../server/utils/ascii");
|
|
30
|
+
var import_userAgent = require("../server/utils/userAgent");
|
|
29
31
|
class PlaywrightServer {
|
|
30
32
|
constructor(options) {
|
|
31
|
-
this._preLaunchedPlaywright = void 0;
|
|
32
|
-
this._options = void 0;
|
|
33
|
-
this._wsServer = void 0;
|
|
34
33
|
this._options = options;
|
|
35
|
-
if (options.preLaunchedBrowser)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
34
|
+
if (options.preLaunchedBrowser)
|
|
35
|
+
this._preLaunchedPlaywright = options.preLaunchedBrowser.attribution.playwright;
|
|
36
|
+
if (options.preLaunchedAndroidDevice)
|
|
37
|
+
this._preLaunchedPlaywright = options.preLaunchedAndroidDevice._android.attribution.playwright;
|
|
38
|
+
const browserSemaphore = new import_semaphore.Semaphore(this._options.maxConnections);
|
|
39
|
+
const controllerSemaphore = new import_semaphore.Semaphore(1);
|
|
40
|
+
const reuseBrowserSemaphore = new import_semaphore.Semaphore(1);
|
|
41
|
+
this._wsServer = new import_wsServer.WSServer({
|
|
41
42
|
onUpgrade: (request, socket) => {
|
|
42
|
-
const uaError =
|
|
43
|
-
if (uaError)
|
|
44
|
-
error: `HTTP/${request.httpVersion} 428 Precondition Required\r
|
|
45
|
-
|
|
43
|
+
const uaError = userAgentVersionMatchesErrorMessage(request.headers["user-agent"] || "");
|
|
44
|
+
if (uaError)
|
|
45
|
+
return { error: `HTTP/${request.httpVersion} 428 Precondition Required\r
|
|
46
|
+
\r
|
|
47
|
+
${uaError}` };
|
|
46
48
|
},
|
|
47
|
-
onHeaders: headers => {
|
|
48
|
-
if (process.env.PWTEST_SERVER_WS_HEADERS)
|
|
49
|
+
onHeaders: (headers) => {
|
|
50
|
+
if (process.env.PWTEST_SERVER_WS_HEADERS)
|
|
51
|
+
headers.push(process.env.PWTEST_SERVER_WS_HEADERS);
|
|
49
52
|
},
|
|
50
53
|
onConnection: (request, url, ws, id) => {
|
|
51
|
-
const browserHeader = request.headers[
|
|
52
|
-
const browserName = url.searchParams.get(
|
|
53
|
-
const proxyHeader = request.headers[
|
|
54
|
-
const proxyValue = url.searchParams.get(
|
|
55
|
-
const launchOptionsHeader = request.headers[
|
|
54
|
+
const browserHeader = request.headers["x-playwright-browser"];
|
|
55
|
+
const browserName = url.searchParams.get("browser") || (Array.isArray(browserHeader) ? browserHeader[0] : browserHeader) || null;
|
|
56
|
+
const proxyHeader = request.headers["x-playwright-proxy"];
|
|
57
|
+
const proxyValue = url.searchParams.get("proxy") || (Array.isArray(proxyHeader) ? proxyHeader[0] : proxyHeader);
|
|
58
|
+
const launchOptionsHeader = request.headers["x-playwright-launch-options"] || "";
|
|
56
59
|
const launchOptionsHeaderValue = Array.isArray(launchOptionsHeader) ? launchOptionsHeader[0] : launchOptionsHeader;
|
|
57
|
-
const launchOptionsParam = url.searchParams.get(
|
|
60
|
+
const launchOptionsParam = url.searchParams.get("launch-options");
|
|
58
61
|
let launchOptions = {};
|
|
59
62
|
try {
|
|
60
63
|
launchOptions = JSON.parse(launchOptionsParam || launchOptionsHeaderValue);
|
|
61
|
-
} catch (e) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const isExtension = this._options.mode === 'extension';
|
|
64
|
+
} catch (e) {
|
|
65
|
+
}
|
|
66
|
+
const isExtension = this._options.mode === "extension";
|
|
65
67
|
if (isExtension) {
|
|
66
|
-
if (!this._preLaunchedPlaywright)
|
|
67
|
-
sdkLanguage:
|
|
68
|
-
isServer: true
|
|
69
|
-
});
|
|
68
|
+
if (!this._preLaunchedPlaywright)
|
|
69
|
+
this._preLaunchedPlaywright = (0, import_playwright.createPlaywright)({ sdkLanguage: "javascript", isServer: true });
|
|
70
70
|
}
|
|
71
|
-
let clientType =
|
|
71
|
+
let clientType = "launch-browser";
|
|
72
72
|
let semaphore = browserSemaphore;
|
|
73
|
-
if (isExtension && url.searchParams.has(
|
|
74
|
-
clientType =
|
|
73
|
+
if (isExtension && url.searchParams.has("debug-controller")) {
|
|
74
|
+
clientType = "controller";
|
|
75
75
|
semaphore = controllerSemaphore;
|
|
76
76
|
} else if (isExtension) {
|
|
77
|
-
clientType =
|
|
77
|
+
clientType = "reuse-browser";
|
|
78
78
|
semaphore = reuseBrowserSemaphore;
|
|
79
|
-
} else if (this._options.mode ===
|
|
80
|
-
clientType =
|
|
79
|
+
} else if (this._options.mode === "launchServer") {
|
|
80
|
+
clientType = "pre-launched-browser-or-android";
|
|
81
81
|
semaphore = browserSemaphore;
|
|
82
82
|
}
|
|
83
|
-
return new
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
83
|
+
return new import_playwrightConnection.PlaywrightConnection(
|
|
84
|
+
semaphore.acquire(),
|
|
85
|
+
clientType,
|
|
86
|
+
ws,
|
|
87
|
+
{ socksProxyPattern: proxyValue, browserName, launchOptions, allowFSPaths: this._options.mode === "extension" },
|
|
88
|
+
{
|
|
89
|
+
playwright: this._preLaunchedPlaywright,
|
|
90
|
+
browser: this._options.preLaunchedBrowser,
|
|
91
|
+
androidDevice: this._options.preLaunchedAndroidDevice,
|
|
92
|
+
socksProxy: this._options.preLaunchedSocksProxy
|
|
93
|
+
},
|
|
94
|
+
id,
|
|
95
|
+
() => semaphore.release()
|
|
96
|
+
);
|
|
93
97
|
},
|
|
94
98
|
onClose: async () => {
|
|
95
|
-
|
|
96
|
-
if (this._preLaunchedPlaywright)
|
|
97
|
-
reason:
|
|
98
|
-
|
|
99
|
-
_debugLogger.debugLogger.log('server', 'closed browsers');
|
|
99
|
+
import_debugLogger.debugLogger.log("server", "closing browsers");
|
|
100
|
+
if (this._preLaunchedPlaywright)
|
|
101
|
+
await Promise.all(this._preLaunchedPlaywright.allBrowsers().map((browser) => browser.close({ reason: "Playwright Server stopped" })));
|
|
102
|
+
import_debugLogger.debugLogger.log("server", "closed browsers");
|
|
100
103
|
}
|
|
101
104
|
});
|
|
102
105
|
}
|
|
@@ -107,4 +110,30 @@ class PlaywrightServer {
|
|
|
107
110
|
await this._wsServer.close();
|
|
108
111
|
}
|
|
109
112
|
}
|
|
110
|
-
|
|
113
|
+
function userAgentVersionMatchesErrorMessage(userAgent) {
|
|
114
|
+
const match = userAgent.match(/^Playwright\/(\d+\.\d+\.\d+)/);
|
|
115
|
+
if (!match) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const received = match[1].split(".").slice(0, 2).join(".");
|
|
119
|
+
const expected = (0, import_userAgent.getPlaywrightVersion)(true);
|
|
120
|
+
if (received !== expected) {
|
|
121
|
+
return (0, import_ascii.wrapInASCIIBox)([
|
|
122
|
+
`Playwright version mismatch:`,
|
|
123
|
+
` - server version: v${expected}`,
|
|
124
|
+
` - client version: v${received}`,
|
|
125
|
+
``,
|
|
126
|
+
`If you are using VSCode extension, restart VSCode.`,
|
|
127
|
+
``,
|
|
128
|
+
`If you are connecting to a remote service,`,
|
|
129
|
+
`keep your local Playwright version in sync`,
|
|
130
|
+
`with the remote service version.`,
|
|
131
|
+
``,
|
|
132
|
+
`<3 Playwright Team`
|
|
133
|
+
].join("\n"), 1);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
137
|
+
0 && (module.exports = {
|
|
138
|
+
PlaywrightServer
|
|
139
|
+
});
|