@checkly/playwright-core 1.41.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.
Files changed (305) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +3 -0
  4. package/ThirdPartyNotices.txt +1513 -0
  5. package/bin/PrintDeps.exe +0 -0
  6. package/bin/README.md +2 -0
  7. package/bin/install_media_pack.ps1 +5 -0
  8. package/bin/reinstall_chrome_beta_linux.sh +40 -0
  9. package/bin/reinstall_chrome_beta_mac.sh +13 -0
  10. package/bin/reinstall_chrome_beta_win.ps1 +23 -0
  11. package/bin/reinstall_chrome_stable_linux.sh +40 -0
  12. package/bin/reinstall_chrome_stable_mac.sh +12 -0
  13. package/bin/reinstall_chrome_stable_win.ps1 +23 -0
  14. package/bin/reinstall_msedge_beta_linux.sh +40 -0
  15. package/bin/reinstall_msedge_beta_mac.sh +11 -0
  16. package/bin/reinstall_msedge_beta_win.ps1 +22 -0
  17. package/bin/reinstall_msedge_dev_linux.sh +40 -0
  18. package/bin/reinstall_msedge_dev_mac.sh +11 -0
  19. package/bin/reinstall_msedge_dev_win.ps1 +22 -0
  20. package/bin/reinstall_msedge_stable_linux.sh +40 -0
  21. package/bin/reinstall_msedge_stable_mac.sh +11 -0
  22. package/bin/reinstall_msedge_stable_win.ps1 +23 -0
  23. package/browsers.json +64 -0
  24. package/cli.js +17 -0
  25. package/index.d.ts +17 -0
  26. package/index.js +33 -0
  27. package/index.mjs +28 -0
  28. package/lib/androidServerImpl.js +69 -0
  29. package/lib/browserServerImpl.js +92 -0
  30. package/lib/cli/driver.js +97 -0
  31. package/lib/cli/program.js +582 -0
  32. package/lib/cli/programWithTestStub.js +67 -0
  33. package/lib/client/accessibility.js +50 -0
  34. package/lib/client/android.js +473 -0
  35. package/lib/client/api.js +272 -0
  36. package/lib/client/artifact.js +79 -0
  37. package/lib/client/browser.js +145 -0
  38. package/lib/client/browserContext.js +509 -0
  39. package/lib/client/browserType.js +233 -0
  40. package/lib/client/cdpSession.js +53 -0
  41. package/lib/client/channelOwner.js +229 -0
  42. package/lib/client/clientHelper.js +57 -0
  43. package/lib/client/clientInstrumentation.js +40 -0
  44. package/lib/client/connection.js +327 -0
  45. package/lib/client/consoleMessage.js +55 -0
  46. package/lib/client/coverage.js +41 -0
  47. package/lib/client/dialog.js +57 -0
  48. package/lib/client/download.js +62 -0
  49. package/lib/client/electron.js +130 -0
  50. package/lib/client/elementHandle.js +291 -0
  51. package/lib/client/errors.js +77 -0
  52. package/lib/client/events.js +93 -0
  53. package/lib/client/fetch.js +343 -0
  54. package/lib/client/fileChooser.js +45 -0
  55. package/lib/client/frame.js +506 -0
  56. package/lib/client/harRouter.js +93 -0
  57. package/lib/client/input.js +111 -0
  58. package/lib/client/jsHandle.js +123 -0
  59. package/lib/client/jsonPipe.js +35 -0
  60. package/lib/client/localUtils.js +35 -0
  61. package/lib/client/locator.js +432 -0
  62. package/lib/client/network.js +601 -0
  63. package/lib/client/page.js +707 -0
  64. package/lib/client/playwright.js +74 -0
  65. package/lib/client/selectors.js +67 -0
  66. package/lib/client/stream.js +54 -0
  67. package/lib/client/tracing.js +135 -0
  68. package/lib/client/types.js +24 -0
  69. package/lib/client/video.js +51 -0
  70. package/lib/client/waiter.js +158 -0
  71. package/lib/client/webError.js +37 -0
  72. package/lib/client/worker.js +71 -0
  73. package/lib/client/writableStream.js +54 -0
  74. package/lib/common/socksProxy.js +569 -0
  75. package/lib/common/timeoutSettings.js +73 -0
  76. package/lib/common/types.js +5 -0
  77. package/lib/generated/consoleApiSource.js +7 -0
  78. package/lib/generated/injectedScriptSource.js +7 -0
  79. package/lib/generated/recorderSource.js +7 -0
  80. package/lib/generated/utilityScriptSource.js +7 -0
  81. package/lib/image_tools/colorUtils.js +98 -0
  82. package/lib/image_tools/compare.js +108 -0
  83. package/lib/image_tools/imageChannel.js +70 -0
  84. package/lib/image_tools/stats.js +102 -0
  85. package/lib/inProcessFactory.js +54 -0
  86. package/lib/inprocess.js +20 -0
  87. package/lib/outofprocess.js +67 -0
  88. package/lib/protocol/debug.js +27 -0
  89. package/lib/protocol/serializers.js +172 -0
  90. package/lib/protocol/transport.js +82 -0
  91. package/lib/protocol/validator.js +2599 -0
  92. package/lib/protocol/validatorPrimitives.js +139 -0
  93. package/lib/remote/playwrightConnection.js +274 -0
  94. package/lib/remote/playwrightServer.js +110 -0
  95. package/lib/server/accessibility.js +62 -0
  96. package/lib/server/android/android.js +441 -0
  97. package/lib/server/android/backendAdb.js +172 -0
  98. package/lib/server/artifact.js +104 -0
  99. package/lib/server/browser.js +129 -0
  100. package/lib/server/browserContext.js +609 -0
  101. package/lib/server/browserType.js +300 -0
  102. package/lib/server/chromium/appIcon.png +0 -0
  103. package/lib/server/chromium/chromium.js +346 -0
  104. package/lib/server/chromium/chromiumSwitches.js +41 -0
  105. package/lib/server/chromium/crAccessibility.js +237 -0
  106. package/lib/server/chromium/crBrowser.js +521 -0
  107. package/lib/server/chromium/crConnection.js +228 -0
  108. package/lib/server/chromium/crCoverage.js +246 -0
  109. package/lib/server/chromium/crDevTools.js +104 -0
  110. package/lib/server/chromium/crDragDrop.js +144 -0
  111. package/lib/server/chromium/crExecutionContext.js +156 -0
  112. package/lib/server/chromium/crInput.js +171 -0
  113. package/lib/server/chromium/crNetworkManager.js +723 -0
  114. package/lib/server/chromium/crPage.js +1173 -0
  115. package/lib/server/chromium/crPdf.js +147 -0
  116. package/lib/server/chromium/crProtocolHelper.js +131 -0
  117. package/lib/server/chromium/crServiceWorker.js +115 -0
  118. package/lib/server/chromium/defaultFontFamilies.js +145 -0
  119. package/lib/server/chromium/videoRecorder.js +155 -0
  120. package/lib/server/console.js +59 -0
  121. package/lib/server/cookieStore.js +112 -0
  122. package/lib/server/debugController.js +236 -0
  123. package/lib/server/debugger.js +132 -0
  124. package/lib/server/deviceDescriptors.js +21 -0
  125. package/lib/server/deviceDescriptorsSource.json +1549 -0
  126. package/lib/server/dialog.js +70 -0
  127. package/lib/server/dispatchers/androidDispatcher.js +193 -0
  128. package/lib/server/dispatchers/artifactDispatcher.js +118 -0
  129. package/lib/server/dispatchers/browserContextDispatcher.js +306 -0
  130. package/lib/server/dispatchers/browserDispatcher.js +170 -0
  131. package/lib/server/dispatchers/browserTypeDispatcher.js +55 -0
  132. package/lib/server/dispatchers/cdpSessionDispatcher.js +48 -0
  133. package/lib/server/dispatchers/debugControllerDispatcher.js +103 -0
  134. package/lib/server/dispatchers/dialogDispatcher.js +44 -0
  135. package/lib/server/dispatchers/dispatcher.js +400 -0
  136. package/lib/server/dispatchers/electronDispatcher.js +80 -0
  137. package/lib/server/dispatchers/elementHandlerDispatcher.js +228 -0
  138. package/lib/server/dispatchers/frameDispatcher.js +287 -0
  139. package/lib/server/dispatchers/jsHandleDispatcher.js +102 -0
  140. package/lib/server/dispatchers/jsonPipeDispatcher.js +61 -0
  141. package/lib/server/dispatchers/localUtilsDispatcher.js +399 -0
  142. package/lib/server/dispatchers/networkDispatchers.js +221 -0
  143. package/lib/server/dispatchers/pageDispatcher.js +363 -0
  144. package/lib/server/dispatchers/playwrightDispatcher.js +105 -0
  145. package/lib/server/dispatchers/selectorsDispatcher.js +36 -0
  146. package/lib/server/dispatchers/streamDispatcher.js +62 -0
  147. package/lib/server/dispatchers/tracingDispatcher.js +54 -0
  148. package/lib/server/dispatchers/writableStreamDispatcher.js +55 -0
  149. package/lib/server/dom.js +808 -0
  150. package/lib/server/download.js +53 -0
  151. package/lib/server/electron/electron.js +254 -0
  152. package/lib/server/electron/loader.js +57 -0
  153. package/lib/server/errors.js +68 -0
  154. package/lib/server/fetch.js +611 -0
  155. package/lib/server/fileChooser.js +42 -0
  156. package/lib/server/fileUploadUtils.js +71 -0
  157. package/lib/server/firefox/ffAccessibility.js +215 -0
  158. package/lib/server/firefox/ffBrowser.js +447 -0
  159. package/lib/server/firefox/ffConnection.js +168 -0
  160. package/lib/server/firefox/ffExecutionContext.js +138 -0
  161. package/lib/server/firefox/ffInput.js +150 -0
  162. package/lib/server/firefox/ffNetworkManager.js +231 -0
  163. package/lib/server/firefox/ffPage.js +558 -0
  164. package/lib/server/firefox/firefox.js +91 -0
  165. package/lib/server/formData.js +75 -0
  166. package/lib/server/frameSelectors.js +171 -0
  167. package/lib/server/frames.js +1597 -0
  168. package/lib/server/har/harRecorder.js +139 -0
  169. package/lib/server/har/harTracer.js +539 -0
  170. package/lib/server/helper.js +103 -0
  171. package/lib/server/index.js +96 -0
  172. package/lib/server/input.js +301 -0
  173. package/lib/server/instrumentation.js +74 -0
  174. package/lib/server/isomorphic/utilityScriptSerializers.js +212 -0
  175. package/lib/server/javascript.js +305 -0
  176. package/lib/server/launchApp.js +90 -0
  177. package/lib/server/macEditingCommands.js +139 -0
  178. package/lib/server/network.js +607 -0
  179. package/lib/server/page.js +793 -0
  180. package/lib/server/pipeTransport.js +85 -0
  181. package/lib/server/playwright.js +82 -0
  182. package/lib/server/progress.js +102 -0
  183. package/lib/server/protocolError.js +49 -0
  184. package/lib/server/recorder/codeGenerator.js +153 -0
  185. package/lib/server/recorder/csharp.js +310 -0
  186. package/lib/server/recorder/java.js +216 -0
  187. package/lib/server/recorder/javascript.js +229 -0
  188. package/lib/server/recorder/jsonl.js +47 -0
  189. package/lib/server/recorder/language.js +44 -0
  190. package/lib/server/recorder/python.js +275 -0
  191. package/lib/server/recorder/recorderActions.js +5 -0
  192. package/lib/server/recorder/recorderApp.js +181 -0
  193. package/lib/server/recorder/recorderUtils.js +48 -0
  194. package/lib/server/recorder/utils.js +45 -0
  195. package/lib/server/recorder.js +700 -0
  196. package/lib/server/registry/browserFetcher.js +168 -0
  197. package/lib/server/registry/dependencies.js +322 -0
  198. package/lib/server/registry/index.js +925 -0
  199. package/lib/server/registry/nativeDeps.js +383 -0
  200. package/lib/server/registry/oopDownloadBrowserMain.js +138 -0
  201. package/lib/server/screenshotter.js +354 -0
  202. package/lib/server/selectors.js +73 -0
  203. package/lib/server/socksInterceptor.js +100 -0
  204. package/lib/server/trace/recorder/snapshotter.js +168 -0
  205. package/lib/server/trace/recorder/snapshotterInjected.js +493 -0
  206. package/lib/server/trace/recorder/tracing.js +552 -0
  207. package/lib/server/trace/test/inMemorySnapshotter.js +93 -0
  208. package/lib/server/trace/viewer/traceViewer.js +229 -0
  209. package/lib/server/transport.js +191 -0
  210. package/lib/server/types.js +24 -0
  211. package/lib/server/usKeyboardLayout.js +555 -0
  212. package/lib/server/webkit/webkit.js +87 -0
  213. package/lib/server/webkit/wkAccessibility.js +194 -0
  214. package/lib/server/webkit/wkBrowser.js +328 -0
  215. package/lib/server/webkit/wkConnection.js +173 -0
  216. package/lib/server/webkit/wkExecutionContext.js +146 -0
  217. package/lib/server/webkit/wkInput.js +169 -0
  218. package/lib/server/webkit/wkInterceptableRequest.js +158 -0
  219. package/lib/server/webkit/wkPage.js +1198 -0
  220. package/lib/server/webkit/wkProvisionalPage.js +59 -0
  221. package/lib/server/webkit/wkWorkers.js +104 -0
  222. package/lib/third_party/diff_match_patch.js +2222 -0
  223. package/lib/third_party/pixelmatch.js +255 -0
  224. package/lib/utils/ascii.js +31 -0
  225. package/lib/utils/comparators.js +171 -0
  226. package/lib/utils/crypto.js +33 -0
  227. package/lib/utils/debug.js +46 -0
  228. package/lib/utils/debugLogger.js +89 -0
  229. package/lib/utils/env.js +47 -0
  230. package/lib/utils/eventsHelper.js +38 -0
  231. package/lib/utils/fileUtils.js +66 -0
  232. package/lib/utils/glob.js +83 -0
  233. package/lib/utils/happy-eyeballs.js +154 -0
  234. package/lib/utils/headers.js +52 -0
  235. package/lib/utils/hostPlatform.js +124 -0
  236. package/lib/utils/httpServer.js +195 -0
  237. package/lib/utils/index.js +324 -0
  238. package/lib/utils/isomorphic/cssParser.js +250 -0
  239. package/lib/utils/isomorphic/cssTokenizer.js +979 -0
  240. package/lib/utils/isomorphic/locatorGenerators.js +651 -0
  241. package/lib/utils/isomorphic/locatorParser.js +179 -0
  242. package/lib/utils/isomorphic/locatorUtils.js +62 -0
  243. package/lib/utils/isomorphic/selectorParser.js +397 -0
  244. package/lib/utils/isomorphic/stringUtils.js +107 -0
  245. package/lib/utils/isomorphic/traceUtils.js +39 -0
  246. package/lib/utils/linuxUtils.js +78 -0
  247. package/lib/utils/manualPromise.js +109 -0
  248. package/lib/utils/mimeType.js +29 -0
  249. package/lib/utils/multimap.js +75 -0
  250. package/lib/utils/network.js +189 -0
  251. package/lib/utils/processLauncher.js +248 -0
  252. package/lib/utils/profiler.js +53 -0
  253. package/lib/utils/rtti.js +41 -0
  254. package/lib/utils/semaphore.js +51 -0
  255. package/lib/utils/spawnAsync.js +45 -0
  256. package/lib/utils/stackTrace.js +123 -0
  257. package/lib/utils/task.js +58 -0
  258. package/lib/utils/time.js +37 -0
  259. package/lib/utils/timeoutRunner.js +131 -0
  260. package/lib/utils/traceUtils.js +44 -0
  261. package/lib/utils/userAgent.js +105 -0
  262. package/lib/utils/wsServer.js +125 -0
  263. package/lib/utils/zipFile.js +75 -0
  264. package/lib/utils/zones.js +99 -0
  265. package/lib/utilsBundle.js +81 -0
  266. package/lib/utilsBundleImpl/index.js +51 -0
  267. package/lib/utilsBundleImpl/xdg-open +1066 -0
  268. package/lib/vite/htmlReport/index.html +66 -0
  269. package/lib/vite/recorder/assets/codeMirrorModule-Hs9-1ZG4.css +1 -0
  270. package/lib/vite/recorder/assets/codeMirrorModule-I9ks4y7D.js +24 -0
  271. package/lib/vite/recorder/assets/codicon-zGuYmc9o.ttf +0 -0
  272. package/lib/vite/recorder/assets/index-ljsTwXtJ.css +1 -0
  273. package/lib/vite/recorder/assets/index-yg8ypzl6.js +47 -0
  274. package/lib/vite/recorder/index.html +29 -0
  275. package/lib/vite/recorder/playwright-logo.svg +9 -0
  276. package/lib/vite/traceViewer/assets/codeMirrorModule-GluP1cQ1.js +24 -0
  277. package/lib/vite/traceViewer/assets/codeMirrorModule-fqJB1XDu.js +24 -0
  278. package/lib/vite/traceViewer/assets/codeMirrorModule-y3M3aAqy.js +24 -0
  279. package/lib/vite/traceViewer/assets/wsPort-Rvwd4WC-.js +69 -0
  280. package/lib/vite/traceViewer/assets/wsPort-dlD7vDkY.js +69 -0
  281. package/lib/vite/traceViewer/assets/wsPort-qOE2NWrO.js +69 -0
  282. package/lib/vite/traceViewer/assets/xtermModule-Yt6xwiJ_.js +9 -0
  283. package/lib/vite/traceViewer/codeMirrorModule.Hs9-1ZG4.css +1 -0
  284. package/lib/vite/traceViewer/codicon.zGuYmc9o.ttf +0 -0
  285. package/lib/vite/traceViewer/index.-g_5lMbJ.css +1 -0
  286. package/lib/vite/traceViewer/index.4X7zDysg.js +2 -0
  287. package/lib/vite/traceViewer/index.HkJgzlGy.js +2 -0
  288. package/lib/vite/traceViewer/index.html +26 -0
  289. package/lib/vite/traceViewer/index.kRjx5sAJ.js +2 -0
  290. package/lib/vite/traceViewer/playwright-logo.svg +9 -0
  291. package/lib/vite/traceViewer/snapshot.html +21 -0
  292. package/lib/vite/traceViewer/sw.bundle.js +4 -0
  293. package/lib/vite/traceViewer/uiMode.1Wcp_Kto.js +10 -0
  294. package/lib/vite/traceViewer/uiMode.GTNzARcV.js +10 -0
  295. package/lib/vite/traceViewer/uiMode.html +17 -0
  296. package/lib/vite/traceViewer/uiMode.pWy0Re7G.css +1 -0
  297. package/lib/vite/traceViewer/uiMode.zV-7Lf9v.js +10 -0
  298. package/lib/vite/traceViewer/wsPort.kSgQKQ0y.css +1 -0
  299. package/lib/vite/traceViewer/xtermModule.0lwXJFHT.css +32 -0
  300. package/lib/zipBundle.js +25 -0
  301. package/lib/zipBundleImpl.js +5 -0
  302. package/package.json +43 -0
  303. package/types/protocol.d.ts +20304 -0
  304. package/types/structs.d.ts +45 -0
  305. package/types/types.d.ts +20626 -0
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.helper = void 0;
7
+ var _debugLogger = require("../utils/debugLogger");
8
+ var _eventsHelper = require("../utils/eventsHelper");
9
+ /**
10
+ * Copyright 2017 Google Inc. All rights reserved.
11
+ * Modifications copyright (c) Microsoft Corporation.
12
+ *
13
+ * Licensed under the Apache License, Version 2.0 (the "License");
14
+ * you may not use this file except in compliance with the License.
15
+ * You may obtain a copy of the License at
16
+ *
17
+ * http://www.apache.org/licenses/LICENSE-2.0
18
+ *
19
+ * Unless required by applicable law or agreed to in writing, software
20
+ * distributed under the License is distributed on an "AS IS" BASIS,
21
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
+ * See the License for the specific language governing permissions and
23
+ * limitations under the License.
24
+ */
25
+
26
+ const MAX_LOG_LENGTH = process.env.MAX_LOG_LENGTH ? +process.env.MAX_LOG_LENGTH : Infinity;
27
+ class Helper {
28
+ static completeUserURL(urlString) {
29
+ if (urlString.startsWith('localhost') || urlString.startsWith('127.0.0.1')) urlString = 'http://' + urlString;
30
+ return urlString;
31
+ }
32
+ static enclosingIntRect(rect) {
33
+ const x = Math.floor(rect.x + 1e-3);
34
+ const y = Math.floor(rect.y + 1e-3);
35
+ const x2 = Math.ceil(rect.x + rect.width - 1e-3);
36
+ const y2 = Math.ceil(rect.y + rect.height - 1e-3);
37
+ return {
38
+ x,
39
+ y,
40
+ width: x2 - x,
41
+ height: y2 - y
42
+ };
43
+ }
44
+ static enclosingIntSize(size) {
45
+ return {
46
+ width: Math.floor(size.width + 1e-3),
47
+ height: Math.floor(size.height + 1e-3)
48
+ };
49
+ }
50
+ static getViewportSizeFromWindowFeatures(features) {
51
+ const widthString = features.find(f => f.startsWith('width='));
52
+ const heightString = features.find(f => f.startsWith('height='));
53
+ const width = widthString ? parseInt(widthString.substring(6), 10) : NaN;
54
+ const height = heightString ? parseInt(heightString.substring(7), 10) : NaN;
55
+ if (!Number.isNaN(width) && !Number.isNaN(height)) return {
56
+ width,
57
+ height
58
+ };
59
+ return null;
60
+ }
61
+ static waitForEvent(progress, emitter, event, predicate) {
62
+ const listeners = [];
63
+ const promise = new Promise((resolve, reject) => {
64
+ listeners.push(_eventsHelper.eventsHelper.addEventListener(emitter, event, eventArg => {
65
+ try {
66
+ if (predicate && !predicate(eventArg)) return;
67
+ _eventsHelper.eventsHelper.removeEventListeners(listeners);
68
+ resolve(eventArg);
69
+ } catch (e) {
70
+ _eventsHelper.eventsHelper.removeEventListeners(listeners);
71
+ reject(e);
72
+ }
73
+ }));
74
+ });
75
+ const dispose = () => _eventsHelper.eventsHelper.removeEventListeners(listeners);
76
+ if (progress) progress.cleanupWhenAborted(dispose);
77
+ return {
78
+ promise,
79
+ dispose
80
+ };
81
+ }
82
+ static secondsToRoundishMillis(value) {
83
+ return (value * 1000000 | 0) / 1000;
84
+ }
85
+ static millisToRoundishMillis(value) {
86
+ return (value * 1000 | 0) / 1000;
87
+ }
88
+ static debugProtocolLogger(protocolLogger) {
89
+ return (direction, message) => {
90
+ if (protocolLogger) protocolLogger(direction, message);
91
+ if (_debugLogger.debugLogger.isEnabled('protocol')) {
92
+ let text = JSON.stringify(message);
93
+ if (text.length > MAX_LOG_LENGTH) text = text.substring(0, MAX_LOG_LENGTH / 2) + ' <<<<<( LOG TRUNCATED )>>>>> ' + text.substring(text.length - MAX_LOG_LENGTH / 2);
94
+ _debugLogger.debugLogger.log('protocol', (direction === 'send' ? 'SEND ► ' : '◀ RECV ') + text);
95
+ }
96
+ };
97
+ }
98
+ static formatBrowserLogs(logs) {
99
+ if (!logs.length) return '';
100
+ return '\n' + logs.join('\n');
101
+ }
102
+ }
103
+ const helper = exports.helper = Helper;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "DispatcherConnection", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _dispatcher.DispatcherConnection;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "PlaywrightDispatcher", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _playwrightDispatcher.PlaywrightDispatcher;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "Registry", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _registry.Registry;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "RootDispatcher", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _dispatcher.RootDispatcher;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "SocksProxy", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _socksProxy.SocksProxy;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "createPlaywright", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _playwright.createPlaywright;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "installBrowsersForNpmInstall", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _registry.installBrowsersForNpmInstall;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "installDefaultBrowsersForNpmInstall", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _registry.installDefaultBrowsersForNpmInstall;
52
+ }
53
+ });
54
+ Object.defineProperty(exports, "openTraceInBrowser", {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _traceViewer.openTraceInBrowser;
58
+ }
59
+ });
60
+ Object.defineProperty(exports, "openTraceViewerApp", {
61
+ enumerable: true,
62
+ get: function () {
63
+ return _traceViewer.openTraceViewerApp;
64
+ }
65
+ });
66
+ Object.defineProperty(exports, "registry", {
67
+ enumerable: true,
68
+ get: function () {
69
+ return _registry.registry;
70
+ }
71
+ });
72
+ Object.defineProperty(exports, "registryDirectory", {
73
+ enumerable: true,
74
+ get: function () {
75
+ return _registry.registryDirectory;
76
+ }
77
+ });
78
+ Object.defineProperty(exports, "serverSideCallMetadata", {
79
+ enumerable: true,
80
+ get: function () {
81
+ return _instrumentation.serverSideCallMetadata;
82
+ }
83
+ });
84
+ Object.defineProperty(exports, "writeDockerVersion", {
85
+ enumerable: true,
86
+ get: function () {
87
+ return _registry.writeDockerVersion;
88
+ }
89
+ });
90
+ var _registry = require("./registry");
91
+ var _dispatcher = require("./dispatchers/dispatcher");
92
+ var _playwrightDispatcher = require("./dispatchers/playwrightDispatcher");
93
+ var _playwright = require("./playwright");
94
+ var _traceViewer = require("./trace/viewer/traceViewer");
95
+ var _instrumentation = require("./instrumentation");
96
+ var _socksProxy = require("../common/socksProxy");
@@ -0,0 +1,301 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.keypadLocation = exports.Touchscreen = exports.Mouse = exports.Keyboard = void 0;
7
+ var _utils = require("../utils");
8
+ var keyboardLayout = _interopRequireWildcard(require("./usKeyboardLayout"));
9
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
10
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
+ /**
12
+ * Copyright (c) Microsoft Corporation.
13
+ *
14
+ * Licensed under the Apache License, Version 2.0 (the "License");
15
+ * you may not use this file except in compliance with the License.
16
+ * You may obtain a copy of the License at
17
+ *
18
+ * http://www.apache.org/licenses/LICENSE-2.0
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software
21
+ * distributed under the License is distributed on an "AS IS" BASIS,
22
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
+ * See the License for the specific language governing permissions and
24
+ * limitations under the License.
25
+ */
26
+
27
+ const keypadLocation = exports.keypadLocation = keyboardLayout.keypadLocation;
28
+ const kModifiers = ['Alt', 'Control', 'Meta', 'Shift'];
29
+ class Keyboard {
30
+ constructor(raw, page) {
31
+ this._pressedModifiers = new Set();
32
+ this._pressedKeys = new Set();
33
+ this._raw = void 0;
34
+ this._page = void 0;
35
+ this._raw = raw;
36
+ this._page = page;
37
+ }
38
+ async down(key) {
39
+ const description = this._keyDescriptionForString(key);
40
+ const autoRepeat = this._pressedKeys.has(description.code);
41
+ this._pressedKeys.add(description.code);
42
+ if (kModifiers.includes(description.key)) this._pressedModifiers.add(description.key);
43
+ const text = description.text;
44
+ await this._raw.keydown(this._pressedModifiers, description.code, description.keyCode, description.keyCodeWithoutLocation, description.key, description.location, autoRepeat, text);
45
+ }
46
+ _keyDescriptionForString(keyString) {
47
+ let description = usKeyboardLayout.get(keyString);
48
+ (0, _utils.assert)(description, `Unknown key: "${keyString}"`);
49
+ const shift = this._pressedModifiers.has('Shift');
50
+ description = shift && description.shifted ? description.shifted : description;
51
+
52
+ // if any modifiers besides shift are pressed, no text should be sent
53
+ if (this._pressedModifiers.size > 1 || !this._pressedModifiers.has('Shift') && this._pressedModifiers.size === 1) return {
54
+ ...description,
55
+ text: ''
56
+ };
57
+ return description;
58
+ }
59
+ async up(key) {
60
+ const description = this._keyDescriptionForString(key);
61
+ if (kModifiers.includes(description.key)) this._pressedModifiers.delete(description.key);
62
+ this._pressedKeys.delete(description.code);
63
+ await this._raw.keyup(this._pressedModifiers, description.code, description.keyCode, description.keyCodeWithoutLocation, description.key, description.location);
64
+ }
65
+ async insertText(text) {
66
+ await this._raw.sendText(text);
67
+ }
68
+ async type(text, options) {
69
+ const delay = options && options.delay || undefined;
70
+ for (const char of text) {
71
+ if (usKeyboardLayout.has(char)) {
72
+ await this.press(char, {
73
+ delay
74
+ });
75
+ } else {
76
+ if (delay) await new Promise(f => setTimeout(f, delay));
77
+ await this.insertText(char);
78
+ }
79
+ }
80
+ }
81
+ async press(key, options = {}) {
82
+ function split(keyString) {
83
+ const keys = [];
84
+ let building = '';
85
+ for (const char of keyString) {
86
+ if (char === '+' && building) {
87
+ keys.push(building);
88
+ building = '';
89
+ } else {
90
+ building += char;
91
+ }
92
+ }
93
+ keys.push(building);
94
+ return keys;
95
+ }
96
+ const tokens = split(key);
97
+ key = tokens[tokens.length - 1];
98
+ for (let i = 0; i < tokens.length - 1; ++i) await this.down(tokens[i]);
99
+ await this.down(key);
100
+ if (options.delay) await new Promise(f => setTimeout(f, options.delay));
101
+ await this.up(key);
102
+ for (let i = tokens.length - 2; i >= 0; --i) await this.up(tokens[i]);
103
+ }
104
+ async _ensureModifiers(modifiers) {
105
+ for (const modifier of modifiers) {
106
+ if (!kModifiers.includes(modifier)) throw new Error('Unknown modifier ' + modifier);
107
+ }
108
+ const restore = Array.from(this._pressedModifiers);
109
+ for (const key of kModifiers) {
110
+ const needDown = modifiers.includes(key);
111
+ const isDown = this._pressedModifiers.has(key);
112
+ if (needDown && !isDown) await this.down(key);else if (!needDown && isDown) await this.up(key);
113
+ }
114
+ return restore;
115
+ }
116
+ _modifiers() {
117
+ return this._pressedModifiers;
118
+ }
119
+ }
120
+ exports.Keyboard = Keyboard;
121
+ class Mouse {
122
+ constructor(raw, page) {
123
+ this._keyboard = void 0;
124
+ this._x = 0;
125
+ this._y = 0;
126
+ this._lastButton = 'none';
127
+ this._buttons = new Set();
128
+ this._raw = void 0;
129
+ this._page = void 0;
130
+ this._raw = raw;
131
+ this._page = page;
132
+ this._keyboard = this._page.keyboard;
133
+ }
134
+ async move(x, y, options = {}, metadata) {
135
+ if (metadata) metadata.point = {
136
+ x,
137
+ y
138
+ };
139
+ const {
140
+ steps = 1
141
+ } = options;
142
+ const fromX = this._x;
143
+ const fromY = this._y;
144
+ this._x = x;
145
+ this._y = y;
146
+ for (let i = 1; i <= steps; i++) {
147
+ const middleX = fromX + (x - fromX) * (i / steps);
148
+ const middleY = fromY + (y - fromY) * (i / steps);
149
+ await this._raw.move(middleX, middleY, this._lastButton, this._buttons, this._keyboard._modifiers(), !!options.forClick);
150
+ }
151
+ }
152
+ async down(options = {}, metadata) {
153
+ if (metadata) metadata.point = {
154
+ x: this._x,
155
+ y: this._y
156
+ };
157
+ const {
158
+ button = 'left',
159
+ clickCount = 1
160
+ } = options;
161
+ this._lastButton = button;
162
+ this._buttons.add(button);
163
+ await this._raw.down(this._x, this._y, this._lastButton, this._buttons, this._keyboard._modifiers(), clickCount);
164
+ }
165
+ async up(options = {}, metadata) {
166
+ if (metadata) metadata.point = {
167
+ x: this._x,
168
+ y: this._y
169
+ };
170
+ const {
171
+ button = 'left',
172
+ clickCount = 1
173
+ } = options;
174
+ this._lastButton = 'none';
175
+ this._buttons.delete(button);
176
+ await this._raw.up(this._x, this._y, button, this._buttons, this._keyboard._modifiers(), clickCount);
177
+ }
178
+ async click(x, y, options = {}, metadata) {
179
+ if (metadata) metadata.point = {
180
+ x: this._x,
181
+ y: this._y
182
+ };
183
+ const {
184
+ delay = null,
185
+ clickCount = 1
186
+ } = options;
187
+ if (delay) {
188
+ this.move(x, y, {
189
+ forClick: true
190
+ });
191
+ for (let cc = 1; cc <= clickCount; ++cc) {
192
+ await this.down({
193
+ ...options,
194
+ clickCount: cc
195
+ });
196
+ await new Promise(f => setTimeout(f, delay));
197
+ await this.up({
198
+ ...options,
199
+ clickCount: cc
200
+ });
201
+ if (cc < clickCount) await new Promise(f => setTimeout(f, delay));
202
+ }
203
+ } else {
204
+ const promises = [];
205
+ promises.push(this.move(x, y, {
206
+ forClick: true
207
+ }));
208
+ for (let cc = 1; cc <= clickCount; ++cc) {
209
+ promises.push(this.down({
210
+ ...options,
211
+ clickCount: cc
212
+ }));
213
+ promises.push(this.up({
214
+ ...options,
215
+ clickCount: cc
216
+ }));
217
+ }
218
+ await Promise.all(promises);
219
+ }
220
+ }
221
+ async dblclick(x, y, options = {}) {
222
+ await this.click(x, y, {
223
+ ...options,
224
+ clickCount: 2
225
+ });
226
+ }
227
+ async wheel(deltaX, deltaY) {
228
+ await this._raw.wheel(this._x, this._y, this._buttons, this._keyboard._modifiers(), deltaX, deltaY);
229
+ }
230
+ }
231
+ exports.Mouse = Mouse;
232
+ const aliases = new Map([['ShiftLeft', ['Shift']], ['ControlLeft', ['Control']], ['AltLeft', ['Alt']], ['MetaLeft', ['Meta']], ['Enter', ['\n', '\r']]]);
233
+ const usKeyboardLayout = buildLayoutClosure(keyboardLayout.USKeyboardLayout);
234
+ function buildLayoutClosure(layout) {
235
+ const result = new Map();
236
+ for (const code in layout) {
237
+ const definition = layout[code];
238
+ const description = {
239
+ key: definition.key || '',
240
+ keyCode: definition.keyCode || 0,
241
+ keyCodeWithoutLocation: definition.keyCodeWithoutLocation || definition.keyCode || 0,
242
+ code,
243
+ text: definition.text || '',
244
+ location: definition.location || 0
245
+ };
246
+ if (definition.key.length === 1) description.text = description.key;
247
+
248
+ // Generate shifted definition.
249
+ let shiftedDescription;
250
+ if (definition.shiftKey) {
251
+ (0, _utils.assert)(definition.shiftKey.length === 1);
252
+ shiftedDescription = {
253
+ ...description
254
+ };
255
+ shiftedDescription.key = definition.shiftKey;
256
+ shiftedDescription.text = definition.shiftKey;
257
+ if (definition.shiftKeyCode) shiftedDescription.keyCode = definition.shiftKeyCode;
258
+ }
259
+
260
+ // Map from code: Digit3 -> { ... descrption, shifted }
261
+ result.set(code, {
262
+ ...description,
263
+ shifted: shiftedDescription
264
+ });
265
+
266
+ // Map from aliases: Shift -> non-shiftable definition
267
+ if (aliases.has(code)) {
268
+ for (const alias of aliases.get(code)) result.set(alias, description);
269
+ }
270
+
271
+ // Do not use numpad when converting keys to codes.
272
+ if (definition.location) continue;
273
+
274
+ // Map from key, no shifted
275
+ if (description.key.length === 1) result.set(description.key, description);
276
+
277
+ // Map from shiftKey, no shifted
278
+ if (shiftedDescription) result.set(shiftedDescription.key, {
279
+ ...shiftedDescription,
280
+ shifted: undefined
281
+ });
282
+ }
283
+ return result;
284
+ }
285
+ class Touchscreen {
286
+ constructor(raw, page) {
287
+ this._raw = void 0;
288
+ this._page = void 0;
289
+ this._raw = raw;
290
+ this._page = page;
291
+ }
292
+ async tap(x, y, metadata) {
293
+ if (metadata) metadata.point = {
294
+ x,
295
+ y
296
+ };
297
+ if (!this._page._browserContext._options.hasTouch) throw new Error('hasTouch must be enabled on the browser context before using the touchscreen.');
298
+ await this._raw.tap(x, y, this._page.keyboard._modifiers());
299
+ }
300
+ }
301
+ exports.Touchscreen = Touchscreen;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SdkObject = void 0;
7
+ exports.createInstrumentation = createInstrumentation;
8
+ exports.kTestSdkObjects = void 0;
9
+ exports.serverSideCallMetadata = serverSideCallMetadata;
10
+ var _events = require("events");
11
+ var _utils = require("../utils");
12
+ /**
13
+ * Copyright (c) Microsoft Corporation. All rights reserved.
14
+ *
15
+ * Licensed under the Apache License, Version 2.0 (the "License");
16
+ * you may not use this file except in compliance with the License.
17
+ * You may obtain a copy of the License at
18
+ *
19
+ * http://www.apache.org/licenses/LICENSE-2.0
20
+ *
21
+ * Unless required by applicable law or agreed to in writing, software
22
+ * distributed under the License is distributed on an "AS IS" BASIS,
23
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
+ * See the License for the specific language governing permissions and
25
+ * limitations under the License.
26
+ */
27
+
28
+ const kTestSdkObjects = exports.kTestSdkObjects = new WeakSet();
29
+ class SdkObject extends _events.EventEmitter {
30
+ constructor(parent, guidPrefix, guid) {
31
+ super();
32
+ this.guid = void 0;
33
+ this.attribution = void 0;
34
+ this.instrumentation = void 0;
35
+ this.guid = guid || `${guidPrefix || ''}@${(0, _utils.createGuid)()}`;
36
+ this.setMaxListeners(0);
37
+ this.attribution = {
38
+ ...parent.attribution
39
+ };
40
+ this.instrumentation = parent.instrumentation;
41
+ if (process.env._PW_INTERNAL_COUNT_SDK_OBJECTS) kTestSdkObjects.add(this);
42
+ }
43
+ }
44
+ exports.SdkObject = SdkObject;
45
+ function createInstrumentation() {
46
+ const listeners = new Map();
47
+ return new Proxy({}, {
48
+ get: (obj, prop) => {
49
+ if (typeof prop !== 'string') return obj[prop];
50
+ if (prop === 'addListener') return (listener, context) => listeners.set(listener, context);
51
+ if (prop === 'removeListener') return listener => listeners.delete(listener);
52
+ if (!prop.startsWith('on')) return obj[prop];
53
+ return async (sdkObject, ...params) => {
54
+ for (const [listener, context] of listeners) {
55
+ var _prop, _ref;
56
+ if (!context || sdkObject.attribution.context === context) await ((_prop = (_ref = listener)[prop]) === null || _prop === void 0 ? void 0 : _prop.call(_ref, sdkObject, ...params));
57
+ }
58
+ };
59
+ }
60
+ });
61
+ }
62
+ function serverSideCallMetadata() {
63
+ return {
64
+ id: '',
65
+ startTime: 0,
66
+ endTime: 0,
67
+ wallTime: Date.now(),
68
+ type: 'Internal',
69
+ method: '',
70
+ params: {},
71
+ log: [],
72
+ isServerSide: true
73
+ };
74
+ }