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
package/src/bidi/Page.ts CHANGED
@@ -8,7 +8,10 @@ import type Protocol from 'devtools-protocol';
8
8
  import * as Bidi from 'webdriver-bidi-protocol';
9
9
 
10
10
  import {firstValueFrom, from, raceWith} from '../../third_party/rxjs/rxjs.js';
11
+ import type {BluetoothEmulation} from '../api/BluetoothEmulation.js';
12
+ import type {WindowId} from '../api/Browser.js';
11
13
  import type {CDPSession} from '../api/CDPSession.js';
14
+ import type {DeviceRequestPrompt} from '../api/DeviceRequestPrompt.js';
12
15
  import type {BoundingBox} from '../api/ElementHandle.js';
13
16
  import type {WaitForOptions} from '../api/Frame.js';
14
17
  import type {HTTPResponse} from '../api/HTTPResponse.js';
@@ -17,6 +20,7 @@ import type {
17
20
  GeolocationOptions,
18
21
  MediaFeature,
19
22
  PageEvents,
23
+ ReloadOptions,
20
24
  WaitTimeoutOptions,
21
25
  } from '../api/Page.js';
22
26
  import {
@@ -44,12 +48,7 @@ import {EventEmitter} from '../common/EventEmitter.js';
44
48
  import {FileChooser} from '../common/FileChooser.js';
45
49
  import type {PDFOptions} from '../common/PDFOptions.js';
46
50
  import type {Awaitable} from '../common/types.js';
47
- import {
48
- evaluationString,
49
- isString,
50
- parsePDFOptions,
51
- timeout,
52
- } from '../common/util.js';
51
+ import {evaluationString, parsePDFOptions, timeout} from '../common/util.js';
53
52
  import type {Viewport} from '../common/Viewport.js';
54
53
  import {assert} from '../util/assert.js';
55
54
  import {bubble} from '../util/decorators.js';
@@ -137,9 +136,7 @@ export class BidiPage extends Page {
137
136
  /**
138
137
  * @internal
139
138
  */
140
- _userAgentHeaders: Record<string, string> = {};
141
- #userAgentInterception?: string;
142
- #userAgentPreloadScript?: string;
139
+ #overrideNavigatorPropertiesPreloadScript?: string;
143
140
  override async setUserAgent(
144
141
  userAgentOrOptions:
145
142
  | string
@@ -185,26 +182,9 @@ export class BidiPage extends Page {
185
182
  const enable = userAgent !== '';
186
183
  userAgent = userAgent ?? (await this.#browserContext.browser().userAgent());
187
184
 
188
- this._userAgentHeaders = enable
189
- ? {
190
- 'User-Agent': userAgent,
191
- }
192
- : {};
193
-
194
- this.#userAgentInterception = await this.#toggleInterception(
195
- [Bidi.Network.InterceptPhase.BeforeRequestSent],
196
- this.#userAgentInterception,
197
- enable,
198
- );
185
+ await this.#frame.browsingContext.setUserAgent(enable ? userAgent : null);
199
186
 
200
- const overrideNavigatorProperties = (
201
- userAgent: string,
202
- platform: string | undefined,
203
- ) => {
204
- Object.defineProperty(navigator, 'userAgent', {
205
- value: userAgent,
206
- configurable: true,
207
- });
187
+ const overrideNavigatorProperties = (platform: string | undefined) => {
208
188
  if (platform) {
209
189
  Object.defineProperty(navigator, 'platform', {
210
190
  value: platform,
@@ -218,16 +198,15 @@ export class BidiPage extends Page {
218
198
  frames.push(...frame.childFrames());
219
199
  }
220
200
 
221
- if (this.#userAgentPreloadScript) {
201
+ if (this.#overrideNavigatorPropertiesPreloadScript) {
222
202
  await this.removeScriptToEvaluateOnNewDocument(
223
- this.#userAgentPreloadScript,
203
+ this.#overrideNavigatorPropertiesPreloadScript,
224
204
  );
225
205
  }
226
206
  const [evaluateToken] = await Promise.all([
227
207
  enable
228
208
  ? this.evaluateOnNewDocument(
229
209
  overrideNavigatorProperties,
230
- userAgent,
231
210
  platform || undefined,
232
211
  )
233
212
  : undefined,
@@ -236,12 +215,11 @@ export class BidiPage extends Page {
236
215
  ...frames.map(frame => {
237
216
  return frame.evaluate(
238
217
  overrideNavigatorProperties,
239
- userAgent,
240
218
  platform || undefined,
241
219
  );
242
220
  }),
243
221
  ]);
244
- this.#userAgentPreloadScript = evaluateToken?.identifier;
222
+ this.#overrideNavigatorPropertiesPreloadScript = evaluateToken?.identifier;
245
223
  }
246
224
 
247
225
  override async setBypassCSP(enabled: boolean): Promise<void> {
@@ -278,11 +256,23 @@ export class BidiPage extends Page {
278
256
  return this.#frame;
279
257
  }
280
258
 
259
+ override async emulateFocusedPage(enabled: boolean): Promise<void> {
260
+ return await this.#cdpEmulationManager.emulateFocus(enabled);
261
+ }
262
+
281
263
  override resize(_params: {
282
264
  contentWidth: number;
283
265
  contentHeight: number;
284
266
  }): Promise<void> {
285
- throw new Error('Method not implemented for WebDriver BiDi yet.');
267
+ throw new UnsupportedOperation();
268
+ }
269
+
270
+ override windowId(): Promise<WindowId> {
271
+ throw new UnsupportedOperation();
272
+ }
273
+
274
+ override openDevTools(): Promise<Page> {
275
+ throw new UnsupportedOperation();
286
276
  }
287
277
 
288
278
  async focusedFrame(): Promise<BidiFrame> {
@@ -332,11 +322,13 @@ export class BidiPage extends Page {
332
322
  }
333
323
 
334
324
  override async reload(
335
- options: WaitForOptions = {},
325
+ options: ReloadOptions = {},
336
326
  ): Promise<BidiHTTPResponse | null> {
337
327
  const [response] = await Promise.all([
338
328
  this.#frame.waitForNavigation(options),
339
- this.#frame.browsingContext.reload(),
329
+ this.#frame.browsingContext.reload({
330
+ ignoreCache: options.ignoreCache ? true : undefined,
331
+ }),
340
332
  ]).catch(
341
333
  rewriteNavigationError(
342
334
  this.url(),
@@ -429,18 +421,42 @@ export class BidiPage extends Page {
429
421
 
430
422
  override async setViewport(viewport: Viewport | null): Promise<void> {
431
423
  if (!this.browser().cdpSupported) {
432
- await this.#frame.browsingContext.setViewport({
433
- viewport:
434
- viewport?.width && viewport?.height
424
+ const viewportSize =
425
+ viewport?.width && viewport?.height
426
+ ? {
427
+ width: viewport.width,
428
+ height: viewport.height,
429
+ }
430
+ : null;
431
+
432
+ const devicePixelRatio = viewport?.deviceScaleFactor
433
+ ? viewport.deviceScaleFactor
434
+ : null;
435
+
436
+ // If `viewport` is not set, remove screen orientation override.
437
+ const screenOrientation: Bidi.Emulation.ScreenOrientation | null =
438
+ viewport
439
+ ? viewport.isLandscape
435
440
  ? {
436
- width: viewport.width,
437
- height: viewport.height,
441
+ natural: Bidi.Emulation.ScreenOrientationNatural.Landscape,
442
+ type: 'landscape-primary',
438
443
  }
439
- : null,
440
- devicePixelRatio: viewport?.deviceScaleFactor
441
- ? viewport.deviceScaleFactor
442
- : null,
443
- });
444
+ : {
445
+ natural: Bidi.Emulation.ScreenOrientationNatural.Portrait,
446
+ type: 'portrait-primary',
447
+ }
448
+ : null;
449
+
450
+ await Promise.all([
451
+ this.#frame.browsingContext.setViewport({
452
+ viewport: viewportSize,
453
+ devicePixelRatio,
454
+ }),
455
+ this.#frame.browsingContext.setScreenOrientationOverride(
456
+ screenOrientation,
457
+ ),
458
+ ]);
459
+
444
460
  this.#viewport = viewport;
445
461
  return;
446
462
  }
@@ -713,10 +729,7 @@ export class BidiPage extends Page {
713
729
 
714
730
  get isNetworkInterceptionEnabled(): boolean {
715
731
  return (
716
- Boolean(this.#requestInterception) ||
717
- Boolean(this.#extraHeadersInterception) ||
718
- Boolean(this.#authInterception) ||
719
- Boolean(this.#userAgentInterception)
732
+ Boolean(this.#requestInterception) || Boolean(this.#authInterception)
720
733
  );
721
734
  }
722
735
 
@@ -732,26 +745,10 @@ export class BidiPage extends Page {
732
745
  /**
733
746
  * @internal
734
747
  */
735
- _extraHTTPHeaders: Record<string, string> = {};
736
- #extraHeadersInterception?: string;
737
748
  override async setExtraHTTPHeaders(
738
749
  headers: Record<string, string>,
739
750
  ): Promise<void> {
740
- const extraHTTPHeaders: Record<string, string> = {};
741
- for (const [key, value] of Object.entries(headers)) {
742
- assert(
743
- isString(value),
744
- `Expected value of header "${key}" to be String, but "${typeof value}" is found.`,
745
- );
746
- extraHTTPHeaders[key.toLowerCase()] = value;
747
- }
748
- this._extraHTTPHeaders = extraHTTPHeaders;
749
-
750
- this.#extraHeadersInterception = await this.#toggleInterception(
751
- [Bidi.Network.InterceptPhase.BeforeRequestSent],
752
- this.#extraHeadersInterception,
753
- Boolean(Object.keys(this._extraHTTPHeaders).length),
754
- );
751
+ await this.#frame.browsingContext.setExtraHTTPHeaders(headers);
755
752
  }
756
753
 
757
754
  /**
@@ -797,7 +794,7 @@ export class BidiPage extends Page {
797
794
 
798
795
  override async setOfflineMode(enabled: boolean): Promise<void> {
799
796
  if (!this.#browserContext.browser().cdpSupported) {
800
- throw new UnsupportedOperation();
797
+ return await this.#frame.browsingContext.setOfflineMode(enabled);
801
798
  }
802
799
 
803
800
  if (!this.#emulatedNetworkConditions) {
@@ -816,8 +813,20 @@ export class BidiPage extends Page {
816
813
  networkConditions: NetworkConditions | null,
817
814
  ): Promise<void> {
818
815
  if (!this.#browserContext.browser().cdpSupported) {
819
- throw new UnsupportedOperation();
816
+ if (
817
+ !networkConditions?.offline &&
818
+ ((networkConditions?.upload ?? -1) >= 0 ||
819
+ (networkConditions?.download ?? -1) >= 0 ||
820
+ (networkConditions?.latency ?? 0) > 0)
821
+ ) {
822
+ // WebDriver BiDi supports only offline mode.
823
+ throw new UnsupportedOperation();
824
+ }
825
+ return await this.#frame.browsingContext.setOfflineMode(
826
+ networkConditions?.offline ?? false,
827
+ );
820
828
  }
829
+
821
830
  if (!this.#emulatedNetworkConditions) {
822
831
  this.#emulatedNetworkConditions = {
823
832
  offline: networkConditions?.offline ?? false,
@@ -989,8 +998,14 @@ export class BidiPage extends Page {
989
998
  }
990
999
  }
991
1000
 
992
- override waitForDevicePrompt(): never {
993
- throw new UnsupportedOperation();
1001
+ override async waitForDevicePrompt(
1002
+ options: WaitTimeoutOptions = {},
1003
+ ): Promise<DeviceRequestPrompt> {
1004
+ return await this.mainFrame().waitForDevicePrompt(options);
1005
+ }
1006
+
1007
+ override get bluetooth(): BluetoothEmulation {
1008
+ return this.mainFrame().browsingContext.bluetooth;
994
1009
  }
995
1010
  }
996
1011
 
@@ -6,9 +6,15 @@
6
6
 
7
7
  import type * as Bidi from 'webdriver-bidi-protocol';
8
8
 
9
+ import type {BluetoothEmulation} from '../../api/BluetoothEmulation.js';
10
+ import type {DeviceRequestPrompt} from '../../api/DeviceRequestPrompt.js';
9
11
  import {EventEmitter} from '../../common/EventEmitter.js';
12
+ import {isString} from '../../common/util.js';
13
+ import {assert} from '../../util/assert.js';
10
14
  import {inertIfDisposed, throwIfDisposed} from '../../util/decorators.js';
11
15
  import {DisposableStack, disposeSymbol} from '../../util/disposable.js';
16
+ import {BidiBluetoothEmulation} from '../BluetoothEmulation.js';
17
+ import {BidiDeviceRequestPromptManager} from '../DeviceRequestPrompt.js';
12
18
 
13
19
  import type {AddPreloadScriptOptions} from './Browser.js';
14
20
  import {Navigation} from './Navigation.js';
@@ -161,9 +167,11 @@ export class BrowsingContext extends EventEmitter<{
161
167
  readonly #emulationState: {
162
168
  javaScriptEnabled: boolean;
163
169
  } = {javaScriptEnabled: true};
170
+ readonly #bluetoothEmulation: BluetoothEmulation;
171
+ readonly #deviceRequestPromptManager: BidiDeviceRequestPromptManager;
164
172
 
165
173
  private constructor(
166
- context: UserContext,
174
+ userContext: UserContext,
167
175
  parent: BrowsingContext | undefined,
168
176
  id: string,
169
177
  url: string,
@@ -174,10 +182,18 @@ export class BrowsingContext extends EventEmitter<{
174
182
  this.#url = url;
175
183
  this.id = id;
176
184
  this.parent = parent;
177
- this.userContext = context;
185
+ this.userContext = userContext;
178
186
  this.originalOpener = originalOpener;
179
187
 
180
188
  this.defaultRealm = this.#createWindowRealm();
189
+ this.#bluetoothEmulation = new BidiBluetoothEmulation(
190
+ this.id,
191
+ this.#session,
192
+ );
193
+ this.#deviceRequestPromptManager = new BidiDeviceRequestPromptManager(
194
+ this.id,
195
+ this.#session,
196
+ );
181
197
  }
182
198
 
183
199
  #initialize() {
@@ -601,6 +617,19 @@ export class BrowsingContext extends EventEmitter<{
601
617
  );
602
618
  }
603
619
 
620
+ @throwIfDisposed<BrowsingContext>(context => {
621
+ // SAFETY: Disposal implies this exists.
622
+ return context.#reason!;
623
+ })
624
+ async setScreenOrientationOverride(
625
+ screenOrientation: Bidi.Emulation.ScreenOrientation | null,
626
+ ): Promise<void> {
627
+ await this.#session.send('emulation.setScreenOrientationOverride', {
628
+ screenOrientation,
629
+ contexts: [this.id],
630
+ });
631
+ }
632
+
604
633
  @throwIfDisposed<BrowsingContext>(context => {
605
634
  // SAFETY: Disposal implies this exists.
606
635
  return context.#reason!;
@@ -726,4 +755,53 @@ export class BrowsingContext extends EventEmitter<{
726
755
  isJavaScriptEnabled(): boolean {
727
756
  return this.#emulationState.javaScriptEnabled;
728
757
  }
758
+
759
+ async setUserAgent(userAgent: string | null): Promise<void> {
760
+ await this.#session.send('emulation.setUserAgentOverride', {
761
+ userAgent,
762
+ contexts: [this.id],
763
+ });
764
+ }
765
+
766
+ async setOfflineMode(enabled: boolean): Promise<void> {
767
+ await this.#session.send('emulation.setNetworkConditions', {
768
+ networkConditions: enabled
769
+ ? {
770
+ type: 'offline',
771
+ }
772
+ : null,
773
+ contexts: [this.id],
774
+ });
775
+ }
776
+
777
+ get bluetooth(): BluetoothEmulation {
778
+ return this.#bluetoothEmulation;
779
+ }
780
+
781
+ async waitForDevicePrompt(
782
+ timeout: number,
783
+ signal?: AbortSignal,
784
+ ): Promise<DeviceRequestPrompt> {
785
+ return await this.#deviceRequestPromptManager.waitForDevicePrompt(
786
+ timeout,
787
+ signal,
788
+ );
789
+ }
790
+
791
+ async setExtraHTTPHeaders(headers: Record<string, string>): Promise<void> {
792
+ await this.#session.send('network.setExtraHeaders', {
793
+ headers: Object.entries(headers).map(([key, value]) => {
794
+ assert(
795
+ isString(value),
796
+ `Expected value of header "${key}" to be String, but "${typeof value}" is found.`,
797
+ );
798
+
799
+ return {
800
+ name: key.toLowerCase(),
801
+ value: {type: 'string', value: value},
802
+ };
803
+ }),
804
+ contexts: [this.id],
805
+ });
806
+ }
729
807
  }
@@ -21,8 +21,9 @@ export type BidiEvents = {
21
21
  /**
22
22
  * @internal
23
23
  */
24
- export interface Connection<Events extends BidiEvents = BidiEvents>
25
- extends EventEmitter<Events> {
24
+ export interface Connection<
25
+ Events extends BidiEvents = BidiEvents,
26
+ > extends EventEmitter<Events> {
26
27
  send<T extends keyof Commands>(
27
28
  method: T,
28
29
  params: Commands[T]['params'],
@@ -6,7 +6,7 @@
6
6
 
7
7
  import * as Bidi from 'webdriver-bidi-protocol';
8
8
 
9
- import {ProtocolError} from '../../common/Errors.js';
9
+ import {ProtocolError, UnsupportedOperation} from '../../common/Errors.js';
10
10
  import {EventEmitter} from '../../common/EventEmitter.js';
11
11
  import {inertIfDisposed} from '../../util/decorators.js';
12
12
  import {DisposableStack, disposeSymbol} from '../../util/disposable.js';
@@ -37,6 +37,7 @@ export class Request extends EventEmitter<{
37
37
  }
38
38
 
39
39
  #responseContentPromise: Promise<Uint8Array<ArrayBufferLike>> | null = null;
40
+ #requestBodyPromise: Promise<string> | null = null;
40
41
  #error?: string;
41
42
  #redirect?: Request;
42
43
  #response?: Bidi.Network.ResponseData;
@@ -153,7 +154,14 @@ export class Request extends EventEmitter<{
153
154
  return this.#event.request.request;
154
155
  }
155
156
  get initiator(): Bidi.Network.Initiator | undefined {
156
- return this.#event.initiator;
157
+ return {
158
+ ...this.#event.initiator,
159
+ // Initiator URL is not specified in BiDi.
160
+ // @ts-expect-error non-standard property.
161
+ url: this.#event.request['goog:resourceInitiator']?.url,
162
+ // @ts-expect-error non-standard property.
163
+ stack: this.#event.request['goog:resourceInitiator']?.stack,
164
+ };
157
165
  }
158
166
  get method(): string {
159
167
  return this.#event.request.method;
@@ -195,8 +203,7 @@ export class Request extends EventEmitter<{
195
203
  }
196
204
 
197
205
  get hasPostData(): boolean {
198
- // @ts-expect-error non-standard attribute.
199
- return this.#event.request['goog:hasPostData'] ?? false;
206
+ return (this.#event.request.bodySize ?? 0) > 0;
200
207
  }
201
208
 
202
209
  async continueRequest({
@@ -237,6 +244,29 @@ export class Request extends EventEmitter<{
237
244
  });
238
245
  }
239
246
 
247
+ async fetchPostData(): Promise<string | undefined> {
248
+ if (!this.hasPostData) {
249
+ return undefined;
250
+ }
251
+ if (!this.#requestBodyPromise) {
252
+ this.#requestBodyPromise = (async () => {
253
+ const data = await this.#session.send('network.getData', {
254
+ dataType: Bidi.Network.DataType.Request,
255
+ request: this.id,
256
+ });
257
+ if (data.result.bytes.type === 'string') {
258
+ return data.result.bytes.value;
259
+ }
260
+
261
+ // TODO: support base64 response.
262
+ throw new UnsupportedOperation(
263
+ `Collected request body data of type ${data.result.bytes.type} is not supported`,
264
+ );
265
+ })();
266
+ }
267
+ return await this.#requestBodyPromise;
268
+ }
269
+
240
270
  async getResponseContent(): Promise<Uint8Array> {
241
271
  if (!this.#responseContentPromise) {
242
272
  this.#responseContentPromise = (async () => {
@@ -258,7 +288,7 @@ export class Request extends EventEmitter<{
258
288
  )
259
289
  ) {
260
290
  throw new ProtocolError(
261
- 'Could not load body for this request. This might happen if the request is a preflight request.',
291
+ 'Could not load response body for this request. This might happen if the request is a preflight request.',
262
292
  );
263
293
  }
264
294
 
package/src/bidi/util.ts CHANGED
@@ -17,6 +17,14 @@ import {BidiDeserializer} from './Deserializer.js';
17
17
  export function createEvaluationError(
18
18
  details: Bidi.Script.ExceptionDetails,
19
19
  ): unknown {
20
+ if (details.exception.type === 'object' && !('value' in details.exception)) {
21
+ // Heuristic detecting a platform object was thrown. WebDriver BiDi serializes
22
+ // platform objects without value. If so, throw a generic error with the actual
23
+ // exception's message, as there is no way to restore the original exception's
24
+ // constructor.
25
+ return new Error(details.text);
26
+ }
27
+
20
28
  if (details.exception.type !== 'error') {
21
29
  return BidiDeserializer.deserialize(details.exception);
22
30
  }
@@ -8,6 +8,7 @@ import type {Protocol} from 'devtools-protocol';
8
8
 
9
9
  import type {ElementHandle} from '../api/ElementHandle.js';
10
10
  import type {Realm} from '../api/Realm.js';
11
+ import {debugError} from '../common/util.js';
11
12
 
12
13
  /**
13
14
  * Represents a Node and the properties of it that are relevant to Accessibility.
@@ -76,11 +77,23 @@ export interface SerializedAXNode {
76
77
  */
77
78
  invalid?: string;
78
79
  orientation?: string;
80
+
81
+ /**
82
+ * Url for link elements.
83
+ */
84
+ url?: string;
79
85
  /**
80
86
  * Children of this node, if there are any.
81
87
  */
82
88
  children?: SerializedAXNode[];
83
89
 
90
+ /**
91
+ * CDP-specifc ID to reference the DOM node.
92
+ *
93
+ * @internal
94
+ */
95
+ backendNodeId?: number;
96
+
84
97
  /**
85
98
  * Get an ElementHandle for this AXNode if available.
86
99
  *
@@ -226,8 +239,13 @@ export class Accessibility {
226
239
  if (!frame) {
227
240
  return;
228
241
  }
229
- const iframeSnapshot = await frame.accessibility.snapshot(options);
230
- root.iframeSnapshot = iframeSnapshot ?? undefined;
242
+ try {
243
+ const iframeSnapshot = await frame.accessibility.snapshot(options);
244
+ root.iframeSnapshot = iframeSnapshot ?? undefined;
245
+ } catch (error) {
246
+ // Frames can get detached at any time resulting in errors.
247
+ debugError(error);
248
+ }
231
249
  }
232
250
  for (const child of root.children) {
233
251
  await populateIframes(child);
@@ -460,12 +478,32 @@ class AXNode {
460
478
  }
461
479
  }
462
480
 
481
+ public isLandmark(): boolean {
482
+ switch (this.#role) {
483
+ case 'banner':
484
+ case 'complementary':
485
+ case 'contentinfo':
486
+ case 'form':
487
+ case 'main':
488
+ case 'navigation':
489
+ case 'region':
490
+ case 'search':
491
+ return true;
492
+ default:
493
+ return false;
494
+ }
495
+ }
496
+
463
497
  public isInteresting(insideControl: boolean): boolean {
464
498
  const role = this.#role;
465
499
  if (role === 'Ignored' || this.#hidden || this.#ignored) {
466
500
  return false;
467
501
  }
468
502
 
503
+ if (this.isLandmark()) {
504
+ return true;
505
+ }
506
+
469
507
  if (this.#focusable || this.#richlyEditable) {
470
508
  return true;
471
509
  }
@@ -514,6 +552,7 @@ class AXNode {
514
552
  return node.nodeType === Node.TEXT_NODE ? node.parentElement : node;
515
553
  })) as ElementHandle<Element>;
516
554
  },
555
+ backendNodeId: this.payload.backendDOMNodeId,
517
556
  };
518
557
 
519
558
  type UserStringProperty =
@@ -522,7 +561,8 @@ class AXNode {
522
561
  | 'description'
523
562
  | 'keyshortcuts'
524
563
  | 'roledescription'
525
- | 'valuetext';
564
+ | 'valuetext'
565
+ | 'url';
526
566
 
527
567
  const userStringProperties: UserStringProperty[] = [
528
568
  'name',
@@ -531,6 +571,7 @@ class AXNode {
531
571
  'keyshortcuts',
532
572
  'roledescription',
533
573
  'valuetext',
574
+ 'url',
534
575
  ];
535
576
  const getUserStringPropertyValue = (key: UserStringProperty): string => {
536
577
  return properties.get(key) as string;
@@ -577,7 +618,7 @@ class AXNode {
577
618
  continue;
578
619
  }
579
620
  const value = getBooleanPropertyValue(booleanProperty);
580
- if (!value) {
621
+ if (value === undefined) {
581
622
  continue;
582
623
  }
583
624
  node[booleanProperty] = getBooleanPropertyValue(booleanProperty);
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google Inc.
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type {
7
+ AdapterState,
8
+ BluetoothEmulation,
9
+ PreconnectedPeripheral,
10
+ } from '../api/BluetoothEmulation.js';
11
+
12
+ import type {Connection} from './Connection.js';
13
+
14
+ /**
15
+ * @internal
16
+ */
17
+ export class CdpBluetoothEmulation implements BluetoothEmulation {
18
+ #connection: Connection;
19
+
20
+ constructor(connection: Connection) {
21
+ this.#connection = connection;
22
+ }
23
+
24
+ async emulateAdapter(state: AdapterState, leSupported = true): Promise<void> {
25
+ // Bluetooth spec requires overriding the existing adapter (step 6). From the CDP
26
+ // perspective, it means disabling the emulation first.
27
+ // https://webbluetoothcg.github.io/web-bluetooth/#bluetooth-simulateAdapter-command
28
+ await this.#connection.send('BluetoothEmulation.disable');
29
+ await this.#connection.send('BluetoothEmulation.enable', {
30
+ state,
31
+ leSupported,
32
+ });
33
+ }
34
+
35
+ async disableEmulation(): Promise<void> {
36
+ await this.#connection.send('BluetoothEmulation.disable');
37
+ }
38
+
39
+ async simulatePreconnectedPeripheral(
40
+ preconnectedPeripheral: PreconnectedPeripheral,
41
+ ): Promise<void> {
42
+ await this.#connection.send(
43
+ 'BluetoothEmulation.simulatePreconnectedPeripheral',
44
+ preconnectedPeripheral,
45
+ );
46
+ }
47
+ }