@checkly/playwright-core 1.51.17-beta.2 → 1.54.2-beta.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 +65 -123
- package/browsers.json +16 -14
- package/index.js +1 -1
- package/lib/androidServerImpl.js +47 -50
- package/lib/browserServerImpl.js +89 -69
- package/lib/checkly/escapeRegExp.js +23 -27
- package/lib/checkly/fetch.js +64 -46
- package/lib/checkly/secretsFilter.js +49 -35
- package/lib/cli/driver.js +71 -69
- package/lib/cli/program.js +400 -359
- package/lib/cli/programWithTestStub.js +51 -45
- package/lib/client/accessibility.js +31 -32
- package/lib/client/android.js +151 -242
- package/lib/client/api.js +135 -283
- package/lib/client/artifact.js +39 -36
- package/lib/client/browser.js +96 -71
- package/lib/client/browserContext.js +314 -345
- package/lib/client/browserType.js +103 -127
- package/lib/client/cdpSession.js +29 -31
- package/lib/client/channelOwner.js +90 -113
- package/lib/client/clientHelper.js +48 -39
- package/lib/client/clientInstrumentation.js +40 -37
- package/lib/client/clientStackTrace.js +41 -37
- package/lib/client/clock.js +36 -36
- package/lib/client/connection.js +188 -214
- package/lib/client/consoleMessage.js +31 -28
- package/lib/client/coverage.js +25 -22
- package/lib/client/dialog.js +30 -31
- package/lib/client/download.js +25 -25
- package/lib/client/electron.js +80 -77
- package/lib/client/elementHandle.js +120 -159
- package/lib/client/errors.js +53 -53
- package/lib/client/eventEmitter.js +124 -121
- package/lib/client/events.js +72 -68
- package/lib/client/fetch.js +166 -190
- package/lib/client/fileChooser.js +25 -24
- package/lib/client/fileUtils.js +31 -28
- package/lib/client/frame.js +207 -306
- package/lib/client/harRouter.js +42 -52
- package/lib/client/input.js +42 -69
- package/lib/client/jsHandle.js +54 -69
- package/lib/client/jsonPipe.js +27 -23
- package/lib/client/localUtils.js +29 -29
- package/lib/client/locator.js +145 -237
- package/lib/client/network.js +282 -307
- package/lib/client/page.js +269 -318
- package/lib/client/platform.js +46 -43
- package/lib/client/playwright.js +51 -76
- package/lib/client/selectors.js +45 -63
- package/lib/client/stream.js +29 -25
- package/lib/client/timeoutSettings.js +55 -41
- package/lib/client/tracing.js +49 -96
- package/lib/client/types.js +26 -22
- package/lib/client/video.js +35 -27
- package/lib/client/waiter.js +69 -88
- package/lib/client/webError.js +25 -23
- package/lib/client/webSocket.js +43 -56
- package/lib/client/worker.js +48 -56
- package/lib/client/writableStream.js +27 -23
- package/lib/generated/bindingsControllerSource.js +28 -0
- package/lib/generated/clockSource.js +26 -6
- package/lib/generated/consoleApiSource.js +26 -6
- package/lib/generated/injectedScriptSource.js +26 -6
- package/lib/generated/pollingRecorderSource.js +26 -6
- package/lib/generated/storageScriptSource.js +28 -0
- package/lib/generated/utilityScriptSource.js +26 -6
- package/lib/generated/webSocketMockSource.js +333 -5
- package/lib/inProcessFactory.js +51 -53
- package/lib/inprocess.js +2 -19
- package/lib/outofprocess.js +51 -46
- package/lib/protocol/serializers.js +153 -134
- package/lib/protocol/validator.js +2807 -2739
- package/lib/protocol/validatorPrimitives.js +114 -73
- package/lib/remote/playwrightConnection.js +88 -242
- package/lib/remote/playwrightServer.js +305 -92
- package/lib/server/accessibility.js +44 -37
- package/lib/server/android/android.js +251 -241
- package/lib/server/android/backendAdb.js +87 -82
- package/lib/server/artifact.js +78 -55
- package/lib/server/bidi/bidiBrowser.js +297 -158
- package/lib/server/bidi/bidiChromium.js +119 -89
- package/lib/server/bidi/bidiConnection.js +66 -83
- package/lib/server/bidi/bidiExecutionContext.js +129 -113
- package/lib/server/bidi/bidiFirefox.js +86 -76
- package/lib/server/bidi/bidiInput.js +106 -117
- package/lib/server/bidi/bidiNetworkManager.js +142 -159
- package/lib/server/bidi/bidiOverCdp.js +57 -58
- package/lib/server/bidi/bidiPage.js +260 -260
- package/lib/server/bidi/bidiPdf.js +52 -86
- package/lib/server/bidi/third_party/bidiCommands.d.js +22 -0
- package/lib/server/bidi/third_party/bidiDeserializer.js +55 -50
- package/lib/server/bidi/third_party/bidiKeyboard.js +236 -220
- package/lib/server/bidi/third_party/bidiProtocol.js +22 -137
- package/lib/server/bidi/third_party/bidiProtocolCore.js +152 -0
- package/lib/server/bidi/third_party/bidiProtocolPermissions.js +42 -0
- package/lib/server/bidi/third_party/bidiSerializer.js +67 -63
- package/lib/server/bidi/third_party/firefoxPrefs.js +141 -119
- package/lib/server/browser.js +93 -95
- package/lib/server/browserContext.js +419 -429
- package/lib/server/browserType.js +186 -216
- package/lib/server/callLog.js +47 -44
- package/lib/server/chromium/chromium.js +235 -203
- package/lib/server/chromium/chromiumSwitches.js +100 -67
- package/lib/server/chromium/crAccessibility.js +157 -131
- package/lib/server/chromium/crBrowser.js +310 -292
- package/lib/server/chromium/crConnection.js +95 -121
- package/lib/server/chromium/crCoverage.js +121 -131
- package/lib/server/chromium/crDevTools.js +60 -51
- package/lib/server/chromium/crDragDrop.js +68 -84
- package/lib/server/chromium/crExecutionContext.js +89 -83
- package/lib/server/chromium/crInput.js +118 -113
- package/lib/server/chromium/crNetworkManager.js +274 -375
- package/lib/server/chromium/crPage.js +536 -593
- package/lib/server/chromium/crPdf.js +54 -86
- package/lib/server/chromium/crProtocolHelper.js +92 -80
- package/lib/server/chromium/crServiceWorker.js +84 -73
- package/lib/server/chromium/defaultFontFamilies.js +152 -135
- package/lib/server/chromium/protocol.d.js +16 -0
- package/lib/server/chromium/videoRecorder.js +66 -99
- package/lib/server/clock.js +107 -83
- package/lib/server/codegen/csharp.js +192 -162
- package/lib/server/codegen/java.js +156 -129
- package/lib/server/codegen/javascript.js +163 -148
- package/lib/server/codegen/jsonl.js +32 -28
- package/lib/server/codegen/language.js +75 -52
- package/lib/server/codegen/languages.js +65 -27
- package/lib/server/codegen/python.js +141 -126
- package/lib/server/codegen/types.js +15 -4
- package/lib/server/console.js +28 -32
- package/lib/server/cookieStore.js +108 -86
- package/lib/server/debugController.js +147 -151
- package/lib/server/debugger.js +86 -78
- package/lib/server/deviceDescriptors.js +37 -24
- package/lib/server/deviceDescriptorsSource.json +238 -128
- package/lib/server/dialog.js +84 -39
- package/lib/server/dispatchers/androidDispatcher.js +257 -148
- package/lib/server/dispatchers/artifactDispatcher.js +79 -79
- package/lib/server/dispatchers/browserContextDispatcher.js +289 -259
- package/lib/server/dispatchers/browserDispatcher.js +96 -148
- package/lib/server/dispatchers/browserTypeDispatcher.js +50 -41
- package/lib/server/dispatchers/cdpSessionDispatcher.js +35 -39
- package/lib/server/dispatchers/debugControllerDispatcher.js +65 -83
- package/lib/server/dispatchers/dialogDispatcher.js +34 -31
- package/lib/server/dispatchers/dispatcher.js +208 -248
- package/lib/server/dispatchers/electronDispatcher.js +66 -70
- package/lib/server/dispatchers/elementHandlerDispatcher.js +164 -216
- package/lib/server/dispatchers/frameDispatcher.js +211 -272
- package/lib/server/dispatchers/jsHandleDispatcher.js +63 -75
- package/lib/server/dispatchers/jsonPipeDispatcher.js +37 -38
- package/lib/server/dispatchers/localUtilsDispatcher.js +121 -119
- package/lib/server/dispatchers/networkDispatchers.js +117 -128
- package/lib/server/dispatchers/pageDispatcher.js +256 -248
- package/lib/server/dispatchers/playwrightDispatcher.js +92 -87
- package/lib/server/dispatchers/streamDispatcher.js +52 -48
- package/lib/server/dispatchers/tracingDispatcher.js +47 -52
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +126 -150
- package/lib/server/dispatchers/writableStreamDispatcher.js +65 -43
- package/lib/server/dom.js +485 -582
- package/lib/server/download.js +47 -37
- package/lib/server/electron/electron.js +216 -243
- package/lib/server/electron/loader.js +9 -37
- package/lib/server/errors.js +47 -46
- package/lib/server/fetch.js +317 -360
- package/lib/server/fileChooser.js +25 -24
- package/lib/server/fileUploadUtils.js +66 -60
- package/lib/server/firefox/ffAccessibility.js +153 -131
- package/lib/server/firefox/ffBrowser.js +268 -305
- package/lib/server/firefox/ffConnection.js +63 -84
- package/lib/server/firefox/ffExecutionContext.js +92 -73
- package/lib/server/firefox/ffInput.js +82 -84
- package/lib/server/firefox/ffNetworkManager.js +137 -114
- package/lib/server/firefox/ffPage.js +261 -293
- package/lib/server/firefox/firefox.js +80 -72
- package/lib/server/firefox/protocol.d.js +16 -0
- package/lib/server/formData.js +107 -35
- package/lib/server/frameSelectors.js +98 -114
- package/lib/server/frames.js +845 -1055
- package/lib/server/har/harRecorder.js +85 -77
- package/lib/server/har/harTracer.js +290 -223
- package/lib/server/harBackend.js +80 -80
- package/lib/server/helper.js +55 -59
- package/lib/server/index.js +59 -99
- package/lib/server/input.js +151 -189
- package/lib/server/instrumentation.js +57 -44
- package/lib/server/javascript.js +133 -134
- package/lib/server/launchApp.js +113 -75
- package/lib/server/localUtils.js +150 -142
- package/lib/server/macEditingCommands.js +141 -137
- package/lib/server/network.js +299 -303
- package/lib/server/page.js +513 -544
- package/lib/server/pipeTransport.js +49 -45
- package/lib/server/playwright.js +58 -67
- package/lib/server/progress.js +137 -68
- package/lib/server/protocolError.js +34 -31
- package/lib/server/recorder/chat.js +70 -86
- package/lib/server/recorder/recorderApp.js +341 -176
- package/lib/server/recorder/recorderInTraceViewer.js +65 -94
- package/lib/server/recorder/recorderRunner.js +93 -116
- package/lib/server/recorder/recorderSignalProcessor.js +83 -0
- package/lib/server/recorder/recorderUtils.js +104 -47
- package/lib/server/recorder/throttledFile.js +42 -30
- package/lib/server/recorder.js +395 -275
- package/lib/server/registry/browserFetcher.js +106 -101
- package/lib/server/registry/dependencies.js +245 -196
- package/lib/server/registry/index.js +930 -803
- package/lib/server/registry/nativeDeps.js +1073 -464
- package/lib/server/registry/oopDownloadBrowserMain.js +57 -75
- package/lib/server/screenshotter.js +160 -191
- package/lib/server/selectors.js +90 -51
- package/lib/server/socksClientCertificatesInterceptor.js +171 -186
- package/lib/server/socksInterceptor.js +62 -70
- package/lib/server/trace/recorder/snapshotter.js +76 -102
- package/lib/server/trace/recorder/snapshotterInjected.js +238 -217
- package/lib/server/trace/recorder/tracing.js +354 -362
- package/lib/server/trace/test/inMemorySnapshotter.js +46 -52
- package/lib/server/trace/viewer/traceViewer.js +160 -147
- package/lib/server/transport.js +119 -134
- package/lib/server/types.js +26 -22
- package/lib/server/usKeyboardLayout.js +135 -545
- package/lib/server/utils/ascii.js +39 -26
- package/lib/server/utils/comparators.js +105 -103
- package/lib/server/utils/crypto.js +157 -112
- package/lib/server/utils/debug.js +36 -32
- package/lib/server/utils/debugLogger.js +77 -48
- package/lib/server/utils/env.js +52 -37
- package/lib/server/utils/eventsHelper.js +29 -28
- package/lib/server/utils/expectUtils.js +31 -26
- package/lib/server/utils/fileUtils.js +123 -136
- package/lib/server/utils/happyEyeballs.js +141 -126
- package/lib/server/utils/hostPlatform.js +84 -120
- package/lib/server/utils/httpServer.js +106 -121
- package/lib/server/utils/image_tools/colorUtils.js +42 -51
- package/lib/server/utils/image_tools/compare.js +44 -43
- package/lib/server/utils/image_tools/imageChannel.js +38 -30
- package/lib/server/utils/image_tools/stats.js +40 -40
- package/lib/server/utils/linuxUtils.js +50 -37
- package/lib/server/utils/network.js +152 -96
- package/lib/server/utils/nodePlatform.js +87 -79
- package/lib/server/utils/pipeTransport.js +44 -42
- package/lib/server/utils/processLauncher.js +111 -121
- package/lib/server/utils/profiler.js +52 -39
- package/lib/server/utils/socksProxy.js +280 -339
- package/lib/server/utils/spawnAsync.js +37 -41
- package/lib/server/utils/task.js +31 -38
- package/lib/server/utils/userAgent.js +73 -66
- package/lib/server/utils/wsServer.js +68 -75
- package/lib/server/utils/zipFile.js +36 -37
- package/lib/server/utils/zones.js +37 -34
- package/lib/server/webkit/protocol.d.js +16 -0
- package/lib/server/webkit/webkit.js +77 -61
- package/lib/server/webkit/wkAccessibility.js +161 -118
- package/lib/server/webkit/wkBrowser.js +193 -184
- package/lib/server/webkit/wkConnection.js +59 -83
- package/lib/server/webkit/wkExecutionContext.js +85 -70
- package/lib/server/webkit/wkInput.js +97 -95
- package/lib/server/webkit/wkInterceptableRequest.js +102 -95
- package/lib/server/webkit/wkPage.js +568 -667
- package/lib/server/webkit/wkProvisionalPage.js +45 -56
- package/lib/server/webkit/wkWorkers.js +79 -79
- package/lib/utils/expectUtils.js +31 -26
- package/lib/utils/isomorphic/ariaSnapshot.js +149 -152
- package/lib/utils/isomorphic/assert.js +28 -22
- package/lib/utils/isomorphic/colors.js +66 -59
- package/lib/utils/isomorphic/cssParser.js +120 -125
- package/lib/utils/isomorphic/cssTokenizer.js +436 -364
- package/lib/utils/isomorphic/headers.js +38 -37
- package/lib/utils/isomorphic/locatorGenerators.js +358 -357
- package/lib/utils/isomorphic/locatorParser.js +96 -105
- package/lib/utils/isomorphic/locatorUtils.js +63 -44
- package/lib/utils/isomorphic/manualPromise.js +46 -39
- package/lib/utils/isomorphic/mimeType.js +447 -25
- package/lib/utils/isomorphic/multimap.js +34 -27
- package/lib/utils/isomorphic/protocolFormatter.js +68 -0
- package/lib/utils/isomorphic/protocolMetainfo.js +321 -0
- package/lib/utils/isomorphic/recorderUtils.js +140 -181
- package/lib/utils/isomorphic/rtti.js +35 -33
- package/lib/utils/isomorphic/selectorParser.js +182 -193
- package/lib/utils/isomorphic/semaphore.js +27 -24
- package/lib/utils/isomorphic/stackTrace.js +87 -98
- package/lib/utils/isomorphic/stringUtils.js +98 -112
- package/lib/utils/isomorphic/time.js +46 -22
- package/lib/utils/isomorphic/timeoutRunner.js +53 -53
- package/lib/utils/isomorphic/traceUtils.js +37 -41
- package/lib/utils/isomorphic/types.js +15 -4
- package/lib/utils/isomorphic/urlMatch.js +113 -67
- package/lib/utils/isomorphic/utilityScriptSerializers.js +251 -0
- package/lib/utils.js +101 -443
- package/lib/utilsBundle.js +101 -52
- package/lib/utilsBundleImpl/index.js +160 -150
- package/lib/zipBundle.js +32 -23
- package/lib/zipBundleImpl.js +4 -4
- package/package.json +1 -1
- package/types/protocol.d.ts +1267 -1057
- package/types/types.d.ts +131 -29
- 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/compare.js +0 -108
- package/lib/image_tools/imageChannel.js +0 -70
- package/lib/image_tools/stats.js +0 -102
- package/lib/protocol/debug.js +0 -27
- package/lib/protocol/transport.js +0 -82
- package/lib/server/dispatchers/selectorsDispatcher.js +0 -36
- package/lib/server/isomorphic/utilityScriptSerializers.js +0 -229
- package/lib/server/recorder/contextRecorder.js +0 -290
- package/lib/server/recorder/recorderCollection.js +0 -104
- package/lib/server/recorder/recorderFrontend.js +0 -5
- package/lib/server/storageScript.js +0 -160
- package/lib/server/timeoutSettings.js +0 -74
- package/lib/third_party/diff_match_patch.js +0 -2222
- package/lib/utils/ascii.js +0 -31
- package/lib/utils/comparators.js +0 -171
- package/lib/utils/crypto.js +0 -174
- 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/fileUtils.js +0 -205
- package/lib/utils/happy-eyeballs.js +0 -210
- package/lib/utils/headers.js +0 -52
- package/lib/utils/hostPlatform.js +0 -133
- package/lib/utils/httpServer.js +0 -237
- package/lib/utils/index.js +0 -368
- 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/spawnAsync.js +0 -45
- package/lib/utils/stackTrace.js +0 -121
- 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 -62
- package/lib/vite/htmlReport/index.html +0 -69
- package/lib/vite/recorder/assets/codeMirrorModule-B9YMkrwa.js +0 -24
- package/lib/vite/recorder/assets/codeMirrorModule-C3UTv-Ge.css +0 -1
- package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- package/lib/vite/recorder/assets/index-ELPgmkwA.js +0 -184
- package/lib/vite/recorder/assets/index-eHBmevrY.css +0 -1
- package/lib/vite/recorder/index.html +0 -29
- package/lib/vite/recorder/playwright-logo.svg +0 -9
- package/lib/vite/traceViewer/assets/codeMirrorModule-gU1OOCQO.js +0 -24
- package/lib/vite/traceViewer/assets/defaultSettingsView-B5n_FjMx.js +0 -1
- package/lib/vite/traceViewer/assets/inspectorTab-6Tru8Mn_.js +0 -235
- package/lib/vite/traceViewer/assets/workbench-B_Nj4NA2.js +0 -25
- package/lib/vite/traceViewer/assets/xtermModule-BoAIEibi.js +0 -9
- package/lib/vite/traceViewer/codeMirrorModule.C3UTv-Ge.css +0 -1
- package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- package/lib/vite/traceViewer/defaultSettingsView.CO3FR0CX.css +0 -1
- package/lib/vite/traceViewer/embedded.DpNPH6mk.js +0 -2
- package/lib/vite/traceViewer/embedded.html +0 -18
- package/lib/vite/traceViewer/embedded.mLhjB5IF.css +0 -1
- package/lib/vite/traceViewer/index.CFOW-Ezb.css +0 -1
- package/lib/vite/traceViewer/index.CuE3SYGw.js +0 -2
- package/lib/vite/traceViewer/index.html +0 -47
- package/lib/vite/traceViewer/inspectorTab.CXDulcFG.css +0 -1
- package/lib/vite/traceViewer/playwright-logo.svg +0 -9
- package/lib/vite/traceViewer/recorder.BD-uZJs7.js +0 -2
- package/lib/vite/traceViewer/recorder.html +0 -17
- package/lib/vite/traceViewer/recorder.tn0RQdqM.css +0 -0
- package/lib/vite/traceViewer/snapshot.html +0 -21
- package/lib/vite/traceViewer/sw.bundle.js +0 -3
- package/lib/vite/traceViewer/uiMode.BatfzHMG.css +0 -1
- package/lib/vite/traceViewer/uiMode.DHrNgddz.js +0 -5
- package/lib/vite/traceViewer/uiMode.html +0 -21
- package/lib/vite/traceViewer/workbench.B9vIAzH9.css +0 -1
- package/lib/vite/traceViewer/xtermModule.Beg8tuEN.css +0 -32
|
@@ -1,71 +1,78 @@
|
|
|
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 android_exports = {};
|
|
30
|
+
__export(android_exports, {
|
|
31
|
+
Android: () => Android,
|
|
32
|
+
AndroidDevice: () => AndroidDevice
|
|
5
33
|
});
|
|
6
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
* Copyright Microsoft Corporation. All rights reserved.
|
|
31
|
-
*
|
|
32
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
33
|
-
* you may not use this file except in compliance with the License.
|
|
34
|
-
* You may obtain a copy of the License at
|
|
35
|
-
*
|
|
36
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
37
|
-
*
|
|
38
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
39
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
40
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
41
|
-
* See the License for the specific language governing permissions and
|
|
42
|
-
* limitations under the License.
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
const ARTIFACTS_FOLDER = _path.default.join(_os.default.tmpdir(), 'playwright-artifacts-');
|
|
46
|
-
class Android extends _instrumentation.SdkObject {
|
|
34
|
+
module.exports = __toCommonJS(android_exports);
|
|
35
|
+
var import_events = require("events");
|
|
36
|
+
var import_fs = __toESM(require("fs"));
|
|
37
|
+
var import_os = __toESM(require("os"));
|
|
38
|
+
var import_path = __toESM(require("path"));
|
|
39
|
+
var import_pipeTransport = require("../utils/pipeTransport");
|
|
40
|
+
var import_crypto = require("../utils/crypto");
|
|
41
|
+
var import_debug = require("../utils/debug");
|
|
42
|
+
var import_env = require("../utils/env");
|
|
43
|
+
var import_task = require("../utils/task");
|
|
44
|
+
var import_debugLogger = require("../utils/debugLogger");
|
|
45
|
+
var import_utilsBundle = require("../../utilsBundle");
|
|
46
|
+
var import_utilsBundle2 = require("../../utilsBundle");
|
|
47
|
+
var import_browserContext = require("../browserContext");
|
|
48
|
+
var import_chromiumSwitches = require("../chromium/chromiumSwitches");
|
|
49
|
+
var import_crBrowser = require("../chromium/crBrowser");
|
|
50
|
+
var import_fileUtils = require("../utils/fileUtils");
|
|
51
|
+
var import_helper = require("../helper");
|
|
52
|
+
var import_instrumentation = require("../instrumentation");
|
|
53
|
+
var import_processLauncher = require("../utils/processLauncher");
|
|
54
|
+
var import_progress = require("../progress");
|
|
55
|
+
var import_registry = require("../registry");
|
|
56
|
+
const ARTIFACTS_FOLDER = import_path.default.join(import_os.default.tmpdir(), "playwright-artifacts-");
|
|
57
|
+
class Android extends import_instrumentation.SdkObject {
|
|
47
58
|
constructor(parent, backend) {
|
|
48
|
-
super(parent,
|
|
49
|
-
this.
|
|
50
|
-
this._devices = new Map();
|
|
51
|
-
this._timeoutSettings = void 0;
|
|
59
|
+
super(parent, "android");
|
|
60
|
+
this._devices = /* @__PURE__ */ new Map();
|
|
52
61
|
this._backend = backend;
|
|
53
|
-
this._timeoutSettings = new _timeoutSettings.TimeoutSettings();
|
|
54
62
|
}
|
|
55
|
-
|
|
56
|
-
this.
|
|
57
|
-
|
|
58
|
-
async devices(options) {
|
|
59
|
-
const devices = (await this._backend.devices(options)).filter(d => d.status === 'device');
|
|
60
|
-
const newSerials = new Set();
|
|
63
|
+
async devices(progress, options) {
|
|
64
|
+
const devices = (await progress.race(this._backend.devices(options))).filter((d) => d.status === "device");
|
|
65
|
+
const newSerials = /* @__PURE__ */ new Set();
|
|
61
66
|
for (const d of devices) {
|
|
62
67
|
newSerials.add(d.serial);
|
|
63
|
-
if (this._devices.has(d.serial))
|
|
64
|
-
|
|
68
|
+
if (this._devices.has(d.serial))
|
|
69
|
+
continue;
|
|
70
|
+
const device = await progress.raceWithCleanup(AndroidDevice.create(this, d, options), (device2) => device2.close());
|
|
65
71
|
this._devices.set(d.serial, device);
|
|
66
72
|
}
|
|
67
73
|
for (const d of this._devices.keys()) {
|
|
68
|
-
if (!newSerials.has(d))
|
|
74
|
+
if (!newSerials.has(d))
|
|
75
|
+
this._devices.delete(d);
|
|
69
76
|
}
|
|
70
77
|
return [...this._devices.values()];
|
|
71
78
|
}
|
|
@@ -73,33 +80,31 @@ class Android extends _instrumentation.SdkObject {
|
|
|
73
80
|
this._devices.delete(device.serial);
|
|
74
81
|
}
|
|
75
82
|
}
|
|
76
|
-
|
|
77
|
-
class AndroidDevice extends _instrumentation.SdkObject {
|
|
83
|
+
class AndroidDevice extends import_instrumentation.SdkObject {
|
|
78
84
|
constructor(android, backend, model, options) {
|
|
79
|
-
super(android,
|
|
80
|
-
this._backend = void 0;
|
|
81
|
-
this.model = void 0;
|
|
82
|
-
this.serial = void 0;
|
|
83
|
-
this._options = void 0;
|
|
84
|
-
this._driverPromise = void 0;
|
|
85
|
+
super(android, "android-device");
|
|
85
86
|
this._lastId = 0;
|
|
86
|
-
this._callbacks = new Map();
|
|
87
|
-
this.
|
|
88
|
-
this.
|
|
89
|
-
this._webViews = new Map();
|
|
90
|
-
this._browserConnections = new Set();
|
|
91
|
-
this._android = void 0;
|
|
87
|
+
this._callbacks = /* @__PURE__ */ new Map();
|
|
88
|
+
this._webViews = /* @__PURE__ */ new Map();
|
|
89
|
+
this._browserConnections = /* @__PURE__ */ new Set();
|
|
92
90
|
this._isClosed = false;
|
|
93
91
|
this._android = android;
|
|
94
92
|
this._backend = backend;
|
|
95
93
|
this.model = model;
|
|
96
94
|
this.serial = backend.serial;
|
|
97
95
|
this._options = options;
|
|
98
|
-
this.
|
|
96
|
+
this.logName = "browser";
|
|
97
|
+
}
|
|
98
|
+
static {
|
|
99
|
+
this.Events = {
|
|
100
|
+
WebViewAdded: "webViewAdded",
|
|
101
|
+
WebViewRemoved: "webViewRemoved",
|
|
102
|
+
Close: "close"
|
|
103
|
+
};
|
|
99
104
|
}
|
|
100
105
|
static async create(android, backend, options) {
|
|
101
106
|
await backend.init();
|
|
102
|
-
const model = await backend.runCommand(
|
|
107
|
+
const model = await backend.runCommand("shell:getprop ro.product.model");
|
|
103
108
|
const device = new AndroidDevice(android, backend, model.toString().trim(), options);
|
|
104
109
|
await device._init();
|
|
105
110
|
return device;
|
|
@@ -108,248 +113,258 @@ class AndroidDevice extends _instrumentation.SdkObject {
|
|
|
108
113
|
await this._refreshWebViews();
|
|
109
114
|
const poll = () => {
|
|
110
115
|
this._pollingWebViews = setTimeout(() => this._refreshWebViews().then(poll).catch(() => {
|
|
111
|
-
this.close().catch(() => {
|
|
116
|
+
this.close().catch(() => {
|
|
117
|
+
});
|
|
112
118
|
}), 500);
|
|
113
119
|
};
|
|
114
120
|
poll();
|
|
115
121
|
}
|
|
116
|
-
setDefaultTimeout(timeout) {
|
|
117
|
-
this._timeoutSettings.setDefaultTimeout(timeout);
|
|
118
|
-
}
|
|
119
122
|
async shell(command) {
|
|
120
123
|
const result = await this._backend.runCommand(`shell:${command}`);
|
|
121
124
|
await this._refreshWebViews();
|
|
122
125
|
return result;
|
|
123
126
|
}
|
|
124
|
-
async open(command) {
|
|
125
|
-
return await this._backend.open(`${command}`);
|
|
127
|
+
async open(progress, command) {
|
|
128
|
+
return await progress.raceWithCleanup(this._backend.open(`${command}`), (socket) => socket.close());
|
|
126
129
|
}
|
|
127
130
|
async screenshot() {
|
|
128
131
|
return await this._backend.runCommand(`shell:screencap -p`);
|
|
129
132
|
}
|
|
130
133
|
async _driver() {
|
|
131
|
-
if (this._isClosed)
|
|
132
|
-
|
|
134
|
+
if (this._isClosed)
|
|
135
|
+
return;
|
|
136
|
+
if (!this._driverPromise) {
|
|
137
|
+
const controller = new import_progress.ProgressController((0, import_instrumentation.serverSideCallMetadata)(), this);
|
|
138
|
+
this._driverPromise = controller.run((progress) => this._installDriver(progress));
|
|
139
|
+
}
|
|
133
140
|
return this._driverPromise;
|
|
134
141
|
}
|
|
135
|
-
async _installDriver() {
|
|
136
|
-
(0,
|
|
137
|
-
await this.shell(`am force-stop com.microsoft.playwright.androiddriver`);
|
|
138
|
-
|
|
139
|
-
// uninstall and install driver on every execution
|
|
142
|
+
async _installDriver(progress) {
|
|
143
|
+
(0, import_utilsBundle.debug)("pw:android")("Stopping the old driver");
|
|
144
|
+
await progress.race(this.shell(`am force-stop com.microsoft.playwright.androiddriver`));
|
|
140
145
|
if (!this._options.omitDriverInstall) {
|
|
141
|
-
(0,
|
|
142
|
-
await this.shell(`cmd package uninstall com.microsoft.playwright.androiddriver`);
|
|
143
|
-
await this.shell(`cmd package uninstall com.microsoft.playwright.androiddriver.test`);
|
|
144
|
-
(0,
|
|
145
|
-
const executable =
|
|
146
|
-
const packageManagerCommand = (0,
|
|
147
|
-
for (const file of [
|
|
148
|
-
const fullName =
|
|
149
|
-
if (!
|
|
150
|
-
|
|
146
|
+
(0, import_utilsBundle.debug)("pw:android")("Uninstalling the old driver");
|
|
147
|
+
await progress.race(this.shell(`cmd package uninstall com.microsoft.playwright.androiddriver`));
|
|
148
|
+
await progress.race(this.shell(`cmd package uninstall com.microsoft.playwright.androiddriver.test`));
|
|
149
|
+
(0, import_utilsBundle.debug)("pw:android")("Installing the new driver");
|
|
150
|
+
const executable = import_registry.registry.findExecutable("android");
|
|
151
|
+
const packageManagerCommand = (0, import_env.getPackageManagerExecCommand)();
|
|
152
|
+
for (const file of ["android-driver.apk", "android-driver-target.apk"]) {
|
|
153
|
+
const fullName = import_path.default.join(executable.directory, file);
|
|
154
|
+
if (!import_fs.default.existsSync(fullName))
|
|
155
|
+
throw new Error(`Please install Android driver apk using '${packageManagerCommand} playwright install android'`);
|
|
156
|
+
await this.installApk(progress, await progress.race(import_fs.default.promises.readFile(fullName)));
|
|
151
157
|
}
|
|
152
158
|
} else {
|
|
153
|
-
(0,
|
|
159
|
+
(0, import_utilsBundle.debug)("pw:android")("Skipping the driver installation");
|
|
154
160
|
}
|
|
155
|
-
(0,
|
|
156
|
-
this.shell(
|
|
157
|
-
const socket = await this._waitForLocalAbstract(
|
|
158
|
-
const transport = new
|
|
159
|
-
transport.onmessage = message => {
|
|
161
|
+
(0, import_utilsBundle.debug)("pw:android")("Starting the new driver");
|
|
162
|
+
this.shell("am instrument -w com.microsoft.playwright.androiddriver.test/androidx.test.runner.AndroidJUnitRunner").catch((e) => (0, import_utilsBundle.debug)("pw:android")(e));
|
|
163
|
+
const socket = await this._waitForLocalAbstract(progress, "playwright_android_driver_socket");
|
|
164
|
+
const transport = new import_pipeTransport.PipeTransport(socket, socket, socket, "be");
|
|
165
|
+
transport.onmessage = (message) => {
|
|
160
166
|
const response = JSON.parse(message);
|
|
161
|
-
const {
|
|
162
|
-
id,
|
|
163
|
-
result,
|
|
164
|
-
error
|
|
165
|
-
} = response;
|
|
167
|
+
const { id, result, error } = response;
|
|
166
168
|
const callback = this._callbacks.get(id);
|
|
167
|
-
if (!callback)
|
|
168
|
-
|
|
169
|
+
if (!callback)
|
|
170
|
+
return;
|
|
171
|
+
if (error)
|
|
172
|
+
callback.reject(new Error(error));
|
|
173
|
+
else
|
|
174
|
+
callback.fulfill(result);
|
|
169
175
|
this._callbacks.delete(id);
|
|
170
176
|
};
|
|
171
177
|
return transport;
|
|
172
178
|
}
|
|
173
|
-
async _waitForLocalAbstract(socketName) {
|
|
179
|
+
async _waitForLocalAbstract(progress, socketName) {
|
|
174
180
|
let socket;
|
|
175
|
-
(0,
|
|
181
|
+
(0, import_utilsBundle.debug)("pw:android")(`Polling the socket localabstract:${socketName}`);
|
|
176
182
|
while (!socket) {
|
|
177
183
|
try {
|
|
178
|
-
socket = await this._backend.open(`localabstract:${socketName}`);
|
|
184
|
+
socket = await progress.raceWithCleanup(this._backend.open(`localabstract:${socketName}`), (socket2) => socket2.close());
|
|
179
185
|
} catch (e) {
|
|
180
|
-
|
|
186
|
+
if ((0, import_progress.isAbortError)(e))
|
|
187
|
+
throw e;
|
|
188
|
+
await progress.wait(250);
|
|
181
189
|
}
|
|
182
190
|
}
|
|
183
|
-
(0,
|
|
191
|
+
(0, import_utilsBundle.debug)("pw:android")(`Connected to localabstract:${socketName}`);
|
|
184
192
|
return socket;
|
|
185
193
|
}
|
|
186
194
|
async send(method, params = {}) {
|
|
187
|
-
|
|
188
|
-
|
|
195
|
+
params = {
|
|
196
|
+
...params,
|
|
197
|
+
// Patch the timeout in, just in case it's missing in one of the commands.
|
|
198
|
+
timeout: params.timeout || 0
|
|
199
|
+
};
|
|
200
|
+
if (params.androidSelector) {
|
|
201
|
+
params.selector = params.androidSelector;
|
|
202
|
+
delete params.androidSelector;
|
|
203
|
+
}
|
|
189
204
|
const driver = await this._driver();
|
|
190
|
-
if (!driver)
|
|
205
|
+
if (!driver)
|
|
206
|
+
throw new Error("Device is closed");
|
|
191
207
|
const id = ++this._lastId;
|
|
192
|
-
const result = new Promise((fulfill, reject) => this._callbacks.set(id, {
|
|
193
|
-
|
|
194
|
-
reject
|
|
195
|
-
}));
|
|
196
|
-
driver.send(JSON.stringify({
|
|
197
|
-
id,
|
|
198
|
-
method,
|
|
199
|
-
params
|
|
200
|
-
}));
|
|
208
|
+
const result = new Promise((fulfill, reject) => this._callbacks.set(id, { fulfill, reject }));
|
|
209
|
+
driver.send(JSON.stringify({ id, method, params }));
|
|
201
210
|
return result;
|
|
202
211
|
}
|
|
203
212
|
async close() {
|
|
204
|
-
if (this._isClosed)
|
|
213
|
+
if (this._isClosed)
|
|
214
|
+
return;
|
|
205
215
|
this._isClosed = true;
|
|
206
|
-
if (this._pollingWebViews)
|
|
207
|
-
|
|
216
|
+
if (this._pollingWebViews)
|
|
217
|
+
clearTimeout(this._pollingWebViews);
|
|
218
|
+
for (const connection of this._browserConnections)
|
|
219
|
+
await connection.close();
|
|
208
220
|
if (this._driverPromise) {
|
|
209
221
|
const driver = await this._driver();
|
|
210
|
-
driver
|
|
222
|
+
driver?.close();
|
|
211
223
|
}
|
|
212
224
|
await this._backend.close();
|
|
213
225
|
this._android._deviceClosed(this);
|
|
214
226
|
this.emit(AndroidDevice.Events.Close);
|
|
215
227
|
}
|
|
216
|
-
async launchBrowser(pkg =
|
|
217
|
-
(0,
|
|
228
|
+
async launchBrowser(progress, pkg = "com.android.chrome", options) {
|
|
229
|
+
(0, import_utilsBundle.debug)("pw:android")("Force-stopping", pkg);
|
|
218
230
|
await this._backend.runCommand(`shell:am force-stop ${pkg}`);
|
|
219
|
-
const socketName = (0,
|
|
220
|
-
const commandLine = this._defaultArgs(options, socketName).join(
|
|
221
|
-
(0,
|
|
222
|
-
|
|
223
|
-
await this._backend.runCommand(`shell:
|
|
224
|
-
await this.
|
|
225
|
-
|
|
226
|
-
await this._backend.runCommand(`shell:rm /data/local/tmp/chrome-command-line`);
|
|
231
|
+
const socketName = (0, import_debug.isUnderTest)() ? "webview_devtools_remote_playwright_test" : "playwright_" + (0, import_crypto.createGuid)() + "_devtools_remote";
|
|
232
|
+
const commandLine = this._defaultArgs(options, socketName).join(" ");
|
|
233
|
+
(0, import_utilsBundle.debug)("pw:android")("Starting", pkg, commandLine);
|
|
234
|
+
await progress.race(this._backend.runCommand(`shell:echo "${Buffer.from(commandLine).toString("base64")}" | base64 -d > /data/local/tmp/chrome-command-line`));
|
|
235
|
+
await progress.race(this._backend.runCommand(`shell:am start -a android.intent.action.VIEW -d about:blank ${pkg}`));
|
|
236
|
+
const browserContext = await this._connectToBrowser(progress, socketName, options);
|
|
237
|
+
await progress.race(this._backend.runCommand(`shell:rm /data/local/tmp/chrome-command-line`));
|
|
227
238
|
return browserContext;
|
|
228
239
|
}
|
|
229
240
|
_defaultArgs(options, socketName) {
|
|
230
|
-
const chromeArguments = [
|
|
241
|
+
const chromeArguments = [
|
|
242
|
+
"_",
|
|
243
|
+
"--disable-fre",
|
|
244
|
+
"--no-default-browser-check",
|
|
245
|
+
`--remote-debugging-socket-name=${socketName}`,
|
|
246
|
+
...(0, import_chromiumSwitches.chromiumSwitches)(),
|
|
247
|
+
...this._innerDefaultArgs(options)
|
|
248
|
+
];
|
|
231
249
|
return chromeArguments;
|
|
232
250
|
}
|
|
233
251
|
_innerDefaultArgs(options) {
|
|
234
|
-
const {
|
|
235
|
-
args = [],
|
|
236
|
-
proxy
|
|
237
|
-
} = options;
|
|
252
|
+
const { args = [], proxy } = options;
|
|
238
253
|
const chromeArguments = [];
|
|
239
254
|
if (proxy) {
|
|
240
255
|
chromeArguments.push(`--proxy-server=${proxy.server}`);
|
|
241
256
|
const proxyBypassRules = [];
|
|
242
|
-
if (proxy.bypass)
|
|
243
|
-
|
|
244
|
-
if (
|
|
257
|
+
if (proxy.bypass)
|
|
258
|
+
proxyBypassRules.push(...proxy.bypass.split(",").map((t) => t.trim()).map((t) => t.startsWith(".") ? "*" + t : t));
|
|
259
|
+
if (!process.env.PLAYWRIGHT_DISABLE_FORCED_CHROMIUM_PROXIED_LOOPBACK && !proxyBypassRules.includes("<-loopback>"))
|
|
260
|
+
proxyBypassRules.push("<-loopback>");
|
|
261
|
+
if (proxyBypassRules.length > 0)
|
|
262
|
+
chromeArguments.push(`--proxy-bypass-list=${proxyBypassRules.join(";")}`);
|
|
245
263
|
}
|
|
246
264
|
chromeArguments.push(...args);
|
|
247
265
|
return chromeArguments;
|
|
248
266
|
}
|
|
249
|
-
async connectToWebView(socketName) {
|
|
267
|
+
async connectToWebView(progress, socketName) {
|
|
250
268
|
const webView = this._webViews.get(socketName);
|
|
251
|
-
if (!webView)
|
|
252
|
-
|
|
269
|
+
if (!webView)
|
|
270
|
+
throw new Error("WebView has been closed");
|
|
271
|
+
return await this._connectToBrowser(progress, socketName);
|
|
253
272
|
}
|
|
254
|
-
async _connectToBrowser(socketName, options = {}) {
|
|
255
|
-
const socket = await this._waitForLocalAbstract(socketName);
|
|
273
|
+
async _connectToBrowser(progress, socketName, options = {}) {
|
|
274
|
+
const socket = await this._waitForLocalAbstract(progress, socketName);
|
|
256
275
|
const androidBrowser = new AndroidBrowser(this, socket);
|
|
257
|
-
|
|
276
|
+
progress.cleanupWhenAborted(() => androidBrowser.close());
|
|
277
|
+
await progress.race(androidBrowser._init());
|
|
258
278
|
this._browserConnections.add(androidBrowser);
|
|
259
|
-
const artifactsDir = await
|
|
279
|
+
const artifactsDir = await progress.race(import_fs.default.promises.mkdtemp(ARTIFACTS_FOLDER));
|
|
260
280
|
const cleanupArtifactsDir = async () => {
|
|
261
|
-
const errors = await (0,
|
|
262
|
-
for (let i = 0; i < (errors || []).length; ++i)
|
|
281
|
+
const errors = (await (0, import_fileUtils.removeFolders)([artifactsDir])).filter(Boolean);
|
|
282
|
+
for (let i = 0; i < (errors || []).length; ++i)
|
|
283
|
+
(0, import_utilsBundle.debug)("pw:android")(`exception while removing ${artifactsDir}: ${errors[i]}`);
|
|
263
284
|
};
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
285
|
+
progress.cleanupWhenAborted(cleanupArtifactsDir);
|
|
286
|
+
import_processLauncher.gracefullyCloseSet.add(cleanupArtifactsDir);
|
|
287
|
+
socket.on("close", async () => {
|
|
288
|
+
import_processLauncher.gracefullyCloseSet.delete(cleanupArtifactsDir);
|
|
289
|
+
cleanupArtifactsDir().catch((e) => (0, import_utilsBundle.debug)("pw:android")(`could not cleanup artifacts dir: ${e}`));
|
|
268
290
|
});
|
|
269
291
|
const browserOptions = {
|
|
270
|
-
name:
|
|
292
|
+
name: "clank",
|
|
271
293
|
isChromium: true,
|
|
272
294
|
slowMo: 0,
|
|
273
|
-
persistent: {
|
|
274
|
-
...options,
|
|
275
|
-
noDefaultViewport: true
|
|
276
|
-
},
|
|
295
|
+
persistent: { ...options, noDefaultViewport: true },
|
|
277
296
|
artifactsDir,
|
|
278
297
|
downloadsPath: artifactsDir,
|
|
279
298
|
tracesDir: artifactsDir,
|
|
280
299
|
browserProcess: new ClankBrowserProcess(androidBrowser),
|
|
281
300
|
proxy: options.proxy,
|
|
282
|
-
protocolLogger:
|
|
283
|
-
browserLogsCollector: new
|
|
301
|
+
protocolLogger: import_helper.helper.debugProtocolLogger(),
|
|
302
|
+
browserLogsCollector: new import_debugLogger.RecentLogsCollector(),
|
|
284
303
|
originalLaunchOptions: {}
|
|
285
304
|
};
|
|
286
|
-
(0,
|
|
287
|
-
const browser = await
|
|
288
|
-
const controller = new _progress.ProgressController((0, _instrumentation.serverSideCallMetadata)(), this);
|
|
305
|
+
(0, import_browserContext.validateBrowserContextOptions)(options, browserOptions);
|
|
306
|
+
const browser = await progress.race(import_crBrowser.CRBrowser.connect(this.attribution.playwright, androidBrowser, browserOptions));
|
|
289
307
|
const defaultContext = browser._defaultContext;
|
|
290
|
-
await
|
|
291
|
-
await defaultContext._loadDefaultContextAsIs(progress);
|
|
292
|
-
});
|
|
308
|
+
await defaultContext._loadDefaultContextAsIs(progress);
|
|
293
309
|
return defaultContext;
|
|
294
310
|
}
|
|
295
311
|
webViews() {
|
|
296
312
|
return [...this._webViews.values()];
|
|
297
313
|
}
|
|
298
|
-
async installApk(content, options) {
|
|
299
|
-
const args = options && options.args ? options.args : [
|
|
300
|
-
(0,
|
|
301
|
-
const installSocket = await this._backend.open(`shell:cmd package install ${args.join(
|
|
302
|
-
(0,
|
|
303
|
-
await installSocket.write(content);
|
|
304
|
-
const success = await new Promise(f => installSocket.on(
|
|
305
|
-
(0,
|
|
314
|
+
async installApk(progress, content, options) {
|
|
315
|
+
const args = options && options.args ? options.args : ["-r", "-t", "-S"];
|
|
316
|
+
(0, import_utilsBundle.debug)("pw:android")("Opening install socket");
|
|
317
|
+
const installSocket = await progress.raceWithCleanup(this._backend.open(`shell:cmd package install ${args.join(" ")} ${content.length}`), (socket) => socket.close());
|
|
318
|
+
(0, import_utilsBundle.debug)("pw:android")("Writing driver bytes: " + content.length);
|
|
319
|
+
await progress.race(installSocket.write(content));
|
|
320
|
+
const success = await progress.race(new Promise((f) => installSocket.on("data", f)));
|
|
321
|
+
(0, import_utilsBundle.debug)("pw:android")("Written driver bytes: " + success);
|
|
306
322
|
installSocket.close();
|
|
307
323
|
}
|
|
308
|
-
async push(content,
|
|
309
|
-
const socket = await this._backend.open(`sync:`);
|
|
324
|
+
async push(progress, content, path2, mode = 420) {
|
|
325
|
+
const socket = await progress.raceWithCleanup(this._backend.open(`sync:`), (socket2) => socket2.close());
|
|
310
326
|
const sendHeader = async (command, length) => {
|
|
311
327
|
const buffer = Buffer.alloc(command.length + 4);
|
|
312
328
|
buffer.write(command, 0);
|
|
313
329
|
buffer.writeUInt32LE(length, command.length);
|
|
314
|
-
await socket.write(buffer);
|
|
330
|
+
await progress.race(socket.write(buffer));
|
|
315
331
|
};
|
|
316
332
|
const send = async (command, data) => {
|
|
317
333
|
await sendHeader(command, data.length);
|
|
318
|
-
await socket.write(data);
|
|
334
|
+
await progress.race(socket.write(data));
|
|
319
335
|
};
|
|
320
|
-
await send(
|
|
336
|
+
await send("SEND", Buffer.from(`${path2},${mode}`));
|
|
321
337
|
const maxChunk = 65535;
|
|
322
|
-
for (let i = 0; i < content.length; i += maxChunk)
|
|
323
|
-
|
|
324
|
-
|
|
338
|
+
for (let i = 0; i < content.length; i += maxChunk)
|
|
339
|
+
await send("DATA", content.slice(i, i + maxChunk));
|
|
340
|
+
await sendHeader("DONE", Date.now() / 1e3 | 0);
|
|
341
|
+
const result = await progress.race(new Promise((f) => socket.once("data", f)));
|
|
325
342
|
const code = result.slice(0, 4).toString();
|
|
326
|
-
if (code !==
|
|
343
|
+
if (code !== "OKAY")
|
|
344
|
+
throw new Error("Could not push: " + code);
|
|
327
345
|
socket.close();
|
|
328
346
|
}
|
|
329
347
|
async _refreshWebViews() {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
const socketNames = new Set();
|
|
348
|
+
const sockets = (await this._backend.runCommand(`shell:cat /proc/net/unix | grep webview_devtools_remote`)).toString().split("\n");
|
|
349
|
+
if (this._isClosed)
|
|
350
|
+
return;
|
|
351
|
+
const socketNames = /* @__PURE__ */ new Set();
|
|
334
352
|
for (const line of sockets) {
|
|
335
353
|
const matchSocketName = line.match(/[^@]+@(.*?webview_devtools_remote_?.*)/);
|
|
336
|
-
if (!matchSocketName)
|
|
354
|
+
if (!matchSocketName)
|
|
355
|
+
continue;
|
|
337
356
|
const socketName = matchSocketName[1];
|
|
338
357
|
socketNames.add(socketName);
|
|
339
|
-
if (this._webViews.has(socketName))
|
|
340
|
-
|
|
341
|
-
// possible line: 0000000000000000: 00000002 00000000 00010000 0001 01 5841881 @webview_devtools_remote_zeus
|
|
342
|
-
// the result: match[1] = ''
|
|
358
|
+
if (this._webViews.has(socketName))
|
|
359
|
+
continue;
|
|
343
360
|
const match = line.match(/[^@]+@.*?webview_devtools_remote_?(\d*)/);
|
|
344
361
|
let pid = -1;
|
|
345
|
-
if (match && match[1])
|
|
362
|
+
if (match && match[1])
|
|
363
|
+
pid = +match[1];
|
|
346
364
|
const pkg = await this._extractPkg(pid);
|
|
347
|
-
if (this._isClosed)
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
pkg,
|
|
351
|
-
socketName
|
|
352
|
-
};
|
|
365
|
+
if (this._isClosed)
|
|
366
|
+
return;
|
|
367
|
+
const webView = { pid, pkg, socketName };
|
|
353
368
|
this._webViews.set(socketName, webView);
|
|
354
369
|
this.emit(AndroidDevice.Events.WebViewAdded, webView);
|
|
355
370
|
}
|
|
@@ -361,44 +376,37 @@ class AndroidDevice extends _instrumentation.SdkObject {
|
|
|
361
376
|
}
|
|
362
377
|
}
|
|
363
378
|
async _extractPkg(pid) {
|
|
364
|
-
let pkg =
|
|
365
|
-
if (pid === -1)
|
|
366
|
-
|
|
379
|
+
let pkg = "";
|
|
380
|
+
if (pid === -1)
|
|
381
|
+
return pkg;
|
|
382
|
+
const procs = (await this._backend.runCommand(`shell:ps -A | grep ${pid}`)).toString().split("\n");
|
|
367
383
|
for (const proc of procs) {
|
|
368
384
|
const match = proc.match(/[^\s]+\s+(\d+).*$/);
|
|
369
|
-
if (!match)
|
|
370
|
-
|
|
385
|
+
if (!match)
|
|
386
|
+
continue;
|
|
387
|
+
pkg = proc.substring(proc.lastIndexOf(" ") + 1);
|
|
371
388
|
}
|
|
372
389
|
return pkg;
|
|
373
390
|
}
|
|
374
391
|
}
|
|
375
|
-
|
|
376
|
-
AndroidDevice.Events = {
|
|
377
|
-
WebViewAdded: 'webViewAdded',
|
|
378
|
-
WebViewRemoved: 'webViewRemoved',
|
|
379
|
-
Close: 'close'
|
|
380
|
-
};
|
|
381
|
-
class AndroidBrowser extends _events.EventEmitter {
|
|
392
|
+
class AndroidBrowser extends import_events.EventEmitter {
|
|
382
393
|
constructor(device, socket) {
|
|
383
394
|
super();
|
|
384
|
-
this.
|
|
385
|
-
this._socket = void 0;
|
|
386
|
-
this._receiver = void 0;
|
|
387
|
-
this._waitForNextTask = (0, _task.makeWaitForNextTask)();
|
|
388
|
-
this.onmessage = void 0;
|
|
389
|
-
this.onclose = void 0;
|
|
395
|
+
this._waitForNextTask = (0, import_task.makeWaitForNextTask)();
|
|
390
396
|
this.setMaxListeners(0);
|
|
391
397
|
this.device = device;
|
|
392
398
|
this._socket = socket;
|
|
393
|
-
this._socket.on(
|
|
399
|
+
this._socket.on("close", () => {
|
|
394
400
|
this._waitForNextTask(() => {
|
|
395
|
-
if (this.onclose)
|
|
401
|
+
if (this.onclose)
|
|
402
|
+
this.onclose();
|
|
396
403
|
});
|
|
397
404
|
});
|
|
398
|
-
this._receiver = new
|
|
399
|
-
this._receiver.on(
|
|
405
|
+
this._receiver = new import_utilsBundle2.wsReceiver();
|
|
406
|
+
this._receiver.on("message", (message) => {
|
|
400
407
|
this._waitForNextTask(() => {
|
|
401
|
-
if (this.onmessage)
|
|
408
|
+
if (this.onmessage)
|
|
409
|
+
this.onmessage(JSON.parse(message));
|
|
402
410
|
});
|
|
403
411
|
});
|
|
404
412
|
}
|
|
@@ -410,11 +418,9 @@ Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r
|
|
|
410
418
|
Sec-WebSocket-Version: 13\r
|
|
411
419
|
\r
|
|
412
420
|
`));
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
// Start sending web frame to receiver.
|
|
417
|
-
this._socket.on('data', data => this._receiver._write(data, 'binary', () => {}));
|
|
421
|
+
await new Promise((f) => this._socket.once("data", f));
|
|
422
|
+
this._socket.on("data", (data) => this._receiver._write(data, "binary", () => {
|
|
423
|
+
}));
|
|
418
424
|
}
|
|
419
425
|
async send(s) {
|
|
420
426
|
await this._socket.write(encodeWebFrame(JSON.stringify(s)));
|
|
@@ -424,7 +430,7 @@ Sec-WebSocket-Version: 13\r
|
|
|
424
430
|
}
|
|
425
431
|
}
|
|
426
432
|
function encodeWebFrame(data) {
|
|
427
|
-
return
|
|
433
|
+
return import_utilsBundle2.wsSender.frame(Buffer.from(data), {
|
|
428
434
|
opcode: 1,
|
|
429
435
|
mask: true,
|
|
430
436
|
fin: true,
|
|
@@ -433,12 +439,16 @@ function encodeWebFrame(data) {
|
|
|
433
439
|
}
|
|
434
440
|
class ClankBrowserProcess {
|
|
435
441
|
constructor(browser) {
|
|
436
|
-
this._browser = void 0;
|
|
437
|
-
this.onclose = void 0;
|
|
438
442
|
this._browser = browser;
|
|
439
443
|
}
|
|
440
|
-
async kill() {
|
|
444
|
+
async kill() {
|
|
445
|
+
}
|
|
441
446
|
async close() {
|
|
442
447
|
await this._browser.close();
|
|
443
448
|
}
|
|
444
|
-
}
|
|
449
|
+
}
|
|
450
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
451
|
+
0 && (module.exports = {
|
|
452
|
+
Android,
|
|
453
|
+
AndroidDevice
|
|
454
|
+
});
|