patchright-bun-core 1.58.0 → 1.58.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (358) hide show
  1. package/README.md +2 -2
  2. package/ThirdPartyNotices.txt +4075 -4075
  3. package/bin/install_media_pack.ps1 +5 -5
  4. package/bin/install_webkit_wsl.ps1 +32 -32
  5. package/bin/reinstall_chrome_beta_linux.sh +42 -42
  6. package/bin/reinstall_chrome_beta_mac.sh +13 -13
  7. package/bin/reinstall_chrome_beta_win.ps1 +24 -24
  8. package/bin/reinstall_chrome_stable_linux.sh +42 -42
  9. package/bin/reinstall_chrome_stable_mac.sh +12 -12
  10. package/bin/reinstall_chrome_stable_win.ps1 +24 -24
  11. package/bin/reinstall_msedge_beta_linux.sh +48 -48
  12. package/bin/reinstall_msedge_beta_mac.sh +11 -11
  13. package/bin/reinstall_msedge_beta_win.ps1 +23 -23
  14. package/bin/reinstall_msedge_dev_linux.sh +48 -48
  15. package/bin/reinstall_msedge_dev_mac.sh +11 -11
  16. package/bin/reinstall_msedge_dev_win.ps1 +23 -23
  17. package/bin/reinstall_msedge_stable_linux.sh +48 -48
  18. package/bin/reinstall_msedge_stable_mac.sh +11 -11
  19. package/bin/reinstall_msedge_stable_win.ps1 +23 -23
  20. package/browsers.json +79 -79
  21. package/cli.js +18 -18
  22. package/index.d.ts +17 -17
  23. package/index.js +32 -32
  24. package/index.mjs +28 -28
  25. package/lib/androidServerImpl.js +65 -65
  26. package/lib/browserServerImpl.js +120 -120
  27. package/lib/cli/driver.js +97 -97
  28. package/lib/cli/program.js +589 -589
  29. package/lib/cli/programWithTestStub.js +74 -74
  30. package/lib/client/android.js +361 -361
  31. package/lib/client/api.js +137 -137
  32. package/lib/client/artifact.js +79 -79
  33. package/lib/client/browser.js +161 -161
  34. package/lib/client/browserContext.js +582 -582
  35. package/lib/client/browserType.js +185 -185
  36. package/lib/client/cdpSession.js +51 -51
  37. package/lib/client/channelOwner.js +194 -194
  38. package/lib/client/clientHelper.js +64 -64
  39. package/lib/client/clientInstrumentation.js +55 -55
  40. package/lib/client/clientStackTrace.js +69 -69
  41. package/lib/client/clock.js +68 -68
  42. package/lib/client/connection.js +318 -318
  43. package/lib/client/consoleMessage.js +58 -58
  44. package/lib/client/coverage.js +44 -44
  45. package/lib/client/dialog.js +56 -56
  46. package/lib/client/download.js +62 -62
  47. package/lib/client/electron.js +138 -138
  48. package/lib/client/elementHandle.js +284 -284
  49. package/lib/client/errors.js +77 -77
  50. package/lib/client/eventEmitter.js +314 -314
  51. package/lib/client/events.js +103 -103
  52. package/lib/client/fetch.js +368 -368
  53. package/lib/client/fileChooser.js +46 -46
  54. package/lib/client/fileUtils.js +34 -34
  55. package/lib/client/frame.js +409 -409
  56. package/lib/client/harRouter.js +87 -87
  57. package/lib/client/input.js +84 -84
  58. package/lib/client/jsHandle.js +109 -109
  59. package/lib/client/jsonPipe.js +39 -39
  60. package/lib/client/localUtils.js +60 -60
  61. package/lib/client/locator.js +369 -369
  62. package/lib/client/network.js +747 -747
  63. package/lib/client/page.js +745 -745
  64. package/lib/client/pageAgent.js +64 -64
  65. package/lib/client/platform.js +77 -77
  66. package/lib/client/playwright.js +71 -71
  67. package/lib/client/selectors.js +55 -55
  68. package/lib/client/stream.js +39 -39
  69. package/lib/client/timeoutSettings.js +79 -79
  70. package/lib/client/tracing.js +119 -119
  71. package/lib/client/types.js +28 -28
  72. package/lib/client/video.js +59 -59
  73. package/lib/client/waiter.js +142 -142
  74. package/lib/client/webError.js +39 -39
  75. package/lib/client/webSocket.js +93 -93
  76. package/lib/client/worker.js +85 -85
  77. package/lib/client/writableStream.js +39 -39
  78. package/lib/generated/bindingsControllerSource.js +28 -28
  79. package/lib/generated/clockSource.js +28 -28
  80. package/lib/generated/injectedScriptSource.js +28 -28
  81. package/lib/generated/pollingRecorderSource.js +28 -28
  82. package/lib/generated/storageScriptSource.js +28 -28
  83. package/lib/generated/utilityScriptSource.js +28 -28
  84. package/lib/generated/webSocketMockSource.js +336 -336
  85. package/lib/inProcessFactory.js +60 -60
  86. package/lib/inprocess.js +3 -3
  87. package/lib/mcpBundle.js +84 -84
  88. package/lib/mcpBundleImpl/index.js +147 -147
  89. package/lib/outofprocess.js +76 -76
  90. package/lib/protocol/serializers.js +197 -197
  91. package/lib/protocol/validator.js +2969 -2969
  92. package/lib/protocol/validatorPrimitives.js +193 -193
  93. package/lib/remote/playwrightConnection.js +129 -129
  94. package/lib/remote/playwrightServer.js +334 -334
  95. package/lib/server/agent/actionRunner.js +335 -335
  96. package/lib/server/agent/actions.js +128 -128
  97. package/lib/server/agent/codegen.js +111 -111
  98. package/lib/server/agent/context.js +150 -150
  99. package/lib/server/agent/expectTools.js +156 -156
  100. package/lib/server/agent/pageAgent.js +204 -204
  101. package/lib/server/agent/performTools.js +262 -262
  102. package/lib/server/agent/tool.js +109 -109
  103. package/lib/server/android/android.js +465 -465
  104. package/lib/server/android/backendAdb.js +177 -177
  105. package/lib/server/artifact.js +127 -127
  106. package/lib/server/bidi/bidiBrowser.js +549 -549
  107. package/lib/server/bidi/bidiChromium.js +149 -148
  108. package/lib/server/bidi/bidiConnection.js +213 -213
  109. package/lib/server/bidi/bidiDeserializer.js +116 -116
  110. package/lib/server/bidi/bidiExecutionContext.js +267 -267
  111. package/lib/server/bidi/bidiFirefox.js +128 -128
  112. package/lib/server/bidi/bidiInput.js +146 -146
  113. package/lib/server/bidi/bidiNetworkManager.js +383 -383
  114. package/lib/server/bidi/bidiOverCdp.js +102 -102
  115. package/lib/server/bidi/bidiPage.js +583 -583
  116. package/lib/server/bidi/bidiPdf.js +106 -106
  117. package/lib/server/bidi/third_party/bidiCommands.d.js +22 -22
  118. package/lib/server/bidi/third_party/bidiKeyboard.js +256 -256
  119. package/lib/server/bidi/third_party/bidiProtocol.js +24 -24
  120. package/lib/server/bidi/third_party/bidiProtocolCore.js +180 -180
  121. package/lib/server/bidi/third_party/bidiProtocolPermissions.js +42 -42
  122. package/lib/server/bidi/third_party/bidiSerializer.js +148 -148
  123. package/lib/server/bidi/third_party/firefoxPrefs.js +259 -259
  124. package/lib/server/browser.js +149 -149
  125. package/lib/server/browserContext.js +702 -702
  126. package/lib/server/browserType.js +336 -336
  127. package/lib/server/callLog.js +82 -82
  128. package/lib/server/chromium/chromium.js +397 -395
  129. package/lib/server/chromium/chromiumSwitches.js +104 -104
  130. package/lib/server/chromium/crBrowser.js +520 -511
  131. package/lib/server/chromium/crConnection.js +197 -197
  132. package/lib/server/chromium/crCoverage.js +235 -235
  133. package/lib/server/chromium/crDevTools.js +111 -111
  134. package/lib/server/chromium/crDragDrop.js +131 -131
  135. package/lib/server/chromium/crExecutionContext.js +146 -146
  136. package/lib/server/chromium/crInput.js +187 -187
  137. package/lib/server/chromium/crNetworkManager.js +707 -707
  138. package/lib/server/chromium/crPage.js +1001 -1001
  139. package/lib/server/chromium/crPdf.js +121 -121
  140. package/lib/server/chromium/crProtocolHelper.js +145 -145
  141. package/lib/server/chromium/crServiceWorker.js +136 -136
  142. package/lib/server/chromium/defaultFontFamilies.js +162 -162
  143. package/lib/server/chromium/protocol.d.js +16 -16
  144. package/lib/server/clock.js +149 -149
  145. package/lib/server/codegen/csharp.js +327 -327
  146. package/lib/server/codegen/java.js +274 -274
  147. package/lib/server/codegen/javascript.js +247 -247
  148. package/lib/server/codegen/jsonl.js +52 -52
  149. package/lib/server/codegen/language.js +132 -132
  150. package/lib/server/codegen/languages.js +68 -68
  151. package/lib/server/codegen/python.js +279 -279
  152. package/lib/server/codegen/types.js +16 -16
  153. package/lib/server/console.js +57 -57
  154. package/lib/server/cookieStore.js +206 -206
  155. package/lib/server/debugController.js +191 -191
  156. package/lib/server/debugger.js +119 -119
  157. package/lib/server/deviceDescriptors.js +39 -39
  158. package/lib/server/deviceDescriptorsSource.json +1778 -1778
  159. package/lib/server/dialog.js +116 -116
  160. package/lib/server/dispatchers/androidDispatcher.js +325 -325
  161. package/lib/server/dispatchers/artifactDispatcher.js +118 -118
  162. package/lib/server/dispatchers/browserContextDispatcher.js +384 -384
  163. package/lib/server/dispatchers/browserDispatcher.js +118 -118
  164. package/lib/server/dispatchers/browserTypeDispatcher.js +64 -64
  165. package/lib/server/dispatchers/cdpSessionDispatcher.js +44 -44
  166. package/lib/server/dispatchers/debugControllerDispatcher.js +78 -78
  167. package/lib/server/dispatchers/dialogDispatcher.js +47 -47
  168. package/lib/server/dispatchers/dispatcher.js +364 -364
  169. package/lib/server/dispatchers/electronDispatcher.js +89 -89
  170. package/lib/server/dispatchers/elementHandlerDispatcher.js +181 -181
  171. package/lib/server/dispatchers/frameDispatcher.js +227 -227
  172. package/lib/server/dispatchers/jsHandleDispatcher.js +85 -85
  173. package/lib/server/dispatchers/jsonPipeDispatcher.js +58 -58
  174. package/lib/server/dispatchers/localUtilsDispatcher.js +149 -149
  175. package/lib/server/dispatchers/networkDispatchers.js +213 -213
  176. package/lib/server/dispatchers/pageAgentDispatcher.js +96 -96
  177. package/lib/server/dispatchers/pageDispatcher.js +393 -393
  178. package/lib/server/dispatchers/playwrightDispatcher.js +108 -108
  179. package/lib/server/dispatchers/streamDispatcher.js +67 -67
  180. package/lib/server/dispatchers/tracingDispatcher.js +68 -68
  181. package/lib/server/dispatchers/webSocketRouteDispatcher.js +165 -165
  182. package/lib/server/dispatchers/writableStreamDispatcher.js +79 -79
  183. package/lib/server/dom.js +815 -815
  184. package/lib/server/download.js +70 -70
  185. package/lib/server/electron/electron.js +273 -273
  186. package/lib/server/electron/loader.js +29 -29
  187. package/lib/server/errors.js +69 -69
  188. package/lib/server/fetch.js +621 -621
  189. package/lib/server/fileChooser.js +43 -43
  190. package/lib/server/fileUploadUtils.js +84 -84
  191. package/lib/server/firefox/ffBrowser.js +418 -418
  192. package/lib/server/firefox/ffConnection.js +142 -142
  193. package/lib/server/firefox/ffExecutionContext.js +150 -150
  194. package/lib/server/firefox/ffInput.js +159 -159
  195. package/lib/server/firefox/ffNetworkManager.js +256 -256
  196. package/lib/server/firefox/ffPage.js +497 -497
  197. package/lib/server/firefox/firefox.js +114 -114
  198. package/lib/server/firefox/protocol.d.js +16 -16
  199. package/lib/server/formData.js +147 -147
  200. package/lib/server/frameSelectors.js +160 -160
  201. package/lib/server/frames.js +1471 -1471
  202. package/lib/server/har/harRecorder.js +147 -147
  203. package/lib/server/har/harTracer.js +607 -607
  204. package/lib/server/harBackend.js +157 -157
  205. package/lib/server/helper.js +96 -96
  206. package/lib/server/index.js +58 -58
  207. package/lib/server/input.js +277 -277
  208. package/lib/server/instrumentation.js +72 -72
  209. package/lib/server/javascript.js +291 -291
  210. package/lib/server/launchApp.js +128 -128
  211. package/lib/server/localUtils.js +214 -214
  212. package/lib/server/macEditingCommands.js +143 -143
  213. package/lib/server/network.js +667 -667
  214. package/lib/server/page.js +830 -830
  215. package/lib/server/pipeTransport.js +89 -89
  216. package/lib/server/playwright.js +69 -69
  217. package/lib/server/progress.js +132 -132
  218. package/lib/server/protocolError.js +52 -52
  219. package/lib/server/recorder/chat.js +161 -161
  220. package/lib/server/recorder/recorderApp.js +366 -366
  221. package/lib/server/recorder/recorderRunner.js +138 -138
  222. package/lib/server/recorder/recorderSignalProcessor.js +83 -83
  223. package/lib/server/recorder/recorderUtils.js +157 -157
  224. package/lib/server/recorder/throttledFile.js +57 -57
  225. package/lib/server/recorder.js +499 -499
  226. package/lib/server/registry/browserFetcher.js +177 -177
  227. package/lib/server/registry/dependencies.js +371 -371
  228. package/lib/server/registry/index.js +1422 -1422
  229. package/lib/server/registry/nativeDeps.js +1280 -1280
  230. package/lib/server/registry/oopDownloadBrowserMain.js +127 -127
  231. package/lib/server/screencast.js +190 -190
  232. package/lib/server/screenshotter.js +333 -333
  233. package/lib/server/selectors.js +112 -112
  234. package/lib/server/socksClientCertificatesInterceptor.js +383 -383
  235. package/lib/server/socksInterceptor.js +95 -95
  236. package/lib/server/trace/recorder/snapshotter.js +147 -147
  237. package/lib/server/trace/recorder/snapshotterInjected.js +561 -561
  238. package/lib/server/trace/recorder/tracing.js +604 -604
  239. package/lib/server/trace/viewer/traceParser.js +72 -72
  240. package/lib/server/trace/viewer/traceViewer.js +245 -245
  241. package/lib/server/transport.js +254 -254
  242. package/lib/server/types.js +28 -28
  243. package/lib/server/usKeyboardLayout.js +145 -145
  244. package/lib/server/utils/ascii.js +44 -44
  245. package/lib/server/utils/comparators.js +139 -139
  246. package/lib/server/utils/crypto.js +216 -216
  247. package/lib/server/utils/debug.js +42 -42
  248. package/lib/server/utils/debugLogger.js +122 -122
  249. package/lib/server/utils/env.js +73 -73
  250. package/lib/server/utils/eventsHelper.js +39 -39
  251. package/lib/server/utils/expectUtils.js +123 -123
  252. package/lib/server/utils/fileUtils.js +191 -191
  253. package/lib/server/utils/happyEyeballs.js +207 -207
  254. package/lib/server/utils/hostPlatform.js +138 -123
  255. package/lib/server/utils/httpServer.js +203 -203
  256. package/lib/server/utils/imageUtils.js +141 -141
  257. package/lib/server/utils/image_tools/colorUtils.js +89 -89
  258. package/lib/server/utils/image_tools/compare.js +109 -109
  259. package/lib/server/utils/image_tools/imageChannel.js +78 -78
  260. package/lib/server/utils/image_tools/stats.js +102 -102
  261. package/lib/server/utils/linuxUtils.js +71 -71
  262. package/lib/server/utils/network.js +242 -242
  263. package/lib/server/utils/nodePlatform.js +154 -154
  264. package/lib/server/utils/pipeTransport.js +84 -84
  265. package/lib/server/utils/processLauncher.js +241 -241
  266. package/lib/server/utils/profiler.js +65 -65
  267. package/lib/server/utils/socksProxy.js +511 -511
  268. package/lib/server/utils/spawnAsync.js +41 -41
  269. package/lib/server/utils/task.js +51 -51
  270. package/lib/server/utils/userAgent.js +98 -98
  271. package/lib/server/utils/wsServer.js +121 -121
  272. package/lib/server/utils/zipFile.js +74 -74
  273. package/lib/server/utils/zones.js +57 -57
  274. package/lib/server/videoRecorder.js +124 -124
  275. package/lib/server/webkit/protocol.d.js +16 -16
  276. package/lib/server/webkit/webkit.js +108 -108
  277. package/lib/server/webkit/wkBrowser.js +335 -335
  278. package/lib/server/webkit/wkConnection.js +144 -144
  279. package/lib/server/webkit/wkExecutionContext.js +154 -154
  280. package/lib/server/webkit/wkInput.js +181 -181
  281. package/lib/server/webkit/wkInterceptableRequest.js +197 -197
  282. package/lib/server/webkit/wkPage.js +1159 -1158
  283. package/lib/server/webkit/wkProvisionalPage.js +83 -83
  284. package/lib/server/webkit/wkWorkers.js +105 -105
  285. package/lib/third_party/pixelmatch.js +255 -255
  286. package/lib/utils/isomorphic/ariaSnapshot.js +455 -455
  287. package/lib/utils/isomorphic/assert.js +31 -31
  288. package/lib/utils/isomorphic/colors.js +72 -72
  289. package/lib/utils/isomorphic/cssParser.js +245 -245
  290. package/lib/utils/isomorphic/cssTokenizer.js +1051 -1051
  291. package/lib/utils/isomorphic/headers.js +53 -53
  292. package/lib/utils/isomorphic/locatorGenerators.js +689 -689
  293. package/lib/utils/isomorphic/locatorParser.js +176 -176
  294. package/lib/utils/isomorphic/locatorUtils.js +81 -81
  295. package/lib/utils/isomorphic/lruCache.js +51 -51
  296. package/lib/utils/isomorphic/manualPromise.js +114 -114
  297. package/lib/utils/isomorphic/mimeType.js +459 -459
  298. package/lib/utils/isomorphic/multimap.js +80 -80
  299. package/lib/utils/isomorphic/protocolFormatter.js +81 -81
  300. package/lib/utils/isomorphic/protocolMetainfo.js +330 -330
  301. package/lib/utils/isomorphic/rtti.js +43 -43
  302. package/lib/utils/isomorphic/selectorParser.js +386 -386
  303. package/lib/utils/isomorphic/semaphore.js +54 -54
  304. package/lib/utils/isomorphic/stackTrace.js +158 -158
  305. package/lib/utils/isomorphic/stringUtils.js +204 -204
  306. package/lib/utils/isomorphic/time.js +49 -49
  307. package/lib/utils/isomorphic/timeoutRunner.js +66 -66
  308. package/lib/utils/isomorphic/trace/entries.js +16 -16
  309. package/lib/utils/isomorphic/trace/snapshotRenderer.js +499 -499
  310. package/lib/utils/isomorphic/trace/snapshotServer.js +120 -120
  311. package/lib/utils/isomorphic/trace/snapshotStorage.js +89 -89
  312. package/lib/utils/isomorphic/trace/traceLoader.js +131 -131
  313. package/lib/utils/isomorphic/trace/traceModel.js +365 -365
  314. package/lib/utils/isomorphic/trace/traceModernizer.js +400 -400
  315. package/lib/utils/isomorphic/trace/versions/traceV3.js +16 -16
  316. package/lib/utils/isomorphic/trace/versions/traceV4.js +16 -16
  317. package/lib/utils/isomorphic/trace/versions/traceV5.js +16 -16
  318. package/lib/utils/isomorphic/trace/versions/traceV6.js +16 -16
  319. package/lib/utils/isomorphic/trace/versions/traceV7.js +16 -16
  320. package/lib/utils/isomorphic/trace/versions/traceV8.js +16 -16
  321. package/lib/utils/isomorphic/traceUtils.js +58 -58
  322. package/lib/utils/isomorphic/types.js +16 -16
  323. package/lib/utils/isomorphic/urlMatch.js +190 -190
  324. package/lib/utils/isomorphic/utilityScriptSerializers.js +251 -251
  325. package/lib/utils/isomorphic/yaml.js +84 -84
  326. package/lib/utils.js +111 -111
  327. package/lib/utilsBundle.js +109 -109
  328. package/lib/utilsBundleImpl/index.js +218 -218
  329. package/lib/utilsBundleImpl/xdg-open +1066 -1066
  330. package/lib/vite/htmlReport/index.html +84 -84
  331. package/lib/vite/recorder/assets/codeMirrorModule-DYBRYzYX.css +1 -1
  332. package/lib/vite/recorder/assets/codeMirrorModule-DadYNm1I.js +32 -32
  333. package/lib/vite/recorder/assets/index-BSjZa4pk.css +1 -1
  334. package/lib/vite/recorder/assets/index-BhTWtUlo.js +193 -193
  335. package/lib/vite/recorder/index.html +29 -29
  336. package/lib/vite/recorder/playwright-logo.svg +9 -9
  337. package/lib/vite/traceViewer/assets/codeMirrorModule-a5XoALAZ.js +32 -32
  338. package/lib/vite/traceViewer/assets/defaultSettingsView-CJSZINFr.js +266 -266
  339. package/lib/vite/traceViewer/assets/xtermModule-CsJ4vdCR.js +9 -9
  340. package/lib/vite/traceViewer/codeMirrorModule.DYBRYzYX.css +1 -1
  341. package/lib/vite/traceViewer/defaultSettingsView.7ch9cixO.css +1 -1
  342. package/lib/vite/traceViewer/{index.Bk2uYQRV.js → index.BDwrLSGN.js} +2 -2
  343. package/lib/vite/traceViewer/index.BVu7tZDe.css +1 -1
  344. package/lib/vite/traceViewer/index.html +43 -43
  345. package/lib/vite/traceViewer/manifest.webmanifest +16 -16
  346. package/lib/vite/traceViewer/playwright-logo.svg +9 -9
  347. package/lib/vite/traceViewer/snapshot.html +21 -21
  348. package/lib/vite/traceViewer/sw.bundle.js +5 -5
  349. package/lib/vite/traceViewer/uiMode.Btcz36p_.css +1 -1
  350. package/lib/vite/traceViewer/uiMode.CQJ9SCIQ.js +5 -5
  351. package/lib/vite/traceViewer/uiMode.html +17 -17
  352. package/lib/vite/traceViewer/xtermModule.DYP7pi_n.css +32 -32
  353. package/lib/zipBundle.js +34 -34
  354. package/lib/zipBundleImpl.js +5 -5
  355. package/package.json +1 -1
  356. package/types/protocol.d.ts +23824 -23824
  357. package/types/structs.d.ts +45 -45
  358. package/types/types.d.ts +22843 -22843
@@ -1,561 +1,561 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var snapshotterInjected_exports = {};
20
- __export(snapshotterInjected_exports, {
21
- frameSnapshotStreamer: () => frameSnapshotStreamer
22
- });
23
- module.exports = __toCommonJS(snapshotterInjected_exports);
24
- function frameSnapshotStreamer(snapshotStreamer, removeNoScript) {
25
- if (window[snapshotStreamer])
26
- return;
27
- const kShadowAttribute = "__playwright_shadow_root_";
28
- const kValueAttribute = "__playwright_value_";
29
- const kCheckedAttribute = "__playwright_checked_";
30
- const kSelectedAttribute = "__playwright_selected_";
31
- const kScrollTopAttribute = "__playwright_scroll_top_";
32
- const kScrollLeftAttribute = "__playwright_scroll_left_";
33
- const kStyleSheetAttribute = "__playwright_style_sheet_";
34
- const kTargetAttribute = "__playwright_target__";
35
- const kCustomElementsAttribute = "__playwright_custom_elements__";
36
- const kCurrentSrcAttribute = "__playwright_current_src__";
37
- const kBoundingRectAttribute = "__playwright_bounding_rect__";
38
- const kPopoverOpenAttribute = "__playwright_popover_open_";
39
- const kDialogOpenAttribute = "__playwright_dialog_open_";
40
- const kSnapshotFrameId = Symbol("__playwright_snapshot_frameid_");
41
- const kCachedData = Symbol("__playwright_snapshot_cache_");
42
- const kEndOfList = Symbol("__playwright_end_of_list_");
43
- function resetCachedData(obj) {
44
- delete obj[kCachedData];
45
- }
46
- function ensureCachedData(obj) {
47
- if (!obj[kCachedData])
48
- obj[kCachedData] = {};
49
- return obj[kCachedData];
50
- }
51
- function removeHash(url) {
52
- try {
53
- const u = new URL(url);
54
- u.hash = "";
55
- return u.toString();
56
- } catch (e) {
57
- return url;
58
- }
59
- }
60
- class Streamer {
61
- constructor() {
62
- this._lastSnapshotNumber = 0;
63
- this._staleStyleSheets = /* @__PURE__ */ new Set();
64
- this._modifiedStyleSheets = /* @__PURE__ */ new Set();
65
- this._readingStyleSheet = false;
66
- const invalidateCSSGroupingRule = (rule) => {
67
- if (rule.parentStyleSheet)
68
- this._invalidateStyleSheet(rule.parentStyleSheet);
69
- };
70
- this._interceptNativeMethod(window.CSSStyleSheet.prototype, "insertRule", (sheet) => this._invalidateStyleSheet(sheet));
71
- this._interceptNativeMethod(window.CSSStyleSheet.prototype, "deleteRule", (sheet) => this._invalidateStyleSheet(sheet));
72
- this._interceptNativeMethod(window.CSSStyleSheet.prototype, "addRule", (sheet) => this._invalidateStyleSheet(sheet));
73
- this._interceptNativeMethod(window.CSSStyleSheet.prototype, "removeRule", (sheet) => this._invalidateStyleSheet(sheet));
74
- this._interceptNativeGetter(window.CSSStyleSheet.prototype, "rules", (sheet) => this._invalidateStyleSheet(sheet));
75
- this._interceptNativeGetter(window.CSSStyleSheet.prototype, "cssRules", (sheet) => this._invalidateStyleSheet(sheet));
76
- this._interceptNativeMethod(window.CSSStyleSheet.prototype, "replaceSync", (sheet) => this._invalidateStyleSheet(sheet));
77
- this._interceptNativeMethod(window.CSSGroupingRule.prototype, "insertRule", invalidateCSSGroupingRule);
78
- this._interceptNativeMethod(window.CSSGroupingRule.prototype, "deleteRule", invalidateCSSGroupingRule);
79
- this._interceptNativeGetter(window.CSSGroupingRule.prototype, "cssRules", invalidateCSSGroupingRule);
80
- this._interceptNativeSetter(window.StyleSheet.prototype, "disabled", (sheet) => {
81
- if (sheet instanceof CSSStyleSheet)
82
- this._invalidateStyleSheet(sheet);
83
- });
84
- this._interceptNativeAsyncMethod(window.CSSStyleSheet.prototype, "replace", (sheet) => this._invalidateStyleSheet(sheet));
85
- this._fakeBase = document.createElement("base");
86
- this._observer = new MutationObserver((list) => this._handleMutations(list));
87
- const observerConfig = { attributes: true, subtree: true };
88
- this._observer.observe(document, observerConfig);
89
- this._refreshListenersWhenNeeded();
90
- }
91
- _refreshListenersWhenNeeded() {
92
- this._refreshListeners();
93
- const customEventName = "__playwright_snapshotter_global_listeners_check__";
94
- let seenEvent = false;
95
- const handleCustomEvent = () => seenEvent = true;
96
- window.addEventListener(customEventName, handleCustomEvent);
97
- const observer = new MutationObserver((entries) => {
98
- const newDocumentElement = entries.some((entry) => Array.from(entry.addedNodes).includes(document.documentElement));
99
- if (newDocumentElement) {
100
- seenEvent = false;
101
- window.dispatchEvent(new CustomEvent(customEventName));
102
- if (!seenEvent) {
103
- window.addEventListener(customEventName, handleCustomEvent);
104
- this._refreshListeners();
105
- }
106
- }
107
- });
108
- observer.observe(document, { childList: true });
109
- }
110
- _refreshListeners() {
111
- document.addEventListener("__playwright_mark_target__", (event) => {
112
- if (!event.detail)
113
- return;
114
- const callId = event.detail;
115
- event.composedPath()[0].__playwright_target__ = callId;
116
- });
117
- document.addEventListener("__playwright_unmark_target__", (event) => {
118
- if (!event.detail)
119
- return;
120
- const callId = event.detail;
121
- if (event.composedPath()[0].__playwright_target__ === callId)
122
- delete event.composedPath()[0].__playwright_target__;
123
- });
124
- }
125
- _interceptNativeMethod(obj, method, cb) {
126
- const native = obj[method];
127
- if (!native)
128
- return;
129
- obj[method] = function(...args) {
130
- const result = native.call(this, ...args);
131
- cb(this, result);
132
- return result;
133
- };
134
- }
135
- _interceptNativeAsyncMethod(obj, method, cb) {
136
- const native = obj[method];
137
- if (!native)
138
- return;
139
- obj[method] = async function(...args) {
140
- const result = await native.call(this, ...args);
141
- cb(this, result);
142
- return result;
143
- };
144
- }
145
- _interceptNativeGetter(obj, prop, cb) {
146
- const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
147
- Object.defineProperty(obj, prop, {
148
- ...descriptor,
149
- get: function() {
150
- const result = descriptor.get.call(this);
151
- cb(this, result);
152
- return result;
153
- }
154
- });
155
- }
156
- _interceptNativeSetter(obj, prop, cb) {
157
- const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
158
- Object.defineProperty(obj, prop, {
159
- ...descriptor,
160
- set: function(value) {
161
- const result = descriptor.set.call(this, value);
162
- cb(this, value);
163
- return result;
164
- }
165
- });
166
- }
167
- _handleMutations(list) {
168
- for (const mutation of list)
169
- ensureCachedData(mutation.target).attributesCached = void 0;
170
- }
171
- _invalidateStyleSheet(sheet) {
172
- if (this._readingStyleSheet)
173
- return;
174
- this._staleStyleSheets.add(sheet);
175
- if (sheet.href !== null)
176
- this._modifiedStyleSheets.add(sheet);
177
- }
178
- _updateStyleElementStyleSheetTextIfNeeded(sheet, forceText) {
179
- const data = ensureCachedData(sheet);
180
- if (this._staleStyleSheets.has(sheet) || forceText && data.cssText === void 0) {
181
- this._staleStyleSheets.delete(sheet);
182
- try {
183
- data.cssText = this._getSheetText(sheet);
184
- } catch (e) {
185
- data.cssText = "";
186
- }
187
- }
188
- return data.cssText;
189
- }
190
- // Returns either content, ref, or no override.
191
- _updateLinkStyleSheetTextIfNeeded(sheet, snapshotNumber) {
192
- const data = ensureCachedData(sheet);
193
- if (this._staleStyleSheets.has(sheet)) {
194
- this._staleStyleSheets.delete(sheet);
195
- try {
196
- data.cssText = this._getSheetText(sheet);
197
- data.cssRef = snapshotNumber;
198
- return data.cssText;
199
- } catch (e) {
200
- }
201
- }
202
- return data.cssRef === void 0 ? void 0 : snapshotNumber - data.cssRef;
203
- }
204
- markIframe(iframeElement, frameId) {
205
- iframeElement[kSnapshotFrameId] = frameId;
206
- }
207
- reset() {
208
- this._staleStyleSheets.clear();
209
- const visitNode = (node) => {
210
- resetCachedData(node);
211
- if (node.nodeType === Node.ELEMENT_NODE) {
212
- const element = node;
213
- if (element.shadowRoot)
214
- visitNode(element.shadowRoot);
215
- }
216
- for (let child = node.firstChild; child; child = child.nextSibling)
217
- visitNode(child);
218
- };
219
- visitNode(document.documentElement);
220
- visitNode(this._fakeBase);
221
- }
222
- __sanitizeMetaAttribute(name, value, httpEquiv) {
223
- if (name === "charset")
224
- return "utf-8";
225
- if (httpEquiv.toLowerCase() !== "content-type" || name !== "content")
226
- return value;
227
- const [type, ...params] = value.split(";");
228
- if (type !== "text/html" || params.length <= 0)
229
- return value;
230
- const charsetParamIdx = params.findIndex((param) => param.trim().startsWith("charset="));
231
- if (charsetParamIdx > -1)
232
- params[charsetParamIdx] = "charset=utf-8";
233
- return `${type}; ${params.join("; ")}`;
234
- }
235
- _sanitizeUrl(url) {
236
- if (url.startsWith("javascript:") || url.startsWith("vbscript:"))
237
- return "";
238
- return url;
239
- }
240
- _sanitizeSrcSet(srcset) {
241
- return srcset.split(",").map((src) => {
242
- src = src.trim();
243
- const spaceIndex = src.lastIndexOf(" ");
244
- if (spaceIndex === -1)
245
- return this._sanitizeUrl(src);
246
- return this._sanitizeUrl(src.substring(0, spaceIndex).trim()) + src.substring(spaceIndex);
247
- }).join(", ");
248
- }
249
- _resolveUrl(base, url) {
250
- if (url === "")
251
- return "";
252
- try {
253
- return new URL(url, base).href;
254
- } catch (e) {
255
- return url;
256
- }
257
- }
258
- _getSheetBase(sheet) {
259
- let rootSheet = sheet;
260
- while (rootSheet.parentStyleSheet)
261
- rootSheet = rootSheet.parentStyleSheet;
262
- if (rootSheet.ownerNode)
263
- return rootSheet.ownerNode.baseURI;
264
- return document.baseURI;
265
- }
266
- _getSheetText(sheet) {
267
- this._readingStyleSheet = true;
268
- try {
269
- if (sheet.disabled)
270
- return "";
271
- const rules = [];
272
- for (const rule of sheet.cssRules)
273
- rules.push(rule.cssText);
274
- return rules.join("\n");
275
- } finally {
276
- this._readingStyleSheet = false;
277
- }
278
- }
279
- captureSnapshot(needsReset) {
280
- const timestamp = performance.now();
281
- const snapshotNumber = ++this._lastSnapshotNumber;
282
- if (needsReset)
283
- this.reset();
284
- let nodeCounter = 0;
285
- let shadowDomNesting = 0;
286
- let headNesting = 0;
287
- this._handleMutations(this._observer.takeRecords());
288
- const definedCustomElements = /* @__PURE__ */ new Set();
289
- const visitNode = (node) => {
290
- const nodeType = node.nodeType;
291
- const nodeName = nodeType === Node.DOCUMENT_FRAGMENT_NODE ? "template" : node.nodeName;
292
- if (nodeType !== Node.ELEMENT_NODE && nodeType !== Node.DOCUMENT_FRAGMENT_NODE && nodeType !== Node.TEXT_NODE)
293
- return;
294
- if (nodeName === "SCRIPT")
295
- return;
296
- if (nodeName === "LINK" && nodeType === Node.ELEMENT_NODE) {
297
- const rel = node.getAttribute("rel")?.toLowerCase();
298
- if (rel === "preload" || rel === "prefetch")
299
- return;
300
- }
301
- if (removeNoScript && nodeName === "NOSCRIPT")
302
- return;
303
- if (nodeName === "META" && node.httpEquiv.toLowerCase() === "content-security-policy")
304
- return;
305
- if ((nodeName === "IFRAME" || nodeName === "FRAME") && headNesting)
306
- return;
307
- const data = ensureCachedData(node);
308
- const values = [];
309
- let equals = !!data.cached;
310
- let extraNodes = 0;
311
- const expectValue = (value) => {
312
- equals = equals && data.cached[values.length] === value;
313
- values.push(value);
314
- };
315
- const checkAndReturn = (n) => {
316
- data.attributesCached = true;
317
- if (equals)
318
- return { equals: true, n: [[snapshotNumber - data.ref[0], data.ref[1]]] };
319
- nodeCounter += extraNodes;
320
- data.ref = [snapshotNumber, nodeCounter++];
321
- data.cached = values;
322
- return { equals: false, n };
323
- };
324
- if (nodeType === Node.TEXT_NODE) {
325
- const value = node.nodeValue || "";
326
- expectValue(value);
327
- return checkAndReturn(value);
328
- }
329
- if (nodeName === "STYLE") {
330
- const sheet = node.sheet;
331
- let cssText;
332
- if (sheet)
333
- cssText = this._updateStyleElementStyleSheetTextIfNeeded(sheet);
334
- cssText = cssText || node.textContent || "";
335
- expectValue(cssText);
336
- extraNodes++;
337
- return checkAndReturn([nodeName, {}, cssText]);
338
- }
339
- const attrs = {};
340
- const result2 = [nodeName, attrs];
341
- const visitChild = (child) => {
342
- const snapshot = visitNode(child);
343
- if (snapshot) {
344
- result2.push(snapshot.n);
345
- expectValue(child);
346
- equals = equals && snapshot.equals;
347
- }
348
- };
349
- const visitChildStyleSheet = (child) => {
350
- const snapshot = visitStyleSheet(child);
351
- if (snapshot) {
352
- result2.push(snapshot.n);
353
- expectValue(child);
354
- equals = equals && snapshot.equals;
355
- }
356
- };
357
- if (nodeType === Node.DOCUMENT_FRAGMENT_NODE)
358
- attrs[kShadowAttribute] = "open";
359
- if (nodeType === Node.ELEMENT_NODE) {
360
- const element = node;
361
- if (element.localName.includes("-") && window.customElements?.get(element.localName))
362
- definedCustomElements.add(element.localName);
363
- if (nodeName === "INPUT" || nodeName === "TEXTAREA") {
364
- const value = element.value;
365
- expectValue(kValueAttribute);
366
- expectValue(value);
367
- attrs[kValueAttribute] = value;
368
- }
369
- if (nodeName === "INPUT" && ["checkbox", "radio"].includes(element.type)) {
370
- const value = element.checked ? "true" : "false";
371
- expectValue(kCheckedAttribute);
372
- expectValue(value);
373
- attrs[kCheckedAttribute] = value;
374
- }
375
- if (nodeName === "OPTION") {
376
- const value = element.selected ? "true" : "false";
377
- expectValue(kSelectedAttribute);
378
- expectValue(value);
379
- attrs[kSelectedAttribute] = value;
380
- }
381
- if (nodeName === "CANVAS" || nodeName === "IFRAME" || nodeName === "FRAME") {
382
- const boundingRect = element.getBoundingClientRect();
383
- const value = JSON.stringify({
384
- left: boundingRect.left,
385
- top: boundingRect.top,
386
- right: boundingRect.right,
387
- bottom: boundingRect.bottom
388
- });
389
- expectValue(kBoundingRectAttribute);
390
- expectValue(value);
391
- attrs[kBoundingRectAttribute] = value;
392
- }
393
- if (element.popover && element.matches && element.matches(":popover-open")) {
394
- const value = "true";
395
- expectValue(kPopoverOpenAttribute);
396
- expectValue(value);
397
- attrs[kPopoverOpenAttribute] = value;
398
- }
399
- if (nodeName === "DIALOG" && element.open) {
400
- const value = element.matches(":modal") ? "modal" : "true";
401
- expectValue(kDialogOpenAttribute);
402
- expectValue(value);
403
- attrs[kDialogOpenAttribute] = value;
404
- }
405
- if (element.scrollTop) {
406
- expectValue(kScrollTopAttribute);
407
- expectValue(element.scrollTop);
408
- attrs[kScrollTopAttribute] = "" + element.scrollTop;
409
- }
410
- if (element.scrollLeft) {
411
- expectValue(kScrollLeftAttribute);
412
- expectValue(element.scrollLeft);
413
- attrs[kScrollLeftAttribute] = "" + element.scrollLeft;
414
- }
415
- if (element.shadowRoot) {
416
- ++shadowDomNesting;
417
- visitChild(element.shadowRoot);
418
- --shadowDomNesting;
419
- }
420
- if ("__playwright_target__" in element) {
421
- expectValue(kTargetAttribute);
422
- expectValue(element["__playwright_target__"]);
423
- attrs[kTargetAttribute] = element["__playwright_target__"];
424
- }
425
- }
426
- if (nodeName === "HEAD") {
427
- ++headNesting;
428
- this._fakeBase.setAttribute("href", document.baseURI);
429
- visitChild(this._fakeBase);
430
- }
431
- for (let child = node.firstChild; child; child = child.nextSibling)
432
- visitChild(child);
433
- if (nodeName === "HEAD")
434
- --headNesting;
435
- expectValue(kEndOfList);
436
- let documentOrShadowRoot = null;
437
- if (node.ownerDocument.documentElement === node)
438
- documentOrShadowRoot = node.ownerDocument;
439
- else if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE)
440
- documentOrShadowRoot = node;
441
- if (documentOrShadowRoot) {
442
- for (const sheet of documentOrShadowRoot.adoptedStyleSheets || [])
443
- visitChildStyleSheet(sheet);
444
- expectValue(kEndOfList);
445
- }
446
- if (nodeName === "IFRAME" || nodeName === "FRAME") {
447
- const element = node;
448
- const frameId = element[kSnapshotFrameId];
449
- const name = "src";
450
- const value = frameId ? `/snapshot/${frameId}` : "";
451
- expectValue(name);
452
- expectValue(value);
453
- attrs[name] = value;
454
- }
455
- if (nodeName === "BODY" && definedCustomElements.size) {
456
- const value = [...definedCustomElements].join(",");
457
- expectValue(kCustomElementsAttribute);
458
- expectValue(value);
459
- attrs[kCustomElementsAttribute] = value;
460
- }
461
- if (nodeName === "IMG" || nodeName === "PICTURE") {
462
- const value = nodeName === "PICTURE" ? "" : this._sanitizeUrl(node.currentSrc);
463
- expectValue(kCurrentSrcAttribute);
464
- expectValue(value);
465
- attrs[kCurrentSrcAttribute] = value;
466
- }
467
- if (equals && data.attributesCached && !shadowDomNesting)
468
- return checkAndReturn(result2);
469
- if (nodeType === Node.ELEMENT_NODE) {
470
- const element = node;
471
- for (let i = 0; i < element.attributes.length; i++) {
472
- const name = element.attributes[i].name;
473
- if (nodeName === "LINK" && name === "integrity")
474
- continue;
475
- if (nodeName === "IFRAME" && (name === "src" || name === "srcdoc" || name === "sandbox"))
476
- continue;
477
- if (nodeName === "FRAME" && name === "src")
478
- continue;
479
- if (nodeName === "DIALOG" && name === "open")
480
- continue;
481
- let value = element.attributes[i].value;
482
- if (nodeName === "META")
483
- value = this.__sanitizeMetaAttribute(name, value, node.httpEquiv);
484
- else if (name === "src" && nodeName === "IMG")
485
- value = this._sanitizeUrl(value);
486
- else if (name === "srcset" && nodeName === "IMG")
487
- value = this._sanitizeSrcSet(value);
488
- else if (name === "srcset" && nodeName === "SOURCE")
489
- value = this._sanitizeSrcSet(value);
490
- else if (name === "href" && nodeName === "LINK")
491
- value = this._sanitizeUrl(value);
492
- else if (name.startsWith("on"))
493
- value = "";
494
- expectValue(name);
495
- expectValue(value);
496
- attrs[name] = value;
497
- }
498
- expectValue(kEndOfList);
499
- }
500
- if (result2.length === 2 && !Object.keys(attrs).length)
501
- result2.pop();
502
- return checkAndReturn(result2);
503
- };
504
- const visitStyleSheet = (sheet) => {
505
- const data = ensureCachedData(sheet);
506
- const oldCSSText = data.cssText;
507
- const cssText = this._updateStyleElementStyleSheetTextIfNeeded(
508
- sheet,
509
- true
510
- /* forceText */
511
- );
512
- if (cssText === oldCSSText)
513
- return { equals: true, n: [[snapshotNumber - data.ref[0], data.ref[1]]] };
514
- data.ref = [snapshotNumber, nodeCounter++];
515
- return {
516
- equals: false,
517
- n: ["template", {
518
- [kStyleSheetAttribute]: cssText
519
- }]
520
- };
521
- };
522
- let html;
523
- if (document.documentElement) {
524
- const { n } = visitNode(document.documentElement);
525
- html = n;
526
- } else {
527
- html = ["html"];
528
- }
529
- const result = {
530
- html,
531
- doctype: document.doctype ? document.doctype.name : void 0,
532
- resourceOverrides: [],
533
- viewport: {
534
- width: window.innerWidth,
535
- height: window.innerHeight
536
- },
537
- url: location.href,
538
- wallTime: Date.now(),
539
- collectionTime: 0
540
- };
541
- for (const sheet of this._modifiedStyleSheets) {
542
- if (sheet.href === null)
543
- continue;
544
- const content = this._updateLinkStyleSheetTextIfNeeded(sheet, snapshotNumber);
545
- if (content === void 0) {
546
- continue;
547
- }
548
- const base = this._getSheetBase(sheet);
549
- const url = removeHash(this._resolveUrl(base, sheet.href));
550
- result.resourceOverrides.push({ url, content, contentType: "text/css" });
551
- }
552
- result.collectionTime = performance.now() - timestamp;
553
- return result;
554
- }
555
- }
556
- window[snapshotStreamer] = new Streamer();
557
- }
558
- // Annotate the CommonJS export names for ESM import in node:
559
- 0 && (module.exports = {
560
- frameSnapshotStreamer
561
- });
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var snapshotterInjected_exports = {};
20
+ __export(snapshotterInjected_exports, {
21
+ frameSnapshotStreamer: () => frameSnapshotStreamer
22
+ });
23
+ module.exports = __toCommonJS(snapshotterInjected_exports);
24
+ function frameSnapshotStreamer(snapshotStreamer, removeNoScript) {
25
+ if (window[snapshotStreamer])
26
+ return;
27
+ const kShadowAttribute = "__playwright_shadow_root_";
28
+ const kValueAttribute = "__playwright_value_";
29
+ const kCheckedAttribute = "__playwright_checked_";
30
+ const kSelectedAttribute = "__playwright_selected_";
31
+ const kScrollTopAttribute = "__playwright_scroll_top_";
32
+ const kScrollLeftAttribute = "__playwright_scroll_left_";
33
+ const kStyleSheetAttribute = "__playwright_style_sheet_";
34
+ const kTargetAttribute = "__playwright_target__";
35
+ const kCustomElementsAttribute = "__playwright_custom_elements__";
36
+ const kCurrentSrcAttribute = "__playwright_current_src__";
37
+ const kBoundingRectAttribute = "__playwright_bounding_rect__";
38
+ const kPopoverOpenAttribute = "__playwright_popover_open_";
39
+ const kDialogOpenAttribute = "__playwright_dialog_open_";
40
+ const kSnapshotFrameId = Symbol("__playwright_snapshot_frameid_");
41
+ const kCachedData = Symbol("__playwright_snapshot_cache_");
42
+ const kEndOfList = Symbol("__playwright_end_of_list_");
43
+ function resetCachedData(obj) {
44
+ delete obj[kCachedData];
45
+ }
46
+ function ensureCachedData(obj) {
47
+ if (!obj[kCachedData])
48
+ obj[kCachedData] = {};
49
+ return obj[kCachedData];
50
+ }
51
+ function removeHash(url) {
52
+ try {
53
+ const u = new URL(url);
54
+ u.hash = "";
55
+ return u.toString();
56
+ } catch (e) {
57
+ return url;
58
+ }
59
+ }
60
+ class Streamer {
61
+ constructor() {
62
+ this._lastSnapshotNumber = 0;
63
+ this._staleStyleSheets = /* @__PURE__ */ new Set();
64
+ this._modifiedStyleSheets = /* @__PURE__ */ new Set();
65
+ this._readingStyleSheet = false;
66
+ const invalidateCSSGroupingRule = (rule) => {
67
+ if (rule.parentStyleSheet)
68
+ this._invalidateStyleSheet(rule.parentStyleSheet);
69
+ };
70
+ this._interceptNativeMethod(window.CSSStyleSheet.prototype, "insertRule", (sheet) => this._invalidateStyleSheet(sheet));
71
+ this._interceptNativeMethod(window.CSSStyleSheet.prototype, "deleteRule", (sheet) => this._invalidateStyleSheet(sheet));
72
+ this._interceptNativeMethod(window.CSSStyleSheet.prototype, "addRule", (sheet) => this._invalidateStyleSheet(sheet));
73
+ this._interceptNativeMethod(window.CSSStyleSheet.prototype, "removeRule", (sheet) => this._invalidateStyleSheet(sheet));
74
+ this._interceptNativeGetter(window.CSSStyleSheet.prototype, "rules", (sheet) => this._invalidateStyleSheet(sheet));
75
+ this._interceptNativeGetter(window.CSSStyleSheet.prototype, "cssRules", (sheet) => this._invalidateStyleSheet(sheet));
76
+ this._interceptNativeMethod(window.CSSStyleSheet.prototype, "replaceSync", (sheet) => this._invalidateStyleSheet(sheet));
77
+ this._interceptNativeMethod(window.CSSGroupingRule.prototype, "insertRule", invalidateCSSGroupingRule);
78
+ this._interceptNativeMethod(window.CSSGroupingRule.prototype, "deleteRule", invalidateCSSGroupingRule);
79
+ this._interceptNativeGetter(window.CSSGroupingRule.prototype, "cssRules", invalidateCSSGroupingRule);
80
+ this._interceptNativeSetter(window.StyleSheet.prototype, "disabled", (sheet) => {
81
+ if (sheet instanceof CSSStyleSheet)
82
+ this._invalidateStyleSheet(sheet);
83
+ });
84
+ this._interceptNativeAsyncMethod(window.CSSStyleSheet.prototype, "replace", (sheet) => this._invalidateStyleSheet(sheet));
85
+ this._fakeBase = document.createElement("base");
86
+ this._observer = new MutationObserver((list) => this._handleMutations(list));
87
+ const observerConfig = { attributes: true, subtree: true };
88
+ this._observer.observe(document, observerConfig);
89
+ this._refreshListenersWhenNeeded();
90
+ }
91
+ _refreshListenersWhenNeeded() {
92
+ this._refreshListeners();
93
+ const customEventName = "__playwright_snapshotter_global_listeners_check__";
94
+ let seenEvent = false;
95
+ const handleCustomEvent = () => seenEvent = true;
96
+ window.addEventListener(customEventName, handleCustomEvent);
97
+ const observer = new MutationObserver((entries) => {
98
+ const newDocumentElement = entries.some((entry) => Array.from(entry.addedNodes).includes(document.documentElement));
99
+ if (newDocumentElement) {
100
+ seenEvent = false;
101
+ window.dispatchEvent(new CustomEvent(customEventName));
102
+ if (!seenEvent) {
103
+ window.addEventListener(customEventName, handleCustomEvent);
104
+ this._refreshListeners();
105
+ }
106
+ }
107
+ });
108
+ observer.observe(document, { childList: true });
109
+ }
110
+ _refreshListeners() {
111
+ document.addEventListener("__playwright_mark_target__", (event) => {
112
+ if (!event.detail)
113
+ return;
114
+ const callId = event.detail;
115
+ event.composedPath()[0].__playwright_target__ = callId;
116
+ });
117
+ document.addEventListener("__playwright_unmark_target__", (event) => {
118
+ if (!event.detail)
119
+ return;
120
+ const callId = event.detail;
121
+ if (event.composedPath()[0].__playwright_target__ === callId)
122
+ delete event.composedPath()[0].__playwright_target__;
123
+ });
124
+ }
125
+ _interceptNativeMethod(obj, method, cb) {
126
+ const native = obj[method];
127
+ if (!native)
128
+ return;
129
+ obj[method] = function(...args) {
130
+ const result = native.call(this, ...args);
131
+ cb(this, result);
132
+ return result;
133
+ };
134
+ }
135
+ _interceptNativeAsyncMethod(obj, method, cb) {
136
+ const native = obj[method];
137
+ if (!native)
138
+ return;
139
+ obj[method] = async function(...args) {
140
+ const result = await native.call(this, ...args);
141
+ cb(this, result);
142
+ return result;
143
+ };
144
+ }
145
+ _interceptNativeGetter(obj, prop, cb) {
146
+ const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
147
+ Object.defineProperty(obj, prop, {
148
+ ...descriptor,
149
+ get: function() {
150
+ const result = descriptor.get.call(this);
151
+ cb(this, result);
152
+ return result;
153
+ }
154
+ });
155
+ }
156
+ _interceptNativeSetter(obj, prop, cb) {
157
+ const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
158
+ Object.defineProperty(obj, prop, {
159
+ ...descriptor,
160
+ set: function(value) {
161
+ const result = descriptor.set.call(this, value);
162
+ cb(this, value);
163
+ return result;
164
+ }
165
+ });
166
+ }
167
+ _handleMutations(list) {
168
+ for (const mutation of list)
169
+ ensureCachedData(mutation.target).attributesCached = void 0;
170
+ }
171
+ _invalidateStyleSheet(sheet) {
172
+ if (this._readingStyleSheet)
173
+ return;
174
+ this._staleStyleSheets.add(sheet);
175
+ if (sheet.href !== null)
176
+ this._modifiedStyleSheets.add(sheet);
177
+ }
178
+ _updateStyleElementStyleSheetTextIfNeeded(sheet, forceText) {
179
+ const data = ensureCachedData(sheet);
180
+ if (this._staleStyleSheets.has(sheet) || forceText && data.cssText === void 0) {
181
+ this._staleStyleSheets.delete(sheet);
182
+ try {
183
+ data.cssText = this._getSheetText(sheet);
184
+ } catch (e) {
185
+ data.cssText = "";
186
+ }
187
+ }
188
+ return data.cssText;
189
+ }
190
+ // Returns either content, ref, or no override.
191
+ _updateLinkStyleSheetTextIfNeeded(sheet, snapshotNumber) {
192
+ const data = ensureCachedData(sheet);
193
+ if (this._staleStyleSheets.has(sheet)) {
194
+ this._staleStyleSheets.delete(sheet);
195
+ try {
196
+ data.cssText = this._getSheetText(sheet);
197
+ data.cssRef = snapshotNumber;
198
+ return data.cssText;
199
+ } catch (e) {
200
+ }
201
+ }
202
+ return data.cssRef === void 0 ? void 0 : snapshotNumber - data.cssRef;
203
+ }
204
+ markIframe(iframeElement, frameId) {
205
+ iframeElement[kSnapshotFrameId] = frameId;
206
+ }
207
+ reset() {
208
+ this._staleStyleSheets.clear();
209
+ const visitNode = (node) => {
210
+ resetCachedData(node);
211
+ if (node.nodeType === Node.ELEMENT_NODE) {
212
+ const element = node;
213
+ if (element.shadowRoot)
214
+ visitNode(element.shadowRoot);
215
+ }
216
+ for (let child = node.firstChild; child; child = child.nextSibling)
217
+ visitNode(child);
218
+ };
219
+ visitNode(document.documentElement);
220
+ visitNode(this._fakeBase);
221
+ }
222
+ __sanitizeMetaAttribute(name, value, httpEquiv) {
223
+ if (name === "charset")
224
+ return "utf-8";
225
+ if (httpEquiv.toLowerCase() !== "content-type" || name !== "content")
226
+ return value;
227
+ const [type, ...params] = value.split(";");
228
+ if (type !== "text/html" || params.length <= 0)
229
+ return value;
230
+ const charsetParamIdx = params.findIndex((param) => param.trim().startsWith("charset="));
231
+ if (charsetParamIdx > -1)
232
+ params[charsetParamIdx] = "charset=utf-8";
233
+ return `${type}; ${params.join("; ")}`;
234
+ }
235
+ _sanitizeUrl(url) {
236
+ if (url.startsWith("javascript:") || url.startsWith("vbscript:"))
237
+ return "";
238
+ return url;
239
+ }
240
+ _sanitizeSrcSet(srcset) {
241
+ return srcset.split(",").map((src) => {
242
+ src = src.trim();
243
+ const spaceIndex = src.lastIndexOf(" ");
244
+ if (spaceIndex === -1)
245
+ return this._sanitizeUrl(src);
246
+ return this._sanitizeUrl(src.substring(0, spaceIndex).trim()) + src.substring(spaceIndex);
247
+ }).join(", ");
248
+ }
249
+ _resolveUrl(base, url) {
250
+ if (url === "")
251
+ return "";
252
+ try {
253
+ return new URL(url, base).href;
254
+ } catch (e) {
255
+ return url;
256
+ }
257
+ }
258
+ _getSheetBase(sheet) {
259
+ let rootSheet = sheet;
260
+ while (rootSheet.parentStyleSheet)
261
+ rootSheet = rootSheet.parentStyleSheet;
262
+ if (rootSheet.ownerNode)
263
+ return rootSheet.ownerNode.baseURI;
264
+ return document.baseURI;
265
+ }
266
+ _getSheetText(sheet) {
267
+ this._readingStyleSheet = true;
268
+ try {
269
+ if (sheet.disabled)
270
+ return "";
271
+ const rules = [];
272
+ for (const rule of sheet.cssRules)
273
+ rules.push(rule.cssText);
274
+ return rules.join("\n");
275
+ } finally {
276
+ this._readingStyleSheet = false;
277
+ }
278
+ }
279
+ captureSnapshot(needsReset) {
280
+ const timestamp = performance.now();
281
+ const snapshotNumber = ++this._lastSnapshotNumber;
282
+ if (needsReset)
283
+ this.reset();
284
+ let nodeCounter = 0;
285
+ let shadowDomNesting = 0;
286
+ let headNesting = 0;
287
+ this._handleMutations(this._observer.takeRecords());
288
+ const definedCustomElements = /* @__PURE__ */ new Set();
289
+ const visitNode = (node) => {
290
+ const nodeType = node.nodeType;
291
+ const nodeName = nodeType === Node.DOCUMENT_FRAGMENT_NODE ? "template" : node.nodeName;
292
+ if (nodeType !== Node.ELEMENT_NODE && nodeType !== Node.DOCUMENT_FRAGMENT_NODE && nodeType !== Node.TEXT_NODE)
293
+ return;
294
+ if (nodeName === "SCRIPT")
295
+ return;
296
+ if (nodeName === "LINK" && nodeType === Node.ELEMENT_NODE) {
297
+ const rel = node.getAttribute("rel")?.toLowerCase();
298
+ if (rel === "preload" || rel === "prefetch")
299
+ return;
300
+ }
301
+ if (removeNoScript && nodeName === "NOSCRIPT")
302
+ return;
303
+ if (nodeName === "META" && node.httpEquiv.toLowerCase() === "content-security-policy")
304
+ return;
305
+ if ((nodeName === "IFRAME" || nodeName === "FRAME") && headNesting)
306
+ return;
307
+ const data = ensureCachedData(node);
308
+ const values = [];
309
+ let equals = !!data.cached;
310
+ let extraNodes = 0;
311
+ const expectValue = (value) => {
312
+ equals = equals && data.cached[values.length] === value;
313
+ values.push(value);
314
+ };
315
+ const checkAndReturn = (n) => {
316
+ data.attributesCached = true;
317
+ if (equals)
318
+ return { equals: true, n: [[snapshotNumber - data.ref[0], data.ref[1]]] };
319
+ nodeCounter += extraNodes;
320
+ data.ref = [snapshotNumber, nodeCounter++];
321
+ data.cached = values;
322
+ return { equals: false, n };
323
+ };
324
+ if (nodeType === Node.TEXT_NODE) {
325
+ const value = node.nodeValue || "";
326
+ expectValue(value);
327
+ return checkAndReturn(value);
328
+ }
329
+ if (nodeName === "STYLE") {
330
+ const sheet = node.sheet;
331
+ let cssText;
332
+ if (sheet)
333
+ cssText = this._updateStyleElementStyleSheetTextIfNeeded(sheet);
334
+ cssText = cssText || node.textContent || "";
335
+ expectValue(cssText);
336
+ extraNodes++;
337
+ return checkAndReturn([nodeName, {}, cssText]);
338
+ }
339
+ const attrs = {};
340
+ const result2 = [nodeName, attrs];
341
+ const visitChild = (child) => {
342
+ const snapshot = visitNode(child);
343
+ if (snapshot) {
344
+ result2.push(snapshot.n);
345
+ expectValue(child);
346
+ equals = equals && snapshot.equals;
347
+ }
348
+ };
349
+ const visitChildStyleSheet = (child) => {
350
+ const snapshot = visitStyleSheet(child);
351
+ if (snapshot) {
352
+ result2.push(snapshot.n);
353
+ expectValue(child);
354
+ equals = equals && snapshot.equals;
355
+ }
356
+ };
357
+ if (nodeType === Node.DOCUMENT_FRAGMENT_NODE)
358
+ attrs[kShadowAttribute] = "open";
359
+ if (nodeType === Node.ELEMENT_NODE) {
360
+ const element = node;
361
+ if (element.localName.includes("-") && window.customElements?.get(element.localName))
362
+ definedCustomElements.add(element.localName);
363
+ if (nodeName === "INPUT" || nodeName === "TEXTAREA") {
364
+ const value = element.value;
365
+ expectValue(kValueAttribute);
366
+ expectValue(value);
367
+ attrs[kValueAttribute] = value;
368
+ }
369
+ if (nodeName === "INPUT" && ["checkbox", "radio"].includes(element.type)) {
370
+ const value = element.checked ? "true" : "false";
371
+ expectValue(kCheckedAttribute);
372
+ expectValue(value);
373
+ attrs[kCheckedAttribute] = value;
374
+ }
375
+ if (nodeName === "OPTION") {
376
+ const value = element.selected ? "true" : "false";
377
+ expectValue(kSelectedAttribute);
378
+ expectValue(value);
379
+ attrs[kSelectedAttribute] = value;
380
+ }
381
+ if (nodeName === "CANVAS" || nodeName === "IFRAME" || nodeName === "FRAME") {
382
+ const boundingRect = element.getBoundingClientRect();
383
+ const value = JSON.stringify({
384
+ left: boundingRect.left,
385
+ top: boundingRect.top,
386
+ right: boundingRect.right,
387
+ bottom: boundingRect.bottom
388
+ });
389
+ expectValue(kBoundingRectAttribute);
390
+ expectValue(value);
391
+ attrs[kBoundingRectAttribute] = value;
392
+ }
393
+ if (element.popover && element.matches && element.matches(":popover-open")) {
394
+ const value = "true";
395
+ expectValue(kPopoverOpenAttribute);
396
+ expectValue(value);
397
+ attrs[kPopoverOpenAttribute] = value;
398
+ }
399
+ if (nodeName === "DIALOG" && element.open) {
400
+ const value = element.matches(":modal") ? "modal" : "true";
401
+ expectValue(kDialogOpenAttribute);
402
+ expectValue(value);
403
+ attrs[kDialogOpenAttribute] = value;
404
+ }
405
+ if (element.scrollTop) {
406
+ expectValue(kScrollTopAttribute);
407
+ expectValue(element.scrollTop);
408
+ attrs[kScrollTopAttribute] = "" + element.scrollTop;
409
+ }
410
+ if (element.scrollLeft) {
411
+ expectValue(kScrollLeftAttribute);
412
+ expectValue(element.scrollLeft);
413
+ attrs[kScrollLeftAttribute] = "" + element.scrollLeft;
414
+ }
415
+ if (element.shadowRoot) {
416
+ ++shadowDomNesting;
417
+ visitChild(element.shadowRoot);
418
+ --shadowDomNesting;
419
+ }
420
+ if ("__playwright_target__" in element) {
421
+ expectValue(kTargetAttribute);
422
+ expectValue(element["__playwright_target__"]);
423
+ attrs[kTargetAttribute] = element["__playwright_target__"];
424
+ }
425
+ }
426
+ if (nodeName === "HEAD") {
427
+ ++headNesting;
428
+ this._fakeBase.setAttribute("href", document.baseURI);
429
+ visitChild(this._fakeBase);
430
+ }
431
+ for (let child = node.firstChild; child; child = child.nextSibling)
432
+ visitChild(child);
433
+ if (nodeName === "HEAD")
434
+ --headNesting;
435
+ expectValue(kEndOfList);
436
+ let documentOrShadowRoot = null;
437
+ if (node.ownerDocument.documentElement === node)
438
+ documentOrShadowRoot = node.ownerDocument;
439
+ else if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE)
440
+ documentOrShadowRoot = node;
441
+ if (documentOrShadowRoot) {
442
+ for (const sheet of documentOrShadowRoot.adoptedStyleSheets || [])
443
+ visitChildStyleSheet(sheet);
444
+ expectValue(kEndOfList);
445
+ }
446
+ if (nodeName === "IFRAME" || nodeName === "FRAME") {
447
+ const element = node;
448
+ const frameId = element[kSnapshotFrameId];
449
+ const name = "src";
450
+ const value = frameId ? `/snapshot/${frameId}` : "";
451
+ expectValue(name);
452
+ expectValue(value);
453
+ attrs[name] = value;
454
+ }
455
+ if (nodeName === "BODY" && definedCustomElements.size) {
456
+ const value = [...definedCustomElements].join(",");
457
+ expectValue(kCustomElementsAttribute);
458
+ expectValue(value);
459
+ attrs[kCustomElementsAttribute] = value;
460
+ }
461
+ if (nodeName === "IMG" || nodeName === "PICTURE") {
462
+ const value = nodeName === "PICTURE" ? "" : this._sanitizeUrl(node.currentSrc);
463
+ expectValue(kCurrentSrcAttribute);
464
+ expectValue(value);
465
+ attrs[kCurrentSrcAttribute] = value;
466
+ }
467
+ if (equals && data.attributesCached && !shadowDomNesting)
468
+ return checkAndReturn(result2);
469
+ if (nodeType === Node.ELEMENT_NODE) {
470
+ const element = node;
471
+ for (let i = 0; i < element.attributes.length; i++) {
472
+ const name = element.attributes[i].name;
473
+ if (nodeName === "LINK" && name === "integrity")
474
+ continue;
475
+ if (nodeName === "IFRAME" && (name === "src" || name === "srcdoc" || name === "sandbox"))
476
+ continue;
477
+ if (nodeName === "FRAME" && name === "src")
478
+ continue;
479
+ if (nodeName === "DIALOG" && name === "open")
480
+ continue;
481
+ let value = element.attributes[i].value;
482
+ if (nodeName === "META")
483
+ value = this.__sanitizeMetaAttribute(name, value, node.httpEquiv);
484
+ else if (name === "src" && nodeName === "IMG")
485
+ value = this._sanitizeUrl(value);
486
+ else if (name === "srcset" && nodeName === "IMG")
487
+ value = this._sanitizeSrcSet(value);
488
+ else if (name === "srcset" && nodeName === "SOURCE")
489
+ value = this._sanitizeSrcSet(value);
490
+ else if (name === "href" && nodeName === "LINK")
491
+ value = this._sanitizeUrl(value);
492
+ else if (name.startsWith("on"))
493
+ value = "";
494
+ expectValue(name);
495
+ expectValue(value);
496
+ attrs[name] = value;
497
+ }
498
+ expectValue(kEndOfList);
499
+ }
500
+ if (result2.length === 2 && !Object.keys(attrs).length)
501
+ result2.pop();
502
+ return checkAndReturn(result2);
503
+ };
504
+ const visitStyleSheet = (sheet) => {
505
+ const data = ensureCachedData(sheet);
506
+ const oldCSSText = data.cssText;
507
+ const cssText = this._updateStyleElementStyleSheetTextIfNeeded(
508
+ sheet,
509
+ true
510
+ /* forceText */
511
+ );
512
+ if (cssText === oldCSSText)
513
+ return { equals: true, n: [[snapshotNumber - data.ref[0], data.ref[1]]] };
514
+ data.ref = [snapshotNumber, nodeCounter++];
515
+ return {
516
+ equals: false,
517
+ n: ["template", {
518
+ [kStyleSheetAttribute]: cssText
519
+ }]
520
+ };
521
+ };
522
+ let html;
523
+ if (document.documentElement) {
524
+ const { n } = visitNode(document.documentElement);
525
+ html = n;
526
+ } else {
527
+ html = ["html"];
528
+ }
529
+ const result = {
530
+ html,
531
+ doctype: document.doctype ? document.doctype.name : void 0,
532
+ resourceOverrides: [],
533
+ viewport: {
534
+ width: window.innerWidth,
535
+ height: window.innerHeight
536
+ },
537
+ url: location.href,
538
+ wallTime: Date.now(),
539
+ collectionTime: 0
540
+ };
541
+ for (const sheet of this._modifiedStyleSheets) {
542
+ if (sheet.href === null)
543
+ continue;
544
+ const content = this._updateLinkStyleSheetTextIfNeeded(sheet, snapshotNumber);
545
+ if (content === void 0) {
546
+ continue;
547
+ }
548
+ const base = this._getSheetBase(sheet);
549
+ const url = removeHash(this._resolveUrl(base, sheet.href));
550
+ result.resourceOverrides.push({ url, content, contentType: "text/css" });
551
+ }
552
+ result.collectionTime = performance.now() - timestamp;
553
+ return result;
554
+ }
555
+ }
556
+ window[snapshotStreamer] = new Streamer();
557
+ }
558
+ // Annotate the CommonJS export names for ESM import in node:
559
+ 0 && (module.exports = {
560
+ frameSnapshotStreamer
561
+ });