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
@@ -8,7 +8,7 @@ import type {ChildProcess} from 'node:child_process';
8
8
 
9
9
  import type {Protocol} from 'devtools-protocol';
10
10
 
11
- import type {DebugInfo} from '../api/Browser.js';
11
+ import type {CreatePageOptions, DebugInfo} from '../api/Browser.js';
12
12
  import {
13
13
  Browser as BrowserBase,
14
14
  BrowserEvent,
@@ -16,6 +16,10 @@ import {
16
16
  type BrowserContextOptions,
17
17
  type IsPageTargetCallback,
18
18
  type TargetFilterCallback,
19
+ type ScreenInfo,
20
+ type AddScreenParams,
21
+ type WindowBounds,
22
+ type WindowId,
19
23
  } from '../api/Browser.js';
20
24
  import {BrowserContextEvent} from '../api/BrowserContext.js';
21
25
  import {CDPSessionEvent} from '../api/CDPSession.js';
@@ -196,7 +200,9 @@ export class CdpBrowser extends BrowserBase {
196
200
  target.type() === 'webview' ||
197
201
  (this.#handleDevToolsAsPage &&
198
202
  target.type() === 'other' &&
199
- target.url().startsWith('devtools://'))
203
+ target
204
+ .url()
205
+ .startsWith('devtools://devtools/bundled/devtools_app.html'))
200
206
  );
201
207
  });
202
208
  }
@@ -343,19 +349,30 @@ export class CdpBrowser extends BrowserBase {
343
349
  return this.#connection.url();
344
350
  }
345
351
 
346
- override async newPage(): Promise<Page> {
347
- return await this.#defaultContext.newPage();
352
+ override async newPage(options?: CreatePageOptions): Promise<Page> {
353
+ return await this.#defaultContext.newPage(options);
348
354
  }
349
355
 
350
- // rebrowser-patches: expose browser CDP session
351
- _connection(): Connection {
352
- return this.#connection;
353
- }
354
-
355
- async _createPageInContext(contextId?: string): Promise<Page> {
356
+ async _createPageInContext(
357
+ contextId?: string,
358
+ options?: CreatePageOptions,
359
+ ): Promise<Page> {
360
+ const hasTargets =
361
+ this.targets().filter(t => {
362
+ return t.browserContext().id === contextId;
363
+ }).length > 0;
364
+ const windowBounds =
365
+ options?.type === 'window' ? options.windowBounds : undefined;
356
366
  const {targetId} = await this.#connection.send('Target.createTarget', {
357
367
  url: 'about:blank',
358
368
  browserContextId: contextId || undefined,
369
+ left: windowBounds?.left,
370
+ top: windowBounds?.top,
371
+ width: windowBounds?.width,
372
+ height: windowBounds?.height,
373
+ windowState: windowBounds?.windowState,
374
+ // Works around crbug.com/454825274.
375
+ newWindow: hasTargets && options?.type === 'window' ? true : undefined,
359
376
  });
360
377
  const target = (await this.waitForTarget(t => {
361
378
  return (t as CdpTarget)._targetId === targetId;
@@ -378,6 +395,38 @@ export class CdpBrowser extends BrowserBase {
378
395
  return page;
379
396
  }
380
397
 
398
+ async _createDevToolsPage(pageTargetId: string): Promise<Page> {
399
+ const openDevToolsResponse = await this.#connection.send(
400
+ 'Target.openDevTools',
401
+ {
402
+ targetId: pageTargetId,
403
+ },
404
+ );
405
+ const target = (await this.waitForTarget(t => {
406
+ return (t as CdpTarget)._targetId === openDevToolsResponse.targetId;
407
+ })) as CdpTarget;
408
+ if (!target) {
409
+ throw new Error(
410
+ `Missing target for DevTools page (id = ${pageTargetId})`,
411
+ );
412
+ }
413
+ const initialized =
414
+ (await target._initializedDeferred.valueOrThrow()) ===
415
+ InitializationStatus.SUCCESS;
416
+ if (!initialized) {
417
+ throw new Error(
418
+ `Failed to create target for DevTools page (id = ${pageTargetId})`,
419
+ );
420
+ }
421
+ const page = await target.page();
422
+ if (!page) {
423
+ throw new Error(
424
+ `Failed to create a DevTools Page for target (id = ${pageTargetId})`,
425
+ );
426
+ }
427
+ return page;
428
+ }
429
+
381
430
  override async installExtension(path: string): Promise<string> {
382
431
  const {id} = await this.#connection.send('Extensions.loadUnpacked', {path});
383
432
  return id;
@@ -387,6 +436,42 @@ export class CdpBrowser extends BrowserBase {
387
436
  return this.#connection.send('Extensions.uninstall', {id});
388
437
  }
389
438
 
439
+ override async screens(): Promise<ScreenInfo[]> {
440
+ const {screenInfos} = await this.#connection.send(
441
+ 'Emulation.getScreenInfos',
442
+ );
443
+ return screenInfos;
444
+ }
445
+
446
+ override async addScreen(params: AddScreenParams): Promise<ScreenInfo> {
447
+ const {screenInfo} = await this.#connection.send(
448
+ 'Emulation.addScreen',
449
+ params,
450
+ );
451
+ return screenInfo;
452
+ }
453
+
454
+ override async removeScreen(screenId: string): Promise<void> {
455
+ return await this.#connection.send('Emulation.removeScreen', {screenId});
456
+ }
457
+
458
+ override async getWindowBounds(windowId: WindowId): Promise<WindowBounds> {
459
+ const {bounds} = await this.#connection.send('Browser.getWindowBounds', {
460
+ windowId: Number(windowId),
461
+ });
462
+ return bounds;
463
+ }
464
+
465
+ override async setWindowBounds(
466
+ windowId: WindowId,
467
+ windowBounds: WindowBounds,
468
+ ): Promise<void> {
469
+ await this.#connection.send('Browser.setWindowBounds', {
470
+ windowId: Number(windowId),
471
+ bounds: windowBounds,
472
+ });
473
+ }
474
+
390
475
  override targets(): CdpTarget[] {
391
476
  return Array.from(
392
477
  this.#targetManager.getAvailableTargets().values(),
@@ -7,6 +7,7 @@
7
7
  import type {ConnectionTransport} from '../common/ConnectionTransport.js';
8
8
  import type {ConnectOptions} from '../common/ConnectOptions.js';
9
9
  import {debugError, DEFAULT_VIEWPORT} from '../common/util.js';
10
+ import {createIncrementalIdGenerator} from '../util/incremental-id-generator.js';
10
11
 
11
12
  import {CdpBrowser} from './Browser.js';
12
13
  import {Connection} from './Connection.js';
@@ -32,6 +33,7 @@ export async function _connectToCdpBrowser(
32
33
  slowMo = 0,
33
34
  protocolTimeout,
34
35
  handleDevToolsAsPage,
36
+ idGenerator = createIncrementalIdGenerator(),
35
37
  } = options;
36
38
 
37
39
  const connection = new Connection(
@@ -39,6 +41,8 @@ export async function _connectToCdpBrowser(
39
41
  connectionTransport,
40
42
  slowMo,
41
43
  protocolTimeout,
44
+ /* rawErrors */ false,
45
+ idGenerator,
42
46
  );
43
47
 
44
48
  const {browserContextIds} = await connection.send(
@@ -4,6 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
+ import type {CreatePageOptions} from '../api/Browser.js';
7
8
  import {
8
9
  WEB_PERMISSION_TO_PROTOCOL_PERMISSION,
9
10
  type Permission,
@@ -44,13 +45,13 @@ export class CdpBrowserContext extends BrowserContext {
44
45
  });
45
46
  }
46
47
 
47
- override async pages(): Promise<Page[]> {
48
+ override async pages(includeAll = false): Promise<Page[]> {
48
49
  const pages = await Promise.all(
49
50
  this.targets()
50
51
  .filter(target => {
51
52
  return (
52
53
  target.type() === 'page' ||
53
- (target.type() === 'other' &&
54
+ ((target.type() === 'other' || includeAll) &&
54
55
  this.#browser._getIsPageTargetCallback()?.(target))
55
56
  );
56
57
  })
@@ -88,9 +89,9 @@ export class CdpBrowserContext extends BrowserContext {
88
89
  });
89
90
  }
90
91
 
91
- override async newPage(): Promise<Page> {
92
+ override async newPage(options?: CreatePageOptions): Promise<Page> {
92
93
  using _guard = await this.waitForScreenshotOperations();
93
- return await this.#browser._createPageInContext(this.#id);
94
+ return await this.#browser._createPageInContext(this.#id, options);
94
95
  }
95
96
 
96
97
  override browser(): CdpBrowser {
@@ -27,7 +27,7 @@ import type {CdpTarget} from './Target.js';
27
27
  export class CdpCDPSession extends CDPSession {
28
28
  #sessionId: string;
29
29
  #targetType: string;
30
- #callbacks = new CallbackRegistry();
30
+ #callbacks: CallbackRegistry;
31
31
  #connection: Connection;
32
32
  #parentSessionId?: string;
33
33
  #target?: CdpTarget;
@@ -46,6 +46,7 @@ export class CdpCDPSession extends CDPSession {
46
46
  super();
47
47
  this.#connection = connection;
48
48
  this.#targetType = targetType;
49
+ this.#callbacks = new CallbackRegistry(connection._idGenerator);
49
50
  this.#sessionId = sessionId;
50
51
  this.#parentSessionId = parentSessionId;
51
52
  this.#rawErrors = rawErrors;
@@ -70,7 +71,7 @@ export class CdpCDPSession extends CDPSession {
70
71
  return this.#target;
71
72
  }
72
73
 
73
- override connection(): Connection | undefined {
74
+ override connection(): Connection {
74
75
  return this.#connection;
75
76
  }
76
77
 
@@ -19,6 +19,10 @@ import {debug} from '../common/Debug.js';
19
19
  import {ConnectionClosedError, TargetCloseError} from '../common/Errors.js';
20
20
  import {EventEmitter} from '../common/EventEmitter.js';
21
21
  import {createProtocolErrorMessage} from '../util/ErrorLike.js';
22
+ import {
23
+ createIncrementalIdGenerator,
24
+ type GetIdFn,
25
+ } from '../util/incremental-id-generator.js';
22
26
 
23
27
  import {CdpCDPSession} from './CdpSession.js';
24
28
 
@@ -38,6 +42,7 @@ export class Connection extends EventEmitter<CDPSessionEvents> {
38
42
  #manuallyAttached = new Set<string>();
39
43
  #callbacks: CallbackRegistry;
40
44
  #rawErrors = false;
45
+ #idGenerator: GetIdFn;
41
46
 
42
47
  constructor(
43
48
  url: string,
@@ -45,10 +50,12 @@ export class Connection extends EventEmitter<CDPSessionEvents> {
45
50
  delay = 0,
46
51
  timeout?: number,
47
52
  rawErrors = false,
53
+ idGenerator: () => number = createIncrementalIdGenerator(),
48
54
  ) {
49
55
  super();
50
56
  this.#rawErrors = rawErrors;
51
- this.#callbacks = new CallbackRegistry();
57
+ this.#idGenerator = idGenerator;
58
+ this.#callbacks = new CallbackRegistry(idGenerator);
52
59
  this.#url = url;
53
60
  this.#delay = delay;
54
61
  this.#timeout = timeout ?? 180_000;
@@ -80,6 +87,13 @@ export class Connection extends EventEmitter<CDPSessionEvents> {
80
87
  return this.#closed;
81
88
  }
82
89
 
90
+ /**
91
+ * @internal
92
+ */
93
+ get _idGenerator(): GetIdFn {
94
+ return this.#idGenerator;
95
+ }
96
+
83
97
  /**
84
98
  * @internal
85
99
  */
@@ -7,59 +7,17 @@
7
7
  import type Protocol from 'devtools-protocol';
8
8
 
9
9
  import type {CDPSession} from '../api/CDPSession.js';
10
+ import {DeviceRequestPrompt} from '../api/DeviceRequestPrompt.js';
11
+ import type {DeviceRequestPromptDevice} from '../api/DeviceRequestPrompt.js';
10
12
  import type {WaitTimeoutOptions} from '../api/Page.js';
11
13
  import type {TimeoutSettings} from '../common/TimeoutSettings.js';
12
14
  import {assert} from '../util/assert.js';
13
15
  import {Deferred} from '../util/Deferred.js';
14
16
 
15
17
  /**
16
- * Device in a request prompt.
17
- *
18
- * @public
19
- */
20
- export class DeviceRequestPromptDevice {
21
- /**
22
- * Device id during a prompt.
23
- */
24
- id: string;
25
-
26
- /**
27
- * Device name as it appears in a prompt.
28
- */
29
- name: string;
30
-
31
- /**
32
- * @internal
33
- */
34
- constructor(id: string, name: string) {
35
- this.id = id;
36
- this.name = name;
37
- }
38
- }
39
-
40
- /**
41
- * Device request prompts let you respond to the page requesting for a device
42
- * through an API like WebBluetooth.
43
- *
44
- * @remarks
45
- * `DeviceRequestPrompt` instances are returned via the
46
- * {@link Page.waitForDevicePrompt} method.
47
- *
48
- * @example
49
- *
50
- * ```ts
51
- * const [devicePrompt] = Promise.all([
52
- * page.waitForDevicePrompt(),
53
- * page.click('#connect-bluetooth'),
54
- * ]);
55
- * await devicePrompt.select(
56
- * await devicePrompt.waitForDevice(({name}) => name.includes('My Device')),
57
- * );
58
- * ```
59
- *
60
- * @public
18
+ * @internal
61
19
  */
62
- export class DeviceRequestPrompt {
20
+ export class CdpDeviceRequestPrompt extends DeviceRequestPrompt {
63
21
  #client: CDPSession | null;
64
22
  #timeoutSettings: TimeoutSettings;
65
23
  #id: string;
@@ -70,19 +28,12 @@ export class DeviceRequestPrompt {
70
28
  promise: Deferred<DeviceRequestPromptDevice>;
71
29
  }>();
72
30
 
73
- /**
74
- * Current list of selectable devices.
75
- */
76
- devices: DeviceRequestPromptDevice[] = [];
77
-
78
- /**
79
- * @internal
80
- */
81
31
  constructor(
82
32
  client: CDPSession,
83
33
  timeoutSettings: TimeoutSettings,
84
34
  firstEvent: Protocol.DeviceAccess.DeviceRequestPromptedEvent,
85
35
  ) {
36
+ super();
86
37
  this.#client = client;
87
38
  this.#timeoutSettings = timeoutSettings;
88
39
  this.#id = firstEvent.id;
@@ -112,10 +63,7 @@ export class DeviceRequestPrompt {
112
63
  continue;
113
64
  }
114
65
 
115
- const newDevice = new DeviceRequestPromptDevice(
116
- rawDevice.id,
117
- rawDevice.name,
118
- );
66
+ const newDevice = {id: rawDevice.id, name: rawDevice.name};
119
67
  this.devices.push(newDevice);
120
68
 
121
69
  for (const waitForDevicePromise of this.#waitForDevicePromises) {
@@ -126,9 +74,6 @@ export class DeviceRequestPrompt {
126
74
  }
127
75
  }
128
76
 
129
- /**
130
- * Resolve to the first device in the prompt matching a filter.
131
- */
132
77
  async waitForDevice(
133
78
  filter: (device: DeviceRequestPromptDevice) => boolean,
134
79
  options: WaitTimeoutOptions = {},
@@ -164,9 +109,6 @@ export class DeviceRequestPrompt {
164
109
  }
165
110
  }
166
111
 
167
- /**
168
- * Select a device in the prompt's list.
169
- */
170
112
  async select(device: DeviceRequestPromptDevice): Promise<void> {
171
113
  assert(
172
114
  this.#client !== null,
@@ -188,9 +130,6 @@ export class DeviceRequestPrompt {
188
130
  });
189
131
  }
190
132
 
191
- /**
192
- * Cancel the prompt.
193
- */
194
133
  async cancel(): Promise<void> {
195
134
  assert(
196
135
  this.#client !== null,
@@ -212,14 +151,11 @@ export class DeviceRequestPrompt {
212
151
  /**
213
152
  * @internal
214
153
  */
215
- export class DeviceRequestPromptManager {
154
+ export class CdpDeviceRequestPromptManager {
216
155
  #client: CDPSession | null;
217
156
  #timeoutSettings: TimeoutSettings;
218
157
  #deviceRequestPromptDeferreds = new Set<Deferred<DeviceRequestPrompt>>();
219
158
 
220
- /**
221
- * @internal
222
- */
223
159
  constructor(client: CDPSession, timeoutSettings: TimeoutSettings) {
224
160
  this.#client = client;
225
161
  this.#timeoutSettings = timeoutSettings;
@@ -232,10 +168,6 @@ export class DeviceRequestPromptManager {
232
168
  });
233
169
  }
234
170
 
235
- /**
236
- * Wait for device prompt created by an action like calling WebBluetooth's
237
- * requestDevice.
238
- */
239
171
  async waitForDevicePrompt(
240
172
  options: WaitTimeoutOptions = {},
241
173
  ): Promise<DeviceRequestPrompt> {
@@ -277,9 +209,6 @@ export class DeviceRequestPromptManager {
277
209
  }
278
210
  }
279
211
 
280
- /**
281
- * @internal
282
- */
283
212
  #onDeviceRequestPrompted(
284
213
  event: Protocol.DeviceAccess.DeviceRequestPromptedEvent,
285
214
  ) {
@@ -288,7 +217,7 @@ export class DeviceRequestPromptManager {
288
217
  }
289
218
 
290
219
  assert(this.#client !== null);
291
- const devicePrompt = new DeviceRequestPrompt(
220
+ const devicePrompt = new CdpDeviceRequestPrompt(
292
221
  this.#client,
293
222
  this.#timeoutSettings,
294
223
  event,
@@ -66,6 +66,11 @@ interface JavascriptEnabledState {
66
66
  active: boolean;
67
67
  }
68
68
 
69
+ interface FocusState {
70
+ enabled: boolean;
71
+ active: boolean;
72
+ }
73
+
69
74
  /**
70
75
  * @internal
71
76
  */
@@ -193,6 +198,14 @@ export class EmulationManager implements ClientProvider {
193
198
  this,
194
199
  this.#setJavaScriptEnabled,
195
200
  );
201
+ #focusState = new EmulatedState<FocusState>(
202
+ {
203
+ enabled: true,
204
+ active: false,
205
+ },
206
+ this,
207
+ this.#emulateFocus,
208
+ );
196
209
 
197
210
  #secondaryClients = new Set<CDPSession>();
198
211
 
@@ -578,4 +591,21 @@ export class EmulationManager implements ClientProvider {
578
591
  javaScriptEnabled: enabled,
579
592
  });
580
593
  }
594
+
595
+ @invokeAtMostOnceForArguments
596
+ async #emulateFocus(client: CDPSession, state: FocusState): Promise<void> {
597
+ if (!state.active) {
598
+ return;
599
+ }
600
+ await client.send('Emulation.setFocusEmulationEnabled', {
601
+ enabled: state.enabled,
602
+ });
603
+ }
604
+
605
+ async emulateFocus(enabled: boolean): Promise<void> {
606
+ await this.#focusState.setState({
607
+ active: true,
608
+ enabled,
609
+ });
610
+ }
581
611
  }
@@ -597,7 +597,9 @@ export class ExecutionContext
597
597
  }
598
598
 
599
599
  if (returnByValue) {
600
- return valueFromRemoteObject(remoteObject);
600
+ return valueFromRemoteObject(remoteObject) as HandleFor<
601
+ Awaited<ReturnType<Func>>
602
+ >;
601
603
  }
602
604
 
603
605
  return this.#world.createCdpHandle(remoteObject) as HandleFor<
@@ -649,7 +651,9 @@ export class ExecutionContext
649
651
  }
650
652
 
651
653
  if (returnByValue) {
652
- return valueFromRemoteObject(remoteObject);
654
+ return valueFromRemoteObject(remoteObject) as unknown as HandleFor<
655
+ Awaited<ReturnType<Func>>
656
+ >;
653
657
  }
654
658
 
655
659
  return this.#world.createCdpHandle(remoteObject) as HandleFor<
@@ -68,7 +68,10 @@ export class ExtensionTransport implements ConnectionTransport {
68
68
  };
69
69
 
70
70
  #dispatchResponse(message: object): void {
71
- this.onmessage?.(JSON.stringify(message));
71
+ // Dispatch in a new task like other transports.
72
+ setTimeout(() => {
73
+ this.onmessage?.(JSON.stringify(message));
74
+ }, 0);
72
75
  }
73
76
 
74
77
  send(message: string): void {
@@ -125,6 +128,7 @@ export class ExtensionTransport implements ConnectionTransport {
125
128
  if (parsed.sessionId === 'tabTargetSessionId') {
126
129
  this.#dispatchResponse({
127
130
  method: 'Target.attachedToTarget',
131
+ sessionId: 'tabTargetSessionId',
128
132
  params: {
129
133
  targetInfo: pageTargetInfo,
130
134
  sessionId: 'pageTargetSessionId',
package/src/cdp/Frame.ts CHANGED
@@ -7,6 +7,7 @@
7
7
  import type {Protocol} from 'devtools-protocol';
8
8
 
9
9
  import type {CDPSession} from '../api/CDPSession.js';
10
+ import type {DeviceRequestPrompt} from '../api/DeviceRequestPrompt.js';
10
11
  import type {ElementHandle} from '../api/ElementHandle.js';
11
12
  import type {WaitForOptions} from '../api/Frame.js';
12
13
  import {Frame, FrameEvent, throwIfDetached} from '../api/Frame.js';
@@ -21,10 +22,7 @@ import {isErrorLike} from '../util/ErrorLike.js';
21
22
  import {Accessibility} from './Accessibility.js';
22
23
  import type {Binding} from './Binding.js';
23
24
  import type {CdpPreloadScript} from './CdpPreloadScript.js';
24
- import type {
25
- DeviceRequestPrompt,
26
- DeviceRequestPromptManager,
27
- } from './DeviceRequestPrompt.js';
25
+ import type {CdpDeviceRequestPromptManager} from './DeviceRequestPrompt.js';
28
26
  import type {FrameManager} from './FrameManager.js';
29
27
  import {FrameManagerEvent} from './FrameManagerEvents.js';
30
28
  import type {IsolatedWorldChart} from './IsolatedWorld.js';
@@ -317,7 +315,7 @@ export class CdpFrame extends Frame {
317
315
  return this._frameManager._frameTree.childFrames(this._id);
318
316
  }
319
317
 
320
- #deviceRequestPromptManager(): DeviceRequestPromptManager {
318
+ #deviceRequestPromptManager(): CdpDeviceRequestPromptManager {
321
319
  return this._frameManager._deviceRequestPromptManager(this.#client);
322
320
  }
323
321
 
@@ -21,7 +21,7 @@ import type {Binding} from './Binding.js';
21
21
  import {CdpPreloadScript} from './CdpPreloadScript.js';
22
22
  import type {CdpCDPSession} from './CdpSession.js';
23
23
  import {isTargetClosedError} from './Connection.js';
24
- import {DeviceRequestPromptManager} from './DeviceRequestPrompt.js';
24
+ import {CdpDeviceRequestPromptManager} from './DeviceRequestPrompt.js';
25
25
  import {ExecutionContext} from './ExecutionContext.js';
26
26
  import {CdpFrame} from './Frame.js';
27
27
  import type {FrameManagerEvents} from './FrameManagerEvents.js';
@@ -60,7 +60,7 @@ export class FrameManager extends EventEmitter<FrameManagerEvents> {
60
60
 
61
61
  #deviceRequestPromptManagerMap = new WeakMap<
62
62
  CDPSession,
63
- DeviceRequestPromptManager
63
+ CdpDeviceRequestPromptManager
64
64
  >();
65
65
 
66
66
  #frameTreeHandled?: Deferred<void>;
@@ -380,10 +380,15 @@ export class FrameManager extends EventEmitter<FrameManagerEvents> {
380
380
  void this.initialize(target._session()!, frame);
381
381
  }
382
382
 
383
- _deviceRequestPromptManager(client: CDPSession): DeviceRequestPromptManager {
383
+ _deviceRequestPromptManager(
384
+ client: CDPSession,
385
+ ): CdpDeviceRequestPromptManager {
384
386
  let manager = this.#deviceRequestPromptManagerMap.get(client);
385
387
  if (manager === undefined) {
386
- manager = new DeviceRequestPromptManager(client, this.#timeoutSettings);
388
+ manager = new CdpDeviceRequestPromptManager(
389
+ client,
390
+ this.#timeoutSettings,
391
+ );
387
392
  this.#deviceRequestPromptManagerMap.set(client, manager);
388
393
  }
389
394
  return manager;
@@ -100,7 +100,11 @@ export class CdpHTTPRequest extends HTTPRequest {
100
100
 
101
101
  this.interception.enabled = allowInterception;
102
102
 
103
- for (const [key, value] of Object.entries(data.request.headers)) {
103
+ this.updateHeaders(data.request.headers);
104
+ }
105
+
106
+ updateHeaders(headers: Protocol.Network.Headers): void {
107
+ for (const [key, value] of Object.entries(headers)) {
104
108
  this.#headers[key.toLowerCase()] = value;
105
109
  }
106
110
  }
@@ -138,7 +142,8 @@ export class CdpHTTPRequest extends HTTPRequest {
138
142
  }
139
143
 
140
144
  override headers(): Record<string, string> {
141
- return this.#headers;
145
+ // Callers should not be allowed to mutate internal structure.
146
+ return structuredClone(this.#headers);
142
147
  }
143
148
 
144
149
  override response(): CdpHTTPResponse | null {
@@ -139,7 +139,7 @@ export class CdpHTTPResponse extends HTTPResponse {
139
139
  'No resource with given identifier found'
140
140
  ) {
141
141
  throw new ProtocolError(
142
- 'Could not load body for this request. This might happen if the request is a preflight request.',
142
+ 'Could not load response body for this request. This might happen if the request is a preflight request.',
143
143
  );
144
144
  }
145
145
 
@@ -45,7 +45,7 @@ export class CdpJSHandle<T = unknown> extends JSHandle<T> {
45
45
 
46
46
  override async jsonValue(): Promise<T> {
47
47
  if (!this.#remoteObject.objectId) {
48
- return valueFromRemoteObject(this.#remoteObject);
48
+ return valueFromRemoteObject(this.#remoteObject) as T;
49
49
  }
50
50
  const value = await this.evaluate(object => {
51
51
  return object;
@@ -83,7 +83,10 @@ export class NetworkEventManager {
83
83
  Protocol.Fetch.RequestPausedEvent
84
84
  >();
85
85
  #httpRequestsMap = new Map<NetworkRequestId, CdpHTTPRequest>();
86
-
86
+ #requestWillBeSentExtraInfoMap = new Map<
87
+ NetworkRequestId,
88
+ Protocol.Network.RequestWillBeSentExtraInfoEvent[]
89
+ >();
87
90
  /*
88
91
  * The below maps are used to reconcile Network.responseReceivedExtraInfo
89
92
  * events with their corresponding request. Each response and redirect
@@ -103,11 +106,23 @@ export class NetworkEventManager {
103
106
  forget(networkRequestId: NetworkRequestId): void {
104
107
  this.#requestWillBeSentMap.delete(networkRequestId);
105
108
  this.#requestPausedMap.delete(networkRequestId);
109
+ this.#requestWillBeSentExtraInfoMap.delete(networkRequestId);
106
110
  this.#queuedEventGroupMap.delete(networkRequestId);
107
111
  this.#queuedRedirectInfoMap.delete(networkRequestId);
108
112
  this.#responseReceivedExtraInfoMap.delete(networkRequestId);
109
113
  }
110
114
 
115
+ requestExtraInfo(
116
+ networkRequestId: NetworkRequestId,
117
+ ): Protocol.Network.RequestWillBeSentExtraInfoEvent[] {
118
+ if (!this.#requestWillBeSentExtraInfoMap.has(networkRequestId)) {
119
+ this.#requestWillBeSentExtraInfoMap.set(networkRequestId, []);
120
+ }
121
+ return this.#requestWillBeSentExtraInfoMap.get(
122
+ networkRequestId,
123
+ ) as Protocol.Network.RequestWillBeSentExtraInfoEvent[];
124
+ }
125
+
111
126
  responseExtraInfo(
112
127
  networkRequestId: NetworkRequestId,
113
128
  ): Protocol.Network.ResponseReceivedExtraInfoEvent[] {