rebrowser-playwright-core 1.49.0 → 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 (373) hide show
  1. package/ThirdPartyNotices.txt +381 -55
  2. package/bin/reinstall_msedge_beta_linux.sh +6 -0
  3. package/bin/reinstall_msedge_dev_linux.sh +6 -0
  4. package/bin/reinstall_msedge_stable_linux.sh +6 -0
  5. package/browsers.json +28 -13
  6. package/index.js +0 -1
  7. package/lib/androidServerImpl.js +42 -48
  8. package/lib/browserServerImpl.js +60 -64
  9. package/lib/cli/driver.js +71 -69
  10. package/lib/cli/program.js +314 -354
  11. package/lib/cli/programWithTestStub.js +51 -44
  12. package/lib/client/accessibility.js +31 -32
  13. package/lib/client/android.js +146 -254
  14. package/lib/client/api.js +135 -283
  15. package/lib/client/artifact.js +39 -39
  16. package/lib/client/browser.js +59 -68
  17. package/lib/client/browserContext.js +302 -322
  18. package/lib/client/browserType.js +95 -143
  19. package/lib/client/cdpSession.js +29 -31
  20. package/lib/client/channelOwner.js +109 -139
  21. package/lib/client/clientHelper.js +49 -42
  22. package/lib/client/clientInstrumentation.js +40 -35
  23. package/lib/client/clientStackTrace.js +69 -0
  24. package/lib/client/clock.js +36 -36
  25. package/lib/client/connection.js +203 -218
  26. package/lib/client/consoleMessage.js +33 -33
  27. package/lib/client/coverage.js +25 -22
  28. package/lib/client/dialog.js +30 -31
  29. package/lib/client/download.js +25 -25
  30. package/lib/client/electron.js +74 -76
  31. package/lib/client/elementHandle.js +126 -163
  32. package/lib/client/errors.js +53 -53
  33. package/lib/client/eventEmitter.js +127 -127
  34. package/lib/client/events.js +72 -68
  35. package/lib/client/fetch.js +154 -178
  36. package/lib/client/fileChooser.js +25 -24
  37. package/lib/client/fileUtils.js +34 -0
  38. package/lib/client/frame.js +189 -307
  39. package/lib/client/harRouter.js +44 -56
  40. package/lib/client/input.js +40 -69
  41. package/lib/client/jsHandle.js +55 -71
  42. package/lib/client/jsonPipe.js +27 -23
  43. package/lib/client/localUtils.js +53 -28
  44. package/lib/client/locator.js +144 -230
  45. package/lib/client/network.js +285 -301
  46. package/lib/client/page.js +273 -312
  47. package/lib/client/platform.js +74 -0
  48. package/lib/client/playwright.js +62 -57
  49. package/lib/client/selectors.js +51 -43
  50. package/lib/client/stream.js +30 -45
  51. package/lib/client/timeoutSettings.js +75 -0
  52. package/lib/client/tracing.js +49 -82
  53. package/lib/client/types.js +26 -22
  54. package/lib/client/video.js +35 -27
  55. package/lib/client/waiter.js +71 -91
  56. package/lib/client/webError.js +25 -23
  57. package/lib/client/webSocket.js +111 -0
  58. package/lib/client/worker.js +48 -56
  59. package/lib/client/writableStream.js +28 -43
  60. package/lib/generated/clockSource.js +26 -5
  61. package/lib/generated/consoleApiSource.js +26 -5
  62. package/lib/generated/injectedScriptSource.js +26 -5
  63. package/lib/generated/pollingRecorderSource.js +26 -5
  64. package/lib/generated/utilityScriptSource.js +26 -5
  65. package/lib/generated/webSocketMockSource.js +375 -4
  66. package/lib/inProcessFactory.js +53 -48
  67. package/lib/inprocess.js +2 -19
  68. package/lib/outofprocess.js +53 -42
  69. package/lib/protocol/debug.js +209 -25
  70. package/lib/protocol/serializers.js +153 -134
  71. package/lib/protocol/validator.js +2712 -2667
  72. package/lib/protocol/validatorPrimitives.js +115 -75
  73. package/lib/remote/playwrightConnection.js +144 -152
  74. package/lib/remote/playwrightServer.js +106 -77
  75. package/lib/server/accessibility.js +44 -37
  76. package/lib/server/android/android.js +216 -206
  77. package/lib/server/android/backendAdb.js +89 -82
  78. package/lib/server/artifact.js +78 -55
  79. package/lib/server/bidi/bidiBrowser.js +227 -158
  80. package/lib/server/bidi/bidiChromium.js +106 -78
  81. package/lib/server/bidi/bidiConnection.js +66 -83
  82. package/lib/server/bidi/bidiExecutionContext.js +161 -97
  83. package/lib/server/bidi/bidiFirefox.js +76 -68
  84. package/lib/server/bidi/bidiInput.js +90 -102
  85. package/lib/server/bidi/bidiNetworkManager.js +141 -159
  86. package/lib/server/bidi/bidiOverCdp.js +57 -58
  87. package/lib/server/bidi/bidiPage.js +262 -261
  88. package/lib/server/bidi/bidiPdf.js +52 -86
  89. package/lib/server/bidi/third_party/bidiCommands.d.js +22 -0
  90. package/lib/server/bidi/third_party/bidiDeserializer.js +55 -50
  91. package/lib/server/bidi/third_party/bidiKeyboard.js +241 -223
  92. package/lib/server/bidi/third_party/bidiProtocol.js +144 -131
  93. package/lib/server/bidi/third_party/bidiSerializer.js +67 -63
  94. package/lib/server/bidi/third_party/firefoxPrefs.js +149 -111
  95. package/lib/server/browser.js +76 -84
  96. package/lib/server/browserContext.js +343 -360
  97. package/lib/server/browserType.js +169 -181
  98. package/lib/server/callLog.js +82 -0
  99. package/lib/server/chromium/chromium.js +212 -190
  100. package/lib/server/chromium/chromiumSwitches.js +99 -44
  101. package/lib/server/chromium/crAccessibility.js +157 -131
  102. package/lib/server/chromium/crBrowser.js +262 -280
  103. package/lib/server/chromium/crConnection.js +121 -178
  104. package/lib/server/chromium/crCoverage.js +113 -127
  105. package/lib/server/chromium/crDevTools.js +64 -55
  106. package/lib/server/chromium/crDragDrop.js +62 -79
  107. package/lib/server/chromium/crExecutionContext.js +100 -91
  108. package/lib/server/chromium/crInput.js +101 -88
  109. package/lib/server/chromium/crNetworkManager.js +269 -370
  110. package/lib/server/chromium/crPage.js +509 -595
  111. package/lib/server/chromium/crPdf.js +54 -86
  112. package/lib/server/chromium/crProtocolHelper.js +92 -80
  113. package/lib/server/chromium/crServiceWorker.js +85 -69
  114. package/lib/server/chromium/defaultFontFamilies.js +152 -135
  115. package/lib/server/chromium/protocol.d.js +16 -0
  116. package/lib/server/chromium/videoRecorder.js +65 -99
  117. package/lib/server/clock.js +58 -46
  118. package/lib/server/codegen/csharp.js +191 -156
  119. package/lib/server/codegen/java.js +163 -125
  120. package/lib/server/codegen/javascript.js +166 -143
  121. package/lib/server/codegen/jsonl.js +33 -29
  122. package/lib/server/codegen/language.js +75 -52
  123. package/lib/server/codegen/languages.js +65 -27
  124. package/lib/server/codegen/python.js +141 -125
  125. package/lib/server/codegen/types.js +15 -4
  126. package/lib/server/console.js +28 -32
  127. package/lib/server/cookieStore.js +105 -86
  128. package/lib/server/debugController.js +102 -154
  129. package/lib/server/debugger.js +82 -78
  130. package/lib/server/deviceDescriptors.js +37 -24
  131. package/lib/server/deviceDescriptorsSource.json +131 -131
  132. package/lib/server/dialog.js +36 -35
  133. package/lib/server/dispatchers/androidDispatcher.js +196 -107
  134. package/lib/server/dispatchers/artifactDispatcher.js +62 -62
  135. package/lib/server/dispatchers/browserContextDispatcher.js +177 -217
  136. package/lib/server/dispatchers/browserDispatcher.js +78 -97
  137. package/lib/server/dispatchers/browserTypeDispatcher.js +35 -35
  138. package/lib/server/dispatchers/cdpSessionDispatcher.js +32 -36
  139. package/lib/server/dispatchers/debugControllerDispatcher.js +48 -64
  140. package/lib/server/dispatchers/dialogDispatcher.js +30 -27
  141. package/lib/server/dispatchers/dispatcher.js +180 -229
  142. package/lib/server/dispatchers/electronDispatcher.js +54 -57
  143. package/lib/server/dispatchers/elementHandlerDispatcher.js +79 -116
  144. package/lib/server/dispatchers/frameDispatcher.js +93 -162
  145. package/lib/server/dispatchers/jsHandleDispatcher.js +49 -66
  146. package/lib/server/dispatchers/jsonPipeDispatcher.js +35 -36
  147. package/lib/server/dispatchers/localUtilsDispatcher.js +107 -365
  148. package/lib/server/dispatchers/networkDispatchers.js +92 -109
  149. package/lib/server/dispatchers/pageDispatcher.js +130 -169
  150. package/lib/server/dispatchers/playwrightDispatcher.js +69 -76
  151. package/lib/server/dispatchers/selectorsDispatcher.js +28 -24
  152. package/lib/server/dispatchers/streamDispatcher.js +42 -44
  153. package/lib/server/dispatchers/tracingDispatcher.js +36 -41
  154. package/lib/server/dispatchers/webSocketRouteDispatcher.js +100 -135
  155. package/lib/server/dispatchers/writableStreamDispatcher.js +54 -39
  156. package/lib/server/dom.js +424 -443
  157. package/lib/server/download.js +45 -35
  158. package/lib/server/electron/electron.js +156 -175
  159. package/lib/server/electron/loader.js +8 -36
  160. package/lib/server/errors.js +47 -46
  161. package/lib/server/fetch.js +302 -331
  162. package/lib/server/fileChooser.js +25 -24
  163. package/lib/server/fileUploadUtils.js +66 -57
  164. package/lib/server/firefox/ffAccessibility.js +153 -131
  165. package/lib/server/firefox/ffBrowser.js +218 -274
  166. package/lib/server/firefox/ffConnection.js +63 -84
  167. package/lib/server/firefox/ffExecutionContext.js +103 -77
  168. package/lib/server/firefox/ffInput.js +72 -63
  169. package/lib/server/firefox/ffNetworkManager.js +131 -110
  170. package/lib/server/firefox/ffPage.js +244 -302
  171. package/lib/server/firefox/firefox.js +76 -69
  172. package/lib/server/firefox/protocol.d.js +16 -0
  173. package/lib/server/formData.js +107 -35
  174. package/lib/server/frameSelectors.js +77 -111
  175. package/lib/server/frames.js +719 -855
  176. package/lib/server/har/harRecorder.js +85 -77
  177. package/lib/server/har/harTracer.js +288 -224
  178. package/lib/server/harBackend.js +157 -0
  179. package/lib/server/helper.js +56 -59
  180. package/lib/server/index.js +59 -106
  181. package/lib/server/input.js +136 -166
  182. package/lib/server/instrumentation.js +49 -44
  183. package/lib/server/javascript.js +157 -151
  184. package/lib/server/launchApp.js +92 -73
  185. package/lib/server/localUtils.js +211 -0
  186. package/lib/server/macEditingCommands.js +141 -137
  187. package/lib/server/network.js +263 -297
  188. package/lib/server/page.js +353 -432
  189. package/lib/server/pageBinding.js +88 -0
  190. package/lib/server/pipeTransport.js +49 -45
  191. package/lib/server/playwright.js +60 -67
  192. package/lib/server/progress.js +56 -51
  193. package/lib/server/protocolError.js +34 -31
  194. package/lib/server/recorder/chat.js +161 -0
  195. package/lib/server/recorder/contextRecorder.js +135 -148
  196. package/lib/server/recorder/recorderApp.js +129 -132
  197. package/lib/server/recorder/recorderCollection.js +57 -57
  198. package/lib/server/recorder/recorderFrontend.js +15 -4
  199. package/lib/server/recorder/recorderRunner.js +80 -100
  200. package/lib/server/recorder/recorderUtils.js +59 -72
  201. package/lib/server/recorder/throttledFile.js +42 -31
  202. package/lib/server/recorder.js +186 -190
  203. package/lib/server/registry/browserFetcher.js +107 -100
  204. package/lib/server/registry/dependencies.js +247 -198
  205. package/lib/server/registry/index.js +928 -709
  206. package/lib/server/registry/nativeDeps.js +1073 -461
  207. package/lib/server/registry/oopDownloadBrowserMain.js +57 -75
  208. package/lib/server/screenshotter.js +166 -182
  209. package/lib/server/selectors.js +85 -46
  210. package/lib/server/socksClientCertificatesInterceptor.js +166 -185
  211. package/lib/server/socksInterceptor.js +62 -67
  212. package/lib/server/storageScript.js +154 -0
  213. package/lib/server/timeoutSettings.js +89 -0
  214. package/lib/server/trace/recorder/snapshotter.js +70 -88
  215. package/lib/server/trace/recorder/snapshotterInjected.js +246 -218
  216. package/lib/server/trace/recorder/tracing.js +324 -327
  217. package/lib/server/trace/test/inMemorySnapshotter.js +46 -52
  218. package/lib/server/trace/viewer/traceViewer.js +172 -137
  219. package/lib/server/transport.js +125 -133
  220. package/lib/server/types.js +26 -22
  221. package/lib/server/usKeyboardLayout.js +135 -545
  222. package/lib/server/utils/ascii.js +44 -0
  223. package/lib/server/utils/comparators.js +161 -0
  224. package/lib/server/utils/crypto.js +216 -0
  225. package/lib/server/utils/debug.js +47 -0
  226. package/lib/server/utils/debugLogger.js +114 -0
  227. package/lib/server/utils/env.js +68 -0
  228. package/lib/server/utils/eventsHelper.js +39 -0
  229. package/lib/server/utils/expectUtils.js +38 -0
  230. package/lib/server/utils/fileUtils.js +191 -0
  231. package/lib/server/utils/happyEyeballs.js +207 -0
  232. package/lib/server/utils/hostPlatform.js +109 -0
  233. package/lib/server/utils/httpServer.js +218 -0
  234. package/lib/server/utils/image_tools/colorUtils.js +89 -0
  235. package/lib/{image_tools → server/utils/image_tools}/compare.js +44 -43
  236. package/lib/server/utils/image_tools/imageChannel.js +78 -0
  237. package/lib/{image_tools → server/utils/image_tools}/stats.js +40 -40
  238. package/lib/server/utils/linuxUtils.js +71 -0
  239. package/lib/server/utils/network.js +217 -0
  240. package/lib/server/utils/nodePlatform.js +148 -0
  241. package/lib/server/utils/pipeTransport.js +84 -0
  242. package/lib/server/utils/processLauncher.js +238 -0
  243. package/lib/server/utils/profiler.js +65 -0
  244. package/lib/server/utils/socksProxy.js +511 -0
  245. package/lib/server/utils/spawnAsync.js +41 -0
  246. package/lib/server/utils/task.js +51 -0
  247. package/lib/server/utils/userAgent.js +98 -0
  248. package/lib/server/utils/wsServer.js +132 -0
  249. package/lib/server/utils/zipFile.js +74 -0
  250. package/lib/server/utils/zones.js +57 -0
  251. package/lib/server/webkit/protocol.d.js +16 -0
  252. package/lib/server/webkit/webkit.js +76 -63
  253. package/lib/server/webkit/wkAccessibility.js +161 -118
  254. package/lib/server/webkit/wkBrowser.js +163 -180
  255. package/lib/server/webkit/wkConnection.js +59 -83
  256. package/lib/server/webkit/wkExecutionContext.js +96 -73
  257. package/lib/server/webkit/wkInput.js +87 -75
  258. package/lib/server/webkit/wkInterceptableRequest.js +102 -95
  259. package/lib/server/webkit/wkPage.js +536 -645
  260. package/lib/server/webkit/wkProvisionalPage.js +45 -56
  261. package/lib/server/webkit/wkWorkers.js +77 -77
  262. package/lib/utils/isomorphic/ariaSnapshot.js +245 -128
  263. package/lib/utils/isomorphic/assert.js +31 -0
  264. package/lib/utils/isomorphic/builtins.js +90 -0
  265. package/lib/utils/isomorphic/colors.js +72 -0
  266. package/lib/utils/isomorphic/cssParser.js +123 -127
  267. package/lib/utils/isomorphic/cssTokenizer.js +436 -364
  268. package/lib/utils/isomorphic/headers.js +53 -0
  269. package/lib/utils/isomorphic/locatorGenerators.js +344 -349
  270. package/lib/utils/isomorphic/locatorParser.js +103 -106
  271. package/lib/utils/isomorphic/locatorUtils.js +63 -44
  272. package/lib/utils/isomorphic/manualPromise.js +115 -0
  273. package/lib/utils/isomorphic/mimeType.js +453 -22
  274. package/lib/utils/isomorphic/multimap.js +81 -0
  275. package/lib/utils/isomorphic/rtti.js +43 -0
  276. package/lib/utils/isomorphic/selectorParser.js +183 -193
  277. package/lib/utils/isomorphic/semaphore.js +54 -0
  278. package/lib/utils/isomorphic/stackTrace.js +158 -0
  279. package/lib/utils/isomorphic/stringUtils.js +113 -106
  280. package/lib/utils/isomorphic/time.js +44 -0
  281. package/lib/utils/isomorphic/timeoutRunner.js +67 -0
  282. package/lib/utils/isomorphic/traceUtils.js +52 -32
  283. package/lib/utils/isomorphic/types.js +16 -0
  284. package/lib/utils/isomorphic/urlMatch.js +114 -71
  285. package/lib/utils/isomorphic/utilityScriptSerializers.js +248 -0
  286. package/lib/utils.js +101 -0
  287. package/lib/utilsBundle.js +101 -76
  288. package/lib/utilsBundleImpl/index.js +114 -116
  289. package/lib/vite/htmlReport/index.html +26 -20
  290. package/lib/vite/recorder/assets/codeMirrorModule-DVQi6prl.js +24 -0
  291. package/lib/vite/recorder/assets/index-97EUAAbk.js +184 -0
  292. package/lib/vite/recorder/assets/{index-iA1aAGZg.css → index-eHBmevrY.css} +1 -1
  293. package/lib/vite/recorder/index.html +2 -2
  294. package/lib/vite/traceViewer/assets/codeMirrorModule-DwAiTpyC.js +24 -0
  295. package/lib/vite/traceViewer/assets/defaultSettingsView-DkkRvn5X.js +265 -0
  296. package/lib/vite/traceViewer/assets/{xtermModule-BeNbaIVa.js → xtermModule-BoAIEibi.js} +7 -7
  297. package/lib/vite/traceViewer/defaultSettingsView.QdHITyLI.css +1 -0
  298. package/lib/vite/traceViewer/index.DvtSwn6E.js +2 -0
  299. package/lib/vite/traceViewer/index.html +4 -7
  300. package/lib/vite/traceViewer/sw.bundle.js +3 -3
  301. package/lib/vite/traceViewer/{uiMode.voC1ZiOQ.css → uiMode.BatfzHMG.css} +1 -1
  302. package/lib/vite/traceViewer/uiMode.Sdytl9wc.js +5 -0
  303. package/lib/vite/traceViewer/uiMode.html +4 -7
  304. package/lib/zipBundle.js +32 -23
  305. package/lib/zipBundleImpl.js +4 -4
  306. package/package.json +7 -7
  307. package/types/protocol.d.ts +819 -127
  308. package/types/types.d.ts +196 -75
  309. package/bin/PrintDeps.exe +0 -0
  310. package/bin/README.md +0 -2
  311. package/lib/common/socksProxy.js +0 -569
  312. package/lib/common/timeoutSettings.js +0 -73
  313. package/lib/common/types.js +0 -5
  314. package/lib/image_tools/colorUtils.js +0 -98
  315. package/lib/image_tools/imageChannel.js +0 -70
  316. package/lib/protocol/transport.js +0 -82
  317. package/lib/server/ariaSnapshot.js +0 -33
  318. package/lib/server/isomorphic/utilityScriptSerializers.js +0 -226
  319. package/lib/server/recorder/recorderInTraceViewer.js +0 -144
  320. package/lib/utils/ascii.js +0 -31
  321. package/lib/utils/comparators.js +0 -153
  322. package/lib/utils/crypto.js +0 -171
  323. package/lib/utils/debug.js +0 -46
  324. package/lib/utils/debugLogger.js +0 -91
  325. package/lib/utils/env.js +0 -49
  326. package/lib/utils/eventsHelper.js +0 -38
  327. package/lib/utils/expectUtils.js +0 -33
  328. package/lib/utils/fileUtils.js +0 -205
  329. package/lib/utils/happy-eyeballs.js +0 -194
  330. package/lib/utils/headers.js +0 -52
  331. package/lib/utils/hostPlatform.js +0 -139
  332. package/lib/utils/httpServer.js +0 -237
  333. package/lib/utils/index.js +0 -368
  334. package/lib/utils/isomorphic/recorderUtils.js +0 -227
  335. package/lib/utils/linuxUtils.js +0 -78
  336. package/lib/utils/manualPromise.js +0 -109
  337. package/lib/utils/multimap.js +0 -75
  338. package/lib/utils/network.js +0 -160
  339. package/lib/utils/processLauncher.js +0 -248
  340. package/lib/utils/profiler.js +0 -53
  341. package/lib/utils/rtti.js +0 -44
  342. package/lib/utils/semaphore.js +0 -51
  343. package/lib/utils/sequence.js +0 -64
  344. package/lib/utils/spawnAsync.js +0 -45
  345. package/lib/utils/stackTrace.js +0 -134
  346. package/lib/utils/task.js +0 -58
  347. package/lib/utils/time.js +0 -37
  348. package/lib/utils/timeoutRunner.js +0 -66
  349. package/lib/utils/traceUtils.js +0 -44
  350. package/lib/utils/userAgent.js +0 -105
  351. package/lib/utils/wsServer.js +0 -127
  352. package/lib/utils/zipFile.js +0 -75
  353. package/lib/utils/zones.js +0 -71
  354. package/lib/vite/recorder/assets/codeMirrorModule-AFvV6hAs.js +0 -24
  355. package/lib/vite/recorder/assets/index-_cTWgVuJ.js +0 -184
  356. package/lib/vite/traceViewer/assets/codeMirrorModule-KatbITLF.js +0 -24
  357. package/lib/vite/traceViewer/assets/inspectorTab-DdpLd2bb.js +0 -68
  358. package/lib/vite/traceViewer/assets/testServerConnection-DeE2kSzz.js +0 -1
  359. package/lib/vite/traceViewer/assets/workbench-CdYbzWFD.js +0 -9
  360. package/lib/vite/traceViewer/embedded.6m3UZh7r.js +0 -2
  361. package/lib/vite/traceViewer/embedded.html +0 -18
  362. package/lib/vite/traceViewer/embedded.w7WN2u1R.css +0 -1
  363. package/lib/vite/traceViewer/index.WUV-8boJ.js +0 -2
  364. package/lib/vite/traceViewer/inspectorTab.DEOUW62d.css +0 -1
  365. package/lib/vite/traceViewer/recorder.B_SY1GJM.css +0 -0
  366. package/lib/vite/traceViewer/recorder.OT2tVHgn.js +0 -2
  367. package/lib/vite/traceViewer/recorder.html +0 -17
  368. package/lib/vite/traceViewer/uiMode.BZBTyvGn.js +0 -5
  369. package/lib/vite/traceViewer/workbench.C-zR9ysA.css +0 -1
  370. /package/lib/vite/recorder/assets/{codeMirrorModule-ez37Vkbh.css → codeMirrorModule-C3UTv-Ge.css} +0 -0
  371. /package/lib/vite/traceViewer/{codeMirrorModule.ez37Vkbh.css → codeMirrorModule.C3UTv-Ge.css} +0 -0
  372. /package/lib/vite/traceViewer/{index.CrbWWHbf.css → index.CFOW-Ezb.css} +0 -0
  373. /package/lib/vite/traceViewer/{xtermModule.DSXBckUd.css → xtermModule.Beg8tuEN.css} +0 -0
@@ -1,91 +1,109 @@
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 browserContext_exports = {};
30
+ __export(browserContext_exports, {
31
+ BrowserContext: () => BrowserContext,
32
+ assertBrowserContextIsNotOwned: () => assertBrowserContextIsNotOwned,
33
+ normalizeProxySettings: () => normalizeProxySettings,
34
+ validateBrowserContextOptions: () => validateBrowserContextOptions,
35
+ verifyClientCertificates: () => verifyClientCertificates,
36
+ verifyGeolocation: () => verifyGeolocation
5
37
  });
6
- exports.BrowserContext = void 0;
7
- exports.assertBrowserContextIsNotOwned = assertBrowserContextIsNotOwned;
8
- exports.normalizeProxySettings = normalizeProxySettings;
9
- exports.validateBrowserContextOptions = validateBrowserContextOptions;
10
- exports.verifyClientCertificates = verifyClientCertificates;
11
- exports.verifyGeolocation = verifyGeolocation;
12
- var _timeoutSettings = require("../common/timeoutSettings");
13
- var _utils = require("../utils");
14
- var _fileUtils = require("../utils/fileUtils");
15
- var _helper = require("./helper");
16
- var network = _interopRequireWildcard(require("./network"));
17
- var _page6 = require("./page");
18
- var _path = _interopRequireDefault(require("path"));
19
- var _fs = _interopRequireDefault(require("fs"));
20
- var _instrumentation = require("./instrumentation");
21
- var _debugger = require("./debugger");
22
- var _tracing = require("./trace/recorder/tracing");
23
- var _harRecorder = require("./har/harRecorder");
24
- var _recorder = require("./recorder");
25
- var consoleApiSource = _interopRequireWildcard(require("../generated/consoleApiSource"));
26
- var _fetch = require("./fetch");
27
- var _clock = require("./clock");
28
- var _recorderApp = require("./recorder/recorderApp");
29
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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 && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
32
- /**
33
- * Copyright 2017 Google Inc. All rights reserved.
34
- * Modifications copyright (c) Microsoft Corporation.
35
- *
36
- * Licensed under the Apache License, Version 2.0 (the "License");
37
- * you may not use this file except in compliance with the License.
38
- * You may obtain a copy of the License at
39
- *
40
- * http://www.apache.org/licenses/LICENSE-2.0
41
- *
42
- * Unless required by applicable law or agreed to in writing, software
43
- * distributed under the License is distributed on an "AS IS" BASIS,
44
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
45
- * See the License for the specific language governing permissions and
46
- * limitations under the License.
47
- */
48
-
49
- class BrowserContext extends _instrumentation.SdkObject {
38
+ module.exports = __toCommonJS(browserContext_exports);
39
+ var import_fs = __toESM(require("fs"));
40
+ var import_path = __toESM(require("path"));
41
+ var import_timeoutSettings = require("./timeoutSettings");
42
+ var import_crypto = require("./utils/crypto");
43
+ var import_debug = require("./utils/debug");
44
+ var import_clock = require("./clock");
45
+ var import_debugger = require("./debugger");
46
+ var import_fetch = require("./fetch");
47
+ var import_fileUtils = require("./utils/fileUtils");
48
+ var import_harRecorder = require("./har/harRecorder");
49
+ var import_helper = require("./helper");
50
+ var import_instrumentation = require("./instrumentation");
51
+ var import_builtins = require("../utils/isomorphic/builtins");
52
+ var utilityScriptSerializers = __toESM(require("../utils/isomorphic/utilityScriptSerializers"));
53
+ var network = __toESM(require("./network"));
54
+ var import_page = require("./page");
55
+ var import_page2 = require("./page");
56
+ var import_recorder = require("./recorder");
57
+ var import_recorderApp = require("./recorder/recorderApp");
58
+ var storageScript = __toESM(require("./storageScript"));
59
+ var consoleApiSource = __toESM(require("../generated/consoleApiSource"));
60
+ var import_tracing = require("./trace/recorder/tracing");
61
+ class BrowserContext extends import_instrumentation.SdkObject {
50
62
  constructor(browser, options, browserContextId) {
51
- super(browser, 'browser-context');
52
- this._timeoutSettings = new _timeoutSettings.TimeoutSettings();
53
- this._pageBindings = new Map();
54
- this._activeProgressControllers = new Set();
55
- this._options = void 0;
56
- this._requestInterceptor = void 0;
57
- this._isPersistentContext = void 0;
58
- this._closedStatus = 'open';
59
- this._closePromise = void 0;
60
- this._closePromiseFulfill = void 0;
61
- this._permissions = new Map();
62
- this._downloads = new Set();
63
- this._browser = void 0;
64
- this._browserContextId = void 0;
65
- this._selectors = void 0;
66
- this._origins = new Set();
67
- this._harRecorders = new Map();
68
- this.tracing = void 0;
69
- this.fetchRequest = void 0;
70
- this._customCloseHandler = void 0;
63
+ super(browser, "browser-context");
64
+ this._timeoutSettings = new import_timeoutSettings.TimeoutSettings();
65
+ this._pageBindings = /* @__PURE__ */ new Map();
66
+ this._activeProgressControllers = /* @__PURE__ */ new Set();
67
+ this._closedStatus = "open";
68
+ this._permissions = /* @__PURE__ */ new Map();
69
+ this._downloads = /* @__PURE__ */ new Set();
70
+ this._origins = /* @__PURE__ */ new Set();
71
+ this._harRecorders = /* @__PURE__ */ new Map();
71
72
  this._tempDirs = [];
72
73
  this._settingStorageState = false;
73
74
  this.initScripts = [];
74
- this._routesInFlight = new Set();
75
- this._debugger = void 0;
76
- this._closeReason = void 0;
77
- this.clock = void 0;
78
- this._clientCertificatesProxy = void 0;
75
+ this._routesInFlight = /* @__PURE__ */ new Set();
79
76
  this.attribution.context = this;
80
77
  this._browser = browser;
81
78
  this._options = options;
82
79
  this._browserContextId = browserContextId;
83
80
  this._isPersistentContext = !browserContextId;
84
- this._closePromise = new Promise(fulfill => this._closePromiseFulfill = fulfill);
85
- this.fetchRequest = new _fetch.BrowserContextAPIRequestContext(this);
86
- if (this._options.recordHar) this._harRecorders.set('', new _harRecorder.HarRecorder(this, null, this._options.recordHar));
87
- this.tracing = new _tracing.Tracing(this, browser.options.tracesDir);
88
- this.clock = new _clock.Clock(this);
81
+ this._closePromise = new Promise((fulfill) => this._closePromiseFulfill = fulfill);
82
+ this.fetchRequest = new import_fetch.BrowserContextAPIRequestContext(this);
83
+ if (this._options.recordHar)
84
+ this._harRecorders.set("", new import_harRecorder.HarRecorder(this, null, this._options.recordHar));
85
+ this.tracing = new import_tracing.Tracing(this, browser.options.tracesDir);
86
+ this.clock = new import_clock.Clock(this);
87
+ }
88
+ static {
89
+ this.Events = {
90
+ Console: "console",
91
+ Close: "close",
92
+ Dialog: "dialog",
93
+ Page: "page",
94
+ // Can't use just 'error' due to node.js special treatment of error events.
95
+ // @see https://nodejs.org/api/events.html#events_error_events
96
+ PageError: "pageerror",
97
+ Request: "request",
98
+ Response: "response",
99
+ RequestFailed: "requestfailed",
100
+ RequestFinished: "requestfinished",
101
+ RequestAborted: "requestaborted",
102
+ RequestFulfilled: "requestfulfilled",
103
+ RequestContinued: "requestcontinued",
104
+ BeforeClose: "beforeclose",
105
+ VideoStarted: "videostarted"
106
+ };
89
107
  }
90
108
  isPersistentContext() {
91
109
  return this._isPersistentContext;
@@ -97,160 +115,167 @@ class BrowserContext extends _instrumentation.SdkObject {
97
115
  return this._selectors || this.attribution.playwright.selectors;
98
116
  }
99
117
  async _initialize() {
100
- if (this.attribution.playwright.options.isInternalPlaywright) return;
101
- // Debugger will pause execution upon page.pause in headed mode.
102
- this._debugger = new _debugger.Debugger(this);
103
-
104
- // When PWDEBUG=1, show inspector for each context.
105
- if ((0, _utils.debugMode)() === 'inspector') await _recorder.Recorder.show('actions', this, _recorderApp.RecorderApp.factory(this), {
106
- pauseOnNextStatement: true
107
- });
108
-
109
- // When paused, show inspector.
110
- if (this._debugger.isPaused()) _recorder.Recorder.showInspectorNoReply(this, _recorderApp.RecorderApp.factory(this));
111
- this._debugger.on(_debugger.Debugger.Events.PausedStateChanged, () => {
112
- if (this._debugger.isPaused()) _recorder.Recorder.showInspectorNoReply(this, _recorderApp.RecorderApp.factory(this));
118
+ if (this.attribution.playwright.options.isInternalPlaywright)
119
+ return;
120
+ this._debugger = new import_debugger.Debugger(this);
121
+ if ((0, import_debug.debugMode)() === "inspector")
122
+ await import_recorder.Recorder.show(this, import_recorderApp.RecorderApp.factory(this), { pauseOnNextStatement: true });
123
+ if (this._debugger.isPaused())
124
+ import_recorder.Recorder.showInspectorNoReply(this, import_recorderApp.RecorderApp.factory(this));
125
+ this._debugger.on(import_debugger.Debugger.Events.PausedStateChanged, () => {
126
+ if (this._debugger.isPaused())
127
+ import_recorder.Recorder.showInspectorNoReply(this, import_recorderApp.RecorderApp.factory(this));
113
128
  });
114
- if ((0, _utils.debugMode)() === 'console') await this.extendInjectedScript(consoleApiSource.source);
115
- if (this._options.serviceWorkers === 'block') await this.addInitScript(`\nif (navigator.serviceWorker) navigator.serviceWorker.register = async () => { console.warn('Service Worker registration blocked by Playwright'); };\n`);
116
- if (this._options.permissions) await this.grantPermissions(this._options.permissions);
129
+ if ((0, import_debug.debugMode)() === "console")
130
+ await this.extendInjectedScript(consoleApiSource.source);
131
+ if (this._options.serviceWorkers === "block")
132
+ await this.addInitScript(`
133
+ if (navigator.serviceWorker) navigator.serviceWorker.register = async () => { console.warn('Service Worker registration blocked by Playwright'); };
134
+ `);
135
+ if (this._options.permissions)
136
+ await this.grantPermissions(this._options.permissions);
117
137
  }
118
138
  debugger() {
119
139
  return this._debugger;
120
140
  }
121
141
  async _ensureVideosPath() {
122
- if (this._options.recordVideo) await (0, _fileUtils.mkdirIfNeeded)(_path.default.join(this._options.recordVideo.dir, 'dummy'));
142
+ if (this._options.recordVideo)
143
+ await (0, import_fileUtils.mkdirIfNeeded)(import_path.default.join(this._options.recordVideo.dir, "dummy"));
123
144
  }
124
145
  canResetForReuse() {
125
- if (this._closedStatus !== 'open') return false;
146
+ if (this._closedStatus !== "open")
147
+ return false;
126
148
  return true;
127
149
  }
128
150
  async stopPendingOperations(reason) {
129
- // When using context reuse, stop pending operations to gracefully terminate all the actions
130
- // with a user-friendly error message containing operation log.
131
- for (const controller of this._activeProgressControllers) controller.abort(new Error(reason));
132
- // Let rejections in microtask generate events before returning.
133
- await new Promise(f => setTimeout(f, 0));
151
+ for (const controller of this._activeProgressControllers)
152
+ controller.abort(new Error(reason));
153
+ await new Promise((f) => setTimeout(f, 0));
134
154
  }
135
155
  static reusableContextHash(params) {
136
- const paramsCopy = {
137
- ...params
138
- };
156
+ const paramsCopy = { ...params };
139
157
  for (const k of Object.keys(paramsCopy)) {
140
158
  const key = k;
141
- if (paramsCopy[key] === defaultNewContextParamValues[key]) delete paramsCopy[key];
159
+ if (paramsCopy[key] === defaultNewContextParamValues[key])
160
+ delete paramsCopy[key];
142
161
  }
143
- for (const key of paramsThatAllowContextReuse) delete paramsCopy[key];
162
+ for (const key of paramsThatAllowContextReuse)
163
+ delete paramsCopy[key];
144
164
  return JSON.stringify(paramsCopy);
145
165
  }
146
166
  async resetForReuse(metadata, params) {
147
- var _page, _page2, _page3, _page4, _page5;
148
- this.setDefaultNavigationTimeout(undefined);
149
- this.setDefaultTimeout(undefined);
167
+ this.setDefaultNavigationTimeout(void 0);
168
+ this.setDefaultTimeout(void 0);
150
169
  this.tracing.resetForReuse();
151
170
  if (params) {
152
- for (const key of paramsThatAllowContextReuse) this._options[key] = params[key];
171
+ for (const key of paramsThatAllowContextReuse)
172
+ this._options[key] = params[key];
153
173
  }
154
174
  await this._cancelAllRoutesInFlight();
155
-
156
- // Close extra pages early.
157
175
  let page = this.pages()[0];
158
176
  const [, ...otherPages] = this.pages();
159
- for (const p of otherPages) await p.close(metadata);
177
+ for (const p of otherPages)
178
+ await p.close(metadata);
160
179
  if (page && page.hasCrashed()) {
161
180
  await page.close(metadata);
162
- page = undefined;
181
+ page = void 0;
163
182
  }
164
-
165
- // Unless dialogs are dismissed, setting extra http headers below does not respond.
166
- (_page = page) === null || _page === void 0 || _page._frameManager.setCloseAllOpeningDialogs(true);
167
- await ((_page2 = page) === null || _page2 === void 0 ? void 0 : _page2._frameManager.closeOpenDialogs());
168
- // Navigate to about:blank first to ensure no page scripts are running after this point.
169
- await ((_page3 = page) === null || _page3 === void 0 ? void 0 : _page3.mainFrame().goto(metadata, 'about:blank', {
170
- timeout: 0
171
- }));
172
- (_page4 = page) === null || _page4 === void 0 || _page4._frameManager.setCloseAllOpeningDialogs(false);
183
+ page?._frameManager.setCloseAllOpeningDialogs(true);
184
+ await page?._frameManager.closeOpenDialogs();
185
+ await page?.mainFrame().goto(metadata, "about:blank", { timeout: 0 });
186
+ page?._frameManager.setCloseAllOpeningDialogs(false);
173
187
  await this._resetStorage();
174
188
  await this._removeExposedBindings();
175
189
  await this._removeInitScripts();
176
190
  this.clock.markAsUninstalled();
177
- // TODO: following can be optimized to not perform noops.
178
- if (this._options.permissions) await this.grantPermissions(this._options.permissions);else await this.clearPermissions();
191
+ if (this._options.permissions)
192
+ await this.grantPermissions(this._options.permissions);
193
+ else
194
+ await this.clearPermissions();
179
195
  await this.setExtraHTTPHeaders(this._options.extraHTTPHeaders || []);
180
196
  await this.setGeolocation(this._options.geolocation);
181
197
  await this.setOffline(!!this._options.offline);
182
198
  await this.setUserAgent(this._options.userAgent);
183
199
  await this.clearCache();
184
200
  await this._resetCookies();
185
- await ((_page5 = page) === null || _page5 === void 0 ? void 0 : _page5.resetForReuse(metadata));
201
+ await page?.resetForReuse(metadata);
186
202
  }
187
203
  _browserClosed() {
188
- for (const page of this.pages()) page._didClose();
204
+ for (const page of this.pages())
205
+ page._didClose();
189
206
  this._didCloseInternal();
190
207
  }
191
208
  _didCloseInternal() {
192
- var _this$_clientCertific;
193
- if (this._closedStatus === 'closed') {
194
- // We can come here twice if we close browser context and browser
195
- // at the same time.
209
+ if (this._closedStatus === "closed") {
196
210
  return;
197
211
  }
198
- (_this$_clientCertific = this._clientCertificatesProxy) === null || _this$_clientCertific === void 0 || _this$_clientCertific.close().catch(() => {});
212
+ this._clientCertificatesProxy?.close().catch(() => {
213
+ });
199
214
  this.tracing.abort();
200
- if (this._isPersistentContext) this.onClosePersistent();
201
- this._closePromiseFulfill(new Error('Context closed'));
215
+ if (this._isPersistentContext)
216
+ this.onClosePersistent();
217
+ this._closePromiseFulfill(new Error("Context closed"));
202
218
  this.emit(BrowserContext.Events.Close);
203
219
  }
204
-
205
- // BrowserContext methods.
206
-
220
+ pages() {
221
+ return this.possiblyUninitializedPages().filter((page) => page.initializedOrUndefined());
222
+ }
207
223
  async cookies(urls = []) {
208
- if (urls && !Array.isArray(urls)) urls = [urls];
224
+ if (urls && !Array.isArray(urls))
225
+ urls = [urls];
209
226
  return await this.doGetCookies(urls);
210
227
  }
211
228
  async clearCookies(options) {
212
229
  const currentCookies = await this.cookies();
213
230
  await this.doClearCookies();
214
231
  const matches = (cookie, prop, value) => {
215
- if (!value) return true;
232
+ if (!value)
233
+ return true;
216
234
  if (value instanceof RegExp) {
217
235
  value.lastIndex = 0;
218
236
  return value.test(cookie[prop]);
219
237
  }
220
238
  return cookie[prop] === value;
221
239
  };
222
- const cookiesToReadd = currentCookies.filter(cookie => {
223
- return !matches(cookie, 'name', options.name) || !matches(cookie, 'domain', options.domain) || !matches(cookie, 'path', options.path);
240
+ const cookiesToReadd = currentCookies.filter((cookie) => {
241
+ return !matches(cookie, "name", options.name) || !matches(cookie, "domain", options.domain) || !matches(cookie, "path", options.path);
224
242
  });
225
243
  await this.addCookies(cookiesToReadd);
226
244
  }
227
245
  setHTTPCredentials(httpCredentials) {
228
246
  return this.doSetHTTPCredentials(httpCredentials);
229
247
  }
248
+ hasBinding(name) {
249
+ return this._pageBindings.has(name);
250
+ }
230
251
  async exposeBinding(name, needsHandle, playwrightBinding) {
231
- if (this._pageBindings.has(name)) throw new Error(`Function "${name}" has been already registered`);
252
+ if (this._pageBindings.has(name))
253
+ throw new Error(`Function "${name}" has been already registered`);
232
254
  for (const page of this.pages()) {
233
- if (page.getBinding(name)) throw new Error(`Function "${name}" has been already registered in one of the pages`);
255
+ if (page.getBinding(name))
256
+ throw new Error(`Function "${name}" has been already registered in one of the pages`);
234
257
  }
235
- const binding = new _page6.PageBinding(name, playwrightBinding, needsHandle);
258
+ const binding = new import_page2.PageBinding(name, playwrightBinding, needsHandle);
236
259
  this._pageBindings.set(name, binding);
237
260
  await this.doAddInitScript(binding.initScript);
238
- const frames = this.pages().map(page => page.frames()).flat();
239
- await Promise.all(frames.map(frame => frame.evaluateExpression(binding.initScript.source).catch(e => {})));
261
+ const frames = this.pages().map((page) => page.frames()).flat();
262
+ await Promise.all(frames.map((frame) => frame.evaluateExpression(binding.initScript.source).catch((e) => {
263
+ })));
240
264
  }
241
265
  async _removeExposedBindings() {
242
266
  for (const [key, binding] of this._pageBindings) {
243
- if (!binding.internal) this._pageBindings.delete(key);
267
+ if (!binding.internal)
268
+ this._pageBindings.delete(key);
244
269
  }
245
270
  }
246
271
  async grantPermissions(permissions, origin) {
247
- let resolvedOrigin = '*';
272
+ let resolvedOrigin = "*";
248
273
  if (origin) {
249
274
  const url = new URL(origin);
250
275
  resolvedOrigin = url.origin;
251
276
  }
252
277
  const existing = new Set(this._permissions.get(resolvedOrigin) || []);
253
- permissions.forEach(p => existing.add(p));
278
+ permissions.forEach((p) => existing.add(p));
254
279
  const list = [...existing.values()];
255
280
  this._permissions.set(resolvedOrigin, list);
256
281
  await this.doGrantPermissions(resolvedOrigin, list);
@@ -266,66 +291,57 @@ class BrowserContext extends _instrumentation.SdkObject {
266
291
  this._timeoutSettings.setDefaultTimeout(timeout);
267
292
  }
268
293
  async _loadDefaultContextAsIs(progress) {
269
- if (!this.pages().length) {
270
- const waitForEvent = _helper.helper.waitForEvent(progress, this, BrowserContext.Events.Page);
294
+ if (!this.possiblyUninitializedPages().length) {
295
+ const waitForEvent = import_helper.helper.waitForEvent(progress, this, BrowserContext.Events.Page);
271
296
  progress.cleanupWhenAborted(() => waitForEvent.dispose);
272
- const page = await waitForEvent.promise;
273
- if (page._pageIsError) throw page._pageIsError;
297
+ await Promise.race([waitForEvent.promise, this._closePromise]);
274
298
  }
275
- const pages = this.pages();
276
- if (pages[0]._pageIsError) throw pages[0]._pageIsError;
277
- await pages[0].mainFrame()._waitForLoadState(progress, 'load');
278
- return pages;
299
+ const page = this.possiblyUninitializedPages()[0];
300
+ if (!page)
301
+ return;
302
+ const pageOrError = await page.waitForInitializedOrError();
303
+ if (pageOrError instanceof Error)
304
+ throw pageOrError;
305
+ await page.mainFrame()._waitForLoadState(progress, "load");
306
+ return page;
279
307
  }
280
308
  async _loadDefaultContext(progress) {
281
- const pages = await this._loadDefaultContextAsIs(progress);
309
+ const defaultPage = await this._loadDefaultContextAsIs(progress);
310
+ if (!defaultPage)
311
+ return;
282
312
  const browserName = this._browser.options.name;
283
- if (this._options.isMobile && browserName === 'chromium' || this._options.locale && browserName === 'webkit') {
284
- // Workaround for:
285
- // - chromium fails to change isMobile for existing page;
286
- // - webkit fails to change locale for existing page.
287
- const oldPage = pages[0];
313
+ if (this._options.isMobile && browserName === "chromium" || this._options.locale && browserName === "webkit") {
288
314
  await this.newPage(progress.metadata);
289
- await oldPage.close(progress.metadata);
315
+ await defaultPage.close(progress.metadata);
290
316
  }
291
317
  }
292
318
  _authenticateProxyViaHeader() {
293
- const proxy = this._options.proxy || this._browser.options.proxy || {
294
- username: undefined,
295
- password: undefined
296
- };
297
- const {
298
- username,
299
- password
300
- } = proxy;
319
+ const proxy = this._options.proxy || this._browser.options.proxy || { username: void 0, password: void 0 };
320
+ const { username, password } = proxy;
301
321
  if (username) {
302
- this._options.httpCredentials = {
303
- username,
304
- password: password
305
- };
306
- const token = Buffer.from(`${username}:${password}`).toString('base64');
307
- this._options.extraHTTPHeaders = network.mergeHeaders([this._options.extraHTTPHeaders, network.singleHeader('Proxy-Authorization', `Basic ${token}`)]);
322
+ this._options.httpCredentials = { username, password };
323
+ const token = Buffer.from(`${username}:${password}`).toString("base64");
324
+ this._options.extraHTTPHeaders = network.mergeHeaders([
325
+ this._options.extraHTTPHeaders,
326
+ network.singleHeader("Proxy-Authorization", `Basic ${token}`)
327
+ ]);
308
328
  }
309
329
  }
310
330
  _authenticateProxyViaCredentials() {
311
331
  const proxy = this._options.proxy || this._browser.options.proxy;
312
- if (!proxy) return;
313
- const {
314
- username,
315
- password
316
- } = proxy;
317
- if (username) this._options.httpCredentials = {
318
- username,
319
- password: password || ''
320
- };
332
+ if (!proxy)
333
+ return;
334
+ const { username, password } = proxy;
335
+ if (username)
336
+ this._options.httpCredentials = { username, password: password || "" };
321
337
  }
322
- async addInitScript(source) {
323
- const initScript = new _page6.InitScript(source);
338
+ async addInitScript(source, name) {
339
+ const initScript = new import_page.InitScript(source, false, name);
324
340
  this.initScripts.push(initScript);
325
341
  await this.doAddInitScript(initScript);
326
342
  }
327
343
  async _removeInitScripts() {
328
- this.initScripts = this.initScripts.filter(script => script.internal);
344
+ this.initScripts = this.initScripts.filter((script) => script.internal);
329
345
  await this.doRemoveNonInternalInitScripts();
330
346
  }
331
347
  async setRequestInterceptor(handler) {
@@ -333,58 +349,53 @@ class BrowserContext extends _instrumentation.SdkObject {
333
349
  await this.doUpdateRequestInterception();
334
350
  }
335
351
  isClosingOrClosed() {
336
- return this._closedStatus !== 'open';
352
+ return this._closedStatus !== "open";
337
353
  }
338
354
  async _deleteAllDownloads() {
339
- await Promise.all(Array.from(this._downloads).map(download => download.artifact.deleteOnContextClose()));
355
+ await Promise.all(Array.from(this._downloads).map((download) => download.artifact.deleteOnContextClose()));
340
356
  }
341
357
  async _deleteAllTempDirs() {
342
- await Promise.all(this._tempDirs.map(async dir => await _fs.default.promises.unlink(dir).catch(e => {})));
358
+ await Promise.all(this._tempDirs.map(async (dir) => await import_fs.default.promises.unlink(dir).catch((e) => {
359
+ })));
343
360
  }
344
361
  setCustomCloseHandler(handler) {
345
362
  this._customCloseHandler = handler;
346
363
  }
347
364
  async close(options) {
348
- if (this._closedStatus === 'open') {
349
- if (options.reason) this._closeReason = options.reason;
365
+ if (this._closedStatus === "open") {
366
+ if (options.reason)
367
+ this._closeReason = options.reason;
350
368
  this.emit(BrowserContext.Events.BeforeClose);
351
- this._closedStatus = 'closing';
352
- for (const harRecorder of this._harRecorders.values()) await harRecorder.flush();
369
+ this._closedStatus = "closing";
370
+ for (const harRecorder of this._harRecorders.values())
371
+ await harRecorder.flush();
353
372
  await this.tracing.flush();
354
-
355
- // Cleanup.
356
373
  const promises = [];
357
- for (const {
358
- context,
359
- artifact
360
- } of this._browser._idToVideo.values()) {
361
- // Wait for the videos to finish.
362
- if (context === this) promises.push(artifact.finishedPromise());
374
+ for (const { context, artifact } of this._browser._idToVideo.values()) {
375
+ if (context === this)
376
+ promises.push(artifact.finishedPromise());
363
377
  }
364
378
  if (this._customCloseHandler) {
365
379
  await this._customCloseHandler();
366
380
  } else {
367
- // Close the context.
368
381
  await this.doClose(options.reason);
369
382
  }
370
-
371
- // We delete downloads after context closure
372
- // so that browser does not write to the download file anymore.
373
383
  promises.push(this._deleteAllDownloads());
374
384
  promises.push(this._deleteAllTempDirs());
375
385
  await Promise.all(promises);
376
-
377
- // Custom handler should trigger didCloseInternal itself.
378
- if (!this._customCloseHandler) this._didCloseInternal();
386
+ if (!this._customCloseHandler)
387
+ this._didCloseInternal();
379
388
  }
380
389
  await this._closePromise;
381
390
  }
382
391
  async newPage(metadata) {
383
- const pageDelegate = await this.newPageDelegate();
384
- if (metadata.isServerSide) pageDelegate.potentiallyUninitializedPage().markAsServerSideOnly();
385
- const pageOrError = await pageDelegate.pageOrError();
386
- if (pageOrError instanceof _page6.Page) {
387
- if (pageOrError.isClosed()) throw new Error('Page has been closed.');
392
+ const page = await this.doCreateNewPage();
393
+ if (metadata.isServerSide)
394
+ page.markAsServerSideOnly();
395
+ const pageOrError = await page.waitForInitializedOrError();
396
+ if (pageOrError instanceof import_page2.Page) {
397
+ if (pageOrError.isClosed())
398
+ throw new Error("Page has been closed.");
388
399
  return pageOrError;
389
400
  }
390
401
  throw pageOrError;
@@ -392,92 +403,74 @@ class BrowserContext extends _instrumentation.SdkObject {
392
403
  addVisitedOrigin(origin) {
393
404
  this._origins.add(origin);
394
405
  }
395
- async storageState() {
406
+ async storageState(indexedDB = false) {
396
407
  const result = {
397
408
  cookies: await this.cookies(),
398
409
  origins: []
399
410
  };
400
411
  const originsToSave = new Set(this._origins);
401
-
402
- // First try collecting storage stage from existing pages.
412
+ const collectScript = `(${storageScript.collect})(${utilityScriptSerializers.source}, (${import_builtins.builtins})(), ${this._browser.options.name === "firefox"}, ${indexedDB})`;
403
413
  for (const page of this.pages()) {
404
414
  const origin = page.mainFrame().origin();
405
- if (!origin || !originsToSave.has(origin)) continue;
415
+ if (!origin || !originsToSave.has(origin))
416
+ continue;
406
417
  try {
407
- const storage = await page.mainFrame().nonStallingEvaluateInExistingContext(`({
408
- localStorage: Object.keys(localStorage).map(name => ({ name, value: localStorage.getItem(name) })),
409
- })`, 'utility');
410
- if (storage.localStorage.length) result.origins.push({
411
- origin,
412
- localStorage: storage.localStorage
413
- });
418
+ const storage = await page.mainFrame().nonStallingEvaluateInExistingContext(collectScript, "utility");
419
+ if (storage.localStorage.length || storage.indexedDB?.length)
420
+ result.origins.push({ origin, localStorage: storage.localStorage, indexedDB: storage.indexedDB });
414
421
  originsToSave.delete(origin);
415
422
  } catch {
416
- // When failed on the live page, we'll retry on the blank page below.
417
423
  }
418
424
  }
419
-
420
- // If there are still origins to save, create a blank page to iterate over origins.
421
425
  if (originsToSave.size) {
422
- const internalMetadata = (0, _instrumentation.serverSideCallMetadata)();
426
+ const internalMetadata = (0, import_instrumentation.serverSideCallMetadata)();
423
427
  const page = await this.newPage(internalMetadata);
424
- await page._setServerRequestInterceptor(handler => {
425
- handler.fulfill({
426
- body: '<html></html>'
427
- }).catch(() => {});
428
+ await page._setServerRequestInterceptor((handler) => {
429
+ handler.fulfill({ body: "<html></html>" }).catch(() => {
430
+ });
428
431
  return true;
429
432
  });
430
433
  for (const origin of originsToSave) {
431
- const originStorage = {
432
- origin,
433
- localStorage: []
434
- };
435
434
  const frame = page.mainFrame();
436
435
  await frame.goto(internalMetadata, origin);
437
- const storage = await frame.evaluateExpression(`({
438
- localStorage: Object.keys(localStorage).map(name => ({ name, value: localStorage.getItem(name) })),
439
- })`, {
440
- world: 'utility'
441
- });
442
- originStorage.localStorage = storage.localStorage;
443
- if (storage.localStorage.length) result.origins.push(originStorage);
436
+ const storage = await frame.evaluateExpression(collectScript, { world: "utility" });
437
+ if (storage.localStorage.length || storage.indexedDB?.length)
438
+ result.origins.push({ origin, localStorage: storage.localStorage, indexedDB: storage.indexedDB });
444
439
  }
445
440
  await page.close(internalMetadata);
446
441
  }
447
442
  return result;
448
443
  }
449
444
  async _resetStorage() {
450
- var _this$_options$storag;
451
445
  const oldOrigins = this._origins;
452
- const newOrigins = new Map(((_this$_options$storag = this._options.storageState) === null || _this$_options$storag === void 0 || (_this$_options$storag = _this$_options$storag.origins) === null || _this$_options$storag === void 0 ? void 0 : _this$_options$storag.map(p => [p.origin, p])) || []);
453
- if (!oldOrigins.size && !newOrigins.size) return;
446
+ const newOrigins = new Map(this._options.storageState?.origins?.map((p) => [p.origin, p]) || []);
447
+ if (!oldOrigins.size && !newOrigins.size)
448
+ return;
454
449
  let page = this.pages()[0];
455
- const internalMetadata = (0, _instrumentation.serverSideCallMetadata)();
456
- page = page || (await this.newPage({
450
+ const internalMetadata = (0, import_instrumentation.serverSideCallMetadata)();
451
+ page = page || await this.newPage({
457
452
  ...internalMetadata,
458
453
  // Do not mark this page as internal, because we will leave it for later reuse
459
454
  // as a user-visible page.
460
455
  isServerSide: false
461
- }));
462
- await page._setServerRequestInterceptor(handler => {
463
- handler.fulfill({
464
- body: '<html></html>'
465
- }).catch(() => {});
456
+ });
457
+ await page._setServerRequestInterceptor((handler) => {
458
+ handler.fulfill({ body: "<html></html>" }).catch(() => {
459
+ });
466
460
  return true;
467
461
  });
468
- for (const origin of new Set([...oldOrigins, ...newOrigins.keys()])) {
462
+ for (const origin of /* @__PURE__ */ new Set([...oldOrigins, ...newOrigins.keys()])) {
469
463
  const frame = page.mainFrame();
470
464
  await frame.goto(internalMetadata, origin);
471
465
  await frame.resetStorageForCurrentOriginBestEffort(newOrigins.get(origin));
472
466
  }
473
- await page._setServerRequestInterceptor(undefined);
474
- this._origins = new Set([...newOrigins.keys()]);
475
- // It is safe to not restore the URL to about:blank since we are doing it in Page::resetForReuse.
467
+ await page._setServerRequestInterceptor(void 0);
468
+ this._origins = /* @__PURE__ */ new Set([...newOrigins.keys()]);
476
469
  }
477
470
  async _resetCookies() {
478
- var _this$_options$storag2, _this$_options$storag3;
479
471
  await this.doClearCookies();
480
- if ((_this$_options$storag2 = this._options.storageState) !== null && _this$_options$storag2 !== void 0 && _this$_options$storag2.cookies) await this.addCookies((_this$_options$storag3 = this._options.storageState) === null || _this$_options$storag3 === void 0 ? void 0 : _this$_options$storag3.cookies);
472
+ if (this._options.storageState?.cookies)
473
+ await this.addCookies(this._options.storageState?.cookies);
481
474
  }
482
475
  isSettingStorageState() {
483
476
  return this._settingStorageState;
@@ -485,27 +478,20 @@ class BrowserContext extends _instrumentation.SdkObject {
485
478
  async setStorageState(metadata, state) {
486
479
  this._settingStorageState = true;
487
480
  try {
488
- if (state.cookies) await this.addCookies(state.cookies);
481
+ if (state.cookies)
482
+ await this.addCookies(state.cookies);
489
483
  if (state.origins && state.origins.length) {
490
- const internalMetadata = (0, _instrumentation.serverSideCallMetadata)();
484
+ const internalMetadata = (0, import_instrumentation.serverSideCallMetadata)();
491
485
  const page = await this.newPage(internalMetadata);
492
- await page._setServerRequestInterceptor(handler => {
493
- handler.fulfill({
494
- body: '<html></html>'
495
- }).catch(() => {});
486
+ await page._setServerRequestInterceptor((handler) => {
487
+ handler.fulfill({ body: "<html></html>" }).catch(() => {
488
+ });
496
489
  return true;
497
490
  });
498
491
  for (const originState of state.origins) {
499
492
  const frame = page.mainFrame();
500
493
  await frame.goto(metadata, originState.origin);
501
- await frame.evaluateExpression(`
502
- originState => {
503
- for (const { name, value } of (originState.localStorage || []))
504
- localStorage.setItem(name, value);
505
- }`, {
506
- isFunction: true,
507
- world: 'utility'
508
- }, originState);
494
+ await frame.evaluateExpression(`(${storageScript.restore})(${utilityScriptSerializers.source}, (${import_builtins.builtins})(), ${JSON.stringify(originState)})`, { world: "utility" });
509
495
  }
510
496
  await page.close(internalMetadata);
511
497
  }
@@ -514,24 +500,25 @@ class BrowserContext extends _instrumentation.SdkObject {
514
500
  }
515
501
  }
516
502
  async extendInjectedScript(source, arg) {
517
- const installInFrame = frame => frame.extendInjectedScript(source, arg).catch(() => {});
518
- const installInPage = page => {
519
- page.on(_page6.Page.Events.InternalFrameNavigatedToNewDocument, installInFrame);
503
+ const installInFrame = (frame) => frame.extendInjectedScript(source, arg).catch(() => {
504
+ });
505
+ const installInPage = (page) => {
506
+ page.on(import_page2.Page.Events.InternalFrameNavigatedToNewDocument, installInFrame);
520
507
  return Promise.all(page.frames().map(installInFrame));
521
508
  };
522
509
  this.on(BrowserContext.Events.Page, installInPage);
523
510
  return Promise.all(this.pages().map(installInPage));
524
511
  }
525
512
  async safeNonStallingEvaluateInAllFrames(expression, world, options = {}) {
526
- await Promise.all(this.pages().map(page => page.safeNonStallingEvaluateInAllFrames(expression, world, options)));
513
+ await Promise.all(this.pages().map((page) => page.safeNonStallingEvaluateInAllFrames(expression, world, options)));
527
514
  }
528
515
  async _harStart(page, options) {
529
- const harId = (0, _utils.createGuid)();
530
- this._harRecorders.set(harId, new _harRecorder.HarRecorder(this, page, options));
516
+ const harId = (0, import_crypto.createGuid)();
517
+ this._harRecorders.set(harId, new import_harRecorder.HarRecorder(this, page, options));
531
518
  return harId;
532
519
  }
533
520
  async _harExport(harId) {
534
- const recorder = this._harRecorders.get(harId || '');
521
+ const recorder = this._harRecorders.get(harId || "");
535
522
  return recorder.export();
536
523
  }
537
524
  addRouteInFlight(route) {
@@ -541,53 +528,32 @@ class BrowserContext extends _instrumentation.SdkObject {
541
528
  this._routesInFlight.delete(route);
542
529
  }
543
530
  async _cancelAllRoutesInFlight() {
544
- await Promise.all([...this._routesInFlight].map(r => r.abort())).catch(() => {});
531
+ await Promise.all([...this._routesInFlight].map((r) => r.abort())).catch(() => {
532
+ });
545
533
  this._routesInFlight.clear();
546
534
  }
547
535
  }
548
- exports.BrowserContext = BrowserContext;
549
- BrowserContext.Events = {
550
- Console: 'console',
551
- Close: 'close',
552
- Dialog: 'dialog',
553
- Page: 'page',
554
- // Can't use just 'error' due to node.js special treatment of error events.
555
- // @see https://nodejs.org/api/events.html#events_error_events
556
- PageError: 'pageerror',
557
- Request: 'request',
558
- Response: 'response',
559
- RequestFailed: 'requestfailed',
560
- RequestFinished: 'requestfinished',
561
- RequestAborted: 'requestaborted',
562
- RequestFulfilled: 'requestfulfilled',
563
- RequestContinued: 'requestcontinued',
564
- BeforeClose: 'beforeclose',
565
- VideoStarted: 'videostarted'
566
- };
567
536
  function assertBrowserContextIsNotOwned(context) {
568
537
  for (const page of context.pages()) {
569
- if (page._ownedContext) throw new Error('Please use browser.newContext() for multi-page scripts that share the context.');
538
+ if (page._ownedContext)
539
+ throw new Error("Please use browser.newContext() for multi-page scripts that share the context.");
570
540
  }
571
541
  }
572
542
  function validateBrowserContextOptions(options, browserOptions) {
573
- if (options.noDefaultViewport && options.deviceScaleFactor !== undefined) throw new Error(`"deviceScaleFactor" option is not supported with null "viewport"`);
574
- if (options.noDefaultViewport && !!options.isMobile) throw new Error(`"isMobile" option is not supported with null "viewport"`);
575
- if (options.acceptDownloads === undefined && browserOptions.name !== 'electron') options.acceptDownloads = 'accept';
576
- // Electron requires explicit acceptDownloads: true since we wait for
577
- // https://github.com/electron/electron/pull/41718 to be widely shipped.
578
- // In 6-12 months, we can remove this check.
579
- else if (options.acceptDownloads === undefined && browserOptions.name === 'electron') options.acceptDownloads = 'internal-browser-default';
580
- if (!options.viewport && !options.noDefaultViewport) options.viewport = {
581
- width: 1280,
582
- height: 720
583
- };
543
+ if (options.noDefaultViewport && options.deviceScaleFactor !== void 0)
544
+ throw new Error(`"deviceScaleFactor" option is not supported with null "viewport"`);
545
+ if (options.noDefaultViewport && !!options.isMobile)
546
+ throw new Error(`"isMobile" option is not supported with null "viewport"`);
547
+ if (options.acceptDownloads === void 0 && browserOptions.name !== "electron")
548
+ options.acceptDownloads = "accept";
549
+ else if (options.acceptDownloads === void 0 && browserOptions.name === "electron")
550
+ options.acceptDownloads = "internal-browser-default";
551
+ if (!options.viewport && !options.noDefaultViewport)
552
+ options.viewport = { width: 1280, height: 720 };
584
553
  if (options.recordVideo) {
585
554
  if (!options.recordVideo.size) {
586
555
  if (options.noDefaultViewport) {
587
- options.recordVideo.size = {
588
- width: 800,
589
- height: 600
590
- };
556
+ options.recordVideo.size = { width: 800, height: 600 };
591
557
  } else {
592
558
  const size = options.viewport;
593
559
  const scale = Math.min(1, 800 / Math.max(size.width, size.height));
@@ -597,61 +563,69 @@ function validateBrowserContextOptions(options, browserOptions) {
597
563
  };
598
564
  }
599
565
  }
600
- // Make sure both dimensions are odd, this is required for vp8
601
566
  options.recordVideo.size.width &= ~1;
602
567
  options.recordVideo.size.height &= ~1;
603
568
  }
604
- if (options.proxy) options.proxy = normalizeProxySettings(options.proxy);
569
+ if (options.proxy)
570
+ options.proxy = normalizeProxySettings(options.proxy);
605
571
  verifyGeolocation(options.geolocation);
606
572
  }
607
573
  function verifyGeolocation(geolocation) {
608
- if (!geolocation) return;
574
+ if (!geolocation)
575
+ return;
609
576
  geolocation.accuracy = geolocation.accuracy || 0;
610
- const {
611
- longitude,
612
- latitude,
613
- accuracy
614
- } = geolocation;
615
- if (longitude < -180 || longitude > 180) throw new Error(`geolocation.longitude: precondition -180 <= LONGITUDE <= 180 failed.`);
616
- if (latitude < -90 || latitude > 90) throw new Error(`geolocation.latitude: precondition -90 <= LATITUDE <= 90 failed.`);
617
- if (accuracy < 0) throw new Error(`geolocation.accuracy: precondition 0 <= ACCURACY failed.`);
577
+ const { longitude, latitude, accuracy } = geolocation;
578
+ if (longitude < -180 || longitude > 180)
579
+ throw new Error(`geolocation.longitude: precondition -180 <= LONGITUDE <= 180 failed.`);
580
+ if (latitude < -90 || latitude > 90)
581
+ throw new Error(`geolocation.latitude: precondition -90 <= LATITUDE <= 90 failed.`);
582
+ if (accuracy < 0)
583
+ throw new Error(`geolocation.accuracy: precondition 0 <= ACCURACY failed.`);
618
584
  }
619
585
  function verifyClientCertificates(clientCertificates) {
620
- if (!clientCertificates) return;
586
+ if (!clientCertificates)
587
+ return;
621
588
  for (const cert of clientCertificates) {
622
- if (!cert.origin) throw new Error(`clientCertificates.origin is required`);
623
- if (!cert.cert && !cert.key && !cert.passphrase && !cert.pfx) throw new Error('None of cert, key, passphrase or pfx is specified');
624
- if (cert.cert && !cert.key) throw new Error('cert is specified without key');
625
- if (!cert.cert && cert.key) throw new Error('key is specified without cert');
626
- if (cert.pfx && (cert.cert || cert.key)) throw new Error('pfx is specified together with cert, key or passphrase');
589
+ if (!cert.origin)
590
+ throw new Error(`clientCertificates.origin is required`);
591
+ if (!cert.cert && !cert.key && !cert.passphrase && !cert.pfx)
592
+ throw new Error("None of cert, key, passphrase or pfx is specified");
593
+ if (cert.cert && !cert.key)
594
+ throw new Error("cert is specified without key");
595
+ if (!cert.cert && cert.key)
596
+ throw new Error("key is specified without cert");
597
+ if (cert.pfx && (cert.cert || cert.key))
598
+ throw new Error("pfx is specified together with cert, key or passphrase");
627
599
  }
628
600
  }
629
601
  function normalizeProxySettings(proxy) {
630
- let {
631
- server,
632
- bypass
633
- } = proxy;
602
+ let { server, bypass } = proxy;
634
603
  let url;
635
604
  try {
636
- // new URL('127.0.0.1:8080') throws
637
- // new URL('localhost:8080') fails to parse host or protocol
638
- // In both of these cases, we need to try re-parse URL with `http://` prefix.
639
605
  url = new URL(server);
640
- if (!url.host || !url.protocol) url = new URL('http://' + server);
606
+ if (!url.host || !url.protocol)
607
+ url = new URL("http://" + server);
641
608
  } catch (e) {
642
- url = new URL('http://' + server);
643
- }
644
- if (url.protocol === 'socks4:' && (proxy.username || proxy.password)) throw new Error(`Socks4 proxy protocol does not support authentication`);
645
- if (url.protocol === 'socks5:' && (proxy.username || proxy.password)) throw new Error(`Browser does not support socks5 proxy authentication`);
646
- server = url.protocol + '//' + url.host;
647
- if (bypass) bypass = bypass.split(',').map(t => t.trim()).join(',');
648
- return {
649
- ...proxy,
650
- server,
651
- bypass
652
- };
609
+ url = new URL("http://" + server);
610
+ }
611
+ if (url.protocol === "socks4:" && (proxy.username || proxy.password))
612
+ throw new Error(`Socks4 proxy protocol does not support authentication`);
613
+ if (url.protocol === "socks5:" && (proxy.username || proxy.password))
614
+ throw new Error(`Browser does not support socks5 proxy authentication`);
615
+ server = url.protocol + "//" + url.host;
616
+ if (bypass)
617
+ bypass = bypass.split(",").map((t) => t.trim()).join(",");
618
+ return { ...proxy, server, bypass };
653
619
  }
654
- const paramsThatAllowContextReuse = ['colorScheme', 'forcedColors', 'reducedMotion', 'screen', 'userAgent', 'viewport'];
620
+ const paramsThatAllowContextReuse = [
621
+ "colorScheme",
622
+ "forcedColors",
623
+ "reducedMotion",
624
+ "contrast",
625
+ "screen",
626
+ "userAgent",
627
+ "viewport"
628
+ ];
655
629
  const defaultNewContextParamValues = {
656
630
  noDefaultViewport: false,
657
631
  ignoreHTTPSErrors: false,
@@ -660,8 +634,17 @@ const defaultNewContextParamValues = {
660
634
  offline: false,
661
635
  isMobile: false,
662
636
  hasTouch: false,
663
- acceptDownloads: 'accept',
637
+ acceptDownloads: "accept",
664
638
  strictSelectors: false,
665
- serviceWorkers: 'allow',
666
- locale: 'en-US'
667
- };
639
+ serviceWorkers: "allow",
640
+ locale: "en-US"
641
+ };
642
+ // Annotate the CommonJS export names for ESM import in node:
643
+ 0 && (module.exports = {
644
+ BrowserContext,
645
+ assertBrowserContextIsNotOwned,
646
+ normalizeProxySettings,
647
+ validateBrowserContextOptions,
648
+ verifyClientCertificates,
649
+ verifyGeolocation
650
+ });