patchright-core 1.51.3 → 1.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) hide show
  1. package/browsers.json +15 -13
  2. package/lib/androidServerImpl.js +42 -48
  3. package/lib/browserServerImpl.js +54 -67
  4. package/lib/cli/driver.js +71 -69
  5. package/lib/cli/program.js +312 -328
  6. package/lib/cli/programWithTestStub.js +51 -45
  7. package/lib/client/accessibility.js +31 -32
  8. package/lib/client/android.js +141 -228
  9. package/lib/client/api.js +135 -283
  10. package/lib/client/artifact.js +39 -36
  11. package/lib/client/browser.js +57 -61
  12. package/lib/client/browserContext.js +297 -326
  13. package/lib/client/browserType.js +92 -106
  14. package/lib/client/cdpSession.js +29 -31
  15. package/lib/client/channelOwner.js +82 -95
  16. package/lib/client/clientHelper.js +46 -38
  17. package/lib/client/clientInstrumentation.js +40 -37
  18. package/lib/client/clientStackTrace.js +41 -37
  19. package/lib/client/clock.js +36 -36
  20. package/lib/client/connection.js +190 -212
  21. package/lib/client/consoleMessage.js +31 -28
  22. package/lib/client/coverage.js +25 -22
  23. package/lib/client/dialog.js +30 -31
  24. package/lib/client/download.js +25 -25
  25. package/lib/client/electron.js +73 -75
  26. package/lib/client/elementHandle.js +111 -147
  27. package/lib/client/errors.js +53 -53
  28. package/lib/client/eventEmitter.js +124 -121
  29. package/lib/client/events.js +72 -68
  30. package/lib/client/fetch.js +135 -158
  31. package/lib/client/fileChooser.js +25 -24
  32. package/lib/client/fileUtils.js +31 -28
  33. package/lib/client/frame.js +187 -306
  34. package/lib/client/harRouter.js +42 -52
  35. package/lib/client/input.js +40 -69
  36. package/lib/client/jsHandle.js +54 -69
  37. package/lib/client/jsonPipe.js +27 -23
  38. package/lib/client/localUtils.js +29 -28
  39. package/lib/client/locator.js +161 -245
  40. package/lib/client/network.js +277 -295
  41. package/lib/client/page.js +270 -318
  42. package/lib/client/platform.js +46 -43
  43. package/lib/client/playwright.js +51 -66
  44. package/lib/client/selectors.js +48 -46
  45. package/lib/client/stream.js +29 -25
  46. package/lib/client/timeoutSettings.js +49 -39
  47. package/lib/client/tracing.js +48 -84
  48. package/lib/client/types.js +26 -22
  49. package/lib/client/video.js +35 -27
  50. package/lib/client/waiter.js +69 -88
  51. package/lib/client/webError.js +25 -23
  52. package/lib/client/webSocket.js +61 -56
  53. package/lib/client/worker.js +48 -58
  54. package/lib/client/writableStream.js +27 -23
  55. package/lib/generated/clockSource.js +26 -5
  56. package/lib/generated/consoleApiSource.js +26 -5
  57. package/lib/generated/injectedScriptSource.js +26 -5
  58. package/lib/generated/pollingRecorderSource.js +26 -5
  59. package/lib/generated/utilityScriptSource.js +26 -5
  60. package/lib/generated/webSocketMockSource.js +375 -4
  61. package/lib/inProcessFactory.js +53 -53
  62. package/lib/inprocess.js +2 -19
  63. package/lib/outofprocess.js +53 -46
  64. package/lib/protocol/debug.js +209 -25
  65. package/lib/protocol/serializers.js +153 -134
  66. package/lib/protocol/validator.js +2714 -2714
  67. package/lib/protocol/validatorPrimitives.js +114 -73
  68. package/lib/remote/playwrightConnection.js +140 -157
  69. package/lib/remote/playwrightServer.js +99 -84
  70. package/lib/server/accessibility.js +44 -37
  71. package/lib/server/android/android.js +216 -209
  72. package/lib/server/android/backendAdb.js +89 -82
  73. package/lib/server/artifact.js +78 -55
  74. package/lib/server/bidi/bidiBrowser.js +221 -155
  75. package/lib/server/bidi/bidiChromium.js +106 -79
  76. package/lib/server/bidi/bidiConnection.js +66 -83
  77. package/lib/server/bidi/bidiExecutionContext.js +128 -113
  78. package/lib/server/bidi/bidiFirefox.js +76 -69
  79. package/lib/server/bidi/bidiInput.js +86 -97
  80. package/lib/server/bidi/bidiNetworkManager.js +137 -154
  81. package/lib/server/bidi/bidiOverCdp.js +57 -58
  82. package/lib/server/bidi/bidiPage.js +247 -219
  83. package/lib/server/bidi/bidiPdf.js +52 -86
  84. package/lib/server/bidi/third_party/bidiCommands.d.js +22 -0
  85. package/lib/server/bidi/third_party/bidiDeserializer.js +55 -50
  86. package/lib/server/bidi/third_party/bidiKeyboard.js +236 -220
  87. package/lib/server/bidi/third_party/bidiProtocol.js +144 -131
  88. package/lib/server/bidi/third_party/bidiSerializer.js +67 -63
  89. package/lib/server/bidi/third_party/firefoxPrefs.js +141 -119
  90. package/lib/server/browser.js +76 -84
  91. package/lib/server/browserContext.js +321 -346
  92. package/lib/server/browserType.js +169 -182
  93. package/lib/server/callLog.js +47 -44
  94. package/lib/server/chromium/chromium.js +212 -190
  95. package/lib/server/chromium/chromiumSwitches.js +86 -64
  96. package/lib/server/chromium/crAccessibility.js +157 -131
  97. package/lib/server/chromium/crBrowser.js +253 -273
  98. package/lib/server/chromium/crConnection.js +91 -116
  99. package/lib/server/chromium/crCoverage.js +113 -127
  100. package/lib/server/chromium/crDevTools.js +59 -51
  101. package/lib/server/chromium/crDragDrop.js +62 -79
  102. package/lib/server/chromium/crExecutionContext.js +88 -83
  103. package/lib/server/chromium/crInput.js +97 -95
  104. package/lib/server/chromium/crNetworkManager.js +284 -404
  105. package/lib/server/chromium/crPage.js +522 -608
  106. package/lib/server/chromium/crPdf.js +54 -86
  107. package/lib/server/chromium/crProtocolHelper.js +92 -80
  108. package/lib/server/chromium/crServiceWorker.js +82 -67
  109. package/lib/server/chromium/defaultFontFamilies.js +152 -135
  110. package/lib/server/chromium/protocol.d.js +16 -0
  111. package/lib/server/chromium/videoRecorder.js +65 -99
  112. package/lib/server/clock.js +62 -50
  113. package/lib/server/codegen/csharp.js +185 -160
  114. package/lib/server/codegen/java.js +155 -128
  115. package/lib/server/codegen/javascript.js +163 -148
  116. package/lib/server/codegen/jsonl.js +32 -28
  117. package/lib/server/codegen/language.js +75 -52
  118. package/lib/server/codegen/languages.js +65 -27
  119. package/lib/server/codegen/python.js +140 -125
  120. package/lib/server/codegen/types.js +15 -4
  121. package/lib/server/console.js +28 -32
  122. package/lib/server/cookieStore.js +105 -86
  123. package/lib/server/debugController.js +97 -124
  124. package/lib/server/debugger.js +82 -78
  125. package/lib/server/deviceDescriptors.js +37 -24
  126. package/lib/server/deviceDescriptorsSource.json +50 -50
  127. package/lib/server/dialog.js +36 -35
  128. package/lib/server/dispatchers/androidDispatcher.js +196 -107
  129. package/lib/server/dispatchers/artifactDispatcher.js +62 -62
  130. package/lib/server/dispatchers/browserContextDispatcher.js +176 -205
  131. package/lib/server/dispatchers/browserDispatcher.js +78 -97
  132. package/lib/server/dispatchers/browserTypeDispatcher.js +35 -35
  133. package/lib/server/dispatchers/cdpSessionDispatcher.js +32 -36
  134. package/lib/server/dispatchers/debugControllerDispatcher.js +48 -66
  135. package/lib/server/dispatchers/dialogDispatcher.js +30 -27
  136. package/lib/server/dispatchers/dispatcher.js +169 -220
  137. package/lib/server/dispatchers/electronDispatcher.js +54 -57
  138. package/lib/server/dispatchers/elementHandlerDispatcher.js +77 -119
  139. package/lib/server/dispatchers/frameDispatcher.js +99 -163
  140. package/lib/server/dispatchers/jsHandleDispatcher.js +49 -66
  141. package/lib/server/dispatchers/jsonPipeDispatcher.js +35 -36
  142. package/lib/server/dispatchers/localUtilsDispatcher.js +95 -80
  143. package/lib/server/dispatchers/networkDispatchers.js +90 -107
  144. package/lib/server/dispatchers/pageDispatcher.js +128 -169
  145. package/lib/server/dispatchers/playwrightDispatcher.js +69 -76
  146. package/lib/server/dispatchers/selectorsDispatcher.js +28 -24
  147. package/lib/server/dispatchers/streamDispatcher.js +42 -45
  148. package/lib/server/dispatchers/tracingDispatcher.js +36 -41
  149. package/lib/server/dispatchers/webSocketRouteDispatcher.js +96 -131
  150. package/lib/server/dispatchers/writableStreamDispatcher.js +54 -38
  151. package/lib/server/dom.js +413 -443
  152. package/lib/server/download.js +45 -35
  153. package/lib/server/electron/electron.js +156 -176
  154. package/lib/server/electron/loader.js +8 -36
  155. package/lib/server/errors.js +47 -46
  156. package/lib/server/fetch.js +289 -323
  157. package/lib/server/fileChooser.js +25 -24
  158. package/lib/server/fileUploadUtils.js +65 -59
  159. package/lib/server/firefox/ffAccessibility.js +153 -131
  160. package/lib/server/firefox/ffBrowser.js +213 -277
  161. package/lib/server/firefox/ffConnection.js +63 -84
  162. package/lib/server/firefox/ffExecutionContext.js +91 -73
  163. package/lib/server/firefox/ffInput.js +67 -69
  164. package/lib/server/firefox/ffNetworkManager.js +131 -110
  165. package/lib/server/firefox/ffPage.js +236 -273
  166. package/lib/server/firefox/firefox.js +76 -67
  167. package/lib/server/firefox/protocol.d.js +16 -0
  168. package/lib/server/formData.js +107 -35
  169. package/lib/server/frameSelectors.js +77 -111
  170. package/lib/server/frames.js +730 -894
  171. package/lib/server/har/harRecorder.js +85 -77
  172. package/lib/server/har/harTracer.js +287 -222
  173. package/lib/server/harBackend.js +80 -80
  174. package/lib/server/helper.js +56 -59
  175. package/lib/server/index.js +59 -99
  176. package/lib/server/input.js +134 -163
  177. package/lib/server/instrumentation.js +49 -44
  178. package/lib/server/javascript.js +143 -134
  179. package/lib/server/launchApp.js +92 -73
  180. package/lib/server/localUtils.js +130 -122
  181. package/lib/server/macEditingCommands.js +141 -137
  182. package/lib/server/network.js +262 -296
  183. package/lib/server/page.js +329 -426
  184. package/lib/server/pageBinding.js +88 -0
  185. package/lib/server/pipeTransport.js +49 -45
  186. package/lib/server/playwright.js +60 -67
  187. package/lib/server/progress.js +56 -51
  188. package/lib/server/protocolError.js +34 -31
  189. package/lib/server/recorder/chat.js +70 -86
  190. package/lib/server/recorder/contextRecorder.js +134 -138
  191. package/lib/server/recorder/recorderApp.js +127 -136
  192. package/lib/server/recorder/recorderCollection.js +56 -44
  193. package/lib/server/recorder/recorderFrontend.js +15 -4
  194. package/lib/server/recorder/recorderRunner.js +79 -103
  195. package/lib/server/recorder/recorderUtils.js +56 -45
  196. package/lib/server/recorder/throttledFile.js +42 -30
  197. package/lib/server/recorder.js +177 -186
  198. package/lib/server/registry/browserFetcher.js +106 -101
  199. package/lib/server/registry/dependencies.js +245 -196
  200. package/lib/server/registry/index.js +904 -792
  201. package/lib/server/registry/nativeDeps.js +1073 -464
  202. package/lib/server/registry/oopDownloadBrowserMain.js +57 -75
  203. package/lib/server/screenshotter.js +166 -182
  204. package/lib/server/selectors.js +85 -46
  205. package/lib/server/socksClientCertificatesInterceptor.js +166 -185
  206. package/lib/server/socksInterceptor.js +62 -70
  207. package/lib/server/storageScript.js +94 -100
  208. package/lib/server/timeoutSettings.js +58 -43
  209. package/lib/server/trace/recorder/snapshotter.js +70 -89
  210. package/lib/server/trace/recorder/snapshotterInjected.js +238 -217
  211. package/lib/server/trace/recorder/tracing.js +321 -333
  212. package/lib/server/trace/test/inMemorySnapshotter.js +46 -52
  213. package/lib/server/trace/viewer/traceViewer.js +168 -146
  214. package/lib/server/transport.js +124 -133
  215. package/lib/server/types.js +26 -22
  216. package/lib/server/usKeyboardLayout.js +135 -545
  217. package/lib/server/utils/ascii.js +39 -26
  218. package/lib/server/utils/comparators.js +105 -103
  219. package/lib/server/utils/crypto.js +157 -112
  220. package/lib/server/utils/debug.js +37 -28
  221. package/lib/server/utils/debugLogger.js +69 -48
  222. package/lib/server/utils/env.js +52 -37
  223. package/lib/server/utils/eventsHelper.js +29 -28
  224. package/lib/server/utils/expectUtils.js +31 -26
  225. package/lib/server/utils/fileUtils.js +123 -136
  226. package/lib/server/utils/happyEyeballs.js +138 -123
  227. package/lib/server/utils/hostPlatform.js +84 -120
  228. package/lib/server/utils/httpServer.js +106 -121
  229. package/lib/server/utils/image_tools/colorUtils.js +42 -51
  230. package/lib/server/utils/image_tools/compare.js +44 -43
  231. package/lib/server/utils/image_tools/imageChannel.js +38 -30
  232. package/lib/server/utils/image_tools/stats.js +40 -40
  233. package/lib/server/utils/linuxUtils.js +50 -37
  234. package/lib/server/utils/network.js +143 -86
  235. package/lib/server/utils/nodePlatform.js +87 -79
  236. package/lib/server/utils/pipeTransport.js +44 -42
  237. package/lib/server/utils/processLauncher.js +111 -121
  238. package/lib/server/utils/profiler.js +52 -39
  239. package/lib/server/utils/socksProxy.js +280 -339
  240. package/lib/server/utils/spawnAsync.js +37 -41
  241. package/lib/server/utils/task.js +31 -38
  242. package/lib/server/utils/userAgent.js +73 -66
  243. package/lib/server/utils/wsServer.js +73 -69
  244. package/lib/server/utils/zipFile.js +36 -37
  245. package/lib/server/utils/zones.js +37 -34
  246. package/lib/server/webkit/protocol.d.js +16 -0
  247. package/lib/server/webkit/webkit.js +76 -63
  248. package/lib/server/webkit/wkAccessibility.js +161 -118
  249. package/lib/server/webkit/wkBrowser.js +159 -176
  250. package/lib/server/webkit/wkConnection.js +59 -83
  251. package/lib/server/webkit/wkExecutionContext.js +84 -70
  252. package/lib/server/webkit/wkInput.js +82 -80
  253. package/lib/server/webkit/wkInterceptableRequest.js +102 -95
  254. package/lib/server/webkit/wkPage.js +525 -619
  255. package/lib/server/webkit/wkProvisionalPage.js +45 -56
  256. package/lib/server/webkit/wkWorkers.js +77 -77
  257. package/lib/utils/isomorphic/ariaSnapshot.js +144 -152
  258. package/lib/utils/isomorphic/assert.js +28 -22
  259. package/lib/utils/isomorphic/builtins.js +90 -0
  260. package/lib/utils/isomorphic/colors.js +66 -59
  261. package/lib/utils/isomorphic/cssParser.js +121 -125
  262. package/lib/utils/isomorphic/cssTokenizer.js +436 -364
  263. package/lib/utils/isomorphic/headers.js +38 -37
  264. package/lib/utils/isomorphic/locatorGenerators.js +340 -357
  265. package/lib/utils/isomorphic/locatorParser.js +96 -105
  266. package/lib/utils/isomorphic/locatorUtils.js +63 -44
  267. package/lib/utils/isomorphic/manualPromise.js +47 -39
  268. package/lib/utils/isomorphic/mimeType.js +448 -25
  269. package/lib/utils/isomorphic/multimap.js +35 -27
  270. package/lib/utils/isomorphic/rtti.js +35 -33
  271. package/lib/utils/isomorphic/selectorParser.js +183 -193
  272. package/lib/utils/isomorphic/semaphore.js +27 -24
  273. package/lib/utils/isomorphic/stackTrace.js +87 -98
  274. package/lib/utils/isomorphic/stringUtils.js +113 -106
  275. package/lib/utils/isomorphic/time.js +41 -22
  276. package/lib/utils/isomorphic/timeoutRunner.js +55 -54
  277. package/lib/utils/isomorphic/traceUtils.js +38 -41
  278. package/lib/utils/isomorphic/types.js +15 -4
  279. package/lib/utils/isomorphic/urlMatch.js +112 -67
  280. package/lib/utils/isomorphic/utilityScriptSerializers.js +248 -0
  281. package/lib/utils.js +97 -443
  282. package/lib/utilsBundle.js +101 -52
  283. package/lib/vite/htmlReport/index.html +21 -15
  284. package/lib/vite/recorder/assets/{codeMirrorModule-B9YMkrwa.js → codeMirrorModule-DVQi6prl.js} +1 -1
  285. package/lib/vite/recorder/assets/index-97EUAAbk.js +184 -0
  286. package/lib/vite/recorder/index.html +1 -1
  287. package/lib/vite/traceViewer/assets/{codeMirrorModule-1DiydmYA.js → codeMirrorModule-dvXVzLxY.js} +1 -1
  288. package/lib/vite/traceViewer/assets/defaultSettingsView-BjymbO6M.js +265 -0
  289. package/lib/vite/traceViewer/{defaultSettingsView.5fN5lw10.css → defaultSettingsView.QdHITyLI.css} +1 -1
  290. package/lib/vite/traceViewer/index.ChIUCJnj.js +2 -0
  291. package/lib/vite/traceViewer/index.html +3 -3
  292. package/lib/vite/traceViewer/sw.bundle.js +3 -3
  293. package/lib/vite/traceViewer/uiMode.html +3 -3
  294. package/lib/vite/traceViewer/uiMode.jUCiCtdp.js +5 -0
  295. package/lib/zipBundle.js +32 -23
  296. package/package.json +1 -1
  297. package/types/protocol.d.ts +436 -17
  298. package/types/types.d.ts +35 -16
  299. package/lib/server/isomorphic/utilityScriptSerializers.js +0 -229
  300. package/lib/vite/recorder/assets/index-ELPgmkwA.js +0 -184
  301. package/lib/vite/traceViewer/assets/defaultSettingsView-l0TyP_G8.js +0 -259
  302. package/lib/vite/traceViewer/index.BqUZLSro.js +0 -2
  303. package/lib/vite/traceViewer/uiMode.C1d2m5sF.js +0 -5
@@ -1,82 +1,86 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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 frames_exports = {};
30
+ __export(frames_exports, {
31
+ Frame: () => Frame,
32
+ FrameManager: () => FrameManager,
33
+ NavigationAbortedError: () => NavigationAbortedError
5
34
  });
6
- exports.NavigationAbortedError = exports.FrameManager = exports.Frame = void 0;
7
- var _crExecutionContext = require("./chromium/crExecutionContext");
8
- var _dom = _interopRequireWildcard(require("./dom"));
9
- var dom = _dom;
10
- var _crypto = _interopRequireDefault(require("crypto"));
11
- var _browserContext = require("./browserContext");
12
- var _errors = require("./errors");
13
- var _fileUploadUtils = require("./fileUploadUtils");
14
- var _frameSelectors = require("./frameSelectors");
15
- var _helper = require("./helper");
16
- var _instrumentation = require("./instrumentation");
17
- var js = _interopRequireWildcard(require("./javascript"));
18
- var network = _interopRequireWildcard(require("./network"));
19
- var _page = require("./page");
20
- var _progress2 = require("./progress");
21
- var types = _interopRequireWildcard(require("./types"));
22
- var _utils = require("../utils");
23
- var _protocolError = require("./protocolError");
24
- var _debugLogger = require("./utils/debugLogger");
25
- var _eventsHelper = require("./utils/eventsHelper");
26
- var _selectorParser = require("../utils/isomorphic/selectorParser");
27
- var _manualPromise = require("../utils/isomorphic/manualPromise");
28
- var _callLog = require("./callLog");
29
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
30
- 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); }
31
- 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 && {}.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; }
32
- // undetected-undetected_playwright-patch - custom imports
33
-
34
- /**
35
- * Copyright 2017 Google Inc. All rights reserved.
36
- * Modifications copyright (c) Microsoft Corporation.
37
- *
38
- * Licensed under the Apache License, Version 2.0 (the "License");
39
- * you may not use this file except in compliance with the License.
40
- * You may obtain a copy of the License at
41
- *
42
- * http://www.apache.org/licenses/LICENSE-2.0
43
- *
44
- * Unless required by applicable law or agreed to in writing, software
45
- * distributed under the License is distributed on an "AS IS" BASIS,
46
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
47
- * See the License for the specific language governing permissions and
48
- * limitations under the License.
49
- */
50
-
35
+ module.exports = __toCommonJS(frames_exports);
36
+ var import_crExecutionContext = require("./chromium/crExecutionContext");
37
+ var import_dom = require("./dom");
38
+ var import_crypto = __toESM(require("crypto"));
39
+ var import_browserContext = require("./browserContext");
40
+ var dom = __toESM(require("./dom"));
41
+ var import_errors = require("./errors");
42
+ var import_fileUploadUtils = require("./fileUploadUtils");
43
+ var import_frameSelectors = require("./frameSelectors");
44
+ var import_helper = require("./helper");
45
+ var import_instrumentation = require("./instrumentation");
46
+ var js = __toESM(require("./javascript"));
47
+ var network = __toESM(require("./network"));
48
+ var import_page = require("./page");
49
+ var import_progress = require("./progress");
50
+ var types = __toESM(require("./types"));
51
+ var import_utils = require("../utils");
52
+ var import_protocolError = require("./protocolError");
53
+ var import_debugLogger = require("./utils/debugLogger");
54
+ var import_eventsHelper = require("./utils/eventsHelper");
55
+ var import_selectorParser = require("../utils/isomorphic/selectorParser");
56
+ var import_manualPromise = require("../utils/isomorphic/manualPromise");
57
+ var import_callLog = require("./callLog");
51
58
  class NavigationAbortedError extends Error {
52
59
  constructor(documentId, message) {
53
60
  super(message);
54
- this.documentId = void 0;
55
61
  this.documentId = documentId;
56
62
  }
57
63
  }
58
- exports.NavigationAbortedError = NavigationAbortedError;
59
- const kDummyFrameId = '<dummy>';
64
+ const kDummyFrameId = "<dummy>";
60
65
  class FrameManager {
61
66
  constructor(page) {
62
- this._page = void 0;
63
- this._frames = new Map();
64
- this._mainFrame = void 0;
65
- this._consoleMessageTags = new Map();
66
- this._signalBarriers = new Set();
67
- this._webSockets = new Map();
68
- this._openedDialogs = new Set();
67
+ this._frames = /* @__PURE__ */ new Map();
68
+ this._consoleMessageTags = /* @__PURE__ */ new Map();
69
+ this._signalBarriers = /* @__PURE__ */ new Set();
70
+ this._webSockets = /* @__PURE__ */ new Map();
71
+ this._openedDialogs = /* @__PURE__ */ new Set();
69
72
  this._closeAllOpeningDialogs = false;
70
73
  this._page = page;
71
- this._mainFrame = undefined;
74
+ this._mainFrame = void 0;
72
75
  }
73
76
  createDummyMainFrameIfNeeded() {
74
- if (!this._mainFrame) this.frameAttached(kDummyFrameId, null);
77
+ if (!this._mainFrame)
78
+ this.frameAttached(kDummyFrameId, null);
75
79
  }
76
80
  dispose() {
77
81
  for (const frame of this._frames.values()) {
78
82
  frame._stopNetworkIdleTimer();
79
- frame._invalidateNonStallingEvaluations('Target crashed');
83
+ frame._invalidateNonStallingEvaluations("Target crashed");
80
84
  }
81
85
  }
82
86
  mainFrame() {
@@ -88,7 +92,8 @@ class FrameManager {
88
92
  return frames;
89
93
  function collect(frame) {
90
94
  frames.push(frame);
91
- for (const subframe of frame.childFrames()) collect(subframe);
95
+ for (const subframe of frame.childFrames())
96
+ collect(subframe);
92
97
  }
93
98
  }
94
99
  frame(frameId) {
@@ -98,55 +103,55 @@ class FrameManager {
98
103
  const parentFrame = parentFrameId ? this._frames.get(parentFrameId) : null;
99
104
  if (!parentFrame) {
100
105
  if (this._mainFrame) {
101
- // Update frame id to retain frame identity on cross-process navigation.
102
106
  this._frames.delete(this._mainFrame._id);
103
107
  this._mainFrame._id = frameId;
104
108
  } else {
105
- (0, _utils.assert)(!this._frames.has(frameId));
109
+ (0, import_utils.assert)(!this._frames.has(frameId));
106
110
  this._mainFrame = new Frame(this._page, frameId, parentFrame);
107
111
  }
108
112
  this._frames.set(frameId, this._mainFrame);
109
113
  return this._mainFrame;
110
114
  } else {
111
- (0, _utils.assert)(!this._frames.has(frameId));
115
+ (0, import_utils.assert)(!this._frames.has(frameId));
112
116
  const frame = new Frame(this._page, frameId, parentFrame);
113
117
  this._frames.set(frameId, frame);
114
- this._page.emit(_page.Page.Events.FrameAttached, frame);
118
+ this._page.emit(import_page.Page.Events.FrameAttached, frame);
115
119
  return frame;
116
120
  }
117
121
  }
118
122
  async waitForSignalsCreatedBy(progress, waitAfter, action) {
119
- if (!waitAfter) return action();
123
+ if (!waitAfter)
124
+ return action();
120
125
  const barrier = new SignalBarrier(progress);
121
126
  this._signalBarriers.add(barrier);
122
- if (progress) progress.cleanupWhenAborted(() => this._signalBarriers.delete(barrier));
127
+ if (progress)
128
+ progress.cleanupWhenAborted(() => this._signalBarriers.delete(barrier));
123
129
  const result = await action();
124
130
  await this._page._delegate.inputActionEpilogue();
125
131
  await barrier.waitFor();
126
132
  this._signalBarriers.delete(barrier);
127
- // Resolve in the next task, after all waitForNavigations.
128
- await new Promise((0, _utils.makeWaitForNextTask)());
133
+ await new Promise((0, import_utils.makeWaitForNextTask)());
129
134
  return result;
130
135
  }
131
136
  frameWillPotentiallyRequestNavigation() {
132
- for (const barrier of this._signalBarriers) barrier.retain();
137
+ for (const barrier of this._signalBarriers)
138
+ barrier.retain();
133
139
  }
134
140
  frameDidPotentiallyRequestNavigation() {
135
- for (const barrier of this._signalBarriers) barrier.release();
141
+ for (const barrier of this._signalBarriers)
142
+ barrier.release();
136
143
  }
137
144
  frameRequestedNavigation(frameId, documentId) {
138
145
  const frame = this._frames.get(frameId);
139
- if (!frame) return;
140
- for (const barrier of this._signalBarriers) barrier.addFrameNavigation(frame);
146
+ if (!frame)
147
+ return;
148
+ for (const barrier of this._signalBarriers)
149
+ barrier.addFrameNavigation(frame);
141
150
  if (frame.pendingDocument() && frame.pendingDocument().documentId === documentId) {
142
- // Do not override request with undefined.
143
151
  return;
144
152
  }
145
- const request = documentId ? Array.from(frame._inflightRequests).find(request => request._documentId === documentId) : undefined;
146
- frame.setPendingDocument({
147
- documentId,
148
- request
149
- });
153
+ const request = documentId ? Array.from(frame._inflightRequests).find((request2) => request2._documentId === documentId) : void 0;
154
+ frame.setPendingDocument({ documentId, request });
150
155
  }
151
156
  frameCommittedNewDocumentNavigation(frameId, url, name, documentId, initial) {
152
157
  const frame = this._frames.get(frameId);
@@ -157,69 +162,47 @@ class FrameManager {
157
162
  let keepPending;
158
163
  const pendingDocument = frame.pendingDocument();
159
164
  if (pendingDocument) {
160
- if (pendingDocument.documentId === undefined) {
161
- // Pending with unknown documentId - assume it is the one being committed.
165
+ if (pendingDocument.documentId === void 0) {
162
166
  pendingDocument.documentId = documentId;
163
167
  }
164
168
  if (pendingDocument.documentId === documentId) {
165
- // Committing a pending document.
166
169
  frame._currentDocument = pendingDocument;
167
170
  } else {
168
- // Sometimes, we already have a new pending when the old one commits.
169
- // An example would be Chromium error page followed by a new navigation request,
170
- // where the error page commit arrives after Network.requestWillBeSent for the
171
- // new navigation.
172
- // We commit, but keep the pending request since it's not done yet.
173
171
  keepPending = pendingDocument;
174
- frame._currentDocument = {
175
- documentId,
176
- request: undefined
177
- };
172
+ frame._currentDocument = { documentId, request: void 0 };
178
173
  }
179
- frame.setPendingDocument(undefined);
174
+ frame.setPendingDocument(void 0);
180
175
  } else {
181
- // No pending - just commit a new document.
182
- frame._currentDocument = {
183
- documentId,
184
- request: undefined
185
- };
176
+ frame._currentDocument = { documentId, request: void 0 };
186
177
  }
187
178
  frame._onClearLifecycle();
188
- const navigationEvent = {
189
- url,
190
- name,
191
- newDocument: frame._currentDocument,
192
- isPublic: true
193
- };
179
+ const navigationEvent = { url, name, newDocument: frame._currentDocument, isPublic: true };
194
180
  this._fireInternalFrameNavigation(frame, navigationEvent);
195
181
  if (!initial) {
196
- _debugLogger.debugLogger.log('api', ` navigated to "${url}"`);
182
+ import_debugLogger.debugLogger.log("api", ` navigated to "${url}"`);
197
183
  this._page.frameNavigatedToNewDocument(frame);
198
184
  }
199
- // Restore pending if any - see comments above about keepPending.
200
185
  frame.setPendingDocument(keepPending);
201
186
  }
202
187
  frameCommittedSameDocumentNavigation(frameId, url) {
203
188
  const frame = this._frames.get(frameId);
204
- if (!frame) return;
189
+ if (!frame)
190
+ return;
205
191
  const pending = frame.pendingDocument();
206
- if (pending && pending.documentId === undefined && pending.request === undefined) {
207
- // WebKit has notified about the same-document navigation being requested, so clear it.
208
- frame.setPendingDocument(undefined);
192
+ if (pending && pending.documentId === void 0 && pending.request === void 0) {
193
+ frame.setPendingDocument(void 0);
209
194
  }
210
195
  frame._url = url;
211
- const navigationEvent = {
212
- url,
213
- name: frame._name,
214
- isPublic: true
215
- };
196
+ const navigationEvent = { url, name: frame._name, isPublic: true };
216
197
  this._fireInternalFrameNavigation(frame, navigationEvent);
217
- _debugLogger.debugLogger.log('api', ` navigated to "${url}"`);
198
+ import_debugLogger.debugLogger.log("api", ` navigated to "${url}"`);
218
199
  }
219
200
  frameAbortedNavigation(frameId, errorText, documentId) {
220
201
  const frame = this._frames.get(frameId);
221
- if (!frame || !frame.pendingDocument()) return;
222
- if (documentId !== undefined && frame.pendingDocument().documentId !== documentId) return;
202
+ if (!frame || !frame.pendingDocument())
203
+ return;
204
+ if (documentId !== void 0 && frame.pendingDocument().documentId !== documentId)
205
+ return;
223
206
  const navigationEvent = {
224
207
  url: frame._url,
225
208
  name: frame._name,
@@ -227,7 +210,7 @@ class FrameManager {
227
210
  error: new NavigationAbortedError(documentId, errorText),
228
211
  isPublic: !(documentId && frame._redirectedNavigations.has(documentId))
229
212
  };
230
- frame.setPendingDocument(undefined);
213
+ frame.setPendingDocument(void 0);
231
214
  this._fireInternalFrameNavigation(frame, navigationEvent);
232
215
  }
233
216
  frameDetached(frameId) {
@@ -239,104 +222,119 @@ class FrameManager {
239
222
  }
240
223
  frameLifecycleEvent(frameId, event) {
241
224
  const frame = this._frames.get(frameId);
242
- if (frame) frame._onLifecycleEvent(event);
225
+ if (frame)
226
+ frame._onLifecycleEvent(event);
243
227
  }
244
228
  requestStarted(request, route) {
245
229
  const frame = request.frame();
246
230
  this._inflightRequestStarted(request);
247
- if (request._documentId) frame.setPendingDocument({
248
- documentId: request._documentId,
249
- request
250
- });
231
+ if (request._documentId)
232
+ frame.setPendingDocument({ documentId: request._documentId, request });
251
233
  if (request._isFavicon) {
252
- // Abort favicon requests to avoid network access in case of interception.
253
- route === null || route === void 0 || route.abort('aborted').catch(() => {});
234
+ route?.abort("aborted").catch(() => {
235
+ });
254
236
  return;
255
237
  }
256
- this._page.emitOnContext(_browserContext.BrowserContext.Events.Request, request);
238
+ this._page.emitOnContext(import_browserContext.BrowserContext.Events.Request, request);
257
239
  if (route) {
258
- var _this$_page$_serverRe, _this$_page, _this$_page$_clientRe, _this$_page2, _this$_page$_browserC, _this$_page$_browserC2;
259
240
  const r = new network.Route(request, route);
260
- if ((_this$_page$_serverRe = (_this$_page = this._page)._serverRequestInterceptor) !== null && _this$_page$_serverRe !== void 0 && _this$_page$_serverRe.call(_this$_page, r, request)) return;
261
- if ((_this$_page$_clientRe = (_this$_page2 = this._page)._clientRequestInterceptor) !== null && _this$_page$_clientRe !== void 0 && _this$_page$_clientRe.call(_this$_page2, r, request)) return;
262
- if ((_this$_page$_browserC = (_this$_page$_browserC2 = this._page._browserContext)._requestInterceptor) !== null && _this$_page$_browserC !== void 0 && _this$_page$_browserC.call(_this$_page$_browserC2, r, request)) return;
263
- r.continue({
264
- isFallback: true
265
- }).catch(() => {});
241
+ if (this._page._serverRequestInterceptor?.(r, request))
242
+ return;
243
+ if (this._page._clientRequestInterceptor?.(r, request))
244
+ return;
245
+ if (this._page._browserContext._requestInterceptor?.(r, request))
246
+ return;
247
+ r.continue({ isFallback: true }).catch(() => {
248
+ });
266
249
  }
267
250
  }
268
251
  requestReceivedResponse(response) {
269
- if (response.request()._isFavicon) return;
270
- this._page.emitOnContext(_browserContext.BrowserContext.Events.Response, response);
252
+ if (response.request()._isFavicon)
253
+ return;
254
+ this._page.emitOnContext(import_browserContext.BrowserContext.Events.Response, response);
271
255
  }
272
256
  reportRequestFinished(request, response) {
273
257
  this._inflightRequestFinished(request);
274
- if (request._isFavicon) return;
275
- this._page.emitOnContext(_browserContext.BrowserContext.Events.RequestFinished, {
276
- request,
277
- response
278
- });
258
+ if (request._isFavicon)
259
+ return;
260
+ this._page.emitOnContext(import_browserContext.BrowserContext.Events.RequestFinished, { request, response });
279
261
  }
280
262
  requestFailed(request, canceled) {
281
263
  const frame = request.frame();
282
264
  this._inflightRequestFinished(request);
283
265
  if (frame.pendingDocument() && frame.pendingDocument().request === request) {
284
266
  let errorText = request.failure().errorText;
285
- if (canceled) errorText += '; maybe frame was detached?';
267
+ if (canceled)
268
+ errorText += "; maybe frame was detached?";
286
269
  this.frameAbortedNavigation(frame._id, errorText, frame.pendingDocument().documentId);
287
270
  }
288
- if (request._isFavicon) return;
289
- this._page.emitOnContext(_browserContext.BrowserContext.Events.RequestFailed, request);
271
+ if (request._isFavicon)
272
+ return;
273
+ this._page.emitOnContext(import_browserContext.BrowserContext.Events.RequestFailed, request);
290
274
  }
291
275
  dialogDidOpen(dialog) {
292
- // Any ongoing evaluations will be stalled until the dialog is closed.
293
- for (const frame of this._frames.values()) frame._invalidateNonStallingEvaluations('JavaScript dialog interrupted evaluation');
294
- if (this._closeAllOpeningDialogs) dialog.close().then(() => {});else this._openedDialogs.add(dialog);
276
+ for (const frame of this._frames.values())
277
+ frame._invalidateNonStallingEvaluations("JavaScript dialog interrupted evaluation");
278
+ if (this._closeAllOpeningDialogs)
279
+ dialog.close().then(() => {
280
+ });
281
+ else
282
+ this._openedDialogs.add(dialog);
295
283
  }
296
284
  dialogWillClose(dialog) {
297
285
  this._openedDialogs.delete(dialog);
298
286
  }
299
287
  async closeOpenDialogs() {
300
- await Promise.all([...this._openedDialogs].map(dialog => dialog.close())).catch(() => {});
288
+ await Promise.all([...this._openedDialogs].map((dialog) => dialog.close())).catch(() => {
289
+ });
301
290
  this._openedDialogs.clear();
302
291
  }
303
292
  setCloseAllOpeningDialogs(closeDialogs) {
304
293
  this._closeAllOpeningDialogs = closeDialogs;
305
294
  }
306
295
  removeChildFramesRecursively(frame) {
307
- for (const child of frame.childFrames()) this._removeFramesRecursively(child);
296
+ for (const child of frame.childFrames())
297
+ this._removeFramesRecursively(child);
308
298
  }
309
299
  _removeFramesRecursively(frame) {
310
300
  this.removeChildFramesRecursively(frame);
311
301
  frame._onDetached();
312
302
  this._frames.delete(frame._id);
313
- if (!this._page.isClosed()) this._page.emit(_page.Page.Events.FrameDetached, frame);
303
+ if (!this._page.isClosed())
304
+ this._page.emit(import_page.Page.Events.FrameDetached, frame);
314
305
  }
315
306
  _inflightRequestFinished(request) {
316
307
  const frame = request.frame();
317
- if (request._isFavicon) return;
318
- if (!frame._inflightRequests.has(request)) return;
308
+ if (request._isFavicon)
309
+ return;
310
+ if (!frame._inflightRequests.has(request))
311
+ return;
319
312
  frame._inflightRequests.delete(request);
320
- if (frame._inflightRequests.size === 0) frame._startNetworkIdleTimer();
313
+ if (frame._inflightRequests.size === 0)
314
+ frame._startNetworkIdleTimer();
321
315
  }
322
316
  _inflightRequestStarted(request) {
323
317
  const frame = request.frame();
324
- if (request._isFavicon) return;
318
+ if (request._isFavicon)
319
+ return;
325
320
  frame._inflightRequests.add(request);
326
- if (frame._inflightRequests.size === 1) frame._stopNetworkIdleTimer();
321
+ if (frame._inflightRequests.size === 1)
322
+ frame._stopNetworkIdleTimer();
327
323
  }
328
324
  interceptConsoleMessage(message) {
329
- if (message.type() !== 'debug') return false;
325
+ if (message.type() !== "debug")
326
+ return false;
330
327
  const tag = message.text();
331
328
  const handler = this._consoleMessageTags.get(tag);
332
- if (!handler) return false;
329
+ if (!handler)
330
+ return false;
333
331
  this._consoleMessageTags.delete(tag);
334
332
  handler();
335
333
  return true;
336
334
  }
337
335
  clearWebSockets(frame) {
338
- // TODO: attribute sockets to frames.
339
- if (frame.parentFrame()) return;
336
+ if (frame.parentFrame())
337
+ return;
340
338
  this._webSockets.clear();
341
339
  }
342
340
  onWebSocketCreated(requestId, url) {
@@ -345,125 +343,131 @@ class FrameManager {
345
343
  }
346
344
  onWebSocketRequest(requestId) {
347
345
  const ws = this._webSockets.get(requestId);
348
- if (ws && ws.markAsNotified()) this._page.emit(_page.Page.Events.WebSocket, ws);
346
+ if (ws && ws.markAsNotified())
347
+ this._page.emit(import_page.Page.Events.WebSocket, ws);
349
348
  }
350
349
  onWebSocketResponse(requestId, status, statusText) {
351
350
  const ws = this._webSockets.get(requestId);
352
- if (status < 400) return;
353
- if (ws) ws.error(`${statusText}: ${status}`);
351
+ if (status < 400)
352
+ return;
353
+ if (ws)
354
+ ws.error(`${statusText}: ${status}`);
354
355
  }
355
356
  onWebSocketFrameSent(requestId, opcode, data) {
356
357
  const ws = this._webSockets.get(requestId);
357
- if (ws) ws.frameSent(opcode, data);
358
+ if (ws)
359
+ ws.frameSent(opcode, data);
358
360
  }
359
361
  webSocketFrameReceived(requestId, opcode, data) {
360
362
  const ws = this._webSockets.get(requestId);
361
- if (ws) ws.frameReceived(opcode, data);
363
+ if (ws)
364
+ ws.frameReceived(opcode, data);
362
365
  }
363
366
  webSocketClosed(requestId) {
364
367
  const ws = this._webSockets.get(requestId);
365
- if (ws) ws.closed();
368
+ if (ws)
369
+ ws.closed();
366
370
  this._webSockets.delete(requestId);
367
371
  }
368
372
  webSocketError(requestId, errorMessage) {
369
373
  const ws = this._webSockets.get(requestId);
370
- if (ws) ws.error(errorMessage);
374
+ if (ws)
375
+ ws.error(errorMessage);
371
376
  }
372
377
  _fireInternalFrameNavigation(frame, event) {
373
378
  frame.emit(Frame.Events.InternalNavigation, event);
374
379
  }
375
380
  }
376
- exports.FrameManager = FrameManager;
377
- class Frame extends _instrumentation.SdkObject {
381
+ class Frame extends import_instrumentation.SdkObject {
378
382
  constructor(page, id, parentFrame) {
379
- super(page, 'frame');
380
- this._id = void 0;
381
- this._firedLifecycleEvents = new Set();
383
+ super(page, "frame");
384
+ this._firedLifecycleEvents = /* @__PURE__ */ new Set();
382
385
  this._firedNetworkIdleSelf = false;
383
- this._currentDocument = void 0;
384
- this._pendingDocument = void 0;
385
- this._page = void 0;
386
- this._parentFrame = void 0;
387
- this._url = '';
388
- this._contextData = new Map();
389
- this._childFrames = new Set();
390
- this._name = '';
391
- this._inflightRequests = new Set();
392
- this._networkIdleTimer = void 0;
386
+ this._url = "";
387
+ this._contextData = /* @__PURE__ */ new Map();
388
+ this._childFrames = /* @__PURE__ */ new Set();
389
+ this._name = "";
390
+ this._inflightRequests = /* @__PURE__ */ new Set();
393
391
  this._setContentCounter = 0;
394
- this._detachedScope = new _utils.LongStandingScope();
395
- this._raceAgainstEvaluationStallingEventsPromises = new Set();
396
- this._redirectedNavigations = new Map();
397
- // documentId -> data
398
- this.selectors = void 0;
399
- this._isolatedWorld = void 0;
400
- this._mainWorld = void 0;
401
- this._iframeWorld = void 0;
392
+ this._detachedScope = new import_utils.LongStandingScope();
393
+ this._raceAgainstEvaluationStallingEventsPromises = /* @__PURE__ */ new Set();
394
+ this._redirectedNavigations = /* @__PURE__ */ new Map();
402
395
  this.attribution.frame = this;
403
396
  this._id = id;
404
397
  this._page = page;
405
398
  this._parentFrame = parentFrame;
406
- this._currentDocument = {
407
- documentId: undefined,
408
- request: undefined
399
+ this._currentDocument = { documentId: void 0, request: void 0 };
400
+ this.selectors = new import_frameSelectors.FrameSelectors(this);
401
+ this._contextData.set("main", { contextPromise: new import_manualPromise.ManualPromise(), context: null });
402
+ this._contextData.set("utility", { contextPromise: new import_manualPromise.ManualPromise(), context: null });
403
+ this._setContext("main", null);
404
+ this._setContext("utility", null);
405
+ if (this._parentFrame)
406
+ this._parentFrame._childFrames.add(this);
407
+ this._firedLifecycleEvents.add("commit");
408
+ if (id !== kDummyFrameId)
409
+ this._startNetworkIdleTimer();
410
+ }
411
+ static {
412
+ this.Events = {
413
+ InternalNavigation: "internalnavigation",
414
+ AddLifecycle: "addlifecycle",
415
+ RemoveLifecycle: "removelifecycle"
409
416
  };
410
- this.selectors = new _frameSelectors.FrameSelectors(this);
411
- this._contextData.set('main', {
412
- contextPromise: new _manualPromise.ManualPromise(),
413
- context: null
414
- });
415
- this._contextData.set('utility', {
416
- contextPromise: new _manualPromise.ManualPromise(),
417
- context: null
418
- });
419
- this._setContext('main', null);
420
- this._setContext('utility', null);
421
- if (this._parentFrame) this._parentFrame._childFrames.add(this);
422
- this._firedLifecycleEvents.add('commit');
423
- if (id !== kDummyFrameId) this._startNetworkIdleTimer();
424
417
  }
425
418
  isDetached() {
426
419
  return this._detachedScope.isClosed();
427
420
  }
428
421
  _onLifecycleEvent(event) {
429
- if (this._firedLifecycleEvents.has(event)) return;
422
+ if (this._firedLifecycleEvents.has(event))
423
+ return;
430
424
  this._firedLifecycleEvents.add(event);
431
425
  this.emit(Frame.Events.AddLifecycle, event);
432
- if (this === this._page.mainFrame() && this._url !== 'about:blank') _debugLogger.debugLogger.log('api', ` "${event}" event fired`);
426
+ if (this === this._page.mainFrame() && this._url !== "about:blank")
427
+ import_debugLogger.debugLogger.log("api", ` "${event}" event fired`);
433
428
  this._page.mainFrame()._recalculateNetworkIdle();
434
429
  }
435
430
  _onClearLifecycle() {
436
- this._isolatedWorld = undefined;
437
- this._mainWorld = undefined;
438
- this._iframeWorld = undefined;
439
- for (const event of this._firedLifecycleEvents) this.emit(Frame.Events.RemoveLifecycle, event);
431
+ this._isolatedWorld = void 0;
432
+ this._mainWorld = void 0;
433
+ this._iframeWorld = void 0;
434
+ for (const event of this._firedLifecycleEvents)
435
+ this.emit(Frame.Events.RemoveLifecycle, event);
440
436
  this._firedLifecycleEvents.clear();
441
- // Keep the current navigation request if any.
442
- this._inflightRequests = new Set(Array.from(this._inflightRequests).filter(request => request === this._currentDocument.request));
437
+ this._inflightRequests = new Set(Array.from(this._inflightRequests).filter((request) => request === this._currentDocument.request));
443
438
  this._stopNetworkIdleTimer();
444
- if (this._inflightRequests.size === 0) this._startNetworkIdleTimer();
439
+ if (this._inflightRequests.size === 0)
440
+ this._startNetworkIdleTimer();
445
441
  this._page.mainFrame()._recalculateNetworkIdle(this);
446
- this._onLifecycleEvent('commit');
442
+ this._onLifecycleEvent("commit");
447
443
  }
448
444
  setPendingDocument(documentInfo) {
449
445
  this._pendingDocument = documentInfo;
450
- if (documentInfo) this._invalidateNonStallingEvaluations('Navigation interrupted the evaluation');
446
+ if (documentInfo)
447
+ this._invalidateNonStallingEvaluations("Navigation interrupted the evaluation");
451
448
  }
452
449
  pendingDocument() {
453
450
  return this._pendingDocument;
454
451
  }
455
452
  _invalidateNonStallingEvaluations(message) {
456
- if (!this._raceAgainstEvaluationStallingEventsPromises.size) return;
453
+ if (!this._raceAgainstEvaluationStallingEventsPromises.size)
454
+ return;
457
455
  const error = new Error(message);
458
- for (const promise of this._raceAgainstEvaluationStallingEventsPromises) promise.reject(error);
456
+ for (const promise of this._raceAgainstEvaluationStallingEventsPromises)
457
+ promise.reject(error);
459
458
  }
460
459
  async raceAgainstEvaluationStallingEvents(cb) {
461
- if (this._pendingDocument) throw new Error('Frame is currently attempting a navigation');
462
- if (this._page._frameManager._openedDialogs.size) throw new Error('Open JavaScript dialog prevents evaluation');
463
- const promise = new _manualPromise.ManualPromise();
460
+ if (this._pendingDocument)
461
+ throw new Error("Frame is currently attempting a navigation");
462
+ if (this._page._frameManager._openedDialogs.size)
463
+ throw new Error("Open JavaScript dialog prevents evaluation");
464
+ const promise = new import_manualPromise.ManualPromise();
464
465
  this._raceAgainstEvaluationStallingEventsPromises.add(promise);
465
466
  try {
466
- return await Promise.race([cb(), promise]);
467
+ return await Promise.race([
468
+ cb(),
469
+ promise
470
+ ]);
467
471
  } finally {
468
472
  this._raceAgainstEvaluationStallingEventsPromises.delete(promise);
469
473
  }
@@ -471,41 +475,42 @@ class Frame extends _instrumentation.SdkObject {
471
475
  nonStallingRawEvaluateInExistingMainContext(expression) {
472
476
  return this.raceAgainstEvaluationStallingEvents(() => {
473
477
  const context = this._existingMainContext();
474
- if (!context) throw new Error('Frame does not yet have a main execution context');
478
+ if (!context)
479
+ throw new Error("Frame does not yet have a main execution context");
475
480
  return context.rawEvaluateJSON(expression);
476
481
  });
477
482
  }
478
483
  nonStallingEvaluateInExistingContext(expression, world) {
479
484
  return this.raceAgainstEvaluationStallingEvents(() => {
480
- var _this$_contextData$ge;
481
- const context = (_this$_contextData$ge = this._contextData.get(world)) === null || _this$_contextData$ge === void 0 ? void 0 : _this$_contextData$ge.context;
482
- if (!context) throw new Error('Frame does not yet have the execution context');
483
- return context.evaluateExpression(expression, {
484
- isFunction: false
485
- });
485
+ const context = this._contextData.get(world)?.context;
486
+ if (!context)
487
+ throw new Error("Frame does not yet have the execution context");
488
+ return context.evaluateExpression(expression, { isFunction: false });
486
489
  });
487
490
  }
488
491
  _recalculateNetworkIdle(frameThatAllowsRemovingNetworkIdle) {
489
492
  let isNetworkIdle = this._firedNetworkIdleSelf;
490
493
  for (const child of this._childFrames) {
491
494
  child._recalculateNetworkIdle(frameThatAllowsRemovingNetworkIdle);
492
- // We require networkidle event to be fired in the whole frame subtree, and then consider it done.
493
- if (!child._firedLifecycleEvents.has('networkidle')) isNetworkIdle = false;
495
+ if (!child._firedLifecycleEvents.has("networkidle"))
496
+ isNetworkIdle = false;
494
497
  }
495
- if (isNetworkIdle && !this._firedLifecycleEvents.has('networkidle')) {
496
- this._firedLifecycleEvents.add('networkidle');
497
- this.emit(Frame.Events.AddLifecycle, 'networkidle');
498
- if (this === this._page.mainFrame() && this._url !== 'about:blank') _debugLogger.debugLogger.log('api', ` "networkidle" event fired`);
498
+ if (isNetworkIdle && !this._firedLifecycleEvents.has("networkidle")) {
499
+ this._firedLifecycleEvents.add("networkidle");
500
+ this.emit(Frame.Events.AddLifecycle, "networkidle");
501
+ if (this === this._page.mainFrame() && this._url !== "about:blank")
502
+ import_debugLogger.debugLogger.log("api", ` "networkidle" event fired`);
499
503
  }
500
- if (frameThatAllowsRemovingNetworkIdle !== this && this._firedLifecycleEvents.has('networkidle') && !isNetworkIdle) {
501
- // Usually, networkidle is fired once and not removed after that.
502
- // However, when we clear them right before a new commit, this is allowed for a particular frame.
503
- this._firedLifecycleEvents.delete('networkidle');
504
- this.emit(Frame.Events.RemoveLifecycle, 'networkidle');
504
+ if (frameThatAllowsRemovingNetworkIdle !== this && this._firedLifecycleEvents.has("networkidle") && !isNetworkIdle) {
505
+ this._firedLifecycleEvents.delete("networkidle");
506
+ this.emit(Frame.Events.RemoveLifecycle, "networkidle");
505
507
  }
506
508
  }
507
509
  async raceNavigationAction(progress, options, action) {
508
- return _utils.LongStandingScope.raceMultiple([this._detachedScope, this._page.openScope], action().catch(e => {
510
+ return import_utils.LongStandingScope.raceMultiple([
511
+ this._detachedScope,
512
+ this._page.openScope
513
+ ], action().catch((e) => {
509
514
  if (e instanceof NavigationAbortedError && e.documentId) {
510
515
  const data = this._redirectedNavigations.get(e.documentId);
511
516
  if (data) {
@@ -517,95 +522,96 @@ class Frame extends _instrumentation.SdkObject {
517
522
  }));
518
523
  }
519
524
  redirectNavigation(url, documentId, referer) {
520
- const controller = new _progress2.ProgressController((0, _instrumentation.serverSideCallMetadata)(), this);
525
+ const controller = new import_progress.ProgressController((0, import_instrumentation.serverSideCallMetadata)(), this);
521
526
  const data = {
522
527
  url,
523
- gotoPromise: controller.run(progress => this._gotoAction(progress, url, {
524
- referer
525
- }), 0)
528
+ gotoPromise: controller.run((progress) => this._gotoAction(progress, url, { referer }), 0)
526
529
  };
527
530
  this._redirectedNavigations.set(documentId, data);
528
531
  data.gotoPromise.finally(() => this._redirectedNavigations.delete(documentId));
529
532
  }
530
533
  async goto(metadata, url, options = {}) {
531
- const constructedNavigationURL = (0, _utils.constructURLBasedOnBaseURL)(this._page._browserContext._options.baseURL, url);
532
- const controller = new _progress2.ProgressController(metadata, this);
533
- return controller.run(progress => this._goto(progress, constructedNavigationURL, options), this._page._timeoutSettings.navigationTimeout(options));
534
+ const constructedNavigationURL = (0, import_utils.constructURLBasedOnBaseURL)(this._page._browserContext._options.baseURL, url);
535
+ const controller = new import_progress.ProgressController(metadata, this);
536
+ return controller.run((progress) => this._goto(progress, constructedNavigationURL, options), this._page._timeoutSettings.navigationTimeout(options));
534
537
  }
535
538
  async _goto(progress, url, options) {
536
539
  return this.raceNavigationAction(progress, options, async () => this._gotoAction(progress, url, options));
537
540
  }
538
541
  async _gotoAction(progress, url, options) {
539
- const waitUntil = verifyLifecycle('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);
542
+ const waitUntil = verifyLifecycle("waitUntil", options.waitUntil === void 0 ? "load" : options.waitUntil);
540
543
  progress.log(`navigating to "${url}", waiting until "${waitUntil}"`);
541
544
  const headers = this._page.extraHTTPHeaders() || [];
542
- const refererHeader = headers.find(h => h.name.toLowerCase() === 'referer');
543
- let referer = refererHeader ? refererHeader.value : undefined;
544
- if (options.referer !== undefined) {
545
- if (referer !== undefined && referer !== options.referer) throw new Error('"referer" is already specified as extra HTTP header');
545
+ const refererHeader = headers.find((h) => h.name.toLowerCase() === "referer");
546
+ let referer = refererHeader ? refererHeader.value : void 0;
547
+ if (options.referer !== void 0) {
548
+ if (referer !== void 0 && referer !== options.referer)
549
+ throw new Error('"referer" is already specified as extra HTTP header');
546
550
  referer = options.referer;
547
551
  }
548
- url = _helper.helper.completeUserURL(url);
552
+ url = import_helper.helper.completeUserURL(url);
549
553
  const navigationEvents = [];
550
- const collectNavigations = arg => navigationEvents.push(arg);
554
+ const collectNavigations = (arg) => navigationEvents.push(arg);
551
555
  this.on(Frame.Events.InternalNavigation, collectNavigations);
552
- const navigateResult = await this._page._delegate.navigateFrame(this, url, referer).finally(() => this.off(Frame.Events.InternalNavigation, collectNavigations));
556
+ const navigateResult = await this._page._delegate.navigateFrame(this, url, referer).finally(
557
+ () => this.off(Frame.Events.InternalNavigation, collectNavigations)
558
+ );
553
559
  let event;
554
560
  if (navigateResult.newDocumentId) {
555
- const predicate = event => {
556
- // We are interested either in this specific document, or any other document that
557
- // did commit and replaced the expected document.
558
- return event.newDocument && (event.newDocument.documentId === navigateResult.newDocumentId || !event.error);
561
+ const predicate = (event2) => {
562
+ return event2.newDocument && (event2.newDocument.documentId === navigateResult.newDocumentId || !event2.error);
559
563
  };
560
564
  const events = navigationEvents.filter(predicate);
561
- if (events.length) event = events[0];else event = await _helper.helper.waitForEvent(progress, this, Frame.Events.InternalNavigation, predicate).promise;
565
+ if (events.length)
566
+ event = events[0];
567
+ else
568
+ event = await import_helper.helper.waitForEvent(progress, this, Frame.Events.InternalNavigation, predicate).promise;
562
569
  if (event.newDocument.documentId !== navigateResult.newDocumentId) {
563
- // This is just a sanity check. In practice, new navigation should
564
- // cancel the previous one and report "request cancelled"-like error.
565
570
  throw new NavigationAbortedError(navigateResult.newDocumentId, `Navigation to "${url}" is interrupted by another navigation to "${event.url}"`);
566
571
  }
567
- if (event.error) throw event.error;
572
+ if (event.error)
573
+ throw event.error;
568
574
  } else {
569
- // Wait for same document navigation.
570
- const predicate = e => !e.newDocument;
575
+ const predicate = (e) => !e.newDocument;
571
576
  const events = navigationEvents.filter(predicate);
572
- if (events.length) event = events[0];else event = await _helper.helper.waitForEvent(progress, this, Frame.Events.InternalNavigation, predicate).promise;
577
+ if (events.length)
578
+ event = events[0];
579
+ else
580
+ event = await import_helper.helper.waitForEvent(progress, this, Frame.Events.InternalNavigation, predicate).promise;
573
581
  }
574
- if (!this._firedLifecycleEvents.has(waitUntil)) await _helper.helper.waitForEvent(progress, this, Frame.Events.AddLifecycle, e => e === waitUntil).promise;
575
- const request = event.newDocument ? event.newDocument.request : undefined;
582
+ if (!this._firedLifecycleEvents.has(waitUntil))
583
+ await import_helper.helper.waitForEvent(progress, this, Frame.Events.AddLifecycle, (e) => e === waitUntil).promise;
584
+ const request = event.newDocument ? event.newDocument.request : void 0;
576
585
  const response = request ? request._finalRequest().response() : null;
577
586
  return response;
578
587
  }
579
588
  async _waitForNavigation(progress, requiresNewDocument, options) {
580
- const waitUntil = verifyLifecycle('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);
589
+ const waitUntil = verifyLifecycle("waitUntil", options.waitUntil === void 0 ? "load" : options.waitUntil);
581
590
  progress.log(`waiting for navigation until "${waitUntil}"`);
582
- const navigationEvent = await _helper.helper.waitForEvent(progress, this, Frame.Events.InternalNavigation, event => {
583
- // Any failed navigation results in a rejection.
584
- if (event.error) return true;
585
- if (requiresNewDocument && !event.newDocument) return false;
591
+ const navigationEvent = await import_helper.helper.waitForEvent(progress, this, Frame.Events.InternalNavigation, (event) => {
592
+ if (event.error)
593
+ return true;
594
+ if (requiresNewDocument && !event.newDocument)
595
+ return false;
586
596
  progress.log(` navigated to "${this._url}"`);
587
597
  return true;
588
598
  }).promise;
589
- if (navigationEvent.error) throw navigationEvent.error;
590
- if (!this._firedLifecycleEvents.has(waitUntil)) await _helper.helper.waitForEvent(progress, this, Frame.Events.AddLifecycle, e => e === waitUntil).promise;
591
- const request = navigationEvent.newDocument ? navigationEvent.newDocument.request : undefined;
599
+ if (navigationEvent.error)
600
+ throw navigationEvent.error;
601
+ if (!this._firedLifecycleEvents.has(waitUntil))
602
+ await import_helper.helper.waitForEvent(progress, this, Frame.Events.AddLifecycle, (e) => e === waitUntil).promise;
603
+ const request = navigationEvent.newDocument ? navigationEvent.newDocument.request : void 0;
592
604
  return request ? request._finalRequest().response() : null;
593
605
  }
594
606
  async _waitForLoadState(progress, state) {
595
- const waitUntil = verifyLifecycle('state', state);
596
- if (!this._firedLifecycleEvents.has(waitUntil)) await _helper.helper.waitForEvent(progress, this, Frame.Events.AddLifecycle, e => e === waitUntil).promise;
607
+ const waitUntil = verifyLifecycle("state", state);
608
+ if (!this._firedLifecycleEvents.has(waitUntil))
609
+ await import_helper.helper.waitForEvent(progress, this, Frame.Events.AddLifecycle, (e) => e === waitUntil).promise;
597
610
  }
598
611
  async frameElement() {
599
612
  return this._page._delegate.getFrameElement(this);
600
613
  }
601
614
  async _context(world) {
602
- /* await this._page._delegate._mainFrameSession._client._sendMayFail('DOM.enable');
603
- var globalDoc = await this._page._delegate._mainFrameSession._client._sendMayFail('DOM.getFrameOwner', { frameId: this._id });
604
- if (globalDoc) {
605
- await this._page._delegate._mainFrameSession._client._sendMayFail("DOM.resolveNode", { nodeId: globalDoc.nodeId })
606
- } */
607
-
608
- // if (this.isDetached()) throw new Error('Frame was detached');
609
615
  try {
610
616
  var client = this._page._delegate._sessionForFrame(this)._client;
611
617
  } catch (e) {
@@ -613,76 +619,54 @@ class Frame extends _instrumentation.SdkObject {
613
619
  }
614
620
  var iframeExecutionContextId = await this._getFrameMainFrameContextId(client);
615
621
  if (world == "main") {
616
- // Iframe Only
617
- if (this != this._page.mainFrame() && iframeExecutionContextId && this._iframeWorld == undefined) {
622
+ if (this != this._page.mainFrame() && iframeExecutionContextId && this._iframeWorld == void 0) {
618
623
  var executionContextId = iframeExecutionContextId;
619
- var crContext = new _crExecutionContext.CRExecutionContext(client, {
620
- id: executionContextId
621
- }, this._id);
622
- this._iframeWorld = new _dom.FrameExecutionContext(crContext, this, world);
624
+ var crContext = new import_crExecutionContext.CRExecutionContext(client, { id: executionContextId }, this._id);
625
+ this._iframeWorld = new import_dom.FrameExecutionContext(crContext, this, world);
623
626
  this._page._delegate._mainFrameSession._onExecutionContextCreated({
624
627
  id: executionContextId,
625
628
  origin: world,
626
629
  name: world,
627
- auxData: {
628
- isDefault: this === this._page.mainFrame(),
629
- type: 'isolated',
630
- frameId: this._id
631
- }
630
+ auxData: { isDefault: this === this._page.mainFrame(), type: "isolated", frameId: this._id }
632
631
  });
633
- } else if (this._mainWorld == undefined) {
634
- var globalThis = await client._sendMayFail('Runtime.evaluate', {
632
+ } else if (this._mainWorld == void 0) {
633
+ var globalThis2 = await client._sendMayFail("Runtime.evaluate", {
635
634
  expression: "globalThis",
636
- serializationOptions: {
637
- serialization: "idOnly"
638
- }
635
+ serializationOptions: { serialization: "idOnly" }
639
636
  });
640
- if (!globalThis) {
637
+ if (!globalThis2) {
641
638
  return;
642
639
  }
643
- var globalThisObjId = globalThis["result"]['objectId'];
644
- var executionContextId = parseInt(globalThisObjId.split('.')[1], 10);
645
- var crContext = new _crExecutionContext.CRExecutionContext(client, {
646
- id: executionContextId
647
- }, this._id);
648
- this._mainWorld = new _dom.FrameExecutionContext(crContext, this, world);
640
+ var globalThisObjId = globalThis2["result"]["objectId"];
641
+ var executionContextId = parseInt(globalThisObjId.split(".")[1], 10);
642
+ var crContext = new import_crExecutionContext.CRExecutionContext(client, { id: executionContextId }, this._id);
643
+ this._mainWorld = new import_dom.FrameExecutionContext(crContext, this, world);
649
644
  this._page._delegate._mainFrameSession._onExecutionContextCreated({
650
645
  id: executionContextId,
651
646
  origin: world,
652
647
  name: world,
653
- auxData: {
654
- isDefault: this === this._page.mainFrame(),
655
- type: 'isolated',
656
- frameId: this._id
657
- }
648
+ auxData: { isDefault: this === this._page.mainFrame(), type: "isolated", frameId: this._id }
658
649
  });
659
650
  }
660
651
  }
661
- if (world != "main" && this._isolatedWorld == undefined) {
652
+ if (world != "main" && this._isolatedWorld == void 0) {
662
653
  world = "utility";
663
- var result = await client._sendMayFail('Page.createIsolatedWorld', {
654
+ var result = await client._sendMayFail("Page.createIsolatedWorld", {
664
655
  frameId: this._id,
665
656
  grantUniveralAccess: true,
666
657
  worldName: world
667
658
  });
668
659
  if (!result) {
669
- // if (this.isDetached()) throw new Error("Frame was detached");
670
660
  return;
671
661
  }
672
662
  var executionContextId = result.executionContextId;
673
- var crContext = new _crExecutionContext.CRExecutionContext(client, {
674
- id: executionContextId
675
- }, this._id);
676
- this._isolatedWorld = new _dom.FrameExecutionContext(crContext, this, world);
663
+ var crContext = new import_crExecutionContext.CRExecutionContext(client, { id: executionContextId }, this._id);
664
+ this._isolatedWorld = new import_dom.FrameExecutionContext(crContext, this, world);
677
665
  this._page._delegate._mainFrameSession._onExecutionContextCreated({
678
666
  id: executionContextId,
679
667
  origin: world,
680
668
  name: world,
681
- auxData: {
682
- isDefault: this === this._page.mainFrame(),
683
- type: 'isolated',
684
- frameId: this._id
685
- }
669
+ auxData: { isDefault: this === this._page.mainFrame(), type: "isolated", frameId: this._id }
686
670
  });
687
671
  }
688
672
  if (world != "main") {
@@ -694,65 +678,59 @@ class Frame extends _instrumentation.SdkObject {
694
678
  }
695
679
  }
696
680
  _mainContext() {
697
- return this._context('main');
681
+ return this._context("main");
698
682
  }
699
683
  _existingMainContext() {
700
- var _this$_contextData$ge2;
701
- return ((_this$_contextData$ge2 = this._contextData.get('main')) === null || _this$_contextData$ge2 === void 0 ? void 0 : _this$_contextData$ge2.context) || null;
684
+ return this._contextData.get("main")?.context || null;
702
685
  }
703
686
  _utilityContext() {
704
- return this._context('utility');
687
+ return this._context("utility");
705
688
  }
706
689
  async evaluateExpression(expression, options = {}, arg) {
707
- var _options$world;
708
- const context = await this._context((_options$world = options.world) !== null && _options$world !== void 0 ? _options$world : 'main');
690
+ const context = await this._context(options.world ?? "main");
709
691
  const value = await context.evaluateExpression(expression, options, arg);
710
692
  return value;
711
693
  }
712
694
  async evaluateExpressionHandle(expression, options = {}, arg) {
713
- var _options$world2;
714
- const context = await this._context((_options$world2 = options.world) !== null && _options$world2 !== void 0 ? _options$world2 : 'main');
695
+ const context = await this._context(options.world ?? "main");
715
696
  const value = await context.evaluateExpressionHandle(expression, options, arg);
716
697
  return value;
717
698
  }
718
699
  async querySelector(selector, options) {
719
- _debugLogger.debugLogger.log('api', ` finding element using the selector "${selector}"`);
700
+ import_debugLogger.debugLogger.log("api", ` finding element using the selector "${selector}"`);
720
701
  return this.selectors.query(selector, options);
721
702
  }
722
703
  async waitForSelector(metadata, selector, options, scope) {
723
- const controller = new _progress2.ProgressController(metadata, this);
724
- if (options.visibility) throw new Error('options.visibility is not supported, did you mean options.state?');
725
- if (options.waitFor && options.waitFor !== 'visible') throw new Error('options.waitFor is not supported, did you mean options.state?');
726
- const {
727
- state = 'visible'
728
- } = options;
729
- if (!['attached', 'detached', 'visible', 'hidden'].includes(state)) throw new Error(`state: expected one of (attached|detached|visible|hidden)`);
730
- return controller.run(async progress => {
731
- progress.log(`waiting for ${this._asLocator(selector)}${state === 'attached' ? '' : ' to be ' + state}`);
704
+ const controller = new import_progress.ProgressController(metadata, this);
705
+ if (options.visibility)
706
+ throw new Error("options.visibility is not supported, did you mean options.state?");
707
+ if (options.waitFor && options.waitFor !== "visible")
708
+ throw new Error("options.waitFor is not supported, did you mean options.state?");
709
+ const { state = "visible" } = options;
710
+ if (!["attached", "detached", "visible", "hidden"].includes(state))
711
+ throw new Error(`state: expected one of (attached|detached|visible|hidden)`);
712
+ return controller.run(async (progress) => {
713
+ progress.log(`waiting for ${this._asLocator(selector)}${state === "attached" ? "" : " to be " + state}`);
732
714
  return await this.waitForSelectorInternal(progress, selector, true, options, scope);
733
715
  }, this._page._timeoutSettings.timeout(options));
734
716
  }
735
717
  async waitForSelectorInternal(progress, selector, performActionPreChecks, options, scope) {
736
718
  const {
737
- state = 'visible'
719
+ state = "visible"
738
720
  } = options;
739
- const promise = this._retryWithProgressIfNotConnected(progress, selector, options.strict, true, async handle => {
721
+ const promise = this._retryWithProgressIfNotConnected(progress, selector, options.strict, true, async (handle) => {
740
722
  const attached = !!handle;
741
723
  var visible = false;
742
724
  if (attached) {
743
725
  if (handle.parentNode.constructor.name == "ElementHandle") {
744
- visible = await handle.parentNode.evaluateInUtility(([injected, node, {
745
- handle
746
- }]) => {
747
- return handle ? injected.utils.isElementVisible(handle) : false;
726
+ visible = await handle.parentNode.evaluateInUtility(([injected, node, { handle: handle2 }]) => {
727
+ return handle2 ? injected.utils.isElementVisible(handle2) : false;
748
728
  }, {
749
729
  handle
750
730
  });
751
731
  } else {
752
- visible = await handle.parentNode.evaluate((injected, {
753
- handle
754
- }) => {
755
- return handle ? injected.utils.isElementVisible(handle) : false;
732
+ visible = await handle.parentNode.evaluate((injected, { handle: handle2 }) => {
733
+ return handle2 ? injected.utils.isElementVisible(handle2) : false;
756
734
  }, {
757
735
  handle
758
736
  });
@@ -770,7 +748,7 @@ class Frame extends _instrumentation.SdkObject {
770
748
  if (options.omitReturnValue) {
771
749
  return null;
772
750
  }
773
- const element = state === 'attached' || state === 'visible' ? handle : null;
751
+ const element = state === "attached" || state === "visible" ? handle : null;
774
752
  if (!element) return null;
775
753
  if (options.__testHookBeforeAdoptNode) await options.__testHookBeforeAdoptNode();
776
754
  try {
@@ -778,51 +756,34 @@ class Frame extends _instrumentation.SdkObject {
778
756
  } catch (e) {
779
757
  return "internal:continuepolling";
780
758
  }
781
- }, 'returnOnNotResolved');
759
+ });
782
760
  return scope ? scope._context._raceAgainstContextDestroyed(promise) : promise;
783
761
  }
784
762
  async dispatchEvent(metadata, selector, type, eventInit = {}, options = {}, scope) {
785
763
  await this._callOnElementOnceMatches(metadata, selector, (injectedScript, element, data) => {
786
764
  injectedScript.dispatchEvent(element, data.type, data.eventInit);
787
- }, {
788
- type,
789
- eventInit
790
- }, {
791
- mainWorld: true,
792
- ...options
793
- }, scope);
765
+ }, { type, eventInit }, { mainWorld: true, ...options }, scope);
794
766
  }
795
767
  async evalOnSelector(selector, strict, expression, isFunction, arg, scope) {
796
- const handle = await this.selectors.query(selector, {
797
- strict
798
- }, scope);
799
- if (!handle) throw new Error(`Failed to find element matching selector "${selector}"`);
800
- const result = await handle.evaluateExpression(expression, {
801
- isFunction
802
- }, arg);
768
+ const handle = await this.selectors.query(selector, { strict }, scope);
769
+ if (!handle)
770
+ throw new Error(`Failed to find element matching selector "${selector}"`);
771
+ const result = await handle.evaluateExpression(expression, { isFunction }, arg);
803
772
  handle.dispose();
804
773
  return result;
805
774
  }
806
775
  async evalOnSelectorAll(selector, expression, isFunction, arg, scope) {
807
776
  const arrayHandle = await this.selectors.queryArrayInMainWorld(selector, scope);
808
- const result = await arrayHandle.evaluateExpression(expression, {
809
- isFunction
810
- }, arg);
777
+ const result = await arrayHandle.evaluateExpression(expression, { isFunction }, arg);
811
778
  arrayHandle.dispose();
812
779
  return result;
813
780
  }
814
781
  async maskSelectors(selectors, color) {
815
782
  const context = await this._utilityContext();
816
783
  const injectedScript = await context.injectedScript();
817
- await injectedScript.evaluate((injected, {
818
- parsed,
819
- color
820
- }) => {
821
- injected.maskSelectors(parsed, color);
822
- }, {
823
- parsed: selectors,
824
- color: color
825
- });
784
+ await injectedScript.evaluate((injected, { parsed, color: color2 }) => {
785
+ injected.maskSelectors(parsed, color2);
786
+ }, { parsed: selectors, color });
826
787
  }
827
788
  async querySelectorAll(selector) {
828
789
  return this.selectors.queryAll(selector);
@@ -832,60 +793,57 @@ class Frame extends _instrumentation.SdkObject {
832
793
  "internal": false,
833
794
  "log": []
834
795
  };
835
- const controller = new _progress.ProgressController(custom_metadata, this);
836
- return await controller.run(async progress => {
796
+ const controller = new import_progress.ProgressController(custom_metadata, this);
797
+ return await controller.run(async (progress) => {
837
798
  progress.log("waiting for " + this._asLocator(selector));
838
- const promise = await this._retryWithProgressIfNotConnected(progress, selector, false, false, async result => {
799
+ const promise = await this._retryWithProgressIfNotConnected(progress, selector, false, false, async (result) => {
839
800
  const handle = result[0];
840
801
  const handles = result[1];
841
802
  return handle ? handles.length : 0;
842
- }, 'returnAll');
803
+ }, "returnAll");
843
804
  return promise;
844
- }, 100); // A bit geeky but its okay :D
805
+ }, 100);
845
806
  }
846
807
  async content() {
847
808
  try {
848
809
  const context = await this._utilityContext();
849
810
  return await context.evaluate(() => {
850
- let retVal = '';
851
- if (document.doctype) retVal = new XMLSerializer().serializeToString(document.doctype);
852
- if (document.documentElement) retVal += document.documentElement.outerHTML;
811
+ let retVal = "";
812
+ if (document.doctype)
813
+ retVal = new XMLSerializer().serializeToString(document.doctype);
814
+ if (document.documentElement)
815
+ retVal += document.documentElement.outerHTML;
853
816
  return retVal;
854
817
  });
855
818
  } catch (e) {
856
- if (js.isJavaScriptErrorInEvaluate(e) || (0, _protocolError.isSessionClosedError)(e)) throw e;
819
+ if (js.isJavaScriptErrorInEvaluate(e) || (0, import_protocolError.isSessionClosedError)(e))
820
+ throw e;
857
821
  throw new Error(`Unable to retrieve content because the page is navigating and changing the content.`);
858
822
  }
859
823
  }
860
824
  async setContent(metadata, html, options = {}) {
861
- const controller = new _progress2.ProgressController(metadata, this);
862
- return controller.run(async progress => {
825
+ const controller = new import_progress.ProgressController(metadata, this);
826
+ return controller.run(async (progress) => {
863
827
  await this.raceNavigationAction(progress, options, async () => {
864
- const waitUntil = options.waitUntil === undefined ? 'load' : options.waitUntil;
828
+ const waitUntil = options.waitUntil === void 0 ? "load" : options.waitUntil;
865
829
  progress.log(`setting frame content, waiting until "${waitUntil}"`);
866
830
  const tag = `--playwright--set--content--${this._id}--${++this._setContentCounter}--`;
867
- const bindingName = "_tagDebug" + _crypto.default.randomBytes(20).toString('hex');
831
+ const bindingName = "_tagDebug" + import_crypto.default.randomBytes(20).toString("hex");
868
832
  const context = await this._utilityContext();
869
- await this._page._delegate._mainFrameSession._client.send('Runtime.addBinding', {
870
- name: bindingName
871
- });
833
+ await this._page._delegate._mainFrameSession._client.send("Runtime.addBinding", { name: bindingName });
872
834
  const lifecyclePromise = new Promise(async (resolve, reject) => {
873
- await this._page.exposeBinding(bindingName, false, tag => {
835
+ await this._page.exposeBinding(bindingName, false, (tag2) => {
874
836
  this._onClearLifecycle();
875
837
  this._waitForLoadState(progress, waitUntil).then(resolve).catch(reject);
876
838
  });
877
839
  });
878
- const contentPromise = context.evaluate(({
879
- html,
880
- tag,
881
- bindingName
882
- }) => {
840
+ const contentPromise = context.evaluate(({ html: html2, tag: tag2, bindingName: bindingName2 }) => {
883
841
  document.open();
884
- var _tagDebug = window[bindingName].bind({});
885
- delete window[bindingName];
886
- _tagDebug('{ "name": "' + bindingName + '", "seq": 1, "serializedArgs": ["' + tag + '"] }');
887
- console.debug(tag); // eslint-disable-line no-console
888
- document.write(html);
842
+ var _tagDebug = window[bindingName2].bind({});
843
+ delete window[bindingName2];
844
+ _tagDebug('{ "name": "' + bindingName2 + '", "seq": 1, "serializedArgs": ["' + tag2 + '"] }');
845
+ console.debug(tag2);
846
+ document.write(html2);
889
847
  document.close();
890
848
  }, {
891
849
  html,
@@ -898,15 +856,15 @@ class Frame extends _instrumentation.SdkObject {
898
856
  }, this._page._timeoutSettings.navigationTimeout(options));
899
857
  }
900
858
  name() {
901
- return this._name || '';
859
+ return this._name || "";
902
860
  }
903
861
  url() {
904
862
  return this._url;
905
863
  }
906
864
  origin() {
907
- var _network$parseURL;
908
- if (!this._url.startsWith('http')) return;
909
- return (_network$parseURL = network.parseURL(this._url)) === null || _network$parseURL === void 0 ? void 0 : _network$parseURL.origin;
865
+ if (!this._url.startsWith("http"))
866
+ return;
867
+ return network.parseURL(this._url)?.origin;
910
868
  }
911
869
  parentFrame() {
912
870
  return this._parentFrame;
@@ -918,44 +876,41 @@ class Frame extends _instrumentation.SdkObject {
918
876
  const {
919
877
  url = null,
920
878
  content = null,
921
- type = ''
879
+ type = ""
922
880
  } = params;
923
- if (!url && !content) throw new Error('Provide an object with a `url`, `path` or `content` property');
881
+ if (!url && !content)
882
+ throw new Error("Provide an object with a `url`, `path` or `content` property");
924
883
  const context = await this._mainContext();
925
884
  return this._raceWithCSPError(async () => {
926
- if (url !== null) return (await context.evaluateHandle(addScriptUrl, {
927
- url,
928
- type
929
- })).asElement();
930
- const result = (await context.evaluateHandle(addScriptContent, {
931
- content: content,
932
- type
933
- })).asElement();
934
- // Another round trip to the browser to ensure that we receive CSP error messages
935
- // (if any) logged asynchronously in a separate task on the content main thread.
936
- if (this._page._delegate.cspErrorsAsynchronousForInlineScripts) await context.evaluate(() => true);
885
+ if (url !== null)
886
+ return (await context.evaluateHandle(addScriptUrl, { url, type })).asElement();
887
+ const result = (await context.evaluateHandle(addScriptContent, { content, type })).asElement();
888
+ if (this._page._delegate.cspErrorsAsynchronousForInlineScripts)
889
+ await context.evaluate(() => true);
937
890
  return result;
938
891
  });
939
- async function addScriptUrl(params) {
940
- const script = document.createElement('script');
941
- script.src = params.url;
942
- if (params.type) script.type = params.type;
892
+ async function addScriptUrl(params2) {
893
+ const script = document.createElement("script");
894
+ script.src = params2.url;
895
+ if (params2.type)
896
+ script.type = params2.type;
943
897
  const promise = new Promise((res, rej) => {
944
898
  script.onload = res;
945
- script.onerror = e => rej(typeof e === 'string' ? new Error(e) : new Error(`Failed to load script at ${script.src}`));
899
+ script.onerror = (e) => rej(typeof e === "string" ? new Error(e) : new Error(`Failed to load script at ${script.src}`));
946
900
  });
947
901
  document.head.appendChild(script);
948
902
  await promise;
949
903
  return script;
950
904
  }
951
- function addScriptContent(params) {
952
- const script = document.createElement('script');
953
- script.type = params.type || 'text/javascript';
954
- script.text = params.content;
905
+ function addScriptContent(params2) {
906
+ const script = document.createElement("script");
907
+ script.type = params2.type || "text/javascript";
908
+ script.text = params2.content;
955
909
  let error = null;
956
- script.onerror = e => error = e;
910
+ script.onerror = (e) => error = e;
957
911
  document.head.appendChild(script);
958
- if (error) throw error;
912
+ if (error)
913
+ throw error;
959
914
  return script;
960
915
  }
961
916
  }
@@ -964,16 +919,18 @@ class Frame extends _instrumentation.SdkObject {
964
919
  url = null,
965
920
  content = null
966
921
  } = params;
967
- if (!url && !content) throw new Error('Provide an object with a `url`, `path` or `content` property');
922
+ if (!url && !content)
923
+ throw new Error("Provide an object with a `url`, `path` or `content` property");
968
924
  const context = await this._mainContext();
969
925
  return this._raceWithCSPError(async () => {
970
- if (url !== null) return (await context.evaluateHandle(addStyleUrl, url)).asElement();
926
+ if (url !== null)
927
+ return (await context.evaluateHandle(addStyleUrl, url)).asElement();
971
928
  return (await context.evaluateHandle(addStyleContent, content)).asElement();
972
929
  });
973
- async function addStyleUrl(url) {
974
- const link = document.createElement('link');
975
- link.rel = 'stylesheet';
976
- link.href = url;
930
+ async function addStyleUrl(url2) {
931
+ const link = document.createElement("link");
932
+ link.rel = "stylesheet";
933
+ link.href = url2;
977
934
  const promise = new Promise((res, rej) => {
978
935
  link.onload = res;
979
936
  link.onerror = rej;
@@ -982,10 +939,10 @@ class Frame extends _instrumentation.SdkObject {
982
939
  await promise;
983
940
  return link;
984
941
  }
985
- async function addStyleContent(content) {
986
- const style = document.createElement('style');
987
- style.type = 'text/css';
988
- style.appendChild(document.createTextNode(content));
942
+ async function addStyleContent(content2) {
943
+ const style = document.createElement("style");
944
+ style.type = "text/css";
945
+ style.appendChild(document.createTextNode(content2));
989
946
  const promise = new Promise((res, rej) => {
990
947
  style.onload = res;
991
948
  style.onerror = rej;
@@ -1000,68 +957,73 @@ class Frame extends _instrumentation.SdkObject {
1000
957
  let result;
1001
958
  let error;
1002
959
  let cspMessage;
1003
- const actionPromise = func().then(r => result = r).catch(e => error = e);
1004
- const errorPromise = new Promise(resolve => {
1005
- listeners.push(_eventsHelper.eventsHelper.addEventListener(this._page._browserContext, _browserContext.BrowserContext.Events.Console, message => {
1006
- if (message.page() !== this._page || message.type() !== 'error') return;
1007
- if (message.text().includes('Content-Security-Policy') || message.text().includes('Content Security Policy')) {
960
+ const actionPromise = func().then((r) => result = r).catch((e) => error = e);
961
+ const errorPromise = new Promise((resolve) => {
962
+ listeners.push(import_eventsHelper.eventsHelper.addEventListener(this._page._browserContext, import_browserContext.BrowserContext.Events.Console, (message) => {
963
+ if (message.page() !== this._page || message.type() !== "error")
964
+ return;
965
+ if (message.text().includes("Content-Security-Policy") || message.text().includes("Content Security Policy")) {
1008
966
  cspMessage = message;
1009
967
  resolve();
1010
968
  }
1011
969
  }));
1012
970
  });
1013
971
  await Promise.race([actionPromise, errorPromise]);
1014
- _eventsHelper.eventsHelper.removeEventListeners(listeners);
1015
- if (cspMessage) throw new Error(cspMessage.text());
1016
- if (error) throw error;
972
+ import_eventsHelper.eventsHelper.removeEventListeners(listeners);
973
+ if (cspMessage)
974
+ throw new Error(cspMessage.text());
975
+ if (error)
976
+ throw error;
1017
977
  return result;
1018
978
  }
1019
979
  async retryWithProgressAndTimeouts(progress, timeouts, action) {
1020
- const continuePolling = Symbol('continuePolling');
980
+ const continuePolling2 = Symbol("continuePolling");
1021
981
  timeouts = [0, ...timeouts];
1022
982
  let timeoutIndex = 0;
1023
983
  while (progress.isRunning()) {
1024
984
  const timeout = timeouts[Math.min(timeoutIndex++, timeouts.length - 1)];
1025
985
  if (timeout) {
1026
- // Make sure we react immediately upon page close or frame detach.
1027
- // We need this to show expected/received values in time.
1028
- const actionPromise = new Promise(f => setTimeout(f, timeout));
1029
- await _utils.LongStandingScope.raceMultiple([this._page.openScope, this._detachedScope], actionPromise);
986
+ const actionPromise = new Promise((f) => setTimeout(f, timeout));
987
+ await import_utils.LongStandingScope.raceMultiple([
988
+ this._page.openScope,
989
+ this._detachedScope
990
+ ], actionPromise);
1030
991
  }
1031
992
  progress.throwIfAborted();
1032
993
  try {
1033
- const result = await action(continuePolling);
1034
- if (result === continuePolling) continue;
994
+ const result = await action(continuePolling2);
995
+ if (result === continuePolling2)
996
+ continue;
1035
997
  return result;
1036
998
  } catch (e) {
1037
- if (this._isErrorThatCannotBeRetried(e)) throw e;
999
+ if (this._isErrorThatCannotBeRetried(e))
1000
+ throw e;
1038
1001
  continue;
1039
1002
  }
1040
1003
  }
1041
1004
  progress.throwIfAborted();
1042
- return undefined;
1005
+ return void 0;
1043
1006
  }
1044
1007
  _isErrorThatCannotBeRetried(e) {
1045
- // Always fail on JavaScript errors or when the main connection is closed.
1046
- if (js.isJavaScriptErrorInEvaluate(e) || (0, _protocolError.isSessionClosedError)(e)) return true;
1047
- // Certain errors opt-out of the retries, throw.
1048
- if (dom.isNonRecoverableDOMError(e) || (0, _selectorParser.isInvalidSelectorError)(e)) return true;
1049
- // If the call is made on the detached frame - throw.
1050
- if (this.isDetached()) return true;
1051
- // Retry upon all other errors.
1008
+ if (js.isJavaScriptErrorInEvaluate(e) || (0, import_protocolError.isSessionClosedError)(e))
1009
+ return true;
1010
+ if (dom.isNonRecoverableDOMError(e) || (0, import_selectorParser.isInvalidSelectorError)(e))
1011
+ return true;
1012
+ if (this.isDetached())
1013
+ return true;
1052
1014
  return false;
1053
1015
  }
1054
1016
  async _retryWithProgressIfNotConnected(progress, selector, strict, performActionPreChecks, action, returnAction) {
1055
1017
  progress.log("waiting for " + this._asLocator(selector));
1056
- return this.retryWithProgressAndTimeouts(progress, [0, 20, 50, 100, 100, 500], async continuePolling => {
1018
+ return this.retryWithProgressAndTimeouts(progress, [0, 20, 50, 100, 100, 500], async (continuePolling2) => {
1057
1019
  if (performActionPreChecks) await this._page.performActionPreChecks(progress);
1058
1020
  const resolved = await this.selectors.resolveInjectedForSelector(selector, {
1059
1021
  strict
1060
1022
  });
1061
1023
  progress.throwIfAborted();
1062
1024
  if (!resolved) {
1063
- if (returnAction === 'returnOnNotResolved' || returnAction === 'returnAll') return null;
1064
- return continuePolling;
1025
+ if (returnAction === "returnOnNotResolved" || returnAction === "returnAll") return null;
1026
+ return continuePolling2;
1065
1027
  }
1066
1028
  try {
1067
1029
  var client = this._page._delegate._sessionForFrame(resolved.frame)._client;
@@ -1069,7 +1031,7 @@ class Frame extends _instrumentation.SdkObject {
1069
1031
  var client = this._page._delegate._mainFrameSession._client;
1070
1032
  }
1071
1033
  var context = await resolved.frame._context("main");
1072
- const documentNode = await client.send('Runtime.evaluate', {
1034
+ const documentNode = await client.send("Runtime.evaluate", {
1073
1035
  expression: "document",
1074
1036
  serializationOptions: {
1075
1037
  serialization: "idOnly"
@@ -1079,9 +1041,8 @@ class Frame extends _instrumentation.SdkObject {
1079
1041
  const documentScope = new dom.ElementHandle(context, documentNode.result.objectId);
1080
1042
  const currentScopingElements = await this._customFindElementsByParsed(resolved, client, context, documentScope, progress, resolved.info.parsed);
1081
1043
  if (currentScopingElements.length == 0) {
1082
- // TODO: Dispose?
1083
- if (returnAction === 'returnOnNotResolved' || returnAction === 'returnAll') return null;
1084
- return continuePolling;
1044
+ if (returnAction === "returnOnNotResolved" || returnAction === "returnAll") return null;
1045
+ return continuePolling2;
1085
1046
  }
1086
1047
  const resultElement = currentScopingElements[0];
1087
1048
  if (currentScopingElements.length > 1) {
@@ -1102,64 +1063,61 @@ class Frame extends _instrumentation.SdkObject {
1102
1063
  }
1103
1064
  try {
1104
1065
  var result = null;
1105
- if (returnAction === 'returnAll') {
1066
+ if (returnAction === "returnAll") {
1106
1067
  result = await action([resultElement, currentScopingElements]);
1107
1068
  } else {
1108
1069
  result = await action(resultElement);
1109
1070
  }
1110
- if (result === 'error:notconnected') {
1111
- progress.log('element was detached from the DOM, retrying');
1112
- return continuePolling;
1113
- } else if (result === 'internal:continuepolling') {
1114
- return continuePolling;
1071
+ if (result === "error:notconnected") {
1072
+ progress.log("element was detached from the DOM, retrying");
1073
+ return continuePolling2;
1074
+ } else if (result === "internal:continuepolling") {
1075
+ return continuePolling2;
1115
1076
  }
1116
1077
  return result;
1117
- } finally {}
1078
+ } finally {
1079
+ }
1118
1080
  });
1119
1081
  }
1120
1082
  async rafrafTimeoutScreenshotElementWithProgress(progress, selector, timeout, options) {
1121
- return await this._retryWithProgressIfNotConnected(progress, selector, true /* strict */, true /* performActionPreChecks */, async handle => {
1083
+ return await this._retryWithProgressIfNotConnected(progress, selector, true, true, async (handle) => {
1122
1084
  await handle._frame.rafrafTimeout(timeout);
1123
1085
  return await this._page._screenshotter.screenshotElement(progress, handle, options);
1124
1086
  });
1125
1087
  }
1126
1088
  async click(metadata, selector, options) {
1127
- const controller = new _progress2.ProgressController(metadata, this);
1128
- return controller.run(async progress => {
1129
- return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /* performActionPreChecks */, handle => handle._click(progress, {
1130
- ...options,
1131
- waitAfter: !options.noWaitAfter
1132
- })));
1089
+ const controller = new import_progress.ProgressController(metadata, this);
1090
+ return controller.run(async (progress) => {
1091
+ return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._click(progress, { ...options, waitAfter: !options.noWaitAfter })));
1133
1092
  }, this._page._timeoutSettings.timeout(options));
1134
1093
  }
1135
1094
  async dblclick(metadata, selector, options = {}) {
1136
- const controller = new _progress2.ProgressController(metadata, this);
1137
- return controller.run(async progress => {
1138
- return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /* performActionPreChecks */, handle => handle._dblclick(progress, options)));
1095
+ const controller = new import_progress.ProgressController(metadata, this);
1096
+ return controller.run(async (progress) => {
1097
+ return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._dblclick(progress, options)));
1139
1098
  }, this._page._timeoutSettings.timeout(options));
1140
1099
  }
1141
1100
  async dragAndDrop(metadata, source, target, options = {}) {
1142
- const controller = new _progress2.ProgressController(metadata, this);
1143
- await controller.run(async progress => {
1144
- dom.assertDone(await this._retryWithProgressIfNotConnected(progress, source, options.strict, !options.force /* performActionPreChecks */, async handle => {
1145
- return handle._retryPointerAction(progress, 'move and down', false, async point => {
1101
+ const controller = new import_progress.ProgressController(metadata, this);
1102
+ await controller.run(async (progress) => {
1103
+ dom.assertDone(await this._retryWithProgressIfNotConnected(progress, source, options.strict, !options.force, async (handle) => {
1104
+ return handle._retryPointerAction(progress, "move and down", false, async (point) => {
1146
1105
  await this._page.mouse.move(point.x, point.y);
1147
1106
  await this._page.mouse.down();
1148
1107
  }, {
1149
1108
  ...options,
1150
- waitAfter: 'disabled',
1109
+ waitAfter: "disabled",
1151
1110
  position: options.sourcePosition,
1152
1111
  timeout: progress.timeUntilDeadline()
1153
1112
  });
1154
1113
  }));
1155
- // Note: do not perform locator handlers checkpoint to avoid moving the mouse in the middle of a drag operation.
1156
- dom.assertDone(await this._retryWithProgressIfNotConnected(progress, target, options.strict, false /* performActionPreChecks */, async handle => {
1157
- return handle._retryPointerAction(progress, 'move and up', false, async point => {
1114
+ dom.assertDone(await this._retryWithProgressIfNotConnected(progress, target, options.strict, false, async (handle) => {
1115
+ return handle._retryPointerAction(progress, "move and up", false, async (point) => {
1158
1116
  await this._page.mouse.move(point.x, point.y);
1159
1117
  await this._page.mouse.up();
1160
1118
  }, {
1161
1119
  ...options,
1162
- waitAfter: 'disabled',
1120
+ waitAfter: "disabled",
1163
1121
  position: options.targetPosition,
1164
1122
  timeout: progress.timeUntilDeadline()
1165
1123
  });
@@ -1167,70 +1125,68 @@ class Frame extends _instrumentation.SdkObject {
1167
1125
  }, this._page._timeoutSettings.timeout(options));
1168
1126
  }
1169
1127
  async tap(metadata, selector, options) {
1170
- if (!this._page._browserContext._options.hasTouch) throw new Error('The page does not support tap. Use hasTouch context option to enable touch support.');
1171
- const controller = new _progress2.ProgressController(metadata, this);
1172
- return controller.run(async progress => {
1173
- return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /* performActionPreChecks */, handle => handle._tap(progress, options)));
1128
+ if (!this._page._browserContext._options.hasTouch)
1129
+ throw new Error("The page does not support tap. Use hasTouch context option to enable touch support.");
1130
+ const controller = new import_progress.ProgressController(metadata, this);
1131
+ return controller.run(async (progress) => {
1132
+ return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._tap(progress, options)));
1174
1133
  }, this._page._timeoutSettings.timeout(options));
1175
1134
  }
1176
1135
  async fill(metadata, selector, value, options) {
1177
- const controller = new _progress2.ProgressController(metadata, this);
1178
- return controller.run(async progress => {
1179
- return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /* performActionPreChecks */, handle => handle._fill(progress, value, options)));
1136
+ const controller = new import_progress.ProgressController(metadata, this);
1137
+ return controller.run(async (progress) => {
1138
+ return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._fill(progress, value, options)));
1180
1139
  }, this._page._timeoutSettings.timeout(options));
1181
1140
  }
1182
1141
  async focus(metadata, selector, options = {}) {
1183
- const controller = new _progress2.ProgressController(metadata, this);
1184
- await controller.run(async progress => {
1185
- dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true /* performActionPreChecks */, handle => handle._focus(progress)));
1142
+ const controller = new import_progress.ProgressController(metadata, this);
1143
+ await controller.run(async (progress) => {
1144
+ dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true, (handle) => handle._focus(progress)));
1186
1145
  }, this._page._timeoutSettings.timeout(options));
1187
1146
  }
1188
1147
  async blur(metadata, selector, options = {}) {
1189
- const controller = new _progress2.ProgressController(metadata, this);
1190
- await controller.run(async progress => {
1191
- dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true /* performActionPreChecks */, handle => handle._blur(progress)));
1148
+ const controller = new import_progress.ProgressController(metadata, this);
1149
+ await controller.run(async (progress) => {
1150
+ dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true, (handle) => handle._blur(progress)));
1192
1151
  }, this._page._timeoutSettings.timeout(options));
1193
1152
  }
1194
1153
  async textContent(metadata, selector, options = {}, scope) {
1195
- return this._callOnElementOnceMatches(metadata, selector, (injected, element) => element.textContent, undefined, options, scope);
1154
+ return this._callOnElementOnceMatches(metadata, selector, (injected, element) => element.textContent, void 0, options, scope);
1196
1155
  }
1197
1156
  async innerText(metadata, selector, options = {}, scope) {
1198
1157
  return this._callOnElementOnceMatches(metadata, selector, (injectedScript, element) => {
1199
- if (element.namespaceURI !== 'http://www.w3.org/1999/xhtml') throw injectedScript.createStacklessError('Node is not an HTMLElement');
1158
+ if (element.namespaceURI !== "http://www.w3.org/1999/xhtml")
1159
+ throw injectedScript.createStacklessError("Node is not an HTMLElement");
1200
1160
  return element.innerText;
1201
- }, undefined, options, scope);
1161
+ }, void 0, options, scope);
1202
1162
  }
1203
1163
  async innerHTML(metadata, selector, options = {}, scope) {
1204
- return this._callOnElementOnceMatches(metadata, selector, (injected, element) => element.innerHTML, undefined, options, scope);
1164
+ return this._callOnElementOnceMatches(metadata, selector, (injected, element) => element.innerHTML, void 0, options, scope);
1205
1165
  }
1206
1166
  async getAttribute(metadata, selector, name, options = {}, scope) {
1207
- return this._callOnElementOnceMatches(metadata, selector, (injected, element, data) => element.getAttribute(data.name), {
1208
- name
1209
- }, options, scope);
1167
+ return this._callOnElementOnceMatches(metadata, selector, (injected, element, data) => element.getAttribute(data.name), { name }, options, scope);
1210
1168
  }
1211
1169
  async inputValue(metadata, selector, options = {}, scope) {
1212
1170
  return this._callOnElementOnceMatches(metadata, selector, (injectedScript, node) => {
1213
- const element = injectedScript.retarget(node, 'follow-label');
1214
- if (!element || element.nodeName !== 'INPUT' && element.nodeName !== 'TEXTAREA' && element.nodeName !== 'SELECT') throw injectedScript.createStacklessError('Node is not an <input>, <textarea> or <select> element');
1171
+ const element = injectedScript.retarget(node, "follow-label");
1172
+ if (!element || element.nodeName !== "INPUT" && element.nodeName !== "TEXTAREA" && element.nodeName !== "SELECT")
1173
+ throw injectedScript.createStacklessError("Node is not an <input>, <textarea> or <select> element");
1215
1174
  return element.value;
1216
- }, undefined, options, scope);
1175
+ }, void 0, options, scope);
1217
1176
  }
1218
1177
  async highlight(selector) {
1219
1178
  const resolved = await this.selectors.resolveInjectedForSelector(selector);
1220
- if (!resolved) return;
1221
- return await resolved.injected.evaluate((injected, {
1222
- info
1223
- }) => {
1179
+ if (!resolved)
1180
+ return;
1181
+ return await resolved.injected.evaluate((injected, { info }) => {
1224
1182
  return injected.highlight(info.parsed);
1225
- }, {
1226
- info: resolved.info
1227
- });
1183
+ }, { info: resolved.info });
1228
1184
  }
1229
1185
  async hideHighlight() {
1230
1186
  return this.raceAgainstEvaluationStallingEvents(async () => {
1231
1187
  const context = await this._utilityContext();
1232
1188
  const injectedScript = await context.injectedScript();
1233
- return await injectedScript.evaluate(injected => {
1189
+ return await injectedScript.evaluate((injected) => {
1234
1190
  return injected.hideHighlight();
1235
1191
  });
1236
1192
  });
@@ -1238,248 +1194,189 @@ class Frame extends _instrumentation.SdkObject {
1238
1194
  async _elementState(metadata, selector, state, options = {}, scope) {
1239
1195
  const result = await this._callOnElementOnceMatches(metadata, selector, (injected, element, data) => {
1240
1196
  return injected.elementState(element, data.state);
1241
- }, {
1242
- state
1243
- }, options, scope);
1244
- if (result.received === 'error:notconnected') dom.throwElementIsNotAttached();
1197
+ }, { state }, options, scope);
1198
+ if (result.received === "error:notconnected")
1199
+ dom.throwElementIsNotAttached();
1245
1200
  return result.matches;
1246
1201
  }
1247
1202
  async isVisible(metadata, selector, options = {}, scope) {
1248
- const controller = new _progress2.ProgressController(metadata, this);
1249
- return controller.run(async progress => {
1203
+ const controller = new import_progress.ProgressController(metadata, this);
1204
+ return controller.run(async (progress) => {
1250
1205
  progress.log(` checking visibility of ${this._asLocator(selector)}`);
1251
1206
  return await this.isVisibleInternal(selector, options, scope);
1252
1207
  }, this._page._timeoutSettings.timeout({}));
1253
1208
  }
1254
1209
  async isVisibleInternal(selector, options = {}, scope) {
1255
1210
  try {
1256
- const custom_metadata = {
1257
- "internal": false,
1258
- "log": []
1259
- };
1260
- const controller = new _progress2.ProgressController(custom_metadata, this);
1261
- return await controller.run(async progress => {
1211
+ const custom_metadata = { "internal": false, "log": [] };
1212
+ const controller = new import_progress.ProgressController(custom_metadata, this);
1213
+ return await controller.run(async (progress) => {
1262
1214
  progress.log("waiting for " + this._asLocator(selector));
1263
- const promise = this._retryWithProgressIfNotConnected(progress, selector, options.strict, false, async handle => {
1215
+ const promise = this._retryWithProgressIfNotConnected(progress, selector, options.strict, false, async (handle) => {
1264
1216
  if (handle.parentNode.constructor.name == "ElementHandle") {
1265
- return await handle.parentNode.evaluateInUtility(([injected, node, {
1266
- handle
1267
- }]) => {
1268
- const state = handle ? injected.elementState(handle, 'visible') : {
1217
+ return await handle.parentNode.evaluateInUtility(([injected, node, { handle: handle2 }]) => {
1218
+ const state = handle2 ? injected.elementState(handle2, "visible") : {
1269
1219
  matches: false,
1270
- received: 'error:notconnected'
1220
+ received: "error:notconnected"
1271
1221
  };
1272
1222
  return state.matches;
1273
- }, {
1274
- handle
1275
- });
1223
+ }, { handle });
1276
1224
  } else {
1277
- return await handle.parentNode.evaluate((injected, {
1278
- handle
1279
- }) => {
1280
- const state = handle ? injected.elementState(handle, 'visible') : {
1225
+ return await handle.parentNode.evaluate((injected, { handle: handle2 }) => {
1226
+ const state = handle2 ? injected.elementState(handle2, "visible") : {
1281
1227
  matches: false,
1282
- received: 'error:notconnected'
1228
+ received: "error:notconnected"
1283
1229
  };
1284
1230
  return state.matches;
1285
- }, {
1286
- handle
1287
- });
1231
+ }, { handle });
1288
1232
  }
1289
1233
  });
1290
1234
  return scope ? scope._context._raceAgainstContextDestroyed(promise) : promise;
1291
- }, 100); // A bit geeky but its okay :D
1235
+ }, 100);
1292
1236
  } catch (e) {
1293
- if (js.isJavaScriptErrorInEvaluate(e) || (0, _selectorParser.isInvalidSelectorError)(e) || (0, _protocolError.isSessionClosedError)(e)) throw e;
1237
+ if (js.isJavaScriptErrorInEvaluate(e) || (0, import_selectorParser.isInvalidSelectorError)(e) || (0, import_protocolError.isSessionClosedError)(e)) throw e;
1294
1238
  return false;
1295
1239
  }
1296
1240
  }
1297
1241
  async isHidden(metadata, selector, options = {}, scope) {
1298
- return !(await this.isVisible(metadata, selector, options, scope));
1242
+ return !await this.isVisible(metadata, selector, options, scope);
1299
1243
  }
1300
1244
  async isDisabled(metadata, selector, options = {}, scope) {
1301
- return this._elementState(metadata, selector, 'disabled', options, scope);
1245
+ return this._elementState(metadata, selector, "disabled", options, scope);
1302
1246
  }
1303
1247
  async isEnabled(metadata, selector, options = {}, scope) {
1304
- return this._elementState(metadata, selector, 'enabled', options, scope);
1248
+ return this._elementState(metadata, selector, "enabled", options, scope);
1305
1249
  }
1306
1250
  async isEditable(metadata, selector, options = {}, scope) {
1307
- return this._elementState(metadata, selector, 'editable', options, scope);
1251
+ return this._elementState(metadata, selector, "editable", options, scope);
1308
1252
  }
1309
1253
  async isChecked(metadata, selector, options = {}, scope) {
1310
- return this._elementState(metadata, selector, 'checked', options, scope);
1254
+ return this._elementState(metadata, selector, "checked", options, scope);
1311
1255
  }
1312
1256
  async hover(metadata, selector, options = {}) {
1313
- const controller = new _progress2.ProgressController(metadata, this);
1314
- return controller.run(async progress => {
1315
- return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /* performActionPreChecks */, handle => handle._hover(progress, options)));
1257
+ const controller = new import_progress.ProgressController(metadata, this);
1258
+ return controller.run(async (progress) => {
1259
+ return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._hover(progress, options)));
1316
1260
  }, this._page._timeoutSettings.timeout(options));
1317
1261
  }
1318
1262
  async selectOption(metadata, selector, elements, values, options = {}) {
1319
- const controller = new _progress2.ProgressController(metadata, this);
1320
- return controller.run(async progress => {
1321
- return await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /* performActionPreChecks */, handle => handle._selectOption(progress, elements, values, options));
1263
+ const controller = new import_progress.ProgressController(metadata, this);
1264
+ return controller.run(async (progress) => {
1265
+ return await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._selectOption(progress, elements, values, options));
1322
1266
  }, this._page._timeoutSettings.timeout(options));
1323
1267
  }
1324
1268
  async setInputFiles(metadata, selector, params) {
1325
- const inputFileItems = await (0, _fileUploadUtils.prepareFilesForUpload)(this, params);
1326
- const controller = new _progress2.ProgressController(metadata, this);
1327
- return controller.run(async progress => {
1328
- return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, params.strict, true /* performActionPreChecks */, handle => handle._setInputFiles(progress, inputFileItems)));
1269
+ const inputFileItems = await (0, import_fileUploadUtils.prepareFilesForUpload)(this, params);
1270
+ const controller = new import_progress.ProgressController(metadata, this);
1271
+ return controller.run(async (progress) => {
1272
+ return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, params.strict, true, (handle) => handle._setInputFiles(progress, inputFileItems)));
1329
1273
  }, this._page._timeoutSettings.timeout(params));
1330
1274
  }
1331
1275
  async type(metadata, selector, text, options = {}) {
1332
- const controller = new _progress2.ProgressController(metadata, this);
1333
- return controller.run(async progress => {
1334
- return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true /* performActionPreChecks */, handle => handle._type(progress, text, options)));
1276
+ const controller = new import_progress.ProgressController(metadata, this);
1277
+ return controller.run(async (progress) => {
1278
+ return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true, (handle) => handle._type(progress, text, options)));
1335
1279
  }, this._page._timeoutSettings.timeout(options));
1336
1280
  }
1337
1281
  async press(metadata, selector, key, options = {}) {
1338
- const controller = new _progress2.ProgressController(metadata, this);
1339
- return controller.run(async progress => {
1340
- return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true /* performActionPreChecks */, handle => handle._press(progress, key, options)));
1282
+ const controller = new import_progress.ProgressController(metadata, this);
1283
+ return controller.run(async (progress) => {
1284
+ return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true, (handle) => handle._press(progress, key, options)));
1341
1285
  }, this._page._timeoutSettings.timeout(options));
1342
1286
  }
1343
1287
  async check(metadata, selector, options = {}) {
1344
- const controller = new _progress2.ProgressController(metadata, this);
1345
- return controller.run(async progress => {
1346
- return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /* performActionPreChecks */, handle => handle._setChecked(progress, true, options)));
1288
+ const controller = new import_progress.ProgressController(metadata, this);
1289
+ return controller.run(async (progress) => {
1290
+ return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._setChecked(progress, true, options)));
1347
1291
  }, this._page._timeoutSettings.timeout(options));
1348
1292
  }
1349
1293
  async uncheck(metadata, selector, options = {}) {
1350
- const controller = new _progress2.ProgressController(metadata, this);
1351
- return controller.run(async progress => {
1352
- return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /* performActionPreChecks */, handle => handle._setChecked(progress, false, options)));
1294
+ const controller = new import_progress.ProgressController(metadata, this);
1295
+ return controller.run(async (progress) => {
1296
+ return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force, (handle) => handle._setChecked(progress, false, options)));
1353
1297
  }, this._page._timeoutSettings.timeout(options));
1354
1298
  }
1355
1299
  async waitForTimeout(metadata, timeout) {
1356
- const controller = new _progress2.ProgressController(metadata, this);
1300
+ const controller = new import_progress.ProgressController(metadata, this);
1357
1301
  return controller.run(async () => {
1358
- await new Promise(resolve => setTimeout(resolve, timeout));
1302
+ await new Promise((resolve) => setTimeout(resolve, timeout));
1359
1303
  });
1360
1304
  }
1361
1305
  async ariaSnapshot(metadata, selector, options = {}) {
1362
- const controller = new _progress2.ProgressController(metadata, this);
1363
- return controller.run(async progress => {
1364
- return await this._retryWithProgressIfNotConnected(progress, selector, true /* strict */, true /* performActionPreChecks */, handle => handle.ariaSnapshot(options));
1306
+ const controller = new import_progress.ProgressController(metadata, this);
1307
+ return controller.run(async (progress) => {
1308
+ return await this._retryWithProgressIfNotConnected(progress, selector, true, true, (handle) => handle.ariaSnapshot(options));
1365
1309
  }, this._page._timeoutSettings.timeout(options));
1366
1310
  }
1367
1311
  async expect(metadata, selector, options) {
1368
1312
  const result = await this._expectImpl(metadata, selector, options);
1369
- // Library mode special case for the expect errors which are return values, not exceptions.
1370
- if (result.matches === options.isNot) metadata.error = {
1371
- error: {
1372
- name: 'Expect',
1373
- message: 'Expect failed'
1374
- }
1375
- };
1313
+ if (result.matches === options.isNot)
1314
+ metadata.error = { error: { name: "Expect", message: "Expect failed" } };
1376
1315
  return result;
1377
1316
  }
1378
1317
  async _expectImpl(metadata, selector, options) {
1379
- const lastIntermediateResult = {
1380
- isSet: false
1381
- };
1318
+ const lastIntermediateResult = { isSet: false };
1382
1319
  try {
1383
1320
  let timeout = this._page._timeoutSettings.timeout(options);
1384
- const start = timeout > 0 ? (0, _utils.monotonicTime)() : 0;
1385
-
1386
- // Step 1: perform locator handlers checkpoint with a specified timeout.
1387
- await new _progress2.ProgressController(metadata, this).run(async progress => {
1388
- progress.log(`${metadata.apiName}${timeout ? ` with timeout ${timeout}ms` : ''}`);
1321
+ const start = timeout > 0 ? (0, import_utils.monotonicTime)() : 0;
1322
+ await new import_progress.ProgressController(metadata, this).run(async (progress) => {
1323
+ progress.log(`${metadata.apiName}${timeout ? ` with timeout ${timeout}ms` : ""}`);
1389
1324
  progress.log(`waiting for ${this._asLocator(selector)}`);
1390
1325
  await this._page.performActionPreChecks(progress);
1391
1326
  }, timeout);
1392
-
1393
- // Step 2: perform one-shot expect check without a timeout.
1394
- // Supports the case of `expect(locator).toBeVisible({ timeout: 1 })`
1395
- // that should succeed when the locator is already visible.
1396
1327
  try {
1397
- const resultOneShot = await new _progress2.ProgressController(metadata, this).run(async progress => {
1328
+ const resultOneShot = await new import_progress.ProgressController(metadata, this).run(async (progress) => {
1398
1329
  return await this._expectInternal(progress, selector, options, lastIntermediateResult);
1399
1330
  });
1400
- if (resultOneShot.matches !== options.isNot) return resultOneShot;
1331
+ if (resultOneShot.matches !== options.isNot)
1332
+ return resultOneShot;
1401
1333
  } catch (e) {
1402
- if (js.isJavaScriptErrorInEvaluate(e) || (0, _selectorParser.isInvalidSelectorError)(e)) throw e;
1403
- // Ignore any other errors from one-shot, we'll handle them during retries.
1334
+ if (js.isJavaScriptErrorInEvaluate(e) || (0, import_selectorParser.isInvalidSelectorError)(e))
1335
+ throw e;
1404
1336
  }
1405
1337
  if (timeout > 0) {
1406
- const elapsed = (0, _utils.monotonicTime)() - start;
1338
+ const elapsed = (0, import_utils.monotonicTime)() - start;
1407
1339
  timeout -= elapsed;
1408
1340
  }
1409
- if (timeout < 0) return {
1410
- matches: options.isNot,
1411
- log: (0, _callLog.compressCallLog)(metadata.log),
1412
- timedOut: true,
1413
- received: lastIntermediateResult.received
1414
- };
1415
-
1416
- // Step 3: auto-retry expect with increasing timeouts. Bounded by the total remaining time.
1417
- return await new _progress2.ProgressController(metadata, this).run(async progress => {
1418
- return await this.retryWithProgressAndTimeouts(progress, [100, 250, 500, 1000], async continuePolling => {
1341
+ if (timeout < 0)
1342
+ return { matches: options.isNot, log: (0, import_callLog.compressCallLog)(metadata.log), timedOut: true, received: lastIntermediateResult.received };
1343
+ return await new import_progress.ProgressController(metadata, this).run(async (progress) => {
1344
+ return await this.retryWithProgressAndTimeouts(progress, [100, 250, 500, 1e3], async (continuePolling2) => {
1419
1345
  await this._page.performActionPreChecks(progress);
1420
- const {
1421
- matches,
1422
- received
1423
- } = await this._expectInternal(progress, selector, options, lastIntermediateResult);
1346
+ const { matches, received } = await this._expectInternal(progress, selector, options, lastIntermediateResult);
1424
1347
  if (matches === options.isNot) {
1425
- // Keep waiting in these cases:
1426
- // expect(locator).conditionThatDoesNotMatch
1427
- // expect(locator).not.conditionThatDoesMatch
1428
- return continuePolling;
1348
+ return continuePolling2;
1429
1349
  }
1430
- return {
1431
- matches,
1432
- received
1433
- };
1350
+ return { matches, received };
1434
1351
  });
1435
1352
  }, timeout);
1436
1353
  } catch (e) {
1437
- // Q: Why not throw upon isSessionClosedError(e) as in other places?
1438
- // A: We want user to receive a friendly message containing the last intermediate result.
1439
- if (js.isJavaScriptErrorInEvaluate(e) || (0, _selectorParser.isInvalidSelectorError)(e)) throw e;
1440
- const result = {
1441
- matches: options.isNot,
1442
- log: (0, _callLog.compressCallLog)(metadata.log)
1443
- };
1444
- if (lastIntermediateResult.isSet) result.received = lastIntermediateResult.received;
1445
- if (e instanceof _errors.TimeoutError) result.timedOut = true;
1354
+ if (js.isJavaScriptErrorInEvaluate(e) || (0, import_selectorParser.isInvalidSelectorError)(e))
1355
+ throw e;
1356
+ const result = { matches: options.isNot, log: (0, import_callLog.compressCallLog)(metadata.log) };
1357
+ if (lastIntermediateResult.isSet)
1358
+ result.received = lastIntermediateResult.received;
1359
+ if (e instanceof import_errors.TimeoutError)
1360
+ result.timedOut = true;
1446
1361
  return result;
1447
1362
  }
1448
1363
  }
1449
1364
  async _expectInternal(progress, selector, options, lastIntermediateResult) {
1450
1365
  progress.log("waiting for " + this._asLocator(selector));
1451
- const isArray = options.expression === 'to.have.count' || options.expression.endsWith('.array');
1452
- const promise = await this._retryWithProgressIfNotConnected(progress, selector, !isArray, false, async result => {
1366
+ const isArray = options.expression === "to.have.count" || options.expression.endsWith(".array");
1367
+ const promise = await this._retryWithProgressIfNotConnected(progress, selector, !isArray, false, async (result) => {
1453
1368
  const handle = result[0];
1454
1369
  const handles = result[1];
1455
1370
  if (handle.parentNode.constructor.name == "ElementHandle") {
1456
- return await handle.parentNode.evaluateInUtility(async ([injected, node, {
1457
- handle,
1458
- options,
1459
- handles
1460
- }]) => {
1461
- return await injected.expect(handle, options, handles);
1462
- }, {
1463
- handle,
1464
- options,
1465
- handles
1466
- });
1371
+ return await handle.parentNode.evaluateInUtility(async ([injected, node, { handle: handle2, options: options2, handles: handles2 }]) => {
1372
+ return await injected.expect(handle2, options2, handles2);
1373
+ }, { handle, options, handles });
1467
1374
  } else {
1468
- return await handle.parentNode.evaluate(async (injected, {
1469
- handle,
1470
- options,
1471
- handles
1472
- }) => {
1473
- return await injected.expect(handle, options, handles);
1474
- }, {
1475
- handle,
1476
- options,
1477
- handles
1478
- });
1375
+ return await handle.parentNode.evaluate(async (injected, { handle: handle2, options: options2, handles: handles2 }) => {
1376
+ return await injected.expect(handle2, options2, handles2);
1377
+ }, { handle, options, handles });
1479
1378
  }
1480
- }, 'returnAll');
1481
-
1482
- // Default Values, if no Elements found
1379
+ }, "returnAll");
1483
1380
  var matches = false;
1484
1381
  var received = 0;
1485
1382
  var missingReceived = null;
@@ -1490,10 +1387,8 @@ class Frame extends _instrumentation.SdkObject {
1490
1387
  } else if (options.expectedNumber === 0) {
1491
1388
  matches = true;
1492
1389
  }
1493
-
1494
- // Note: missingReceived avoids unexpected value "undefined" when element was not found.
1495
1390
  if (matches === options.isNot) {
1496
- lastIntermediateResult.received = missingReceived ? '<element(s) not found>' : received;
1391
+ lastIntermediateResult.received = missingReceived ? "<element(s) not found>" : received;
1497
1392
  lastIntermediateResult.isSet = true;
1498
1393
  if (!missingReceived && !Array.isArray(received)) progress.log(' unexpected value "' + renderUnexpectedValue(options.expression, received) + '"');
1499
1394
  }
@@ -1502,34 +1397,27 @@ class Frame extends _instrumentation.SdkObject {
1502
1397
  received
1503
1398
  };
1504
1399
  }
1505
- async _waitForFunctionExpression(metadata, expression, isFunction, arg, options, world = 'main') {
1506
- const controller = new _progress2.ProgressController(metadata, this);
1507
- if (typeof options.pollingInterval === 'number') (0, _utils.assert)(options.pollingInterval > 0, 'Cannot poll with non-positive interval: ' + options.pollingInterval);
1400
+ async _waitForFunctionExpression(metadata, expression, isFunction, arg, options, world = "main") {
1401
+ const controller = new import_progress.ProgressController(metadata, this);
1402
+ if (typeof options.pollingInterval === "number")
1403
+ (0, import_utils.assert)(options.pollingInterval > 0, "Cannot poll with non-positive interval: " + options.pollingInterval);
1508
1404
  expression = js.normalizeEvaluationExpression(expression, isFunction);
1509
- return controller.run(async progress => {
1405
+ return controller.run(async (progress) => {
1510
1406
  return this.retryWithProgressAndTimeouts(progress, [100], async () => {
1511
- const context = world === 'main' ? await this._mainContext() : await this._utilityContext();
1407
+ const context = world === "main" ? await this._mainContext() : await this._utilityContext();
1512
1408
  const injectedScript = await context.injectedScript();
1513
- const handle = await injectedScript.evaluateHandle((injected, {
1514
- expression,
1515
- isFunction,
1516
- polling,
1517
- arg
1518
- }) => {
1409
+ const handle = await injectedScript.evaluateHandle((injected, { expression: expression2, isFunction: isFunction2, polling, arg: arg2 }) => {
1519
1410
  const predicate = () => {
1520
- // NOTE: make sure to use `globalThis.eval` instead of `self.eval` due to a bug with sandbox isolation
1521
- // in firefox.
1522
- // See https://bugzilla.mozilla.org/show_bug.cgi?id=1814898
1523
- let result = globalThis.eval(expression);
1524
- if (isFunction === true) {
1525
- result = result(arg);
1526
- } else if (isFunction === false) {
1527
- result = result;
1411
+ let result2 = globalThis.eval(expression2);
1412
+ if (isFunction2 === true) {
1413
+ result2 = result2(arg2);
1414
+ } else if (isFunction2 === false) {
1415
+ result2 = result2;
1528
1416
  } else {
1529
- // auto detect.
1530
- if (typeof result === 'function') result = result(arg);
1417
+ if (typeof result2 === "function")
1418
+ result2 = result2(arg2);
1531
1419
  }
1532
- return result;
1420
+ return result2;
1533
1421
  };
1534
1422
  let fulfill;
1535
1423
  let reject;
@@ -1539,31 +1427,28 @@ class Frame extends _instrumentation.SdkObject {
1539
1427
  reject = r;
1540
1428
  });
1541
1429
  const next = () => {
1542
- if (aborted) return;
1430
+ if (aborted)
1431
+ return;
1543
1432
  try {
1544
1433
  const success = predicate();
1545
1434
  if (success) {
1546
1435
  fulfill(success);
1547
1436
  return;
1548
1437
  }
1549
- if (typeof polling !== 'number') injected.builtinRequestAnimationFrame(next);else injected.builtinSetTimeout(next, polling);
1438
+ if (typeof polling !== "number")
1439
+ injected.utils.builtins.requestAnimationFrame(next);
1440
+ else
1441
+ injected.utils.builtins.setTimeout(next, polling);
1550
1442
  } catch (e) {
1551
1443
  reject(e);
1552
1444
  }
1553
1445
  };
1554
1446
  next();
1555
- return {
1556
- result,
1557
- abort: () => aborted = true
1558
- };
1559
- }, {
1560
- expression,
1561
- isFunction,
1562
- polling: options.pollingInterval,
1563
- arg
1564
- });
1565
- progress.cleanupWhenAborted(() => handle.evaluate(h => h.abort()).catch(() => {}));
1566
- return handle.evaluateHandle(h => h.result);
1447
+ return { result, abort: () => aborted = true };
1448
+ }, { expression, isFunction, polling: options.pollingInterval, arg });
1449
+ progress.cleanupWhenAborted(() => handle.evaluate((h) => h.abort()).catch(() => {
1450
+ }));
1451
+ return handle.evaluateHandle((h) => h.result);
1567
1452
  });
1568
1453
  }, this._page._timeoutSettings.timeout(options));
1569
1454
  }
@@ -1574,9 +1459,7 @@ class Frame extends _instrumentation.SdkObject {
1574
1459
  return result;
1575
1460
  return JSON.stringify(result);
1576
1461
  }`;
1577
- const handle = await this._waitForFunctionExpression((0, _instrumentation.serverSideCallMetadata)(), expression, true, undefined, {
1578
- timeout: progress.timeUntilDeadline()
1579
- }, 'utility');
1462
+ const handle = await this._waitForFunctionExpression((0, import_instrumentation.serverSideCallMetadata)(), expression, true, void 0, { timeout: progress.timeUntilDeadline() }, "utility");
1580
1463
  return JSON.parse(handle.rawValue());
1581
1464
  }
1582
1465
  async title() {
@@ -1584,55 +1467,50 @@ class Frame extends _instrumentation.SdkObject {
1584
1467
  return context.evaluate(() => document.title);
1585
1468
  }
1586
1469
  async rafrafTimeout(timeout) {
1587
- if (timeout === 0) return;
1470
+ if (timeout === 0)
1471
+ return;
1588
1472
  const context = await this._utilityContext();
1589
1473
  await Promise.all([
1590
- // wait for double raf
1591
- context.evaluate(() => new Promise(x => {
1592
- requestAnimationFrame(() => {
1593
- requestAnimationFrame(x);
1594
- });
1595
- })), new Promise(fulfill => setTimeout(fulfill, timeout))]);
1474
+ // wait for double raf
1475
+ context.evaluate(() => new Promise((x) => {
1476
+ requestAnimationFrame(() => {
1477
+ requestAnimationFrame(x);
1478
+ });
1479
+ })),
1480
+ new Promise((fulfill) => setTimeout(fulfill, timeout))
1481
+ ]);
1596
1482
  }
1597
1483
  _onDetached() {
1598
1484
  this._stopNetworkIdleTimer();
1599
- this._detachedScope.close(new Error('Frame was detached'));
1485
+ this._detachedScope.close(new Error("Frame was detached"));
1600
1486
  for (const data of this._contextData.values()) {
1601
- if (data.context) data.context.contextDestroyed('Frame was detached');
1602
- data.contextPromise.resolve({
1603
- destroyedReason: 'Frame was detached'
1604
- });
1487
+ if (data.context)
1488
+ data.context.contextDestroyed("Frame was detached");
1489
+ data.contextPromise.resolve({ destroyedReason: "Frame was detached" });
1605
1490
  }
1606
- if (this._parentFrame) this._parentFrame._childFrames.delete(this);
1491
+ if (this._parentFrame)
1492
+ this._parentFrame._childFrames.delete(this);
1607
1493
  this._parentFrame = null;
1608
1494
  }
1609
1495
  async _callOnElementOnceMatches(metadata, selector, body, taskData, options = {}, scope) {
1610
1496
  const callbackText = body.toString();
1611
- const controller = new _progress2.ProgressController(metadata, this);
1612
- return controller.run(async progress => {
1497
+ const controller = new import_progress.ProgressController(metadata, this);
1498
+ return controller.run(async (progress) => {
1613
1499
  progress.log("waiting for " + this._asLocator(selector));
1614
- const promise = this._retryWithProgressIfNotConnected(progress, selector, false, false, async handle => {
1500
+ const promise = this._retryWithProgressIfNotConnected(progress, selector, false, false, async (handle) => {
1615
1501
  if (handle.parentNode.constructor.name == "ElementHandle") {
1616
- return await handle.parentNode.evaluateInUtility(([injected, node, {
1617
- callbackText,
1618
- handle,
1619
- taskData
1620
- }]) => {
1621
- const callback = injected.eval(callbackText);
1622
- return callback(injected, handle, taskData);
1502
+ return await handle.parentNode.evaluateInUtility(([injected, node, { callbackText: callbackText2, handle: handle2, taskData: taskData2 }]) => {
1503
+ const callback = injected.eval(callbackText2);
1504
+ return callback(injected, handle2, taskData2);
1623
1505
  }, {
1624
1506
  callbackText,
1625
1507
  handle,
1626
1508
  taskData
1627
1509
  });
1628
1510
  } else {
1629
- return await handle.parentNode.evaluate((injected, {
1630
- callbackText,
1631
- handle,
1632
- taskData
1633
- }) => {
1634
- const callback = injected.eval(callbackText);
1635
- return callback(injected, handle, taskData);
1511
+ return await handle.parentNode.evaluate((injected, { callbackText: callbackText2, handle: handle2, taskData: taskData2 }) => {
1512
+ const callback = injected.eval(callbackText2);
1513
+ return callback(injected, handle2, taskData2);
1636
1514
  }, {
1637
1515
  callbackText,
1638
1516
  handle,
@@ -1646,98 +1524,79 @@ class Frame extends _instrumentation.SdkObject {
1646
1524
  _setContext(world, context) {
1647
1525
  const data = this._contextData.get(world);
1648
1526
  data.context = context;
1649
- if (context) data.contextPromise.resolve(context);else data.contextPromise = new _manualPromise.ManualPromise();
1527
+ if (context)
1528
+ data.contextPromise.resolve(context);
1529
+ else
1530
+ data.contextPromise = new import_manualPromise.ManualPromise();
1650
1531
  }
1651
1532
  _contextCreated(world, context) {
1652
1533
  const data = this._contextData.get(world);
1653
- // In case of multiple sessions to the same target, there's a race between
1654
- // connections so we might end up creating multiple isolated worlds.
1655
- // We can use either.
1656
1534
  if (data.context) {
1657
- data.context.contextDestroyed('Execution context was destroyed, most likely because of a navigation');
1535
+ data.context.contextDestroyed("Execution context was destroyed, most likely because of a navigation");
1658
1536
  this._setContext(world, null);
1659
1537
  }
1660
1538
  this._setContext(world, context);
1661
1539
  }
1662
1540
  _contextDestroyed(context) {
1663
- // Sometimes we get this after detach, in which case we should not reset
1664
- // our already destroyed contexts to something that will never resolve.
1665
- if (this._detachedScope.isClosed()) return;
1666
- context.contextDestroyed('Execution context was destroyed, most likely because of a navigation');
1541
+ if (this._detachedScope.isClosed())
1542
+ return;
1543
+ context.contextDestroyed("Execution context was destroyed, most likely because of a navigation");
1667
1544
  for (const [world, data] of this._contextData) {
1668
- if (data.context === context) this._setContext(world, null);
1545
+ if (data.context === context)
1546
+ this._setContext(world, null);
1669
1547
  }
1670
1548
  }
1671
1549
  _startNetworkIdleTimer() {
1672
- (0, _utils.assert)(!this._networkIdleTimer);
1673
- // We should not start a timer and report networkidle in detached frames.
1674
- // This happens at least in Firefox for child frames, where we may get requestFinished
1675
- // after the frame was detached - probably a race in the Firefox itself.
1676
- if (this._firedLifecycleEvents.has('networkidle') || this._detachedScope.isClosed()) return;
1550
+ (0, import_utils.assert)(!this._networkIdleTimer);
1551
+ if (this._firedLifecycleEvents.has("networkidle") || this._detachedScope.isClosed())
1552
+ return;
1677
1553
  this._networkIdleTimer = setTimeout(() => {
1678
1554
  this._firedNetworkIdleSelf = true;
1679
1555
  this._page.mainFrame()._recalculateNetworkIdle();
1680
1556
  }, 500);
1681
1557
  }
1682
1558
  _stopNetworkIdleTimer() {
1683
- if (this._networkIdleTimer) clearTimeout(this._networkIdleTimer);
1684
- this._networkIdleTimer = undefined;
1559
+ if (this._networkIdleTimer)
1560
+ clearTimeout(this._networkIdleTimer);
1561
+ this._networkIdleTimer = void 0;
1685
1562
  this._firedNetworkIdleSelf = false;
1686
1563
  }
1687
1564
  async extendInjectedScript(source, arg) {
1688
- const context = await this._context('main');
1565
+ const context = await this._context("main");
1689
1566
  const injectedScriptHandle = await context.injectedScript();
1690
- return injectedScriptHandle.evaluateHandle((injectedScript, {
1691
- source,
1692
- arg
1693
- }) => {
1694
- return injectedScript.extend(source, arg);
1695
- }, {
1696
- source,
1697
- arg
1698
- });
1567
+ return injectedScriptHandle.evaluateHandle((injectedScript, { source: source2, arg: arg2 }) => {
1568
+ return injectedScript.extend(source2, arg2);
1569
+ }, { source, arg });
1699
1570
  }
1700
1571
  async resetStorageForCurrentOriginBestEffort(newStorage) {
1701
1572
  const context = await this._utilityContext();
1702
- await context.evaluate(async ({
1703
- ls
1704
- }) => {
1705
- // Clean DOMStorage.
1573
+ await context.evaluate(async ({ ls }) => {
1706
1574
  sessionStorage.clear();
1707
1575
  localStorage.clear();
1708
-
1709
- // Add new DOM Storage values.
1710
- for (const entry of ls || []) localStorage[entry.name] = entry.value;
1711
-
1712
- // Clean Service Workers
1576
+ for (const entry of ls || [])
1577
+ localStorage[entry.name] = entry.value;
1713
1578
  const registrations = navigator.serviceWorker ? await navigator.serviceWorker.getRegistrations() : [];
1714
- await Promise.all(registrations.map(async r => {
1715
- // Heuristic for service workers that stalled during main script fetch or importScripts:
1716
- // Waiting for them to finish unregistering takes ages so we do not await.
1717
- // However, they will unregister immediately after fetch finishes and should not affect next page load.
1718
- // Unfortunately, loading next page in Chromium still takes 5 seconds waiting for
1719
- // some operation on this bogus service worker to finish.
1720
- if (!r.installing && !r.waiting && !r.active) r.unregister().catch(() => {});else await r.unregister().catch(() => {});
1579
+ await Promise.all(registrations.map(async (r) => {
1580
+ if (!r.installing && !r.waiting && !r.active)
1581
+ r.unregister().catch(() => {
1582
+ });
1583
+ else
1584
+ await r.unregister().catch(() => {
1585
+ });
1721
1586
  }));
1722
-
1723
- // Clean IndexedDB
1724
- for (const db of (await ((_indexedDB$databases = (_indexedDB = indexedDB).databases) === null || _indexedDB$databases === void 0 ? void 0 : _indexedDB$databases.call(_indexedDB))) || []) {
1725
- var _indexedDB$databases, _indexedDB;
1726
- // Do not wait for the callback - it is called on timer in Chromium (slow).
1727
- if (db.name) indexedDB.deleteDatabase(db.name);
1587
+ for (const db of await indexedDB.databases?.() || []) {
1588
+ if (db.name)
1589
+ indexedDB.deleteDatabase(db.name);
1728
1590
  }
1729
- }, {
1730
- ls: newStorage === null || newStorage === void 0 ? void 0 : newStorage.localStorage
1731
- }).catch(() => {});
1591
+ }, { ls: newStorage?.localStorage }).catch(() => {
1592
+ });
1732
1593
  }
1733
1594
  _asLocator(selector) {
1734
- return (0, _utils.asLocator)(this._page.attribution.playwright.options.sdkLanguage, selector);
1595
+ return (0, import_utils.asLocator)(this._page.attribution.playwright.options.sdkLanguage, selector);
1735
1596
  }
1736
1597
  async _getFrameMainFrameContextId(client) {
1737
1598
  try {
1738
- var globalDocument = await client._sendMayFail("DOM.getFrameOwner", {
1739
- frameId: this._id
1740
- });
1599
+ var globalDocument = await client._sendMayFail("DOM.getFrameOwner", { frameId: this._id });
1741
1600
  if (globalDocument && globalDocument.nodeId) {
1742
1601
  var describedNode = await client._sendMayFail("DOM.describeNode", {
1743
1602
  backendNodeId: globalDocument.backendNodeId
@@ -1750,20 +1609,17 @@ class Frame extends _instrumentation.SdkObject {
1750
1609
  return _executionContextId;
1751
1610
  }
1752
1611
  }
1753
- } catch (e) {}
1612
+ } catch (e) {
1613
+ }
1754
1614
  return 0;
1755
1615
  }
1756
1616
  async _customFindElementsByParsed(resolved, client, context, documentScope, progress, parsed) {
1757
- var parsedEdits = {
1758
- ...parsed
1759
- };
1760
- // Note: We start scoping at document level
1617
+ var parsedEdits = { ...parsed };
1761
1618
  var currentScopingElements = [documentScope];
1762
1619
  while (parsed.parts.length > 0) {
1763
1620
  var part = parsed.parts.shift();
1764
1621
  parsedEdits.parts = [part];
1765
1622
  var isUsingXPath = false;
1766
- // Getting All Elements
1767
1623
  var elements = [];
1768
1624
  var elementsIndexes = [];
1769
1625
  if (part.name == "xpath") {
@@ -1782,53 +1638,49 @@ class Frame extends _instrumentation.SdkObject {
1782
1638
  elements = currentScopingElements.concat(orredElements);
1783
1639
  } else if (part.name == "internal:and") {
1784
1640
  var andedElements = await this._customFindElementsByParsed(resolved, client, context, documentScope, progress, part.body.parsed);
1785
- const backendNodeIds = new Set(andedElements.map(item => item.backendNodeId));
1786
- elements = currentScopingElements.filter(item => backendNodeIds.has(item.backendNodeId));
1641
+ const backendNodeIds = new Set(andedElements.map((item) => item.backendNodeId));
1642
+ elements = currentScopingElements.filter((item) => backendNodeIds.has(item.backendNodeId));
1787
1643
  } else {
1788
1644
  for (const scope of currentScopingElements) {
1789
- const describedScope = await client.send('DOM.describeNode', {
1645
+ const describedScope = await client.send("DOM.describeNode", {
1790
1646
  objectId: scope._objectId,
1791
1647
  depth: -1,
1792
1648
  pierce: true
1793
1649
  });
1794
-
1795
- // Elements Queryed in the "current round"
1796
1650
  var queryingElements = [];
1797
1651
  if (!isUsingXPath) {
1798
- function findClosedShadowRoots(node, results = []) {
1799
- if (!node || typeof node !== 'object') return results;
1652
+ let findClosedShadowRoots2 = function(node, results = []) {
1653
+ if (!node || typeof node !== "object") return results;
1800
1654
  if (node.shadowRoots && Array.isArray(node.shadowRoots)) {
1801
- for (const shadowRoot of node.shadowRoots) {
1802
- if (shadowRoot.shadowRootType === 'closed' && shadowRoot.backendNodeId) {
1803
- results.push(shadowRoot.backendNodeId);
1655
+ for (const shadowRoot2 of node.shadowRoots) {
1656
+ if (shadowRoot2.shadowRootType === "closed" && shadowRoot2.backendNodeId) {
1657
+ results.push(shadowRoot2.backendNodeId);
1804
1658
  }
1805
- findClosedShadowRoots(shadowRoot, results);
1659
+ findClosedShadowRoots2(shadowRoot2, results);
1806
1660
  }
1807
1661
  }
1808
- if (node.nodeName !== 'IFRAME' && node.children && Array.isArray(node.children)) {
1662
+ if (node.nodeName !== "IFRAME" && node.children && Array.isArray(node.children)) {
1809
1663
  for (const child of node.children) {
1810
- findClosedShadowRoots(child, results);
1664
+ findClosedShadowRoots2(child, results);
1811
1665
  }
1812
1666
  }
1813
1667
  return results;
1814
- }
1815
- var shadowRootBackendIds = findClosedShadowRoots(describedScope.node);
1668
+ };
1669
+ var findClosedShadowRoots = findClosedShadowRoots2;
1670
+ var shadowRootBackendIds = findClosedShadowRoots2(describedScope.node);
1816
1671
  var shadowRoots = [];
1817
1672
  for (var shadowRootBackendId of shadowRootBackendIds) {
1818
- var resolvedShadowRoot = await client.send('DOM.resolveNode', {
1673
+ var resolvedShadowRoot = await client.send("DOM.resolveNode", {
1819
1674
  backendNodeId: shadowRootBackendId,
1820
1675
  contextId: context.delegate._contextId
1821
1676
  });
1822
1677
  shadowRoots.push(new dom.ElementHandle(context, resolvedShadowRoot.object.objectId));
1823
1678
  }
1824
1679
  for (var shadowRoot of shadowRoots) {
1825
- const shadowElements = await shadowRoot.evaluateHandleInUtility(([injected, node, {
1826
- parsed,
1827
- callId
1828
- }]) => {
1829
- const elements = injected.querySelectorAll(parsed, node);
1830
- if (callId) injected.markTargetElements(new Set(elements), callId);
1831
- return elements;
1680
+ const shadowElements = await shadowRoot.evaluateHandleInUtility(([injected, node, { parsed: parsed2, callId }]) => {
1681
+ const elements2 = injected.querySelectorAll(parsed2, node);
1682
+ if (callId) injected.markTargetElements(new Set(elements2), callId);
1683
+ return elements2;
1832
1684
  }, {
1833
1685
  parsed: parsedEdits,
1834
1686
  callId: progress.metadata.id
@@ -1837,70 +1689,45 @@ class Frame extends _instrumentation.SdkObject {
1837
1689
  queryingElements.push([shadowElements, shadowElementsAmount, shadowRoot]);
1838
1690
  }
1839
1691
  }
1840
-
1841
- // Document Root Elements (not in CSR)
1842
- const rootElements = await scope.evaluateHandleInUtility(([injected, node, {
1843
- parsed,
1844
- callId
1845
- }]) => {
1846
- const elements = injected.querySelectorAll(parsed, node);
1847
- if (callId) injected.markTargetElements(new Set(elements), callId);
1848
- return elements;
1692
+ const rootElements = await scope.evaluateHandleInUtility(([injected, node, { parsed: parsed2, callId }]) => {
1693
+ const elements2 = injected.querySelectorAll(parsed2, node);
1694
+ if (callId) injected.markTargetElements(new Set(elements2), callId);
1695
+ return elements2;
1849
1696
  }, {
1850
1697
  parsed: parsedEdits,
1851
1698
  callId: progress.metadata.id
1852
1699
  });
1853
1700
  const rootElementsAmount = await rootElements.getProperty("length");
1854
1701
  queryingElements.push([rootElements, rootElementsAmount, resolved.injected]);
1855
-
1856
- // Querying and Sorting the elements by their backendNodeId
1857
1702
  for (var queryedElement of queryingElements) {
1858
1703
  var elementsToCheck = queryedElement[0];
1859
1704
  var elementsAmount = await queryedElement[1].jsonValue();
1860
1705
  var parentNode = queryedElement[2];
1861
1706
  for (var i = 0; i < elementsAmount; i++) {
1862
1707
  if (parentNode.constructor.name == "ElementHandle") {
1863
- var elementToCheck = await parentNode.evaluateHandleInUtility(([injected, node, {
1864
- index,
1865
- elementsToCheck
1866
- }]) => {
1867
- return elementsToCheck[index];
1868
- }, {
1869
- index: i,
1870
- elementsToCheck: elementsToCheck
1871
- });
1708
+ var elementToCheck = await parentNode.evaluateHandleInUtility(([injected, node, { index, elementsToCheck: elementsToCheck2 }]) => {
1709
+ return elementsToCheck2[index];
1710
+ }, { index: i, elementsToCheck });
1872
1711
  } else {
1873
- var elementToCheck = await parentNode.evaluateHandle((injected, {
1874
- index,
1875
- elementsToCheck
1876
- }) => {
1877
- return elementsToCheck[index];
1878
- }, {
1879
- index: i,
1880
- elementsToCheck: elementsToCheck
1881
- });
1712
+ var elementToCheck = await parentNode.evaluateHandle((injected, { index, elementsToCheck: elementsToCheck2 }) => {
1713
+ return elementsToCheck2[index];
1714
+ }, { index: i, elementsToCheck });
1882
1715
  }
1883
- // For other Functions/Utilities
1884
1716
  elementToCheck.parentNode = parentNode;
1885
- var resolvedElement = await client.send('DOM.describeNode', {
1717
+ var resolvedElement = await client.send("DOM.describeNode", {
1886
1718
  objectId: elementToCheck._objectId,
1887
1719
  depth: -1
1888
1720
  });
1889
- // Note: Possible Bug, Maybe well actually have to check the Documents Node Position instead of using the backendNodeId
1890
1721
  elementToCheck.backendNodeId = resolvedElement.node.backendNodeId;
1891
1722
  elements.push(elementToCheck);
1892
1723
  }
1893
1724
  }
1894
1725
  }
1895
1726
  }
1896
- // Setting currentScopingElements to the elements we just queried
1897
1727
  currentScopingElements = [];
1898
1728
  for (var element of elements) {
1899
1729
  var elemIndex = element.backendNodeId;
1900
- // Sorting the Elements by their occourance in the DOM
1901
- var elemPos = elementsIndexes.findIndex(index => index > elemIndex);
1902
-
1903
- // Sort the elements by their backendNodeId
1730
+ var elemPos = elementsIndexes.findIndex((index) => index > elemIndex);
1904
1731
  if (elemPos === -1) {
1905
1732
  currentScopingElements.push(element);
1906
1733
  elementsIndexes.push(elemIndex);
@@ -1913,17 +1740,10 @@ class Frame extends _instrumentation.SdkObject {
1913
1740
  return currentScopingElements;
1914
1741
  }
1915
1742
  }
1916
- exports.Frame = Frame;
1917
- Frame.Events = {
1918
- InternalNavigation: 'internalnavigation',
1919
- AddLifecycle: 'addlifecycle',
1920
- RemoveLifecycle: 'removelifecycle'
1921
- };
1922
1743
  class SignalBarrier {
1923
1744
  constructor(progress) {
1924
- this._progress = void 0;
1925
1745
  this._protectCount = 0;
1926
- this._promise = new _manualPromise.ManualPromise();
1746
+ this._promise = new import_manualPromise.ManualPromise();
1927
1747
  this._progress = progress;
1928
1748
  this.retain();
1929
1749
  }
@@ -1932,15 +1752,21 @@ class SignalBarrier {
1932
1752
  return this._promise;
1933
1753
  }
1934
1754
  async addFrameNavigation(frame) {
1935
- // Auto-wait top-level navigations only.
1936
- if (frame.parentFrame()) return;
1755
+ if (frame.parentFrame())
1756
+ return;
1937
1757
  this.retain();
1938
- const waiter = _helper.helper.waitForEvent(null, frame, Frame.Events.InternalNavigation, e => {
1939
- if (!e.isPublic) return false;
1940
- if (!e.error && this._progress) this._progress.log(` navigated to "${frame._url}"`);
1758
+ const waiter = import_helper.helper.waitForEvent(null, frame, Frame.Events.InternalNavigation, (e) => {
1759
+ if (!e.isPublic)
1760
+ return false;
1761
+ if (!e.error && this._progress)
1762
+ this._progress.log(` navigated to "${frame._url}"`);
1941
1763
  return true;
1942
1764
  });
1943
- await _utils.LongStandingScope.raceMultiple([frame._page.openScope, frame._detachedScope], waiter.promise).catch(() => {});
1765
+ await import_utils.LongStandingScope.raceMultiple([
1766
+ frame._page.openScope,
1767
+ frame._detachedScope
1768
+ ], waiter.promise).catch(() => {
1769
+ });
1944
1770
  waiter.dispose();
1945
1771
  this.release();
1946
1772
  }
@@ -1949,15 +1775,25 @@ class SignalBarrier {
1949
1775
  }
1950
1776
  release() {
1951
1777
  --this._protectCount;
1952
- if (!this._protectCount) this._promise.resolve();
1778
+ if (!this._protectCount)
1779
+ this._promise.resolve();
1953
1780
  }
1954
1781
  }
1955
1782
  function verifyLifecycle(name, waitUntil) {
1956
- if (waitUntil === 'networkidle0') waitUntil = 'networkidle';
1957
- if (!types.kLifecycleEvents.has(waitUntil)) throw new Error(`${name}: expected one of (load|domcontentloaded|networkidle|commit)`);
1783
+ if (waitUntil === "networkidle0")
1784
+ waitUntil = "networkidle";
1785
+ if (!types.kLifecycleEvents.has(waitUntil))
1786
+ throw new Error(`${name}: expected one of (load|domcontentloaded|networkidle|commit)`);
1958
1787
  return waitUntil;
1959
1788
  }
1960
1789
  function renderUnexpectedValue(expression, received) {
1961
- if (expression === 'to.match.aria') return received ? received.raw : received;
1790
+ if (expression === "to.match.aria")
1791
+ return received ? received.raw : received;
1962
1792
  return received;
1963
- }
1793
+ }
1794
+ // Annotate the CommonJS export names for ESM import in node:
1795
+ 0 && (module.exports = {
1796
+ Frame,
1797
+ FrameManager,
1798
+ NavigationAbortedError
1799
+ });