patchright-core 1.48.2

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 (333) hide show
  1. package/README.md +3 -0
  2. package/ThirdPartyNotices.txt +1548 -0
  3. package/bin/PrintDeps.exe +0 -0
  4. package/bin/README.md +2 -0
  5. package/bin/install_media_pack.ps1 +5 -0
  6. package/bin/reinstall_chrome_beta_linux.sh +40 -0
  7. package/bin/reinstall_chrome_beta_mac.sh +13 -0
  8. package/bin/reinstall_chrome_beta_win.ps1 +24 -0
  9. package/bin/reinstall_chrome_stable_linux.sh +40 -0
  10. package/bin/reinstall_chrome_stable_mac.sh +12 -0
  11. package/bin/reinstall_chrome_stable_win.ps1 +24 -0
  12. package/bin/reinstall_msedge_beta_linux.sh +40 -0
  13. package/bin/reinstall_msedge_beta_mac.sh +11 -0
  14. package/bin/reinstall_msedge_beta_win.ps1 +23 -0
  15. package/bin/reinstall_msedge_dev_linux.sh +40 -0
  16. package/bin/reinstall_msedge_dev_mac.sh +11 -0
  17. package/bin/reinstall_msedge_dev_win.ps1 +23 -0
  18. package/bin/reinstall_msedge_stable_linux.sh +40 -0
  19. package/bin/reinstall_msedge_stable_mac.sh +11 -0
  20. package/bin/reinstall_msedge_stable_win.ps1 +24 -0
  21. package/browsers.json +57 -0
  22. package/cli.js +18 -0
  23. package/index.d.ts +17 -0
  24. package/index.js +33 -0
  25. package/index.mjs +28 -0
  26. package/lib/androidServerImpl.js +69 -0
  27. package/lib/browserServerImpl.js +92 -0
  28. package/lib/cli/driver.js +95 -0
  29. package/lib/cli/program.js +589 -0
  30. package/lib/cli/programWithTestStub.js +67 -0
  31. package/lib/client/accessibility.js +50 -0
  32. package/lib/client/android.js +473 -0
  33. package/lib/client/api.js +285 -0
  34. package/lib/client/artifact.js +79 -0
  35. package/lib/client/browser.js +145 -0
  36. package/lib/client/browserContext.js +583 -0
  37. package/lib/client/browserType.js +241 -0
  38. package/lib/client/cdpSession.js +53 -0
  39. package/lib/client/channelOwner.js +235 -0
  40. package/lib/client/clientHelper.js +57 -0
  41. package/lib/client/clientInstrumentation.js +50 -0
  42. package/lib/client/clock.js +69 -0
  43. package/lib/client/connection.js +333 -0
  44. package/lib/client/consoleMessage.js +55 -0
  45. package/lib/client/coverage.js +41 -0
  46. package/lib/client/dialog.js +57 -0
  47. package/lib/client/download.js +62 -0
  48. package/lib/client/electron.js +135 -0
  49. package/lib/client/elementHandle.js +321 -0
  50. package/lib/client/errors.js +77 -0
  51. package/lib/client/eventEmitter.js +314 -0
  52. package/lib/client/events.js +94 -0
  53. package/lib/client/fetch.js +391 -0
  54. package/lib/client/fileChooser.js +45 -0
  55. package/lib/client/frame.js +504 -0
  56. package/lib/client/harRouter.js +99 -0
  57. package/lib/client/input.js +111 -0
  58. package/lib/client/jsHandle.js +121 -0
  59. package/lib/client/jsonPipe.js +35 -0
  60. package/lib/client/localUtils.js +36 -0
  61. package/lib/client/locator.js +441 -0
  62. package/lib/client/network.js +762 -0
  63. package/lib/client/page.js +770 -0
  64. package/lib/client/playwright.js +80 -0
  65. package/lib/client/selectors.js +67 -0
  66. package/lib/client/stream.js +54 -0
  67. package/lib/client/tracing.js +134 -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/clockSource.js +7 -0
  78. package/lib/generated/consoleApiSource.js +7 -0
  79. package/lib/generated/injectedScriptSource.js +7 -0
  80. package/lib/generated/pollingRecorderSource.js +7 -0
  81. package/lib/generated/utilityScriptSource.js +7 -0
  82. package/lib/generated/webSocketMockSource.js +7 -0
  83. package/lib/image_tools/colorUtils.js +98 -0
  84. package/lib/image_tools/compare.js +108 -0
  85. package/lib/image_tools/imageChannel.js +70 -0
  86. package/lib/image_tools/stats.js +102 -0
  87. package/lib/inProcessFactory.js +54 -0
  88. package/lib/inprocess.js +20 -0
  89. package/lib/outofprocess.js +67 -0
  90. package/lib/protocol/debug.js +27 -0
  91. package/lib/protocol/serializers.js +173 -0
  92. package/lib/protocol/transport.js +82 -0
  93. package/lib/protocol/validator.js +2760 -0
  94. package/lib/protocol/validatorPrimitives.js +139 -0
  95. package/lib/remote/playwrightConnection.js +274 -0
  96. package/lib/remote/playwrightServer.js +110 -0
  97. package/lib/server/accessibility.js +62 -0
  98. package/lib/server/android/android.js +441 -0
  99. package/lib/server/android/backendAdb.js +172 -0
  100. package/lib/server/artifact.js +104 -0
  101. package/lib/server/bidi/bidiBrowser.js +311 -0
  102. package/lib/server/bidi/bidiChromium.js +124 -0
  103. package/lib/server/bidi/bidiConnection.js +206 -0
  104. package/lib/server/bidi/bidiExecutionContext.js +159 -0
  105. package/lib/server/bidi/bidiFirefox.js +104 -0
  106. package/lib/server/bidi/bidiInput.js +158 -0
  107. package/lib/server/bidi/bidiNetworkManager.js +338 -0
  108. package/lib/server/bidi/bidiOverCdp.js +103 -0
  109. package/lib/server/bidi/bidiPage.js +529 -0
  110. package/lib/server/bidi/bidiPdf.js +140 -0
  111. package/lib/server/bidi/third_party/bidiDeserializer.js +93 -0
  112. package/lib/server/bidi/third_party/bidiKeyboard.js +238 -0
  113. package/lib/server/bidi/third_party/bidiProtocol.js +139 -0
  114. package/lib/server/bidi/third_party/bidiSerializer.js +144 -0
  115. package/lib/server/bidi/third_party/firefoxPrefs.js +221 -0
  116. package/lib/server/browser.js +148 -0
  117. package/lib/server/browserContext.js +666 -0
  118. package/lib/server/browserType.js +335 -0
  119. package/lib/server/chromium/appIcon.png +0 -0
  120. package/lib/server/chromium/chromium.js +350 -0
  121. package/lib/server/chromium/chromiumSwitches.js +36 -0
  122. package/lib/server/chromium/crAccessibility.js +237 -0
  123. package/lib/server/chromium/crBrowser.js +522 -0
  124. package/lib/server/chromium/crConnection.js +228 -0
  125. package/lib/server/chromium/crCoverage.js +246 -0
  126. package/lib/server/chromium/crDevTools.js +104 -0
  127. package/lib/server/chromium/crDragDrop.js +143 -0
  128. package/lib/server/chromium/crExecutionContext.js +149 -0
  129. package/lib/server/chromium/crInput.js +171 -0
  130. package/lib/server/chromium/crNetworkManager.js +809 -0
  131. package/lib/server/chromium/crPage.js +1235 -0
  132. package/lib/server/chromium/crPdf.js +153 -0
  133. package/lib/server/chromium/crProtocolHelper.js +133 -0
  134. package/lib/server/chromium/crServiceWorker.js +111 -0
  135. package/lib/server/chromium/defaultFontFamilies.js +145 -0
  136. package/lib/server/chromium/videoRecorder.js +155 -0
  137. package/lib/server/clock.js +133 -0
  138. package/lib/server/codegen/csharp.js +299 -0
  139. package/lib/server/codegen/java.js +235 -0
  140. package/lib/server/codegen/javascript.js +223 -0
  141. package/lib/server/codegen/jsonl.js +47 -0
  142. package/lib/server/codegen/language.js +88 -0
  143. package/lib/server/codegen/languages.js +30 -0
  144. package/lib/server/codegen/python.js +265 -0
  145. package/lib/server/codegen/types.js +5 -0
  146. package/lib/server/console.js +57 -0
  147. package/lib/server/cookieStore.js +185 -0
  148. package/lib/server/debugController.js +234 -0
  149. package/lib/server/debugger.js +132 -0
  150. package/lib/server/deviceDescriptors.js +26 -0
  151. package/lib/server/deviceDescriptorsSource.json +1669 -0
  152. package/lib/server/dialog.js +71 -0
  153. package/lib/server/dispatchers/androidDispatcher.js +193 -0
  154. package/lib/server/dispatchers/artifactDispatcher.js +118 -0
  155. package/lib/server/dispatchers/browserContextDispatcher.js +368 -0
  156. package/lib/server/dispatchers/browserDispatcher.js +170 -0
  157. package/lib/server/dispatchers/browserTypeDispatcher.js +55 -0
  158. package/lib/server/dispatchers/cdpSessionDispatcher.js +48 -0
  159. package/lib/server/dispatchers/debugControllerDispatcher.js +103 -0
  160. package/lib/server/dispatchers/dialogDispatcher.js +44 -0
  161. package/lib/server/dispatchers/dispatcher.js +395 -0
  162. package/lib/server/dispatchers/electronDispatcher.js +93 -0
  163. package/lib/server/dispatchers/elementHandlerDispatcher.js +228 -0
  164. package/lib/server/dispatchers/frameDispatcher.js +286 -0
  165. package/lib/server/dispatchers/jsHandleDispatcher.js +97 -0
  166. package/lib/server/dispatchers/jsonPipeDispatcher.js +59 -0
  167. package/lib/server/dispatchers/localUtilsDispatcher.js +413 -0
  168. package/lib/server/dispatchers/networkDispatchers.js +221 -0
  169. package/lib/server/dispatchers/pageDispatcher.js +367 -0
  170. package/lib/server/dispatchers/playwrightDispatcher.js +107 -0
  171. package/lib/server/dispatchers/selectorsDispatcher.js +36 -0
  172. package/lib/server/dispatchers/streamDispatcher.js +62 -0
  173. package/lib/server/dispatchers/tracingDispatcher.js +54 -0
  174. package/lib/server/dispatchers/webSocketRouteDispatcher.js +189 -0
  175. package/lib/server/dispatchers/writableStreamDispatcher.js +58 -0
  176. package/lib/server/dom.js +845 -0
  177. package/lib/server/download.js +60 -0
  178. package/lib/server/electron/electron.js +296 -0
  179. package/lib/server/electron/loader.js +57 -0
  180. package/lib/server/errors.js +68 -0
  181. package/lib/server/fetch.js +656 -0
  182. package/lib/server/fileChooser.js +42 -0
  183. package/lib/server/fileUploadUtils.js +75 -0
  184. package/lib/server/firefox/ffAccessibility.js +216 -0
  185. package/lib/server/firefox/ffBrowser.js +460 -0
  186. package/lib/server/firefox/ffConnection.js +168 -0
  187. package/lib/server/firefox/ffExecutionContext.js +135 -0
  188. package/lib/server/firefox/ffInput.js +150 -0
  189. package/lib/server/firefox/ffNetworkManager.js +233 -0
  190. package/lib/server/firefox/ffPage.js +559 -0
  191. package/lib/server/firefox/firefox.js +99 -0
  192. package/lib/server/formData.js +75 -0
  193. package/lib/server/frameSelectors.js +171 -0
  194. package/lib/server/frames.js +1808 -0
  195. package/lib/server/har/harRecorder.js +139 -0
  196. package/lib/server/har/harTracer.js +542 -0
  197. package/lib/server/helper.js +103 -0
  198. package/lib/server/index.js +114 -0
  199. package/lib/server/input.js +310 -0
  200. package/lib/server/instrumentation.js +70 -0
  201. package/lib/server/isomorphic/utilityScriptSerializers.js +226 -0
  202. package/lib/server/javascript.js +299 -0
  203. package/lib/server/launchApp.js +91 -0
  204. package/lib/server/macEditingCommands.js +139 -0
  205. package/lib/server/network.js +617 -0
  206. package/lib/server/page.js +819 -0
  207. package/lib/server/pipeTransport.js +85 -0
  208. package/lib/server/playwright.js +88 -0
  209. package/lib/server/progress.js +102 -0
  210. package/lib/server/protocolError.js +49 -0
  211. package/lib/server/recorder/contextRecorder.js +299 -0
  212. package/lib/server/recorder/recorderApp.js +196 -0
  213. package/lib/server/recorder/recorderCollection.js +116 -0
  214. package/lib/server/recorder/recorderFrontend.js +5 -0
  215. package/lib/server/recorder/recorderInTraceViewer.js +144 -0
  216. package/lib/server/recorder/recorderRunner.js +155 -0
  217. package/lib/server/recorder/recorderUtils.js +112 -0
  218. package/lib/server/recorder/throttledFile.js +46 -0
  219. package/lib/server/recorder.js +329 -0
  220. package/lib/server/registry/browserFetcher.js +168 -0
  221. package/lib/server/registry/dependencies.js +322 -0
  222. package/lib/server/registry/index.js +1005 -0
  223. package/lib/server/registry/nativeDeps.js +490 -0
  224. package/lib/server/registry/oopDownloadBrowserMain.js +138 -0
  225. package/lib/server/screenshotter.js +348 -0
  226. package/lib/server/selectors.js +73 -0
  227. package/lib/server/socksClientCertificatesInterceptor.js +340 -0
  228. package/lib/server/socksInterceptor.js +100 -0
  229. package/lib/server/trace/recorder/snapshotter.js +172 -0
  230. package/lib/server/trace/recorder/snapshotterInjected.js +493 -0
  231. package/lib/server/trace/recorder/tracing.js +542 -0
  232. package/lib/server/trace/test/inMemorySnapshotter.js +93 -0
  233. package/lib/server/trace/viewer/traceViewer.js +213 -0
  234. package/lib/server/transport.js +191 -0
  235. package/lib/server/types.js +24 -0
  236. package/lib/server/usKeyboardLayout.js +555 -0
  237. package/lib/server/webkit/webkit.js +87 -0
  238. package/lib/server/webkit/wkAccessibility.js +194 -0
  239. package/lib/server/webkit/wkBrowser.js +329 -0
  240. package/lib/server/webkit/wkConnection.js +173 -0
  241. package/lib/server/webkit/wkExecutionContext.js +143 -0
  242. package/lib/server/webkit/wkInput.js +169 -0
  243. package/lib/server/webkit/wkInterceptableRequest.js +162 -0
  244. package/lib/server/webkit/wkPage.js +1219 -0
  245. package/lib/server/webkit/wkProvisionalPage.js +94 -0
  246. package/lib/server/webkit/wkWorkers.js +104 -0
  247. package/lib/third_party/diff_match_patch.js +2222 -0
  248. package/lib/third_party/pixelmatch.js +255 -0
  249. package/lib/utils/ascii.js +31 -0
  250. package/lib/utils/comparators.js +171 -0
  251. package/lib/utils/crypto.js +174 -0
  252. package/lib/utils/debug.js +46 -0
  253. package/lib/utils/debugLogger.js +91 -0
  254. package/lib/utils/env.js +49 -0
  255. package/lib/utils/eventsHelper.js +38 -0
  256. package/lib/utils/expectUtils.js +33 -0
  257. package/lib/utils/fileUtils.js +205 -0
  258. package/lib/utils/happy-eyeballs.js +194 -0
  259. package/lib/utils/headers.js +52 -0
  260. package/lib/utils/hostPlatform.js +133 -0
  261. package/lib/utils/httpServer.js +237 -0
  262. package/lib/utils/index.js +368 -0
  263. package/lib/utils/isomorphic/cssParser.js +250 -0
  264. package/lib/utils/isomorphic/cssTokenizer.js +979 -0
  265. package/lib/utils/isomorphic/locatorGenerators.js +642 -0
  266. package/lib/utils/isomorphic/locatorParser.js +179 -0
  267. package/lib/utils/isomorphic/locatorUtils.js +62 -0
  268. package/lib/utils/isomorphic/mimeType.js +29 -0
  269. package/lib/utils/isomorphic/recorderUtils.js +195 -0
  270. package/lib/utils/isomorphic/selectorParser.js +397 -0
  271. package/lib/utils/isomorphic/stringUtils.js +139 -0
  272. package/lib/utils/isomorphic/traceUtils.js +39 -0
  273. package/lib/utils/isomorphic/urlMatch.js +120 -0
  274. package/lib/utils/linuxUtils.js +78 -0
  275. package/lib/utils/manualPromise.js +109 -0
  276. package/lib/utils/multimap.js +75 -0
  277. package/lib/utils/network.js +160 -0
  278. package/lib/utils/processLauncher.js +248 -0
  279. package/lib/utils/profiler.js +53 -0
  280. package/lib/utils/rtti.js +44 -0
  281. package/lib/utils/semaphore.js +51 -0
  282. package/lib/utils/spawnAsync.js +45 -0
  283. package/lib/utils/stackTrace.js +121 -0
  284. package/lib/utils/task.js +58 -0
  285. package/lib/utils/time.js +37 -0
  286. package/lib/utils/timeoutRunner.js +66 -0
  287. package/lib/utils/traceUtils.js +44 -0
  288. package/lib/utils/userAgent.js +105 -0
  289. package/lib/utils/wsServer.js +127 -0
  290. package/lib/utils/zipFile.js +75 -0
  291. package/lib/utils/zones.js +62 -0
  292. package/lib/utilsBundle.js +82 -0
  293. package/lib/utilsBundleImpl/index.js +53 -0
  294. package/lib/utilsBundleImpl/xdg-open +1066 -0
  295. package/lib/vite/htmlReport/index.html +66 -0
  296. package/lib/vite/recorder/assets/codeMirrorModule-baozm8ur.js +24 -0
  297. package/lib/vite/recorder/assets/codeMirrorModule-ez37Vkbh.css +1 -0
  298. package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
  299. package/lib/vite/recorder/assets/index-2ElAIWFB.js +42 -0
  300. package/lib/vite/recorder/assets/index-BW-aOBcL.css +1 -0
  301. package/lib/vite/recorder/index.html +29 -0
  302. package/lib/vite/recorder/playwright-logo.svg +9 -0
  303. package/lib/vite/traceViewer/assets/codeMirrorModule-Bh1rfd2w.js +24 -0
  304. package/lib/vite/traceViewer/assets/inspectorTab-7GHnKvSD.js +64 -0
  305. package/lib/vite/traceViewer/assets/testServerConnection-DeE2kSzz.js +1 -0
  306. package/lib/vite/traceViewer/assets/workbench-DPQnTHYP.js +9 -0
  307. package/lib/vite/traceViewer/assets/xtermModule-BeNbaIVa.js +9 -0
  308. package/lib/vite/traceViewer/codeMirrorModule.ez37Vkbh.css +1 -0
  309. package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
  310. package/lib/vite/traceViewer/embedded.BlHoW5LY.js +2 -0
  311. package/lib/vite/traceViewer/embedded.html +18 -0
  312. package/lib/vite/traceViewer/embedded.w7WN2u1R.css +1 -0
  313. package/lib/vite/traceViewer/index.CrbWWHbf.css +1 -0
  314. package/lib/vite/traceViewer/index.DaWVfou1.js +2 -0
  315. package/lib/vite/traceViewer/index.html +29 -0
  316. package/lib/vite/traceViewer/inspectorTab.DLjBDrQR.css +1 -0
  317. package/lib/vite/traceViewer/playwright-logo.svg +9 -0
  318. package/lib/vite/traceViewer/recorder.B_SY1GJM.css +0 -0
  319. package/lib/vite/traceViewer/recorder.C4zxcvd2.js +2 -0
  320. package/lib/vite/traceViewer/recorder.html +17 -0
  321. package/lib/vite/traceViewer/snapshot.html +21 -0
  322. package/lib/vite/traceViewer/sw.bundle.js +3 -0
  323. package/lib/vite/traceViewer/uiMode.CAYqod-m.css +1 -0
  324. package/lib/vite/traceViewer/uiMode.html +20 -0
  325. package/lib/vite/traceViewer/uiMode.mTXWniJb.js +5 -0
  326. package/lib/vite/traceViewer/workbench.D3JVcA9K.css +1 -0
  327. package/lib/vite/traceViewer/xtermModule.DSXBckUd.css +32 -0
  328. package/lib/zipBundle.js +25 -0
  329. package/lib/zipBundleImpl.js +5 -0
  330. package/package.json +44 -0
  331. package/types/protocol.d.ts +21571 -0
  332. package/types/structs.d.ts +45 -0
  333. package/types/types.d.ts +22519 -0
@@ -0,0 +1,770 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Page = exports.BindingCall = void 0;
7
+ var _fs = _interopRequireDefault(require("fs"));
8
+ var _path = _interopRequireDefault(require("path"));
9
+ var _errors = require("./errors");
10
+ var _timeoutSettings = require("../common/timeoutSettings");
11
+ var _utils = require("../utils");
12
+ var _accessibility = require("./accessibility");
13
+ var _artifact = require("./artifact");
14
+ var _channelOwner = require("./channelOwner");
15
+ var _clientHelper = require("./clientHelper");
16
+ var _coverage = require("./coverage");
17
+ var _download = require("./download");
18
+ var _elementHandle = require("./elementHandle");
19
+ var _events = require("./events");
20
+ var _fileChooser = require("./fileChooser");
21
+ var _frame = require("./frame");
22
+ var _input = require("./input");
23
+ var _jsHandle = require("./jsHandle");
24
+ var _network = require("./network");
25
+ var _video = require("./video");
26
+ var _waiter = require("./waiter");
27
+ var _worker = require("./worker");
28
+ var _harRouter = require("./harRouter");
29
+ let _Symbol$asyncDispose;
30
+ /**
31
+ * Copyright 2017 Google Inc. All rights reserved.
32
+ * Modifications copyright (c) Microsoft Corporation.
33
+ *
34
+ * Licensed under the Apache License, Version 2.0 (the "License");
35
+ * you may not use this file except in compliance with the License.
36
+ * You may obtain a copy of the License at
37
+ *
38
+ * http://www.apache.org/licenses/LICENSE-2.0
39
+ *
40
+ * Unless required by applicable law or agreed to in writing, software
41
+ * distributed under the License is distributed on an "AS IS" BASIS,
42
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
43
+ * See the License for the specific language governing permissions and
44
+ * limitations under the License.
45
+ */
46
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
47
+ _Symbol$asyncDispose = Symbol.asyncDispose;
48
+ class Page extends _channelOwner.ChannelOwner {
49
+ static from(page) {
50
+ return page._object;
51
+ }
52
+ static fromNullable(page) {
53
+ return page ? Page.from(page) : null;
54
+ }
55
+ constructor(parent, type, guid, initializer) {
56
+ super(parent, type, guid, initializer);
57
+ this._browserContext = void 0;
58
+ this._ownedContext = void 0;
59
+ this._mainFrame = void 0;
60
+ this._frames = new Set();
61
+ this._workers = new Set();
62
+ this._closed = false;
63
+ this._closedOrCrashedScope = new _utils.LongStandingScope();
64
+ this._viewportSize = void 0;
65
+ this._routes = [];
66
+ this._webSocketRoutes = [];
67
+ this.accessibility = void 0;
68
+ this.coverage = void 0;
69
+ this.keyboard = void 0;
70
+ this.mouse = void 0;
71
+ this.request = void 0;
72
+ this.touchscreen = void 0;
73
+ this.clock = void 0;
74
+ this._bindings = new Map();
75
+ this._timeoutSettings = void 0;
76
+ this._video = null;
77
+ this._opener = void 0;
78
+ this._closeReason = void 0;
79
+ this._closeWasCalled = false;
80
+ this._harRouters = [];
81
+ this._locatorHandlers = new Map();
82
+ this.routeInjecting = false;
83
+ this._browserContext = parent;
84
+ this._timeoutSettings = new _timeoutSettings.TimeoutSettings(this._browserContext._timeoutSettings);
85
+ this.accessibility = new _accessibility.Accessibility(this._channel);
86
+ this.keyboard = new _input.Keyboard(this);
87
+ this.mouse = new _input.Mouse(this);
88
+ this.request = this._browserContext.request;
89
+ this.touchscreen = new _input.Touchscreen(this);
90
+ this.clock = this._browserContext.clock;
91
+ this._mainFrame = _frame.Frame.from(initializer.mainFrame);
92
+ this._mainFrame._page = this;
93
+ this._frames.add(this._mainFrame);
94
+ this._viewportSize = initializer.viewportSize || null;
95
+ this._closed = initializer.isClosed;
96
+ this._opener = Page.fromNullable(initializer.opener);
97
+ this._channel.on('bindingCall', ({
98
+ binding
99
+ }) => this._onBinding(BindingCall.from(binding)));
100
+ this._channel.on('close', () => this._onClose());
101
+ this._channel.on('crash', () => this._onCrash());
102
+ this._channel.on('download', ({
103
+ url,
104
+ suggestedFilename,
105
+ artifact
106
+ }) => {
107
+ const artifactObject = _artifact.Artifact.from(artifact);
108
+ this.emit(_events.Events.Page.Download, new _download.Download(this, url, suggestedFilename, artifactObject));
109
+ });
110
+ this._channel.on('fileChooser', ({
111
+ element,
112
+ isMultiple
113
+ }) => this.emit(_events.Events.Page.FileChooser, new _fileChooser.FileChooser(this, _elementHandle.ElementHandle.from(element), isMultiple)));
114
+ this._channel.on('frameAttached', ({
115
+ frame
116
+ }) => this._onFrameAttached(_frame.Frame.from(frame)));
117
+ this._channel.on('frameDetached', ({
118
+ frame
119
+ }) => this._onFrameDetached(_frame.Frame.from(frame)));
120
+ this._channel.on('locatorHandlerTriggered', ({
121
+ uid
122
+ }) => this._onLocatorHandlerTriggered(uid));
123
+ this._channel.on('route', ({
124
+ route
125
+ }) => this._onRoute(_network.Route.from(route)));
126
+ this._channel.on('webSocketRoute', ({
127
+ webSocketRoute
128
+ }) => this._onWebSocketRoute(_network.WebSocketRoute.from(webSocketRoute)));
129
+ this._channel.on('video', ({
130
+ artifact
131
+ }) => {
132
+ const artifactObject = _artifact.Artifact.from(artifact);
133
+ this._forceVideo()._artifactReady(artifactObject);
134
+ });
135
+ this._channel.on('webSocket', ({
136
+ webSocket
137
+ }) => this.emit(_events.Events.Page.WebSocket, _network.WebSocket.from(webSocket)));
138
+ this._channel.on('worker', ({
139
+ worker
140
+ }) => this._onWorker(_worker.Worker.from(worker)));
141
+ this.coverage = new _coverage.Coverage(this._channel);
142
+ this.once(_events.Events.Page.Close, () => this._closedOrCrashedScope.close(this._closeErrorWithReason()));
143
+ this.once(_events.Events.Page.Crash, () => this._closedOrCrashedScope.close(new _errors.TargetClosedError()));
144
+ this._setEventToSubscriptionMapping(new Map([[_events.Events.Page.Console, 'console'], [_events.Events.Page.Dialog, 'dialog'], [_events.Events.Page.Request, 'request'], [_events.Events.Page.Response, 'response'], [_events.Events.Page.RequestFinished, 'requestFinished'], [_events.Events.Page.RequestFailed, 'requestFailed'], [_events.Events.Page.FileChooser, 'fileChooser']]));
145
+ }
146
+ _onFrameAttached(frame) {
147
+ frame._page = this;
148
+ this._frames.add(frame);
149
+ if (frame._parentFrame) frame._parentFrame._childFrames.add(frame);
150
+ this.emit(_events.Events.Page.FrameAttached, frame);
151
+ }
152
+ _onFrameDetached(frame) {
153
+ this._frames.delete(frame);
154
+ frame._detached = true;
155
+ if (frame._parentFrame) frame._parentFrame._childFrames.delete(frame);
156
+ this.emit(_events.Events.Page.FrameDetached, frame);
157
+ }
158
+ async _onRoute(route) {
159
+ route._context = this.context();
160
+ const routeHandlers = this._routes.slice();
161
+ for (const routeHandler of routeHandlers) {
162
+ // If the page was closed we stall all requests right away.
163
+ if (this._closeWasCalled || this._browserContext._closeWasCalled) return;
164
+ if (!routeHandler.matches(route.request().url())) continue;
165
+ const index = this._routes.indexOf(routeHandler);
166
+ if (index === -1) continue;
167
+ if (routeHandler.willExpire()) this._routes.splice(index, 1);
168
+ const handled = await routeHandler.handle(route);
169
+ if (!this._routes.length) this._wrapApiCall(() => this._updateInterceptionPatterns(), true).catch(() => {});
170
+ if (handled) return;
171
+ }
172
+ await this._browserContext._onRoute(route);
173
+ }
174
+ async _onWebSocketRoute(webSocketRoute) {
175
+ const routeHandler = this._webSocketRoutes.find(route => route.matches(webSocketRoute.url()));
176
+ if (routeHandler) await routeHandler.handle(webSocketRoute);else await this._browserContext._onWebSocketRoute(webSocketRoute);
177
+ }
178
+ async _onBinding(bindingCall) {
179
+ const func = this._bindings.get(bindingCall._initializer.name);
180
+ if (func) {
181
+ await bindingCall.call(func);
182
+ return;
183
+ }
184
+ await this._browserContext._onBinding(bindingCall);
185
+ }
186
+ _onWorker(worker) {
187
+ this._workers.add(worker);
188
+ worker._page = this;
189
+ this.emit(_events.Events.Page.Worker, worker);
190
+ }
191
+ _onClose() {
192
+ this._closed = true;
193
+ this._browserContext._pages.delete(this);
194
+ this._browserContext._backgroundPages.delete(this);
195
+ this._disposeHarRouters();
196
+ this.emit(_events.Events.Page.Close, this);
197
+ }
198
+ _onCrash() {
199
+ this.emit(_events.Events.Page.Crash, this);
200
+ }
201
+ context() {
202
+ return this._browserContext;
203
+ }
204
+ async opener() {
205
+ if (!this._opener || this._opener.isClosed()) return null;
206
+ return this._opener;
207
+ }
208
+ mainFrame() {
209
+ return this._mainFrame;
210
+ }
211
+ frame(frameSelector) {
212
+ const name = (0, _utils.isString)(frameSelector) ? frameSelector : frameSelector.name;
213
+ const url = (0, _utils.isObject)(frameSelector) ? frameSelector.url : undefined;
214
+ (0, _utils.assert)(name || url, 'Either name or url matcher should be specified');
215
+ return this.frames().find(f => {
216
+ if (name) return f.name() === name;
217
+ return (0, _utils.urlMatches)(this._browserContext._options.baseURL, f.url(), url);
218
+ }) || null;
219
+ }
220
+ frames() {
221
+ return [...this._frames];
222
+ }
223
+ setDefaultNavigationTimeout(timeout) {
224
+ this._timeoutSettings.setDefaultNavigationTimeout(timeout);
225
+ this._wrapApiCall(async () => {
226
+ this._channel.setDefaultNavigationTimeoutNoReply({
227
+ timeout
228
+ }).catch(() => {});
229
+ }, true);
230
+ }
231
+ setDefaultTimeout(timeout) {
232
+ this._timeoutSettings.setDefaultTimeout(timeout);
233
+ this._wrapApiCall(async () => {
234
+ this._channel.setDefaultTimeoutNoReply({
235
+ timeout
236
+ }).catch(() => {});
237
+ }, true);
238
+ }
239
+ _forceVideo() {
240
+ if (!this._video) this._video = new _video.Video(this, this._connection);
241
+ return this._video;
242
+ }
243
+ video() {
244
+ // Note: we are creating Video object lazily, because we do not know
245
+ // BrowserContextOptions when constructing the page - it is assigned
246
+ // too late during launchPersistentContext.
247
+ if (!this._browserContext._options.recordVideo) return null;
248
+ return this._forceVideo();
249
+ }
250
+ async $(selector, options) {
251
+ return await this._mainFrame.$(selector, options);
252
+ }
253
+ async waitForSelector(selector, options) {
254
+ return await this._mainFrame.waitForSelector(selector, options);
255
+ }
256
+ async dispatchEvent(selector, type, eventInit, options) {
257
+ return await this._mainFrame.dispatchEvent(selector, type, eventInit, options);
258
+ }
259
+ async evaluateHandle(pageFunction, arg) {
260
+ (0, _jsHandle.assertMaxArguments)(arguments.length, 2);
261
+ return await this._mainFrame.evaluateHandle(pageFunction, arg);
262
+ }
263
+ async $eval(selector, pageFunction, arg) {
264
+ (0, _jsHandle.assertMaxArguments)(arguments.length, 3);
265
+ return await this._mainFrame.$eval(selector, pageFunction, arg);
266
+ }
267
+ async $$eval(selector, pageFunction, arg) {
268
+ (0, _jsHandle.assertMaxArguments)(arguments.length, 3);
269
+ return await this._mainFrame.$$eval(selector, pageFunction, arg);
270
+ }
271
+ async $$(selector) {
272
+ return await this._mainFrame.$$(selector);
273
+ }
274
+ async addScriptTag(options = {}) {
275
+ return await this._mainFrame.addScriptTag(options);
276
+ }
277
+ async addStyleTag(options = {}) {
278
+ return await this._mainFrame.addStyleTag(options);
279
+ }
280
+ async exposeFunction(name, callback) {
281
+ await this.installInjectRoute();
282
+ await this._channel.exposeBinding({
283
+ name
284
+ });
285
+ const binding = (source, ...args) => callback(...args);
286
+ this._bindings.set(name, binding);
287
+ }
288
+ async exposeBinding(name, callback, options = {}) {
289
+ await this.installInjectRoute();
290
+ await this._channel.exposeBinding({
291
+ name,
292
+ needsHandle: options.handle
293
+ });
294
+ this._bindings.set(name, callback);
295
+ }
296
+ async setExtraHTTPHeaders(headers) {
297
+ (0, _network.validateHeaders)(headers);
298
+ await this._channel.setExtraHTTPHeaders({
299
+ headers: (0, _utils.headersObjectToArray)(headers)
300
+ });
301
+ }
302
+ url() {
303
+ return this._mainFrame.url();
304
+ }
305
+ async content() {
306
+ return await this._mainFrame.content();
307
+ }
308
+ async setContent(html, options) {
309
+ return await this._mainFrame.setContent(html, options);
310
+ }
311
+ async goto(url, options) {
312
+ return await this._mainFrame.goto(url, options);
313
+ }
314
+ async reload(options = {}) {
315
+ const waitUntil = (0, _frame.verifyLoadState)('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);
316
+ return _network.Response.fromNullable((await this._channel.reload({
317
+ ...options,
318
+ waitUntil
319
+ })).response);
320
+ }
321
+ async addLocatorHandler(locator, handler, options = {}) {
322
+ if (locator._frame !== this._mainFrame) throw new Error(`Locator must belong to the main frame of this page`);
323
+ if (options.times === 0) return;
324
+ const {
325
+ uid
326
+ } = await this._channel.registerLocatorHandler({
327
+ selector: locator._selector,
328
+ noWaitAfter: options.noWaitAfter
329
+ });
330
+ this._locatorHandlers.set(uid, {
331
+ locator,
332
+ handler,
333
+ times: options.times
334
+ });
335
+ }
336
+ async _onLocatorHandlerTriggered(uid) {
337
+ let remove = false;
338
+ try {
339
+ const handler = this._locatorHandlers.get(uid);
340
+ if (handler && handler.times !== 0) {
341
+ if (handler.times !== undefined) handler.times--;
342
+ await handler.handler(handler.locator);
343
+ }
344
+ remove = (handler === null || handler === void 0 ? void 0 : handler.times) === 0;
345
+ } finally {
346
+ if (remove) this._locatorHandlers.delete(uid);
347
+ this._wrapApiCall(() => this._channel.resolveLocatorHandlerNoReply({
348
+ uid,
349
+ remove
350
+ }), true).catch(() => {});
351
+ }
352
+ }
353
+ async removeLocatorHandler(locator) {
354
+ for (const [uid, data] of this._locatorHandlers) {
355
+ if (data.locator._equals(locator)) {
356
+ this._locatorHandlers.delete(uid);
357
+ await this._channel.unregisterLocatorHandler({
358
+ uid
359
+ }).catch(() => {});
360
+ }
361
+ }
362
+ }
363
+ async waitForLoadState(state, options) {
364
+ return await this._mainFrame.waitForLoadState(state, options);
365
+ }
366
+ async waitForNavigation(options) {
367
+ return await this._mainFrame.waitForNavigation(options);
368
+ }
369
+ async waitForURL(url, options) {
370
+ return await this._mainFrame.waitForURL(url, options);
371
+ }
372
+ async waitForRequest(urlOrPredicate, options = {}) {
373
+ const predicate = async request => {
374
+ if ((0, _utils.isString)(urlOrPredicate) || (0, _utils.isRegExp)(urlOrPredicate)) return (0, _utils.urlMatches)(this._browserContext._options.baseURL, request.url(), urlOrPredicate);
375
+ return await urlOrPredicate(request);
376
+ };
377
+ const trimmedUrl = trimUrl(urlOrPredicate);
378
+ const logLine = trimmedUrl ? `waiting for request ${trimmedUrl}` : undefined;
379
+ return await this._waitForEvent(_events.Events.Page.Request, {
380
+ predicate,
381
+ timeout: options.timeout
382
+ }, logLine);
383
+ }
384
+ async waitForResponse(urlOrPredicate, options = {}) {
385
+ const predicate = async response => {
386
+ if ((0, _utils.isString)(urlOrPredicate) || (0, _utils.isRegExp)(urlOrPredicate)) return (0, _utils.urlMatches)(this._browserContext._options.baseURL, response.url(), urlOrPredicate);
387
+ return await urlOrPredicate(response);
388
+ };
389
+ const trimmedUrl = trimUrl(urlOrPredicate);
390
+ const logLine = trimmedUrl ? `waiting for response ${trimmedUrl}` : undefined;
391
+ return await this._waitForEvent(_events.Events.Page.Response, {
392
+ predicate,
393
+ timeout: options.timeout
394
+ }, logLine);
395
+ }
396
+ async waitForEvent(event, optionsOrPredicate = {}) {
397
+ return await this._waitForEvent(event, optionsOrPredicate, `waiting for event "${event}"`);
398
+ }
399
+ _closeErrorWithReason() {
400
+ return new _errors.TargetClosedError(this._closeReason || this._browserContext._effectiveCloseReason());
401
+ }
402
+ async _waitForEvent(event, optionsOrPredicate, logLine) {
403
+ return await this._wrapApiCall(async () => {
404
+ const timeout = this._timeoutSettings.timeout(typeof optionsOrPredicate === 'function' ? {} : optionsOrPredicate);
405
+ const predicate = typeof optionsOrPredicate === 'function' ? optionsOrPredicate : optionsOrPredicate.predicate;
406
+ const waiter = _waiter.Waiter.createForEvent(this, event);
407
+ if (logLine) waiter.log(logLine);
408
+ waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);
409
+ if (event !== _events.Events.Page.Crash) waiter.rejectOnEvent(this, _events.Events.Page.Crash, new Error('Page crashed'));
410
+ if (event !== _events.Events.Page.Close) waiter.rejectOnEvent(this, _events.Events.Page.Close, () => this._closeErrorWithReason());
411
+ const result = await waiter.waitForEvent(this, event, predicate);
412
+ waiter.dispose();
413
+ return result;
414
+ });
415
+ }
416
+ async goBack(options = {}) {
417
+ const waitUntil = (0, _frame.verifyLoadState)('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);
418
+ return _network.Response.fromNullable((await this._channel.goBack({
419
+ ...options,
420
+ waitUntil
421
+ })).response);
422
+ }
423
+ async goForward(options = {}) {
424
+ const waitUntil = (0, _frame.verifyLoadState)('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);
425
+ return _network.Response.fromNullable((await this._channel.goForward({
426
+ ...options,
427
+ waitUntil
428
+ })).response);
429
+ }
430
+ async requestGC() {
431
+ await this._channel.requestGC();
432
+ }
433
+ async emulateMedia(options = {}) {
434
+ await this._channel.emulateMedia({
435
+ media: options.media === null ? 'no-override' : options.media,
436
+ colorScheme: options.colorScheme === null ? 'no-override' : options.colorScheme,
437
+ reducedMotion: options.reducedMotion === null ? 'no-override' : options.reducedMotion,
438
+ forcedColors: options.forcedColors === null ? 'no-override' : options.forcedColors
439
+ });
440
+ }
441
+ async setViewportSize(viewportSize) {
442
+ this._viewportSize = viewportSize;
443
+ await this._channel.setViewportSize({
444
+ viewportSize
445
+ });
446
+ }
447
+ viewportSize() {
448
+ return this._viewportSize;
449
+ }
450
+ async evaluate(pageFunction, arg) {
451
+ (0, _jsHandle.assertMaxArguments)(arguments.length, 2);
452
+ return await this._mainFrame.evaluate(pageFunction, arg);
453
+ }
454
+ async addInitScript(script, arg) {
455
+ await this.installInjectRoute();
456
+ const source = await (0, _clientHelper.evaluationScript)(script, arg);
457
+ await this._channel.addInitScript({
458
+ source
459
+ });
460
+ }
461
+ async route(url, handler, options = {}) {
462
+ this._routes.unshift(new _network.RouteHandler(this._browserContext._options.baseURL, url, handler, options.times));
463
+ await this._updateInterceptionPatterns();
464
+ }
465
+ async routeFromHAR(har, options = {}) {
466
+ if (options.update) {
467
+ await this._browserContext._recordIntoHAR(har, this, options);
468
+ return;
469
+ }
470
+ const harRouter = await _harRouter.HarRouter.create(this._connection.localUtils(), har, options.notFound || 'abort', {
471
+ urlMatch: options.url
472
+ });
473
+ this._harRouters.push(harRouter);
474
+ await harRouter.addPageRoute(this);
475
+ }
476
+ async routeWebSocket(url, handler) {
477
+ this._webSocketRoutes.unshift(new _network.WebSocketRouteHandler(this._browserContext._options.baseURL, url, handler));
478
+ await this._updateWebSocketInterceptionPatterns();
479
+ }
480
+ _disposeHarRouters() {
481
+ this._harRouters.forEach(router => router.dispose());
482
+ this._harRouters = [];
483
+ }
484
+ async unrouteAll(options) {
485
+ await this._unrouteInternal(this._routes, [], options === null || options === void 0 ? void 0 : options.behavior);
486
+ this._disposeHarRouters();
487
+ }
488
+ async unroute(url, handler) {
489
+ const removed = [];
490
+ const remaining = [];
491
+ for (const route of this._routes) {
492
+ if ((0, _utils.urlMatchesEqual)(route.url, url) && (!handler || route.handler === handler)) removed.push(route);else remaining.push(route);
493
+ }
494
+ await this._unrouteInternal(removed, remaining, 'default');
495
+ }
496
+ async _unrouteInternal(removed, remaining, behavior) {
497
+ this._routes = remaining;
498
+ await this._updateInterceptionPatterns();
499
+ if (!behavior || behavior === 'default') return;
500
+ const promises = removed.map(routeHandler => routeHandler.stop(behavior));
501
+ await Promise.all(promises);
502
+ }
503
+ async _updateInterceptionPatterns() {
504
+ const patterns = _network.RouteHandler.prepareInterceptionPatterns(this._routes);
505
+ await this._channel.setNetworkInterceptionPatterns({
506
+ patterns
507
+ });
508
+ }
509
+ async _updateWebSocketInterceptionPatterns() {
510
+ const patterns = _network.WebSocketRouteHandler.prepareInterceptionPatterns(this._webSocketRoutes);
511
+ await this._channel.setWebSocketInterceptionPatterns({
512
+ patterns
513
+ });
514
+ }
515
+ async screenshot(options = {}) {
516
+ const copy = {
517
+ ...options,
518
+ mask: undefined
519
+ };
520
+ if (!copy.type) copy.type = (0, _elementHandle.determineScreenshotType)(options);
521
+ if (options.mask) {
522
+ copy.mask = options.mask.map(locator => ({
523
+ frame: locator._frame._channel,
524
+ selector: locator._selector
525
+ }));
526
+ }
527
+ const result = await this._channel.screenshot(copy);
528
+ if (options.path) {
529
+ await (0, _utils.mkdirIfNeeded)(options.path);
530
+ await _fs.default.promises.writeFile(options.path, result.binary);
531
+ }
532
+ return result.binary;
533
+ }
534
+ async _expectScreenshot(options) {
535
+ const mask = options !== null && options !== void 0 && options.mask ? options === null || options === void 0 ? void 0 : options.mask.map(locator => ({
536
+ frame: locator._frame._channel,
537
+ selector: locator._selector
538
+ })) : undefined;
539
+ const locator = options.locator ? {
540
+ frame: options.locator._frame._channel,
541
+ selector: options.locator._selector
542
+ } : undefined;
543
+ return await this._channel.expectScreenshot({
544
+ ...options,
545
+ isNot: !!options.isNot,
546
+ locator,
547
+ mask
548
+ });
549
+ }
550
+ async title() {
551
+ return await this._mainFrame.title();
552
+ }
553
+ async bringToFront() {
554
+ await this._channel.bringToFront();
555
+ }
556
+ async [_Symbol$asyncDispose]() {
557
+ await this.close();
558
+ }
559
+ async close(options = {}) {
560
+ this._closeReason = options.reason;
561
+ this._closeWasCalled = true;
562
+ try {
563
+ if (this._ownedContext) await this._ownedContext.close();else await this._channel.close(options);
564
+ } catch (e) {
565
+ if ((0, _errors.isTargetClosedError)(e) && !options.runBeforeUnload) return;
566
+ throw e;
567
+ }
568
+ }
569
+ isClosed() {
570
+ return this._closed;
571
+ }
572
+ async click(selector, options) {
573
+ return await this._mainFrame.click(selector, options);
574
+ }
575
+ async dragAndDrop(source, target, options) {
576
+ return await this._mainFrame.dragAndDrop(source, target, options);
577
+ }
578
+ async dblclick(selector, options) {
579
+ return await this._mainFrame.dblclick(selector, options);
580
+ }
581
+ async tap(selector, options) {
582
+ return await this._mainFrame.tap(selector, options);
583
+ }
584
+ async fill(selector, value, options) {
585
+ return await this._mainFrame.fill(selector, value, options);
586
+ }
587
+ locator(selector, options) {
588
+ return this.mainFrame().locator(selector, options);
589
+ }
590
+ getByTestId(testId) {
591
+ return this.mainFrame().getByTestId(testId);
592
+ }
593
+ getByAltText(text, options) {
594
+ return this.mainFrame().getByAltText(text, options);
595
+ }
596
+ getByLabel(text, options) {
597
+ return this.mainFrame().getByLabel(text, options);
598
+ }
599
+ getByPlaceholder(text, options) {
600
+ return this.mainFrame().getByPlaceholder(text, options);
601
+ }
602
+ getByText(text, options) {
603
+ return this.mainFrame().getByText(text, options);
604
+ }
605
+ getByTitle(text, options) {
606
+ return this.mainFrame().getByTitle(text, options);
607
+ }
608
+ getByRole(role, options = {}) {
609
+ return this.mainFrame().getByRole(role, options);
610
+ }
611
+ frameLocator(selector) {
612
+ return this.mainFrame().frameLocator(selector);
613
+ }
614
+ async focus(selector, options) {
615
+ return await this._mainFrame.focus(selector, options);
616
+ }
617
+ async textContent(selector, options) {
618
+ return await this._mainFrame.textContent(selector, options);
619
+ }
620
+ async innerText(selector, options) {
621
+ return await this._mainFrame.innerText(selector, options);
622
+ }
623
+ async innerHTML(selector, options) {
624
+ return await this._mainFrame.innerHTML(selector, options);
625
+ }
626
+ async getAttribute(selector, name, options) {
627
+ return await this._mainFrame.getAttribute(selector, name, options);
628
+ }
629
+ async inputValue(selector, options) {
630
+ return await this._mainFrame.inputValue(selector, options);
631
+ }
632
+ async isChecked(selector, options) {
633
+ return await this._mainFrame.isChecked(selector, options);
634
+ }
635
+ async isDisabled(selector, options) {
636
+ return await this._mainFrame.isDisabled(selector, options);
637
+ }
638
+ async isEditable(selector, options) {
639
+ return await this._mainFrame.isEditable(selector, options);
640
+ }
641
+ async isEnabled(selector, options) {
642
+ return await this._mainFrame.isEnabled(selector, options);
643
+ }
644
+ async isHidden(selector, options) {
645
+ return await this._mainFrame.isHidden(selector, options);
646
+ }
647
+ async isVisible(selector, options) {
648
+ return await this._mainFrame.isVisible(selector, options);
649
+ }
650
+ async hover(selector, options) {
651
+ return await this._mainFrame.hover(selector, options);
652
+ }
653
+ async selectOption(selector, values, options) {
654
+ return await this._mainFrame.selectOption(selector, values, options);
655
+ }
656
+ async setInputFiles(selector, files, options) {
657
+ return await this._mainFrame.setInputFiles(selector, files, options);
658
+ }
659
+ async type(selector, text, options) {
660
+ return await this._mainFrame.type(selector, text, options);
661
+ }
662
+ async press(selector, key, options) {
663
+ return await this._mainFrame.press(selector, key, options);
664
+ }
665
+ async check(selector, options) {
666
+ return await this._mainFrame.check(selector, options);
667
+ }
668
+ async uncheck(selector, options) {
669
+ return await this._mainFrame.uncheck(selector, options);
670
+ }
671
+ async setChecked(selector, checked, options) {
672
+ return await this._mainFrame.setChecked(selector, checked, options);
673
+ }
674
+ async waitForTimeout(timeout) {
675
+ return await this._mainFrame.waitForTimeout(timeout);
676
+ }
677
+ async waitForFunction(pageFunction, arg, options) {
678
+ return await this._mainFrame.waitForFunction(pageFunction, arg, options);
679
+ }
680
+ workers() {
681
+ return [...this._workers];
682
+ }
683
+ async pause() {
684
+ var _this$_instrumentatio;
685
+ if (require('inspector').url()) return;
686
+ const defaultNavigationTimeout = this._browserContext._timeoutSettings.defaultNavigationTimeout();
687
+ const defaultTimeout = this._browserContext._timeoutSettings.defaultTimeout();
688
+ this._browserContext.setDefaultNavigationTimeout(0);
689
+ this._browserContext.setDefaultTimeout(0);
690
+ (_this$_instrumentatio = this._instrumentation) === null || _this$_instrumentatio === void 0 || _this$_instrumentatio.onWillPause();
691
+ await this._closedOrCrashedScope.safeRace(this.context()._channel.pause());
692
+ this._browserContext.setDefaultNavigationTimeout(defaultNavigationTimeout);
693
+ this._browserContext.setDefaultTimeout(defaultTimeout);
694
+ }
695
+ async pdf(options = {}) {
696
+ const transportOptions = {
697
+ ...options
698
+ };
699
+ if (transportOptions.margin) transportOptions.margin = {
700
+ ...transportOptions.margin
701
+ };
702
+ if (typeof options.width === 'number') transportOptions.width = options.width + 'px';
703
+ if (typeof options.height === 'number') transportOptions.height = options.height + 'px';
704
+ for (const margin of ['top', 'right', 'bottom', 'left']) {
705
+ const index = margin;
706
+ if (options.margin && typeof options.margin[index] === 'number') transportOptions.margin[index] = transportOptions.margin[index] + 'px';
707
+ }
708
+ const result = await this._channel.pdf(transportOptions);
709
+ if (options.path) {
710
+ await _fs.default.promises.mkdir(_path.default.dirname(options.path), {
711
+ recursive: true
712
+ });
713
+ await _fs.default.promises.writeFile(options.path, result.pdf);
714
+ }
715
+ return result.pdf;
716
+ }
717
+ async installInjectRoute() {
718
+ if (this.routeInjecting || this.context().routeInjecting) return;
719
+ await this.route('**/*', async route => {
720
+ if (route.request().resourceType() === 'document' && route.request().url().startsWith('http')) {
721
+ try {
722
+ const response = await route.fetch({
723
+ maxRedirects: 0
724
+ });
725
+ await route.fulfill({
726
+ response: response
727
+ });
728
+ } catch (e) {
729
+ await route.continue();
730
+ }
731
+ } else {
732
+ await route.continue();
733
+ }
734
+ });
735
+ this.routeInjecting = true;
736
+ }
737
+ }
738
+ exports.Page = Page;
739
+ class BindingCall extends _channelOwner.ChannelOwner {
740
+ static from(channel) {
741
+ return channel._object;
742
+ }
743
+ constructor(parent, type, guid, initializer) {
744
+ super(parent, type, guid, initializer);
745
+ }
746
+ async call(func) {
747
+ try {
748
+ const frame = _frame.Frame.from(this._initializer.frame);
749
+ const source = {
750
+ context: frame._page.context(),
751
+ page: frame._page,
752
+ frame
753
+ };
754
+ let result;
755
+ if (this._initializer.handle) result = await func(source, _jsHandle.JSHandle.from(this._initializer.handle));else result = await func(source, ...this._initializer.args.map(_jsHandle.parseResult));
756
+ this._channel.resolve({
757
+ result: (0, _jsHandle.serializeArgument)(result)
758
+ }).catch(() => {});
759
+ } catch (e) {
760
+ this._channel.reject({
761
+ error: (0, _errors.serializeError)(e)
762
+ }).catch(() => {});
763
+ }
764
+ }
765
+ }
766
+ exports.BindingCall = BindingCall;
767
+ function trimUrl(param) {
768
+ if ((0, _utils.isRegExp)(param)) return `/${(0, _utils.trimStringWithEllipsis)(param.source, 50)}/${param.flags}`;
769
+ if ((0, _utils.isString)(param)) return `"${(0, _utils.trimStringWithEllipsis)(param, 50)}"`;
770
+ }