brave-real-puppeteer-core 24.25.0 → 24.33.0-patch.1

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 (468) hide show
  1. package/README.md +5 -5
  2. package/advanced-stealth.js +1 -1
  3. package/lib/cjs/puppeteer/api/BluetoothEmulation.d.ts +96 -0
  4. package/lib/cjs/puppeteer/api/BluetoothEmulation.d.ts.map +1 -0
  5. package/lib/cjs/puppeteer/api/BluetoothEmulation.js +8 -0
  6. package/lib/cjs/puppeteer/api/BluetoothEmulation.js.map +1 -0
  7. package/lib/cjs/puppeteer/api/Browser.d.ts +111 -2
  8. package/lib/cjs/puppeteer/api/Browser.d.ts.map +1 -1
  9. package/lib/cjs/puppeteer/api/Browser.js +4 -2
  10. package/lib/cjs/puppeteer/api/Browser.js.map +1 -1
  11. package/lib/cjs/puppeteer/api/BrowserContext.d.ts +5 -3
  12. package/lib/cjs/puppeteer/api/BrowserContext.d.ts.map +1 -1
  13. package/lib/cjs/puppeteer/api/BrowserContext.js.map +1 -1
  14. package/lib/cjs/puppeteer/api/CDPSession.d.ts.map +1 -1
  15. package/lib/cjs/puppeteer/api/CDPSession.js.map +1 -1
  16. package/lib/cjs/puppeteer/api/DeviceRequestPrompt.d.ts +62 -0
  17. package/lib/cjs/puppeteer/api/DeviceRequestPrompt.d.ts.map +1 -0
  18. package/lib/cjs/puppeteer/api/DeviceRequestPrompt.js +38 -0
  19. package/lib/cjs/puppeteer/api/DeviceRequestPrompt.js.map +1 -0
  20. package/lib/cjs/puppeteer/api/ElementHandle.d.ts.map +1 -1
  21. package/lib/cjs/puppeteer/api/ElementHandle.js +1 -1
  22. package/lib/cjs/puppeteer/api/ElementHandle.js.map +1 -1
  23. package/lib/cjs/puppeteer/api/Frame.d.ts +1 -1
  24. package/lib/cjs/puppeteer/api/Frame.d.ts.map +1 -1
  25. package/lib/cjs/puppeteer/api/Frame.js +4 -4
  26. package/lib/cjs/puppeteer/api/Frame.js.map +1 -1
  27. package/lib/cjs/puppeteer/api/HTTPRequest.d.ts +1 -1
  28. package/lib/cjs/puppeteer/api/Page.d.ts +41 -7
  29. package/lib/cjs/puppeteer/api/Page.d.ts.map +1 -1
  30. package/lib/cjs/puppeteer/api/Page.js.map +1 -1
  31. package/lib/cjs/puppeteer/api/api.d.ts +2 -0
  32. package/lib/cjs/puppeteer/api/api.d.ts.map +1 -1
  33. package/lib/cjs/puppeteer/api/api.js +1 -0
  34. package/lib/cjs/puppeteer/api/api.js.map +1 -1
  35. package/lib/cjs/puppeteer/bidi/BidiOverCdp.d.ts.map +1 -1
  36. package/lib/cjs/puppeteer/bidi/BidiOverCdp.js +1 -1
  37. package/lib/cjs/puppeteer/bidi/BidiOverCdp.js.map +1 -1
  38. package/lib/cjs/puppeteer/bidi/BluetoothEmulation.d.ts +18 -0
  39. package/lib/cjs/puppeteer/bidi/BluetoothEmulation.d.ts.map +1 -0
  40. package/lib/cjs/puppeteer/bidi/BluetoothEmulation.js +42 -0
  41. package/lib/cjs/puppeteer/bidi/BluetoothEmulation.js.map +1 -0
  42. package/lib/cjs/puppeteer/bidi/Browser.d.ts +6 -1
  43. package/lib/cjs/puppeteer/bidi/Browser.d.ts.map +1 -1
  44. package/lib/cjs/puppeteer/bidi/Browser.js +36 -14
  45. package/lib/cjs/puppeteer/bidi/Browser.js.map +1 -1
  46. package/lib/cjs/puppeteer/bidi/BrowserConnector.d.ts.map +1 -1
  47. package/lib/cjs/puppeteer/bidi/BrowserConnector.js +4 -3
  48. package/lib/cjs/puppeteer/bidi/BrowserConnector.js.map +1 -1
  49. package/lib/cjs/puppeteer/bidi/BrowserContext.d.ts +3 -3
  50. package/lib/cjs/puppeteer/bidi/BrowserContext.d.ts.map +1 -1
  51. package/lib/cjs/puppeteer/bidi/BrowserContext.js +6 -3
  52. package/lib/cjs/puppeteer/bidi/BrowserContext.js.map +1 -1
  53. package/lib/cjs/puppeteer/bidi/Connection.d.ts +2 -1
  54. package/lib/cjs/puppeteer/bidi/Connection.d.ts.map +1 -1
  55. package/lib/cjs/puppeteer/bidi/Connection.js +19 -2
  56. package/lib/cjs/puppeteer/bidi/Connection.js.map +1 -1
  57. package/lib/cjs/puppeteer/bidi/DeviceRequestPrompt.d.ts +27 -0
  58. package/lib/cjs/puppeteer/bidi/DeviceRequestPrompt.d.ts.map +1 -0
  59. package/lib/cjs/puppeteer/bidi/DeviceRequestPrompt.js +90 -0
  60. package/lib/cjs/puppeteer/bidi/DeviceRequestPrompt.js.map +1 -0
  61. package/lib/cjs/puppeteer/bidi/Frame.d.ts +3 -1
  62. package/lib/cjs/puppeteer/bidi/Frame.d.ts.map +1 -1
  63. package/lib/cjs/puppeteer/bidi/Frame.js +3 -2
  64. package/lib/cjs/puppeteer/bidi/Frame.js.map +1 -1
  65. package/lib/cjs/puppeteer/bidi/HTTPRequest.d.ts +0 -1
  66. package/lib/cjs/puppeteer/bidi/HTTPRequest.d.ts.map +1 -1
  67. package/lib/cjs/puppeteer/bidi/HTTPRequest.js +2 -29
  68. package/lib/cjs/puppeteer/bidi/HTTPRequest.js.map +1 -1
  69. package/lib/cjs/puppeteer/bidi/Page.d.ts +10 -8
  70. package/lib/cjs/puppeteer/bidi/Page.d.ts.map +1 -1
  71. package/lib/cjs/puppeteer/bidi/Page.js +63 -47
  72. package/lib/cjs/puppeteer/bidi/Page.js.map +1 -1
  73. package/lib/cjs/puppeteer/bidi/core/BrowsingContext.d.ts +8 -0
  74. package/lib/cjs/puppeteer/bidi/core/BrowsingContext.d.ts.map +1 -1
  75. package/lib/cjs/puppeteer/bidi/core/BrowsingContext.js +55 -2
  76. package/lib/cjs/puppeteer/bidi/core/BrowsingContext.js.map +1 -1
  77. package/lib/cjs/puppeteer/bidi/core/Connection.d.ts.map +1 -1
  78. package/lib/cjs/puppeteer/bidi/core/Realm.d.ts +1 -12
  79. package/lib/cjs/puppeteer/bidi/core/Realm.d.ts.map +1 -1
  80. package/lib/cjs/puppeteer/bidi/core/Request.d.ts +1 -0
  81. package/lib/cjs/puppeteer/bidi/core/Request.d.ts.map +1 -1
  82. package/lib/cjs/puppeteer/bidi/core/Request.js +30 -4
  83. package/lib/cjs/puppeteer/bidi/core/Request.js.map +1 -1
  84. package/lib/cjs/puppeteer/bidi/util.d.ts.map +1 -1
  85. package/lib/cjs/puppeteer/bidi/util.js +7 -0
  86. package/lib/cjs/puppeteer/bidi/util.js.map +1 -1
  87. package/lib/cjs/puppeteer/cdp/Accessibility.d.ts +10 -0
  88. package/lib/cjs/puppeteer/cdp/Accessibility.d.ts.map +1 -1
  89. package/lib/cjs/puppeteer/cdp/Accessibility.js +30 -3
  90. package/lib/cjs/puppeteer/cdp/Accessibility.js.map +1 -1
  91. package/lib/cjs/puppeteer/cdp/BluetoothEmulation.d.ts +18 -0
  92. package/lib/cjs/puppeteer/cdp/BluetoothEmulation.d.ts.map +1 -0
  93. package/lib/cjs/puppeteer/cdp/BluetoothEmulation.js +30 -0
  94. package/lib/cjs/puppeteer/cdp/BluetoothEmulation.js.map +1 -0
  95. package/lib/cjs/puppeteer/cdp/Browser.d.ts +10 -5
  96. package/lib/cjs/puppeteer/cdp/Browser.d.ts.map +1 -1
  97. package/lib/cjs/puppeteer/cdp/Browser.js +61 -8
  98. package/lib/cjs/puppeteer/cdp/Browser.js.map +1 -1
  99. package/lib/cjs/puppeteer/cdp/BrowserConnector.d.ts.map +1 -1
  100. package/lib/cjs/puppeteer/cdp/BrowserConnector.js +4 -2
  101. package/lib/cjs/puppeteer/cdp/BrowserConnector.js.map +1 -1
  102. package/lib/cjs/puppeteer/cdp/BrowserContext.d.ts +3 -2
  103. package/lib/cjs/puppeteer/cdp/BrowserContext.d.ts.map +1 -1
  104. package/lib/cjs/puppeteer/cdp/BrowserContext.js +4 -4
  105. package/lib/cjs/puppeteer/cdp/BrowserContext.js.map +1 -1
  106. package/lib/cjs/puppeteer/cdp/CdpSession.d.ts +1 -1
  107. package/lib/cjs/puppeteer/cdp/CdpSession.d.ts.map +1 -1
  108. package/lib/cjs/puppeteer/cdp/CdpSession.js +2 -1
  109. package/lib/cjs/puppeteer/cdp/CdpSession.js.map +1 -1
  110. package/lib/cjs/puppeteer/cdp/Connection.d.ts +6 -1
  111. package/lib/cjs/puppeteer/cdp/Connection.d.ts.map +1 -1
  112. package/lib/cjs/puppeteer/cdp/Connection.js +11 -2
  113. package/lib/cjs/puppeteer/cdp/Connection.js.map +1 -1
  114. package/lib/cjs/puppeteer/cdp/DeviceRequestPrompt.d.ts +5 -64
  115. package/lib/cjs/puppeteer/cdp/DeviceRequestPrompt.d.ts.map +1 -1
  116. package/lib/cjs/puppeteer/cdp/DeviceRequestPrompt.js +10 -76
  117. package/lib/cjs/puppeteer/cdp/DeviceRequestPrompt.js.map +1 -1
  118. package/lib/cjs/puppeteer/cdp/EmulationManager.d.ts +1 -0
  119. package/lib/cjs/puppeteer/cdp/EmulationManager.d.ts.map +1 -1
  120. package/lib/cjs/puppeteer/cdp/EmulationManager.js +22 -0
  121. package/lib/cjs/puppeteer/cdp/EmulationManager.js.map +1 -1
  122. package/lib/cjs/puppeteer/cdp/ExecutionContext.d.ts.map +1 -1
  123. package/lib/cjs/puppeteer/cdp/ExecutionContext.js.map +1 -1
  124. package/lib/cjs/puppeteer/cdp/ExtensionTransport.d.ts.map +1 -1
  125. package/lib/cjs/puppeteer/cdp/ExtensionTransport.js +5 -1
  126. package/lib/cjs/puppeteer/cdp/ExtensionTransport.js.map +1 -1
  127. package/lib/cjs/puppeteer/cdp/Frame.d.ts +1 -1
  128. package/lib/cjs/puppeteer/cdp/Frame.d.ts.map +1 -1
  129. package/lib/cjs/puppeteer/cdp/Frame.js.map +1 -1
  130. package/lib/cjs/puppeteer/cdp/FrameManager.d.ts +2 -2
  131. package/lib/cjs/puppeteer/cdp/FrameManager.d.ts.map +1 -1
  132. package/lib/cjs/puppeteer/cdp/FrameManager.js +1 -1
  133. package/lib/cjs/puppeteer/cdp/FrameManager.js.map +1 -1
  134. package/lib/cjs/puppeteer/cdp/HTTPRequest.d.ts +1 -0
  135. package/lib/cjs/puppeteer/cdp/HTTPRequest.d.ts.map +1 -1
  136. package/lib/cjs/puppeteer/cdp/HTTPRequest.js +6 -2
  137. package/lib/cjs/puppeteer/cdp/HTTPRequest.js.map +1 -1
  138. package/lib/cjs/puppeteer/cdp/HTTPResponse.js +1 -1
  139. package/lib/cjs/puppeteer/cdp/HTTPResponse.js.map +1 -1
  140. package/lib/cjs/puppeteer/cdp/JSHandle.js.map +1 -1
  141. package/lib/cjs/puppeteer/cdp/NetworkEventManager.d.ts +1 -0
  142. package/lib/cjs/puppeteer/cdp/NetworkEventManager.d.ts.map +1 -1
  143. package/lib/cjs/puppeteer/cdp/NetworkEventManager.js +8 -0
  144. package/lib/cjs/puppeteer/cdp/NetworkEventManager.js.map +1 -1
  145. package/lib/cjs/puppeteer/cdp/NetworkManager.d.ts.map +1 -1
  146. package/lib/cjs/puppeteer/cdp/NetworkManager.js +25 -1
  147. package/lib/cjs/puppeteer/cdp/NetworkManager.js.map +1 -1
  148. package/lib/cjs/puppeteer/cdp/Page.d.ts +9 -4
  149. package/lib/cjs/puppeteer/cdp/Page.d.ts.map +1 -1
  150. package/lib/cjs/puppeteer/cdp/Page.js +30 -7
  151. package/lib/cjs/puppeteer/cdp/Page.js.map +1 -1
  152. package/lib/cjs/puppeteer/cdp/TargetManager.d.ts +1 -1
  153. package/lib/cjs/puppeteer/cdp/TargetManager.d.ts.map +1 -1
  154. package/lib/cjs/puppeteer/cdp/TargetManager.js +29 -27
  155. package/lib/cjs/puppeteer/cdp/TargetManager.js.map +1 -1
  156. package/lib/cjs/puppeteer/cdp/WebWorker.d.ts.map +1 -1
  157. package/lib/cjs/puppeteer/cdp/WebWorker.js +8 -3
  158. package/lib/cjs/puppeteer/cdp/WebWorker.js.map +1 -1
  159. package/lib/cjs/puppeteer/cdp/cdp.d.ts +1 -0
  160. package/lib/cjs/puppeteer/cdp/cdp.d.ts.map +1 -1
  161. package/lib/cjs/puppeteer/cdp/cdp.js +1 -0
  162. package/lib/cjs/puppeteer/cdp/cdp.js.map +1 -1
  163. package/lib/cjs/puppeteer/cdp/utils.d.ts +2 -2
  164. package/lib/cjs/puppeteer/cdp/utils.d.ts.map +1 -1
  165. package/lib/cjs/puppeteer/common/BrowserConnector.js +47 -3
  166. package/lib/cjs/puppeteer/common/BrowserConnector.js.map +1 -1
  167. package/lib/cjs/puppeteer/common/CallbackRegistry.d.ts +2 -0
  168. package/lib/cjs/puppeteer/common/CallbackRegistry.d.ts.map +1 -1
  169. package/lib/cjs/puppeteer/common/CallbackRegistry.js +4 -3
  170. package/lib/cjs/puppeteer/common/CallbackRegistry.js.map +1 -1
  171. package/lib/cjs/puppeteer/common/ConnectOptions.d.ts +22 -0
  172. package/lib/cjs/puppeteer/common/ConnectOptions.d.ts.map +1 -1
  173. package/lib/cjs/puppeteer/common/ConsoleMessage.d.ts +8 -1
  174. package/lib/cjs/puppeteer/common/ConsoleMessage.d.ts.map +1 -1
  175. package/lib/cjs/puppeteer/common/ConsoleMessage.js +11 -1
  176. package/lib/cjs/puppeteer/common/ConsoleMessage.js.map +1 -1
  177. package/lib/cjs/puppeteer/common/EventEmitter.d.ts.map +1 -1
  178. package/lib/cjs/puppeteer/injected/injected.d.ts +1 -1
  179. package/lib/cjs/puppeteer/node/BrowserLauncher.d.ts +4 -0
  180. package/lib/cjs/puppeteer/node/BrowserLauncher.d.ts.map +1 -1
  181. package/lib/cjs/puppeteer/node/BrowserLauncher.js +10 -4
  182. package/lib/cjs/puppeteer/node/BrowserLauncher.js.map +1 -1
  183. package/lib/cjs/puppeteer/node/ChromeLauncher.d.ts +1 -1
  184. package/lib/cjs/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
  185. package/lib/cjs/puppeteer/node/ChromeLauncher.js +2 -13
  186. package/lib/cjs/puppeteer/node/ChromeLauncher.js.map +1 -1
  187. package/lib/cjs/puppeteer/node/LaunchOptions.d.ts +5 -3
  188. package/lib/cjs/puppeteer/node/LaunchOptions.d.ts.map +1 -1
  189. package/lib/cjs/puppeteer/node/LaunchOptions.js +17 -0
  190. package/lib/cjs/puppeteer/node/LaunchOptions.js.map +1 -1
  191. package/lib/cjs/puppeteer/revisions.d.ts +3 -3
  192. package/lib/cjs/puppeteer/revisions.js +3 -3
  193. package/lib/cjs/puppeteer/util/Mutex.d.ts +2 -2
  194. package/lib/cjs/puppeteer/util/disposable.d.ts +2 -2
  195. package/lib/cjs/puppeteer/util/disposable.d.ts.map +1 -1
  196. package/lib/cjs/puppeteer/util/disposable.js +3 -1
  197. package/lib/cjs/puppeteer/util/disposable.js.map +1 -1
  198. package/lib/cjs/puppeteer/util/util.d.ts +1 -0
  199. package/lib/cjs/puppeteer/util/util.d.ts.map +1 -1
  200. package/lib/cjs/puppeteer/util/util.js +1 -0
  201. package/lib/cjs/puppeteer/util/util.js.map +1 -1
  202. package/lib/cjs/puppeteer/util/version.d.ts +1 -1
  203. package/lib/cjs/puppeteer/util/version.js +1 -1
  204. package/lib/es5-iife/puppeteer-core-browser.d.ts +304 -22
  205. package/lib/es5-iife/puppeteer-core-browser.js +484 -224
  206. package/lib/esm/puppeteer/api/BluetoothEmulation.d.ts +96 -0
  207. package/lib/esm/puppeteer/api/BluetoothEmulation.d.ts.map +1 -0
  208. package/lib/esm/puppeteer/api/BluetoothEmulation.js +7 -0
  209. package/lib/esm/puppeteer/api/BluetoothEmulation.js.map +1 -0
  210. package/lib/esm/puppeteer/api/Browser.d.ts +111 -2
  211. package/lib/esm/puppeteer/api/Browser.d.ts.map +1 -1
  212. package/lib/esm/puppeteer/api/Browser.js +4 -2
  213. package/lib/esm/puppeteer/api/Browser.js.map +1 -1
  214. package/lib/esm/puppeteer/api/BrowserContext.d.ts +5 -3
  215. package/lib/esm/puppeteer/api/BrowserContext.d.ts.map +1 -1
  216. package/lib/esm/puppeteer/api/BrowserContext.js.map +1 -1
  217. package/lib/esm/puppeteer/api/CDPSession.d.ts.map +1 -1
  218. package/lib/esm/puppeteer/api/CDPSession.js.map +1 -1
  219. package/lib/esm/puppeteer/api/DeviceRequestPrompt.d.ts +62 -0
  220. package/lib/esm/puppeteer/api/DeviceRequestPrompt.d.ts.map +1 -0
  221. package/lib/esm/puppeteer/api/DeviceRequestPrompt.js +34 -0
  222. package/lib/esm/puppeteer/api/DeviceRequestPrompt.js.map +1 -0
  223. package/lib/esm/puppeteer/api/ElementHandle.d.ts.map +1 -1
  224. package/lib/esm/puppeteer/api/ElementHandle.js +1 -1
  225. package/lib/esm/puppeteer/api/ElementHandle.js.map +1 -1
  226. package/lib/esm/puppeteer/api/Frame.d.ts +1 -1
  227. package/lib/esm/puppeteer/api/Frame.d.ts.map +1 -1
  228. package/lib/esm/puppeteer/api/Frame.js +4 -4
  229. package/lib/esm/puppeteer/api/Frame.js.map +1 -1
  230. package/lib/esm/puppeteer/api/HTTPRequest.d.ts +1 -1
  231. package/lib/esm/puppeteer/api/Input.d.ts +1 -1
  232. package/lib/esm/puppeteer/api/Input.d.ts.map +1 -1
  233. package/lib/esm/puppeteer/api/Page.d.ts +41 -7
  234. package/lib/esm/puppeteer/api/Page.d.ts.map +1 -1
  235. package/lib/esm/puppeteer/api/Page.js.map +1 -1
  236. package/lib/esm/puppeteer/api/api.d.ts +2 -0
  237. package/lib/esm/puppeteer/api/api.d.ts.map +1 -1
  238. package/lib/esm/puppeteer/api/api.js +1 -0
  239. package/lib/esm/puppeteer/api/api.js.map +1 -1
  240. package/lib/esm/puppeteer/bidi/BidiOverCdp.d.ts.map +1 -1
  241. package/lib/esm/puppeteer/bidi/BidiOverCdp.js +1 -1
  242. package/lib/esm/puppeteer/bidi/BidiOverCdp.js.map +1 -1
  243. package/lib/esm/puppeteer/bidi/BluetoothEmulation.d.ts +18 -0
  244. package/lib/esm/puppeteer/bidi/BluetoothEmulation.d.ts.map +1 -0
  245. package/lib/esm/puppeteer/bidi/BluetoothEmulation.js +38 -0
  246. package/lib/esm/puppeteer/bidi/BluetoothEmulation.js.map +1 -0
  247. package/lib/esm/puppeteer/bidi/Browser.d.ts +6 -1
  248. package/lib/esm/puppeteer/bidi/Browser.d.ts.map +1 -1
  249. package/lib/esm/puppeteer/bidi/Browser.js +36 -14
  250. package/lib/esm/puppeteer/bidi/Browser.js.map +1 -1
  251. package/lib/esm/puppeteer/bidi/BrowserConnector.d.ts.map +1 -1
  252. package/lib/esm/puppeteer/bidi/BrowserConnector.js +4 -3
  253. package/lib/esm/puppeteer/bidi/BrowserConnector.js.map +1 -1
  254. package/lib/esm/puppeteer/bidi/BrowserContext.d.ts +3 -3
  255. package/lib/esm/puppeteer/bidi/BrowserContext.d.ts.map +1 -1
  256. package/lib/esm/puppeteer/bidi/BrowserContext.js +6 -3
  257. package/lib/esm/puppeteer/bidi/BrowserContext.js.map +1 -1
  258. package/lib/esm/puppeteer/bidi/Connection.d.ts +2 -1
  259. package/lib/esm/puppeteer/bidi/Connection.d.ts.map +1 -1
  260. package/lib/esm/puppeteer/bidi/Connection.js +19 -2
  261. package/lib/esm/puppeteer/bidi/Connection.js.map +1 -1
  262. package/lib/esm/puppeteer/bidi/DeviceRequestPrompt.d.ts +27 -0
  263. package/lib/esm/puppeteer/bidi/DeviceRequestPrompt.d.ts.map +1 -0
  264. package/lib/esm/puppeteer/bidi/DeviceRequestPrompt.js +85 -0
  265. package/lib/esm/puppeteer/bidi/DeviceRequestPrompt.js.map +1 -0
  266. package/lib/esm/puppeteer/bidi/Frame.d.ts +3 -1
  267. package/lib/esm/puppeteer/bidi/Frame.d.ts.map +1 -1
  268. package/lib/esm/puppeteer/bidi/Frame.js +3 -2
  269. package/lib/esm/puppeteer/bidi/Frame.js.map +1 -1
  270. package/lib/esm/puppeteer/bidi/HTTPRequest.d.ts +0 -1
  271. package/lib/esm/puppeteer/bidi/HTTPRequest.d.ts.map +1 -1
  272. package/lib/esm/puppeteer/bidi/HTTPRequest.js +2 -29
  273. package/lib/esm/puppeteer/bidi/HTTPRequest.js.map +1 -1
  274. package/lib/esm/puppeteer/bidi/Page.d.ts +10 -8
  275. package/lib/esm/puppeteer/bidi/Page.d.ts.map +1 -1
  276. package/lib/esm/puppeteer/bidi/Page.js +64 -48
  277. package/lib/esm/puppeteer/bidi/Page.js.map +1 -1
  278. package/lib/esm/puppeteer/bidi/core/BrowsingContext.d.ts +8 -0
  279. package/lib/esm/puppeteer/bidi/core/BrowsingContext.d.ts.map +1 -1
  280. package/lib/esm/puppeteer/bidi/core/BrowsingContext.js +55 -2
  281. package/lib/esm/puppeteer/bidi/core/BrowsingContext.js.map +1 -1
  282. package/lib/esm/puppeteer/bidi/core/Connection.d.ts.map +1 -1
  283. package/lib/esm/puppeteer/bidi/core/Realm.d.ts +1 -12
  284. package/lib/esm/puppeteer/bidi/core/Realm.d.ts.map +1 -1
  285. package/lib/esm/puppeteer/bidi/core/Request.d.ts +1 -0
  286. package/lib/esm/puppeteer/bidi/core/Request.d.ts.map +1 -1
  287. package/lib/esm/puppeteer/bidi/core/Request.js +31 -5
  288. package/lib/esm/puppeteer/bidi/core/Request.js.map +1 -1
  289. package/lib/esm/puppeteer/bidi/util.d.ts.map +1 -1
  290. package/lib/esm/puppeteer/bidi/util.js +7 -0
  291. package/lib/esm/puppeteer/bidi/util.js.map +1 -1
  292. package/lib/esm/puppeteer/cdp/Accessibility.d.ts +10 -0
  293. package/lib/esm/puppeteer/cdp/Accessibility.d.ts.map +1 -1
  294. package/lib/esm/puppeteer/cdp/Accessibility.js +30 -3
  295. package/lib/esm/puppeteer/cdp/Accessibility.js.map +1 -1
  296. package/lib/esm/puppeteer/cdp/BluetoothEmulation.d.ts +18 -0
  297. package/lib/esm/puppeteer/cdp/BluetoothEmulation.d.ts.map +1 -0
  298. package/lib/esm/puppeteer/cdp/BluetoothEmulation.js +26 -0
  299. package/lib/esm/puppeteer/cdp/BluetoothEmulation.js.map +1 -0
  300. package/lib/esm/puppeteer/cdp/Browser.d.ts +10 -5
  301. package/lib/esm/puppeteer/cdp/Browser.d.ts.map +1 -1
  302. package/lib/esm/puppeteer/cdp/Browser.js +61 -8
  303. package/lib/esm/puppeteer/cdp/Browser.js.map +1 -1
  304. package/lib/esm/puppeteer/cdp/BrowserConnector.d.ts.map +1 -1
  305. package/lib/esm/puppeteer/cdp/BrowserConnector.js +4 -2
  306. package/lib/esm/puppeteer/cdp/BrowserConnector.js.map +1 -1
  307. package/lib/esm/puppeteer/cdp/BrowserContext.d.ts +3 -2
  308. package/lib/esm/puppeteer/cdp/BrowserContext.d.ts.map +1 -1
  309. package/lib/esm/puppeteer/cdp/BrowserContext.js +4 -4
  310. package/lib/esm/puppeteer/cdp/BrowserContext.js.map +1 -1
  311. package/lib/esm/puppeteer/cdp/CdpSession.d.ts +1 -1
  312. package/lib/esm/puppeteer/cdp/CdpSession.d.ts.map +1 -1
  313. package/lib/esm/puppeteer/cdp/CdpSession.js +2 -1
  314. package/lib/esm/puppeteer/cdp/CdpSession.js.map +1 -1
  315. package/lib/esm/puppeteer/cdp/Connection.d.ts +6 -1
  316. package/lib/esm/puppeteer/cdp/Connection.d.ts.map +1 -1
  317. package/lib/esm/puppeteer/cdp/Connection.js +11 -2
  318. package/lib/esm/puppeteer/cdp/Connection.js.map +1 -1
  319. package/lib/esm/puppeteer/cdp/DeviceRequestPrompt.d.ts +5 -64
  320. package/lib/esm/puppeteer/cdp/DeviceRequestPrompt.d.ts.map +1 -1
  321. package/lib/esm/puppeteer/cdp/DeviceRequestPrompt.js +7 -72
  322. package/lib/esm/puppeteer/cdp/DeviceRequestPrompt.js.map +1 -1
  323. package/lib/esm/puppeteer/cdp/EmulationManager.d.ts +1 -0
  324. package/lib/esm/puppeteer/cdp/EmulationManager.d.ts.map +1 -1
  325. package/lib/esm/puppeteer/cdp/EmulationManager.js +22 -0
  326. package/lib/esm/puppeteer/cdp/EmulationManager.js.map +1 -1
  327. package/lib/esm/puppeteer/cdp/ExecutionContext.d.ts.map +1 -1
  328. package/lib/esm/puppeteer/cdp/ExecutionContext.js.map +1 -1
  329. package/lib/esm/puppeteer/cdp/ExtensionTransport.d.ts.map +1 -1
  330. package/lib/esm/puppeteer/cdp/ExtensionTransport.js +5 -1
  331. package/lib/esm/puppeteer/cdp/ExtensionTransport.js.map +1 -1
  332. package/lib/esm/puppeteer/cdp/Frame.d.ts +1 -1
  333. package/lib/esm/puppeteer/cdp/Frame.d.ts.map +1 -1
  334. package/lib/esm/puppeteer/cdp/Frame.js.map +1 -1
  335. package/lib/esm/puppeteer/cdp/FrameManager.d.ts +2 -2
  336. package/lib/esm/puppeteer/cdp/FrameManager.d.ts.map +1 -1
  337. package/lib/esm/puppeteer/cdp/FrameManager.js +2 -2
  338. package/lib/esm/puppeteer/cdp/FrameManager.js.map +1 -1
  339. package/lib/esm/puppeteer/cdp/HTTPRequest.d.ts +1 -0
  340. package/lib/esm/puppeteer/cdp/HTTPRequest.d.ts.map +1 -1
  341. package/lib/esm/puppeteer/cdp/HTTPRequest.js +6 -2
  342. package/lib/esm/puppeteer/cdp/HTTPRequest.js.map +1 -1
  343. package/lib/esm/puppeteer/cdp/HTTPResponse.js +1 -1
  344. package/lib/esm/puppeteer/cdp/HTTPResponse.js.map +1 -1
  345. package/lib/esm/puppeteer/cdp/JSHandle.js.map +1 -1
  346. package/lib/esm/puppeteer/cdp/NetworkEventManager.d.ts +1 -0
  347. package/lib/esm/puppeteer/cdp/NetworkEventManager.d.ts.map +1 -1
  348. package/lib/esm/puppeteer/cdp/NetworkEventManager.js +8 -0
  349. package/lib/esm/puppeteer/cdp/NetworkEventManager.js.map +1 -1
  350. package/lib/esm/puppeteer/cdp/NetworkManager.d.ts.map +1 -1
  351. package/lib/esm/puppeteer/cdp/NetworkManager.js +25 -1
  352. package/lib/esm/puppeteer/cdp/NetworkManager.js.map +1 -1
  353. package/lib/esm/puppeteer/cdp/Page.d.ts +9 -4
  354. package/lib/esm/puppeteer/cdp/Page.d.ts.map +1 -1
  355. package/lib/esm/puppeteer/cdp/Page.js +30 -7
  356. package/lib/esm/puppeteer/cdp/Page.js.map +1 -1
  357. package/lib/esm/puppeteer/cdp/TargetManager.d.ts +1 -1
  358. package/lib/esm/puppeteer/cdp/TargetManager.d.ts.map +1 -1
  359. package/lib/esm/puppeteer/cdp/TargetManager.js +30 -28
  360. package/lib/esm/puppeteer/cdp/TargetManager.js.map +1 -1
  361. package/lib/esm/puppeteer/cdp/WebWorker.d.ts.map +1 -1
  362. package/lib/esm/puppeteer/cdp/WebWorker.js +8 -3
  363. package/lib/esm/puppeteer/cdp/WebWorker.js.map +1 -1
  364. package/lib/esm/puppeteer/cdp/cdp.d.ts +1 -0
  365. package/lib/esm/puppeteer/cdp/cdp.d.ts.map +1 -1
  366. package/lib/esm/puppeteer/cdp/cdp.js +1 -0
  367. package/lib/esm/puppeteer/cdp/cdp.js.map +1 -1
  368. package/lib/esm/puppeteer/cdp/utils.d.ts +2 -2
  369. package/lib/esm/puppeteer/cdp/utils.d.ts.map +1 -1
  370. package/lib/esm/puppeteer/common/BrowserConnector.js +48 -4
  371. package/lib/esm/puppeteer/common/BrowserConnector.js.map +1 -1
  372. package/lib/esm/puppeteer/common/CallbackRegistry.d.ts +2 -0
  373. package/lib/esm/puppeteer/common/CallbackRegistry.d.ts.map +1 -1
  374. package/lib/esm/puppeteer/common/CallbackRegistry.js +4 -3
  375. package/lib/esm/puppeteer/common/CallbackRegistry.js.map +1 -1
  376. package/lib/esm/puppeteer/common/ConnectOptions.d.ts +22 -0
  377. package/lib/esm/puppeteer/common/ConnectOptions.d.ts.map +1 -1
  378. package/lib/esm/puppeteer/common/ConsoleMessage.d.ts +8 -1
  379. package/lib/esm/puppeteer/common/ConsoleMessage.d.ts.map +1 -1
  380. package/lib/esm/puppeteer/common/ConsoleMessage.js +11 -1
  381. package/lib/esm/puppeteer/common/ConsoleMessage.js.map +1 -1
  382. package/lib/esm/puppeteer/common/EventEmitter.d.ts.map +1 -1
  383. package/lib/esm/puppeteer/node/BrowserLauncher.d.ts +4 -0
  384. package/lib/esm/puppeteer/node/BrowserLauncher.d.ts.map +1 -1
  385. package/lib/esm/puppeteer/node/BrowserLauncher.js +10 -4
  386. package/lib/esm/puppeteer/node/BrowserLauncher.js.map +1 -1
  387. package/lib/esm/puppeteer/node/ChromeLauncher.d.ts +1 -1
  388. package/lib/esm/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
  389. package/lib/esm/puppeteer/node/ChromeLauncher.js +2 -13
  390. package/lib/esm/puppeteer/node/ChromeLauncher.js.map +1 -1
  391. package/lib/esm/puppeteer/node/LaunchOptions.d.ts +5 -3
  392. package/lib/esm/puppeteer/node/LaunchOptions.d.ts.map +1 -1
  393. package/lib/esm/puppeteer/node/LaunchOptions.js +16 -1
  394. package/lib/esm/puppeteer/node/LaunchOptions.js.map +1 -1
  395. package/lib/esm/puppeteer/revisions.d.ts +3 -3
  396. package/lib/esm/puppeteer/revisions.js +3 -3
  397. package/lib/esm/puppeteer/util/disposable.d.ts +2 -2
  398. package/lib/esm/puppeteer/util/disposable.d.ts.map +1 -1
  399. package/lib/esm/puppeteer/util/disposable.js +2 -2
  400. package/lib/esm/puppeteer/util/disposable.js.map +1 -1
  401. package/lib/esm/puppeteer/util/util.d.ts +1 -0
  402. package/lib/esm/puppeteer/util/util.d.ts.map +1 -1
  403. package/lib/esm/puppeteer/util/util.js +1 -0
  404. package/lib/esm/puppeteer/util/util.js.map +1 -1
  405. package/lib/esm/puppeteer/util/version.d.ts +1 -1
  406. package/lib/esm/puppeteer/util/version.js +1 -1
  407. package/lib/types.d.ts +304 -22
  408. package/package.json +15 -15
  409. package/src/api/BluetoothEmulation.ts +103 -0
  410. package/src/api/Browser.ts +130 -3
  411. package/src/api/BrowserContext.ts +10 -3
  412. package/src/api/CDPSession.ts +1 -2
  413. package/src/api/DeviceRequestPrompt.ts +71 -0
  414. package/src/api/ElementHandle.ts +3 -5
  415. package/src/api/Frame.ts +7 -9
  416. package/src/api/HTTPRequest.ts +1 -1
  417. package/src/api/Page.ts +48 -11
  418. package/src/api/api.ts +2 -0
  419. package/src/bidi/BidiOverCdp.ts +1 -0
  420. package/src/bidi/BluetoothEmulation.ts +52 -0
  421. package/src/bidi/Browser.ts +52 -14
  422. package/src/bidi/BrowserConnector.ts +8 -1
  423. package/src/bidi/BrowserContext.ts +9 -6
  424. package/src/bidi/Connection.ts +20 -1
  425. package/src/bidi/DeviceRequestPrompt.ts +138 -0
  426. package/src/bidi/Frame.ts +7 -3
  427. package/src/bidi/HTTPRequest.ts +2 -45
  428. package/src/bidi/Page.ts +86 -71
  429. package/src/bidi/core/BrowsingContext.ts +80 -2
  430. package/src/bidi/core/Connection.ts +3 -2
  431. package/src/bidi/core/Request.ts +35 -5
  432. package/src/bidi/util.ts +8 -0
  433. package/src/cdp/Accessibility.ts +45 -4
  434. package/src/cdp/BluetoothEmulation.ts +47 -0
  435. package/src/cdp/Browser.ts +95 -10
  436. package/src/cdp/BrowserConnector.ts +4 -0
  437. package/src/cdp/BrowserContext.ts +5 -4
  438. package/src/cdp/CdpSession.ts +3 -2
  439. package/src/cdp/Connection.ts +15 -1
  440. package/src/cdp/DeviceRequestPrompt.ts +8 -79
  441. package/src/cdp/EmulationManager.ts +30 -0
  442. package/src/cdp/ExecutionContext.ts +6 -2
  443. package/src/cdp/ExtensionTransport.ts +5 -1
  444. package/src/cdp/Frame.ts +3 -5
  445. package/src/cdp/FrameManager.ts +9 -4
  446. package/src/cdp/HTTPRequest.ts +7 -2
  447. package/src/cdp/HTTPResponse.ts +1 -1
  448. package/src/cdp/JSHandle.ts +1 -1
  449. package/src/cdp/NetworkEventManager.ts +16 -1
  450. package/src/cdp/NetworkManager.ts +31 -1
  451. package/src/cdp/Page.ts +49 -14
  452. package/src/cdp/TargetManager.ts +36 -43
  453. package/src/cdp/WebWorker.ts +8 -3
  454. package/src/cdp/cdp.ts +1 -0
  455. package/src/cdp/utils.ts +2 -2
  456. package/src/common/BrowserConnector.ts +67 -4
  457. package/src/common/CallbackRegistry.ts +7 -5
  458. package/src/common/ConnectOptions.ts +28 -0
  459. package/src/common/ConsoleMessage.ts +14 -0
  460. package/src/common/EventEmitter.ts +3 -3
  461. package/src/node/BrowserLauncher.ts +22 -1
  462. package/src/node/ChromeLauncher.ts +5 -17
  463. package/src/node/LaunchOptions.ts +23 -7
  464. package/src/revisions.ts +3 -3
  465. package/src/util/disposable.ts +2 -2
  466. package/src/util/util.ts +1 -0
  467. package/src/util/version.ts +1 -1
  468. package/src/templates/version.ts.tmpl +0 -4
@@ -88,6 +88,7 @@ export class NetworkManager extends EventEmitter<NetworkManagerEvents> {
88
88
  ['Fetch.requestPaused', this.#onRequestPaused],
89
89
  ['Fetch.authRequired', this.#onAuthRequired],
90
90
  ['Network.requestWillBeSent', this.#onRequestWillBeSent],
91
+ ['Network.requestWillBeSentExtraInfo', this.#onRequestWillBeSentExtraInfo],
91
92
  ['Network.requestServedFromCache', this.#onRequestServedFromCache],
92
93
  ['Network.responseReceived', this.#onResponseReceived],
93
94
  ['Network.loadingFinished', this.#onLoadingFinished],
@@ -108,7 +109,9 @@ export class NetworkManager extends EventEmitter<NetworkManagerEvents> {
108
109
  #canIgnoreError(error: unknown) {
109
110
  return (
110
111
  isErrorLike(error) &&
111
- (isTargetClosedError(error) || error.message.includes('Not supported'))
112
+ (isTargetClosedError(error) ||
113
+ error.message.includes('Not supported') ||
114
+ error.message.includes("wasn't found"))
112
115
  );
113
116
  }
114
117
 
@@ -534,6 +537,13 @@ export class NetworkManager extends EventEmitter<NetworkManagerEvents> {
534
537
  redirectResponseExtraInfo,
535
538
  );
536
539
  redirectChain = request._redirectChain;
540
+
541
+ const extraInfo = this.#networkEventManager
542
+ .requestExtraInfo(event.requestId)
543
+ .shift();
544
+ if (extraInfo) {
545
+ request.updateHeaders(extraInfo.headers);
546
+ }
537
547
  }
538
548
  }
539
549
  const frame = event.frameId
@@ -548,12 +558,32 @@ export class NetworkManager extends EventEmitter<NetworkManagerEvents> {
548
558
  event,
549
559
  redirectChain,
550
560
  );
561
+
562
+ const extraInfo = this.#networkEventManager
563
+ .requestExtraInfo(event.requestId)
564
+ .shift();
565
+ if (extraInfo) {
566
+ request.updateHeaders(extraInfo.headers);
567
+ }
568
+
551
569
  request._fromMemoryCache = fromMemoryCache;
552
570
  this.#networkEventManager.storeRequest(event.requestId, request);
553
571
  this.emit(NetworkManagerEvent.Request, request);
554
572
  void request.finalizeInterceptions();
555
573
  }
556
574
 
575
+ #onRequestWillBeSentExtraInfo(
576
+ _client: CDPSession,
577
+ event: Protocol.Network.RequestWillBeSentExtraInfoEvent,
578
+ ): void {
579
+ const request = this.#networkEventManager.getRequest(event.requestId);
580
+ if (request) {
581
+ request.updateHeaders(event.headers);
582
+ } else {
583
+ this.#networkEventManager.requestExtraInfo(event.requestId).push(event);
584
+ }
585
+ }
586
+
557
587
  #onRequestServedFromCache(
558
588
  client: CDPSession,
559
589
  event: Protocol.Network.RequestServedFromCacheEvent,
package/src/cdp/Page.ts CHANGED
@@ -7,14 +7,16 @@
7
7
  import type {Protocol} from 'devtools-protocol';
8
8
 
9
9
  import {firstValueFrom, from, raceWith} from '../../third_party/rxjs/rxjs.js';
10
- import type {Browser} from '../api/Browser.js';
10
+ import type {BluetoothEmulation} from '../api/BluetoothEmulation.js';
11
+ import type {Browser, WindowId} from '../api/Browser.js';
11
12
  import type {BrowserContext} from '../api/BrowserContext.js';
12
13
  import {CDPSessionEvent, type CDPSession} from '../api/CDPSession.js';
14
+ import type {DeviceRequestPrompt} from '../api/DeviceRequestPrompt.js';
13
15
  import type {ElementHandle} from '../api/ElementHandle.js';
14
16
  import type {Frame, WaitForOptions} from '../api/Frame.js';
15
17
  import type {HTTPResponse} from '../api/HTTPResponse.js';
16
18
  import type {JSHandle} from '../api/JSHandle.js';
17
- import type {Credentials} from '../api/Page.js';
19
+ import type {Credentials, ReloadOptions} from '../api/Page.js';
18
20
  import {
19
21
  Page,
20
22
  PageEvent,
@@ -58,10 +60,11 @@ import {AsyncDisposableStack} from '../util/disposable.js';
58
60
  import {isErrorLike} from '../util/ErrorLike.js';
59
61
 
60
62
  import {Binding} from './Binding.js';
63
+ import {CdpBluetoothEmulation} from './BluetoothEmulation.js';
64
+ import type {CdpBrowser} from './Browser.js';
61
65
  import {CdpCDPSession} from './CdpSession.js';
62
66
  import {isTargetClosedError} from './Connection.js';
63
67
  import {Coverage} from './Coverage.js';
64
- import type {DeviceRequestPrompt} from './DeviceRequestPrompt.js';
65
68
  import {CdpDialog} from './Dialog.js';
66
69
  import {EmulationManager} from './EmulationManager.js';
67
70
  import type {CdpFrame} from './Frame.js';
@@ -119,6 +122,7 @@ export class CdpPage extends Page {
119
122
 
120
123
  #closed = false;
121
124
  readonly #targetManager: TargetManager;
125
+ readonly #cdpBluetoothEmulation: CdpBluetoothEmulation;
122
126
 
123
127
  #primaryTargetClient: CdpCDPSession;
124
128
  #primaryTarget: CdpTarget;
@@ -158,6 +162,12 @@ export class CdpPage extends Page {
158
162
  this.#coverage = new Coverage(client);
159
163
  this.#viewport = null;
160
164
 
165
+ // Use browser context's connection, as current Bluetooth emulation in Chromium is
166
+ // implemented on the browser context level, and not tight to the specific tab.
167
+ this.#cdpBluetoothEmulation = new CdpBluetoothEmulation(
168
+ this.#primaryTargetClient.connection(),
169
+ );
170
+
161
171
  const frameManagerEmitter = new EventEmitter(this.#frameManager);
162
172
  frameManagerEmitter.on(FrameManagerEvent.FrameAttached, frame => {
163
173
  this.emit(PageEvent.FrameAttached, frame);
@@ -365,17 +375,22 @@ export class CdpPage extends Page {
365
375
  contentWidth: number;
366
376
  contentHeight: number;
367
377
  }): Promise<void> {
368
- const {windowId} = await this.#primaryTargetClient.send(
369
- 'Browser.getWindowForTarget',
370
- );
371
-
378
+ const windowId = await this.windowId();
372
379
  await this.#primaryTargetClient.send('Browser.setContentsSize', {
373
- windowId,
380
+ windowId: Number(windowId),
374
381
  width: params.contentWidth,
375
382
  height: params.contentHeight,
376
383
  });
377
384
  }
378
385
 
386
+ override async windowId(): Promise<WindowId> {
387
+ const {windowId} = await this.#primaryTargetClient.send(
388
+ 'Browser.getWindowForTarget',
389
+ );
390
+
391
+ return windowId.toString();
392
+ }
393
+
379
394
  async #onFileChooser(
380
395
  event: Protocol.Page.FileChooserOpenedEvent,
381
396
  ): Promise<void> {
@@ -417,6 +432,13 @@ export class CdpPage extends Page {
417
432
  return this.#emulationManager.javascriptEnabled;
418
433
  }
419
434
 
435
+ override async openDevTools(): Promise<Page> {
436
+ const pageTargetId = this.target()._targetId;
437
+ const browser = this.browser() as CdpBrowser;
438
+ const devtoolsPage = await browser._createDevToolsPage(pageTargetId);
439
+ return devtoolsPage;
440
+ }
441
+
420
442
  override async waitForFileChooser(
421
443
  options: WaitTimeoutOptions = {},
422
444
  ): Promise<FileChooser> {
@@ -480,7 +502,8 @@ export class CdpPage extends Page {
480
502
  }
481
503
 
482
504
  #onLogEntryAdded(event: Protocol.Log.EntryAddedEvent): void {
483
- const {level, text, args, source, url, lineNumber} = event.entry;
505
+ const {level, text, args, source, url, lineNumber, stackTrace} =
506
+ event.entry;
484
507
  if (args) {
485
508
  args.map(arg => {
486
509
  void releaseObject(this.#primaryTargetClient, arg);
@@ -494,6 +517,8 @@ export class CdpPage extends Page {
494
517
  text,
495
518
  [],
496
519
  [{url, lineNumber}],
520
+ undefined,
521
+ stackTrace,
497
522
  ),
498
523
  );
499
524
  }
@@ -560,6 +585,10 @@ export class CdpPage extends Page {
560
585
  );
561
586
  }
562
587
 
588
+ override async emulateFocusedPage(enabled: boolean): Promise<void> {
589
+ return await this.#emulationManager.emulateFocus(enabled);
590
+ }
591
+
563
592
  override setDefaultNavigationTimeout(timeout: number): void {
564
593
  this._timeoutSettings.setDefaultNavigationTimeout(timeout);
565
594
  }
@@ -859,7 +888,7 @@ export class CdpPage extends Page {
859
888
  }
860
889
  const textTokens = [];
861
890
  // eslint-disable-next-line max-len -- The comment is long.
862
- // eslint-disable-next-line rulesdir/use-using -- These are not owned by this function.
891
+ // eslint-disable-next-line @puppeteer/use-using -- These are not owned by this function.
863
892
  for (const arg of args) {
864
893
  const remoteObject = arg.remoteObject();
865
894
  if (remoteObject.objectId) {
@@ -883,6 +912,8 @@ export class CdpPage extends Page {
883
912
  textTokens.join(' '),
884
913
  args,
885
914
  stackTraceLocations,
915
+ undefined,
916
+ stackTrace,
886
917
  );
887
918
  this.emit(PageEvent.Console, message);
888
919
  }
@@ -898,15 +929,15 @@ export class CdpPage extends Page {
898
929
  this.emit(PageEvent.Dialog, dialog);
899
930
  }
900
931
 
901
- override async reload(
902
- options?: WaitForOptions,
903
- ): Promise<HTTPResponse | null> {
932
+ override async reload(options?: ReloadOptions): Promise<HTTPResponse | null> {
904
933
  const [result] = await Promise.all([
905
934
  this.waitForNavigation({
906
935
  ...options,
907
936
  ignoreSameDocumentNavigation: true,
908
937
  }),
909
- this.#primaryTargetClient.send('Page.reload'),
938
+ this.#primaryTargetClient.send('Page.reload', {
939
+ ignoreCache: options?.ignoreCache ?? false,
940
+ }),
910
941
  ]);
911
942
 
912
943
  return result;
@@ -1219,6 +1250,10 @@ export class CdpPage extends Page {
1219
1250
  ): Promise<DeviceRequestPrompt> {
1220
1251
  return await this.mainFrame().waitForDevicePrompt(options);
1221
1252
  }
1253
+
1254
+ override get bluetooth(): BluetoothEmulation {
1255
+ return this.#cdpBluetoothEmulation;
1256
+ }
1222
1257
  }
1223
1258
 
1224
1259
  const supportedMetrics = new Set<string>([
@@ -15,7 +15,8 @@ import {Deferred} from '../util/Deferred.js';
15
15
 
16
16
  import {CdpCDPSession} from './CdpSession.js';
17
17
  import type {Connection} from './Connection.js';
18
- import {CdpTarget, InitializationStatus} from './Target.js';
18
+ import type {CdpTarget} from './Target.js';
19
+ import {InitializationStatus} from './Target.js';
19
20
  import type {TargetManagerEvents} from './TargetManageEvents.js';
20
21
  import {TargetManagerEvent} from './TargetManageEvents.js';
21
22
 
@@ -90,10 +91,20 @@ export class TargetManager
90
91
  >();
91
92
 
92
93
  #initializeDeferred = Deferred.create<void>();
93
- #targetsIdsForInit = new Set<string>();
94
94
  #waitForInitiallyDiscoveredTargets = true;
95
95
 
96
96
  #discoveryFilter: Protocol.Target.FilterEntry[] = [{}];
97
+ // IDs of tab targets detected while running the initial Target.setAutoAttach
98
+ // request. These are the targets whose initialization we want to await for
99
+ // before resolving puppeteer.connect() or launch() to avoid flakiness.
100
+ // Whenever a sub-target whose parent is a tab target is attached, we remove
101
+ // the tab target from this list. Once the list is empty, we resolve the
102
+ // initializeDeferred.
103
+ #targetsIdsForInit = new Set<string>();
104
+ // This is false until the connection-level Target.setAutoAttach request is
105
+ // done. It indicates whethere we are running the initial auto-attach step or
106
+ // if we are handling targets after that.
107
+ #initialAttachDone = false;
97
108
 
98
109
  constructor(
99
110
  connection: Connection,
@@ -117,45 +128,12 @@ export class TargetManager
117
128
  this.#setupAttachmentListeners(this.#connection);
118
129
  }
119
130
 
120
- #storeExistingTargetsForInit = () => {
121
- if (!this.#waitForInitiallyDiscoveredTargets) {
122
- return;
123
- }
124
- for (const [
125
- targetId,
126
- targetInfo,
127
- ] of this.#discoveredTargetsByTargetId.entries()) {
128
- const targetForFilter = new CdpTarget(
129
- targetInfo,
130
- undefined,
131
- undefined,
132
- this,
133
- undefined,
134
- );
135
- // Only wait for pages and frames (except those from extensions)
136
- // to auto-attach.
137
- const isPageOrFrame =
138
- targetInfo.type === 'page' || targetInfo.type === 'iframe';
139
- const isExtension = targetInfo.url.startsWith('chrome-extension://');
140
- if (
141
- (!this.#targetFilterCallback ||
142
- this.#targetFilterCallback(targetForFilter)) &&
143
- isPageOrFrame &&
144
- !isExtension
145
- ) {
146
- this.#targetsIdsForInit.add(targetId);
147
- }
148
- }
149
- };
150
-
151
131
  async initialize(): Promise<void> {
152
132
  await this.#connection.send('Target.setDiscoverTargets', {
153
133
  discover: true,
154
134
  filter: this.#discoveryFilter,
155
135
  });
156
136
 
157
- this.#storeExistingTargetsForInit();
158
-
159
137
  await this.#connection.send('Target.setAutoAttach', {
160
138
  waitForDebuggerOnStart: true,
161
139
  flatten: true,
@@ -168,6 +146,7 @@ export class TargetManager
168
146
  ...this.#discoveryFilter,
169
147
  ],
170
148
  });
149
+ this.#initialAttachDone = true;
171
150
  this.#finishInitializationIfReady();
172
151
  await this.#initializeDeferred.valueOrThrow();
173
152
  }
@@ -346,7 +325,6 @@ export class TargetManager
346
325
  // should determine if a target is auto-attached or not with the help of
347
326
  // CDP.
348
327
  if (targetInfo.type === 'service_worker') {
349
- this.#finishInitializationIfReady(targetInfo.targetId);
350
328
  await silentDetach();
351
329
  if (this.#attachedTargetsByTargetId.has(targetInfo.targetId)) {
352
330
  return;
@@ -370,13 +348,26 @@ export class TargetManager
370
348
  parentSession instanceof CdpCDPSession ? parentSession : undefined,
371
349
  );
372
350
 
351
+ const parentTarget =
352
+ parentSession instanceof CdpCDPSession ? parentSession.target() : null;
353
+
373
354
  if (this.#targetFilterCallback && !this.#targetFilterCallback(target)) {
374
355
  this.#ignoredTargets.add(targetInfo.targetId);
375
- this.#finishInitializationIfReady(targetInfo.targetId);
356
+ if (parentTarget?.type() === 'tab') {
357
+ this.#finishInitializationIfReady(parentTarget._targetId);
358
+ }
376
359
  await silentDetach();
377
360
  return;
378
361
  }
379
362
 
363
+ if (
364
+ this.#waitForInitiallyDiscoveredTargets &&
365
+ event.targetInfo.type === 'tab' &&
366
+ !this.#initialAttachDone
367
+ ) {
368
+ this.#targetsIdsForInit.add(event.targetInfo.targetId);
369
+ }
370
+
380
371
  this.#setupAttachmentListeners(session);
381
372
 
382
373
  if (isExistingTarget) {
@@ -391,19 +382,16 @@ export class TargetManager
391
382
  this.#attachedTargetsBySessionId.set(session.id(), target);
392
383
  }
393
384
 
394
- const parentTarget =
395
- parentSession instanceof CDPSession
396
- ? (parentSession as CdpCDPSession).target()
397
- : null;
398
385
  parentTarget?._addChildTarget(target);
399
386
 
400
387
  parentSession.emit(CDPSessionEvent.Ready, session);
401
388
 
402
- this.#targetsIdsForInit.delete(target._targetId);
403
389
  if (!isExistingTarget) {
404
390
  this.emit(TargetManagerEvent.TargetAvailable, target);
405
391
  }
406
- this.#finishInitializationIfReady();
392
+ if (parentTarget?.type() === 'tab') {
393
+ this.#finishInitializationIfReady(parentTarget._targetId);
394
+ }
407
395
 
408
396
  // TODO: the browser might be shutting down here. What do we do with the
409
397
  // error?
@@ -422,6 +410,11 @@ export class TargetManager
422
410
  if (targetId !== undefined) {
423
411
  this.#targetsIdsForInit.delete(targetId);
424
412
  }
413
+ // If we are still initializing it might be that we have not learned about
414
+ // some targets yet.
415
+ if (!this.#initialAttachDone) {
416
+ return;
417
+ }
425
418
  if (this.#targetsIdsForInit.size === 0) {
426
419
  this.#initializeDeferred.resolve();
427
420
  }
@@ -114,9 +114,8 @@ export class CdpWebWorker extends WebWorker {
114
114
 
115
115
  override async close(): Promise<void> {
116
116
  switch (this.#targetType) {
117
- case TargetType.SERVICE_WORKER:
118
- case TargetType.SHARED_WORKER: {
119
- // For service and shared workers we need to close the target and detach to allow
117
+ case TargetType.SERVICE_WORKER: {
118
+ // For service workers we need to close the target and detach to allow
120
119
  // the worker to stop.
121
120
  await this.client.connection()?.send('Target.closeTarget', {
122
121
  targetId: this.#id,
@@ -126,6 +125,12 @@ export class CdpWebWorker extends WebWorker {
126
125
  });
127
126
  break;
128
127
  }
128
+ case TargetType.SHARED_WORKER: {
129
+ await this.client.connection()?.send('Target.closeTarget', {
130
+ targetId: this.#id,
131
+ });
132
+ break;
133
+ }
129
134
  default:
130
135
  await this.evaluate(() => {
131
136
  self.close();
package/src/cdp/cdp.ts CHANGED
@@ -6,6 +6,7 @@
6
6
 
7
7
  export * from './Accessibility.js';
8
8
  export * from './Binding.js';
9
+ export * from './BluetoothEmulation.js';
9
10
  export * from './Browser.js';
10
11
  export * from './BrowserContext.js';
11
12
  export * from './BrowserConnector.js';
package/src/cdp/utils.ts CHANGED
@@ -94,7 +94,7 @@ const getErrorDetails = (details: Protocol.Runtime.ExceptionDetails) => {
94
94
  */
95
95
  export function createClientError(
96
96
  details: Protocol.Runtime.ExceptionDetails,
97
- ): Error {
97
+ ): Error | unknown {
98
98
  let name: string;
99
99
  let message: string;
100
100
  if (!details.exception) {
@@ -141,7 +141,7 @@ export function createClientError(
141
141
  */
142
142
  export function valueFromRemoteObject(
143
143
  remoteObject: Protocol.Runtime.RemoteObject,
144
- ): any {
144
+ ): unknown {
145
145
  assert(!remoteObject.objectId, 'Cannot extract value when objectId is given');
146
146
  if (remoteObject.unserializableValue) {
147
147
  if (remoteObject.type === 'bigint') {
@@ -7,7 +7,7 @@
7
7
  import type {Browser} from '../api/Browser.js';
8
8
  import {_connectToBiDiBrowser} from '../bidi/BrowserConnector.js';
9
9
  import {_connectToCdpBrowser} from '../cdp/BrowserConnector.js';
10
- import {isNode} from '../environment.js';
10
+ import {environment, isNode} from '../environment.js';
11
11
  import {assert} from '../util/assert.js';
12
12
  import {isErrorLike} from '../util/ErrorLike.js';
13
13
 
@@ -57,12 +57,21 @@ export async function _connectToBrowser(
57
57
  async function getConnectionTransport(
58
58
  options: ConnectOptions,
59
59
  ): Promise<{connectionTransport: ConnectionTransport; endpointUrl: string}> {
60
- const {browserWSEndpoint, browserURL, transport, headers = {}} = options;
60
+ const {
61
+ browserWSEndpoint,
62
+ browserURL,
63
+ channel,
64
+ transport,
65
+ headers = {},
66
+ } = options;
61
67
 
62
68
  assert(
63
- Number(!!browserWSEndpoint) + Number(!!browserURL) + Number(!!transport) ===
69
+ Number(!!browserWSEndpoint) +
70
+ Number(!!browserURL) +
71
+ Number(!!transport) +
72
+ Number(!!channel) ===
64
73
  1,
65
- 'Exactly one of browserWSEndpoint, browserURL or transport must be passed to puppeteer.connect',
74
+ 'Exactly one of browserWSEndpoint, browserURL, transport or channel must be passed to puppeteer.connect',
66
75
  );
67
76
 
68
77
  if (transport) {
@@ -84,6 +93,60 @@ async function getConnectionTransport(
84
93
  connectionTransport: connectionTransport,
85
94
  endpointUrl: connectionURL,
86
95
  };
96
+ } else if (options.channel && isNode) {
97
+ const {detectBrowserPlatform, resolveDefaultUserDataDir, Browser} =
98
+ await import('@puppeteer/browsers');
99
+ const platform = detectBrowserPlatform();
100
+ if (!platform) {
101
+ throw new Error('Could not detect required browser platform');
102
+ }
103
+ const {convertPuppeteerChannelToBrowsersChannel} =
104
+ await import('../node/LaunchOptions.js');
105
+ const {join} = await import('node:path');
106
+ const userDataDir = resolveDefaultUserDataDir(
107
+ Browser.CHROME,
108
+ platform,
109
+ convertPuppeteerChannelToBrowsersChannel(options.channel),
110
+ );
111
+ const portPath = join(userDataDir, 'DevToolsActivePort');
112
+ try {
113
+ const fileContent = await environment.value.fs.promises.readFile(
114
+ portPath,
115
+ 'ascii',
116
+ );
117
+ const [rawPort, rawPath] = fileContent
118
+ .split('\n')
119
+ .map(line => {
120
+ return line.trim();
121
+ })
122
+ .filter(line => {
123
+ return !!line;
124
+ });
125
+ if (!rawPort || !rawPath) {
126
+ throw new Error(`Invalid DevToolsActivePort '${fileContent}' found`);
127
+ }
128
+ const port = parseInt(rawPort, 10);
129
+ if (isNaN(port) || port <= 0 || port > 65535) {
130
+ throw new Error(`Invalid port '${rawPort}' found`);
131
+ }
132
+ const browserWSEndpoint = `ws://localhost:${port}${rawPath}`;
133
+ const WebSocketClass = await getWebSocketTransportClass();
134
+ const connectionTransport = await WebSocketClass.create(
135
+ browserWSEndpoint,
136
+ headers,
137
+ );
138
+ return {
139
+ connectionTransport: connectionTransport,
140
+ endpointUrl: browserWSEndpoint,
141
+ };
142
+ } catch (error) {
143
+ throw new Error(
144
+ `Could not find DevToolsActivePort for ${options.channel} at ${portPath}`,
145
+ {
146
+ cause: error,
147
+ },
148
+ );
149
+ }
87
150
  }
88
151
  throw new Error('Invalid connection options');
89
152
  }
@@ -6,21 +6,23 @@
6
6
 
7
7
  import {Deferred} from '../util/Deferred.js';
8
8
  import {rewriteError} from '../util/ErrorLike.js';
9
- import {createIncrementalIdGenerator} from '../util/incremental-id-generator.js';
9
+ import type {GetIdFn} from '../util/incremental-id-generator.js';
10
10
 
11
11
  import {ProtocolError, TargetCloseError} from './Errors.js';
12
12
  import {debugError} from './util.js';
13
13
 
14
- const idGenerator = createIncrementalIdGenerator();
15
-
16
14
  /**
17
15
  * Manages callbacks and their IDs for the protocol request/response communication.
18
16
  *
19
17
  * @internal
20
18
  */
21
19
  export class CallbackRegistry {
22
- #callbacks = new Map<number, Callback>();
23
- #idGenerator = idGenerator;
20
+ readonly #callbacks = new Map<number, Callback>();
21
+ readonly #idGenerator: GetIdFn;
22
+
23
+ constructor(idGenerator: GetIdFn) {
24
+ this.#idGenerator = idGenerator;
25
+ }
24
26
 
25
27
  create(
26
28
  label: string,
@@ -38,6 +38,15 @@ export interface SupportedWebDriverCapabilities {
38
38
  alwaysMatch?: SupportedWebDriverCapability;
39
39
  }
40
40
 
41
+ /**
42
+ * @public
43
+ */
44
+ export type ChromeReleaseChannel =
45
+ | 'chrome'
46
+ | 'chrome-beta'
47
+ | 'chrome-canary'
48
+ | 'chrome-dev';
49
+
41
50
  /**
42
51
  * Generic browser options that can be passed when launching any browser or when
43
52
  * connecting to an existing browser instance.
@@ -49,6 +58,17 @@ export interface ConnectOptions {
49
58
  * @defaultValue `false`
50
59
  */
51
60
  acceptInsecureCerts?: boolean;
61
+ /**
62
+ * If specified, puppeteer looks for an open WebSocket at the well-known
63
+ * default user data directory for the specified channel and attempts to
64
+ * connect to it using ws://localhost:$ActivePort/devtools/browser. Only works
65
+ * for Chrome and when run in Node.js.
66
+ *
67
+ * This option is experimental when used with puppeteer.connect().
68
+ *
69
+ * @experimental
70
+ */
71
+ channel?: ChromeReleaseChannel;
52
72
  /**
53
73
  * Experimental setting to disable monitoring network events by default. When
54
74
  * set to `false`, parts of Puppeteer that depend on network events would not
@@ -112,6 +132,14 @@ export interface ConnectOptions {
112
132
  browserWSEndpoint?: string;
113
133
  browserURL?: string;
114
134
  transport?: ConnectionTransport;
135
+ /**
136
+ * @internal
137
+ *
138
+ * Custom ID generator for CDP / BiDi messages. Useful if the same transport
139
+ * is shared for multiple connections.
140
+ */
141
+ idGenerator?: () => number;
142
+
115
143
  /**
116
144
  * Headers to use for the web socket connection.
117
145
  * @remarks
@@ -4,6 +4,8 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
+ import type {Protocol} from 'devtools-protocol';
8
+
7
9
  import type {Frame} from '../api/Frame.js';
8
10
  import type {JSHandle} from '../api/JSHandle.js';
9
11
 
@@ -62,6 +64,7 @@ export class ConsoleMessage {
62
64
  #args: JSHandle[];
63
65
  #stackTraceLocations: ConsoleMessageLocation[];
64
66
  #frame?: Frame;
67
+ #rawStackTrace?: Protocol.Runtime.StackTrace;
65
68
 
66
69
  /**
67
70
  * @internal
@@ -72,12 +75,14 @@ export class ConsoleMessage {
72
75
  args: JSHandle[],
73
76
  stackTraceLocations: ConsoleMessageLocation[],
74
77
  frame?: Frame,
78
+ rawStackTrace?: Protocol.Runtime.StackTrace,
75
79
  ) {
76
80
  this.#type = type;
77
81
  this.#text = text;
78
82
  this.#args = args;
79
83
  this.#stackTraceLocations = stackTraceLocations;
80
84
  this.#frame = frame;
85
+ this.#rawStackTrace = rawStackTrace;
81
86
  }
82
87
 
83
88
  /**
@@ -117,4 +122,13 @@ export class ConsoleMessage {
117
122
  stackTrace(): ConsoleMessageLocation[] {
118
123
  return this.#stackTraceLocations;
119
124
  }
125
+
126
+ /**
127
+ * The underlying protocol stack trace if available.
128
+ *
129
+ * @internal
130
+ */
131
+ _rawStackTrace(): Protocol.Runtime.StackTrace | undefined {
132
+ return this.#rawStackTrace;
133
+ }
120
134
  }
@@ -56,9 +56,9 @@ export type EventsWithWildcard<Events extends Record<EventType, unknown>> =
56
56
  *
57
57
  * @public
58
58
  */
59
- export class EventEmitter<Events extends Record<EventType, unknown>>
60
- implements CommonEventEmitter<EventsWithWildcard<Events>>
61
- {
59
+ export class EventEmitter<
60
+ Events extends Record<EventType, unknown>,
61
+ > implements CommonEventEmitter<EventsWithWildcard<Events>> {
62
62
  #emitter: Emitter<EventsWithWildcard<Events>> | EventEmitter<Events>;
63
63
  #handlers = new Map<keyof Events | '*', Array<Handler<any>>>();
64
64