chrome-devtools-frontend 1.0.923319 → 1.0.923788

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 (223) hide show
  1. package/front_end/core/common/EventTarget.ts +7 -13
  2. package/front_end/core/common/Object.ts +5 -9
  3. package/front_end/core/common/Settings.ts +12 -9
  4. package/front_end/core/sdk/RuntimeModel.ts +1 -1
  5. package/front_end/core/sdk/SourceMap.ts +74 -31
  6. package/front_end/core/sdk/TargetManager.ts +7 -7
  7. package/front_end/models/bindings/CompilerScriptMapping.ts +24 -6
  8. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +30 -30
  9. package/front_end/models/extensions/ExtensionServer.ts +10 -13
  10. package/front_end/models/workspace/WorkspaceImpl.ts +1 -1
  11. package/front_end/models/workspace_diff/WorkspaceDiff.ts +24 -20
  12. package/front_end/panels/application/ApplicationPanelSidebar.ts +14 -19
  13. package/front_end/panels/application/DatabaseModel.ts +6 -1
  14. package/front_end/panels/application/IndexedDBModel.ts +9 -1
  15. package/front_end/panels/console/ConsolePinPane.ts +1 -2
  16. package/front_end/panels/coverage/CoverageModel.ts +9 -3
  17. package/front_end/panels/media/PlayerMessagesView.ts +2 -4
  18. package/front_end/panels/profiler/HeapProfileView.ts +12 -2
  19. package/front_end/panels/profiler/HeapSnapshotView.ts +52 -20
  20. package/front_end/panels/profiler/ProfileHeader.ts +11 -2
  21. package/front_end/panels/profiler/ProfilesPanel.ts +7 -6
  22. package/front_end/panels/timeline/TimelineUIUtils.ts +1 -2
  23. package/front_end/panels/web_audio/WebAudioModel.ts +19 -1
  24. package/front_end/panels/web_audio/WebAudioView.ts +25 -19
  25. package/front_end/third_party/puppeteer/README.chromium +1 -1
  26. package/front_end/third_party/puppeteer/package/CHANGELOG.md +66 -0
  27. package/front_end/third_party/puppeteer/package/README.md +34 -13
  28. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/AriaQueryHandler.d.ts.map +1 -1
  29. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/AriaQueryHandler.js +5 -5
  30. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/AriaQueryHandler.js.map +1 -1
  31. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Browser.d.ts +18 -2
  32. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Browser.d.ts.map +1 -1
  33. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Browser.js +8 -3
  34. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Browser.js.map +1 -1
  35. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Connection.d.ts +2 -2
  36. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Connection.js +2 -2
  37. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Coverage.d.ts +22 -6
  38. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Coverage.d.ts.map +1 -1
  39. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Coverage.js +14 -7
  40. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Coverage.js.map +1 -1
  41. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/DOMWorld.d.ts +1 -0
  42. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/DOMWorld.d.ts.map +1 -1
  43. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/DOMWorld.js +10 -6
  44. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/DOMWorld.js.map +1 -1
  45. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/DeviceDescriptors.d.ts.map +1 -1
  46. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/DeviceDescriptors.js +120 -0
  47. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/DeviceDescriptors.js.map +1 -1
  48. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/EvalTypes.d.ts +1 -1
  49. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/EvalTypes.d.ts.map +1 -1
  50. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/FrameManager.d.ts.map +1 -1
  51. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/FrameManager.js +2 -2
  52. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/FrameManager.js.map +1 -1
  53. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPRequest.d.ts +62 -3
  54. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPRequest.d.ts.map +1 -1
  55. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPRequest.js +131 -3
  56. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/HTTPRequest.js.map +1 -1
  57. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Input.d.ts +40 -0
  58. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Input.d.ts.map +1 -1
  59. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Input.js +76 -0
  60. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Input.js.map +1 -1
  61. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/JSHandle.d.ts +53 -2
  62. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/JSHandle.d.ts.map +1 -1
  63. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/JSHandle.js +82 -13
  64. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/JSHandle.js.map +1 -1
  65. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/NetworkManager.d.ts +2 -1
  66. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/NetworkManager.d.ts.map +1 -1
  67. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/NetworkManager.js +14 -2
  68. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/NetworkManager.js.map +1 -1
  69. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/PDFOptions.d.ts +5 -0
  70. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/PDFOptions.d.ts.map +1 -1
  71. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/PDFOptions.js.map +1 -1
  72. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Page.d.ts +1053 -29
  73. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Page.d.ts.map +1 -1
  74. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Page.js +1114 -22
  75. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Page.js.map +1 -1
  76. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Tracing.d.ts.map +1 -1
  77. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Tracing.js +17 -6
  78. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/Tracing.js.map +1 -1
  79. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/assert.d.ts +1 -0
  80. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/assert.d.ts.map +1 -1
  81. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/assert.js +6 -1
  82. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/assert.js.map +1 -1
  83. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/helper.d.ts +21 -5
  84. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/helper.d.ts.map +1 -1
  85. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/helper.js +47 -28
  86. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/helper.js.map +1 -1
  87. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/global.d.ts +17 -0
  88. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/global.d.ts.map +1 -0
  89. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/global.js +3 -0
  90. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/global.js.map +1 -0
  91. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserFetcher.d.ts.map +1 -1
  92. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserFetcher.js +9 -10
  93. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserFetcher.js.map +1 -1
  94. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserRunner.d.ts.map +1 -1
  95. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserRunner.js +5 -2
  96. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserRunner.js.map +1 -1
  97. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/LaunchOptions.d.ts +10 -2
  98. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/LaunchOptions.d.ts.map +1 -1
  99. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/Launcher.d.ts +1 -1
  100. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/Launcher.d.ts.map +1 -1
  101. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/Launcher.js +83 -6
  102. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/Launcher.js.map +1 -1
  103. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/NodeWebSocketTransport.d.ts.map +1 -1
  104. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/NodeWebSocketTransport.js +7 -1
  105. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/NodeWebSocketTransport.js.map +1 -1
  106. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/Puppeteer.d.ts +1 -1
  107. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/Puppeteer.d.ts.map +1 -1
  108. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/Puppeteer.js +2 -2
  109. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/Puppeteer.js.map +1 -1
  110. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/install.d.ts.map +1 -1
  111. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/install.js +17 -3
  112. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/install.js.map +1 -1
  113. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +1 -1
  114. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/AriaQueryHandler.d.ts.map +1 -1
  115. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/AriaQueryHandler.js +5 -5
  116. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/AriaQueryHandler.js.map +1 -1
  117. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Browser.d.ts +18 -2
  118. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Browser.d.ts.map +1 -1
  119. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Browser.js +8 -3
  120. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Browser.js.map +1 -1
  121. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Connection.d.ts +2 -2
  122. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Connection.js +2 -2
  123. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Coverage.d.ts +22 -6
  124. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Coverage.d.ts.map +1 -1
  125. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Coverage.js +14 -7
  126. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Coverage.js.map +1 -1
  127. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/DOMWorld.d.ts +1 -0
  128. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/DOMWorld.d.ts.map +1 -1
  129. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/DOMWorld.js +10 -6
  130. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/DOMWorld.js.map +1 -1
  131. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/DeviceDescriptors.d.ts.map +1 -1
  132. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/DeviceDescriptors.js +120 -0
  133. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/DeviceDescriptors.js.map +1 -1
  134. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/EvalTypes.d.ts +1 -1
  135. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/EvalTypes.d.ts.map +1 -1
  136. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/FrameManager.d.ts.map +1 -1
  137. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/FrameManager.js +2 -2
  138. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/FrameManager.js.map +1 -1
  139. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPRequest.d.ts +62 -3
  140. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPRequest.d.ts.map +1 -1
  141. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPRequest.js +131 -3
  142. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/HTTPRequest.js.map +1 -1
  143. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Input.d.ts +40 -0
  144. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Input.d.ts.map +1 -1
  145. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Input.js +76 -0
  146. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Input.js.map +1 -1
  147. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/JSHandle.d.ts +53 -2
  148. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/JSHandle.d.ts.map +1 -1
  149. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/JSHandle.js +82 -13
  150. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/JSHandle.js.map +1 -1
  151. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/NetworkManager.d.ts +2 -1
  152. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/NetworkManager.d.ts.map +1 -1
  153. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/NetworkManager.js +14 -2
  154. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/NetworkManager.js.map +1 -1
  155. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/PDFOptions.d.ts +5 -0
  156. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/PDFOptions.d.ts.map +1 -1
  157. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/PDFOptions.js.map +1 -1
  158. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Page.d.ts +1053 -29
  159. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Page.d.ts.map +1 -1
  160. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Page.js +1115 -23
  161. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Page.js.map +1 -1
  162. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Tracing.d.ts.map +1 -1
  163. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Tracing.js +17 -6
  164. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/Tracing.js.map +1 -1
  165. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/assert.d.ts +1 -0
  166. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/assert.d.ts.map +1 -1
  167. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/assert.js +4 -0
  168. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/assert.js.map +1 -1
  169. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/helper.d.ts +21 -5
  170. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/helper.d.ts.map +1 -1
  171. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/helper.js +32 -13
  172. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/helper.js.map +1 -1
  173. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/global.d.ts +17 -0
  174. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/global.d.ts.map +1 -0
  175. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/global.js +2 -0
  176. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/global.js.map +1 -0
  177. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserFetcher.d.ts.map +1 -1
  178. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserFetcher.js +9 -10
  179. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserFetcher.js.map +1 -1
  180. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserRunner.d.ts.map +1 -1
  181. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserRunner.js +5 -2
  182. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserRunner.js.map +1 -1
  183. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/LaunchOptions.d.ts +10 -2
  184. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/LaunchOptions.d.ts.map +1 -1
  185. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/Launcher.d.ts +1 -1
  186. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/Launcher.d.ts.map +1 -1
  187. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/Launcher.js +83 -6
  188. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/Launcher.js.map +1 -1
  189. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/NodeWebSocketTransport.d.ts.map +1 -1
  190. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/NodeWebSocketTransport.js +7 -1
  191. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/NodeWebSocketTransport.js.map +1 -1
  192. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/Puppeteer.d.ts +1 -1
  193. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/Puppeteer.d.ts.map +1 -1
  194. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/Puppeteer.js +2 -2
  195. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/Puppeteer.js.map +1 -1
  196. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/install.d.ts.map +1 -1
  197. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/install.js +17 -3
  198. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/install.js.map +1 -1
  199. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +1 -1
  200. package/front_end/third_party/puppeteer/package/lib/types.d.ts +1382 -19726
  201. package/front_end/third_party/puppeteer/package/package.json +9 -6
  202. package/front_end/third_party/wasmparser/README.chromium +2 -2
  203. package/front_end/third_party/wasmparser/package/CHANGELOG.md +13 -0
  204. package/front_end/third_party/wasmparser/package/dist/cjs/WasmDis.js +50 -10
  205. package/front_end/third_party/wasmparser/package/dist/cjs/WasmDis.js.map +1 -1
  206. package/front_end/third_party/wasmparser/package/dist/cjs/WasmParser.d.ts +21 -4
  207. package/front_end/third_party/wasmparser/package/dist/cjs/WasmParser.js +76 -8
  208. package/front_end/third_party/wasmparser/package/dist/cjs/WasmParser.js.map +1 -1
  209. package/front_end/third_party/wasmparser/package/dist/esm/WasmDis.js +50 -10
  210. package/front_end/third_party/wasmparser/package/dist/esm/WasmDis.js.map +1 -1
  211. package/front_end/third_party/wasmparser/package/dist/esm/WasmParser.d.ts +21 -4
  212. package/front_end/third_party/wasmparser/package/dist/esm/WasmParser.js +76 -8
  213. package/front_end/third_party/wasmparser/package/dist/esm/WasmParser.js.map +1 -1
  214. package/front_end/third_party/wasmparser/package/package.json +1 -1
  215. package/front_end/third_party/wasmparser/package/src/WasmDis.ts +47 -10
  216. package/front_end/third_party/wasmparser/package/src/WasmParser.ts +75 -5
  217. package/front_end/ui/components/icon_button/iconButton.css +4 -0
  218. package/front_end/ui/legacy/GlassPane.ts +1 -3
  219. package/front_end/ui/legacy/UIUtils.ts +2 -3
  220. package/front_end/ui/legacy/components/perf_ui/OverviewGrid.ts +3 -3
  221. package/front_end/ui/legacy/reportView.css +1 -0
  222. package/package.json +1 -1
  223. package/scripts/build/rollup.config.js +0 -5
@@ -16,7 +16,7 @@
16
16
  import { isNode } from '../environment.js';
17
17
 
18
18
  import { Accessibility } from './Accessibility.js';
19
- import { assert } from './assert.js';
19
+ import { assert, assertNever } from './assert.js';
20
20
  import { CDPSessionEmittedEvents, Connection, } from './Connection.js';
21
21
  import { ConsoleMessage } from './ConsoleMessage.js';
22
22
  import { Coverage } from './Coverage.js';
@@ -101,6 +101,7 @@ export class Page extends EventEmitter {
101
101
  // TODO: improve this typedef - it's a function that takes a file chooser or
102
102
  // something?
103
103
  this._fileChooserInterceptors = new Set();
104
+ this._userDragInterceptionEnabled = false;
104
105
  this._client = client;
105
106
  this._target = target;
106
107
  this._keyboard = new Keyboard(client);
@@ -120,7 +121,7 @@ export class Page extends EventEmitter {
120
121
  // We still want to attach to workers for emitting events.
121
122
  // We still want to attach to iframes so sessions may interact with them.
122
123
  // We detach from all other types out of an abundance of caution.
123
- // See https://source.chromium.org/chromium/chromium/src/+/master:content/browser/devtools/devtools_agent_host_impl.cc?q=f:devtools%20-f:out%20%22::kTypePage%5B%5D%22&ss=chromium
124
+ // See https://source.chromium.org/chromium/chromium/src/+/main:content/browser/devtools/devtools_agent_host_impl.cc?ss=chromium&q=f:devtools%20-f:out%20%22::kTypePage%5B%5D%22
124
125
  // for the complete list of available types.
125
126
  client
126
127
  .send('Target.detachFromTarget', {
@@ -200,6 +201,12 @@ export class Page extends EventEmitter {
200
201
  for (const interceptor of interceptors)
201
202
  interceptor.call(null, fileChooser);
202
203
  }
204
+ /**
205
+ * @returns `true` if drag events are being intercepted, `false` otherwise.
206
+ */
207
+ isDragInterceptionEnabled() {
208
+ return this._userDragInterceptionEnabled;
209
+ }
203
210
  /**
204
211
  * @returns `true` if the page has JavaScript enabled, `false` otherwise.
205
212
  */
@@ -209,9 +216,15 @@ export class Page extends EventEmitter {
209
216
  /**
210
217
  * Listen to page events.
211
218
  */
219
+ // Note: this method exists to define event typings and handle
220
+ // proper wireup of cooperative request interception. Actual event listening and
221
+ // dispatching is delegated to EventEmitter.
212
222
  on(eventName, handler) {
213
- // Note: this method only exists to define the types; we delegate the impl
214
- // to EventEmitter.
223
+ if (eventName === 'request') {
224
+ return super.on(eventName, (event) => {
225
+ event.enqueueInterceptAction(() => handler(event));
226
+ });
227
+ }
215
228
  return super.on(eventName, handler);
216
229
  }
217
230
  once(eventName, handler) {
@@ -220,8 +233,26 @@ export class Page extends EventEmitter {
220
233
  return super.once(eventName, handler);
221
234
  }
222
235
  /**
236
+ * This method is typically coupled with an action that triggers file
237
+ * choosing. The following example clicks a button that issues a file chooser
238
+ * and then responds with `/tmp/myfile.pdf` as if a user has selected this file.
239
+ *
240
+ * ```js
241
+ * const [fileChooser] = await Promise.all([
242
+ * page.waitForFileChooser(),
243
+ * page.click('#upload-file-button'),
244
+ * // some button that triggers file selection
245
+ * ]);
246
+ * await fileChooser.accept(['/tmp/myfile.pdf']);
247
+ * ```
248
+ *
249
+ * NOTE: This must be called before the file chooser is launched. It will not
250
+ * return a currently active file chooser.
223
251
  * @param options - Optional waiting parameters
224
252
  * @returns Resolves after a page requests a file picker.
253
+ * @remarks
254
+ * NOTE: In non-headless Chromium, this method results in the native file picker
255
+ * dialog `not showing up` for the user.
225
256
  */
226
257
  async waitForFileChooser(options = {}) {
227
258
  if (!this._fileChooserInterceptors.size)
@@ -241,11 +272,9 @@ export class Page extends EventEmitter {
241
272
  }
242
273
  /**
243
274
  * Sets the page's geolocation.
244
- *
245
275
  * @remarks
246
- * Consider using {@link BrowserContext.overridePermissions} to grant
276
+ * NOTE: Consider using {@link BrowserContext.overridePermissions} to grant
247
277
  * permissions for the page to read its geolocation.
248
- *
249
278
  * @example
250
279
  * ```js
251
280
  * await page.setGeolocation({latitude: 59.95, longitude: 30.31667});
@@ -272,13 +301,20 @@ export class Page extends EventEmitter {
272
301
  return this._target;
273
302
  }
274
303
  /**
275
- * @returns The browser this page belongs to.
304
+ * Get the CDP session client the page belongs to.
305
+ * @internal
306
+ */
307
+ client() {
308
+ return this._client;
309
+ }
310
+ /**
311
+ * Get the browser the page belongs to.
276
312
  */
277
313
  browser() {
278
314
  return this._target.browser();
279
315
  }
280
316
  /**
281
- * @returns The browser context that the page belongs to
317
+ * Get the browser context that the page belongs to.
282
318
  */
283
319
  browserContext() {
284
320
  return this._target.browserContext();
@@ -295,6 +331,8 @@ export class Page extends EventEmitter {
295
331
  }
296
332
  /**
297
333
  * @returns The page's main frame.
334
+ * @remarks
335
+ * Page is guaranteed to have a main frame which persists during navigations.
298
336
  */
299
337
  mainFrame() {
300
338
  return this._frameManager.mainFrame();
@@ -322,8 +360,11 @@ export class Page extends EventEmitter {
322
360
  }
323
361
  /**
324
362
  * @returns all of the dedicated
325
- * {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API | WebWorkers}
363
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API |
364
+ * WebWorkers}
326
365
  * associated with the page.
366
+ * @remarks
367
+ * NOTE: This does not contain ServiceWorkers
327
368
  */
328
369
  workers() {
329
370
  return Array.from(this._workers.values());
@@ -358,22 +399,74 @@ export class Page extends EventEmitter {
358
399
  * await browser.close();
359
400
  * })();
360
401
  * ```
402
+ * NOTE: Enabling request interception disables page caching.
361
403
  */
362
404
  async setRequestInterception(value) {
363
405
  return this._frameManager.networkManager().setRequestInterception(value);
364
406
  }
407
+ /**
408
+ * @param enabled - Whether to enable drag interception.
409
+ *
410
+ * @remarks
411
+ * Activating drag interception enables the `Input.drag`,
412
+ * methods This provides the capability to capture drag events emitted
413
+ * on the page, which can then be used to simulate drag-and-drop.
414
+ */
415
+ async setDragInterception(enabled) {
416
+ this._userDragInterceptionEnabled = enabled;
417
+ return this._client.send('Input.setInterceptDrags', { enabled });
418
+ }
365
419
  /**
366
420
  * @param enabled - When `true`, enables offline mode for the page.
421
+ * @remarks
422
+ * NOTE: while this method sets the network connection to offline, it does
423
+ * not change the parameters used in [page.emulateNetworkConditions(networkConditions)]
424
+ * (#pageemulatenetworkconditionsnetworkconditions)
367
425
  */
368
426
  setOfflineMode(enabled) {
369
427
  return this._frameManager.networkManager().setOfflineMode(enabled);
370
428
  }
429
+ /**
430
+ * @param networkConditions - Passing `null` disables network condition emulation.
431
+ * @example
432
+ * ```js
433
+ * const puppeteer = require('puppeteer');
434
+ * const slow3G = puppeteer.networkConditions['Slow 3G'];
435
+ *
436
+ * (async () => {
437
+ * const browser = await puppeteer.launch();
438
+ * const page = await browser.newPage();
439
+ * await page.emulateNetworkConditions(slow3G);
440
+ * await page.goto('https://www.google.com');
441
+ * // other actions...
442
+ * await browser.close();
443
+ * })();
444
+ * ```
445
+ * @remarks
446
+ * NOTE: This does not affect WebSockets and WebRTC PeerConnections (see
447
+ * https://crbug.com/563644). To set the page offline, you can use
448
+ * [page.setOfflineMode(enabled)](#pagesetofflinemodeenabled).
449
+ */
371
450
  emulateNetworkConditions(networkConditions) {
372
451
  return this._frameManager
373
452
  .networkManager()
374
453
  .emulateNetworkConditions(networkConditions);
375
454
  }
376
455
  /**
456
+ * This setting will change the default maximum navigation time for the
457
+ * following methods and related shortcuts:
458
+ *
459
+ * - {@link Page.goBack | page.goBack(options)}
460
+ *
461
+ * - {@link Page.goForward | page.goForward(options)}
462
+ *
463
+ * - {@link Page.goto | page.goto(url,options)}
464
+ *
465
+ * - {@link Page.reload | page.reload(options)}
466
+ *
467
+ * - {@link Page.setContent | page.setContent(html,options)}
468
+ *
469
+ * - {@link Page.waitForNavigation | page.waitForNavigation(options)}
377
470
  * @param timeout - Maximum navigation time in milliseconds.
378
471
  */
379
472
  setDefaultNavigationTimeout(timeout) {
@@ -457,6 +550,9 @@ export class Page extends EventEmitter {
457
550
  * given prototype.
458
551
  *
459
552
  * @remarks
553
+ * Shortcut for
554
+ * {@link ExecutionContext.queryObjects |
555
+ * page.mainFrame().executionContext().queryObjects(prototypeHandle)}.
460
556
  *
461
557
  * @example
462
558
  *
@@ -473,6 +569,8 @@ export class Page extends EventEmitter {
473
569
  * await mapPrototype.dispose();
474
570
  * ```
475
571
  * @param prototypeHandle - a handle to the object prototype.
572
+ * @returns Promise which resolves to a handle to an array of objects with
573
+ * this prototype.
476
574
  */
477
575
  async queryObjects(prototypeHandle) {
478
576
  const context = await this.mainFrame().executionContext();
@@ -604,9 +702,24 @@ export class Page extends EventEmitter {
604
702
  async $$eval(selector, pageFunction, ...args) {
605
703
  return this.mainFrame().$$eval(selector, pageFunction, ...args);
606
704
  }
705
+ /**
706
+ * The method runs `document.querySelectorAll` within the page. If no elements
707
+ * match the selector, the return value resolves to `[]`.
708
+ * @remarks
709
+ * Shortcut for {@link Frame.$$ | Page.mainFrame().$$(selector) }.
710
+ * @param selector - A `selector` to query page for
711
+ */
607
712
  async $$(selector) {
608
713
  return this.mainFrame().$$(selector);
609
714
  }
715
+ /**
716
+ * The method evaluates the XPath expression relative to the page document as
717
+ * its context node. If there are no such elements, the method resolves to an
718
+ * empty array.
719
+ * @remarks
720
+ * Shortcut for {@link Frame.$x | Page.mainFrame().$x(expression) }.
721
+ * @param expression - Expression to evaluate
722
+ */
610
723
  async $x(expression) {
611
724
  return this.mainFrame().$x(expression);
612
725
  }
@@ -635,6 +748,12 @@ export class Page extends EventEmitter {
635
748
  await this._client.send('Network.deleteCookies', item);
636
749
  }
637
750
  }
751
+ /**
752
+ * @example
753
+ * ```js
754
+ * await page.setCookie(cookieObject1, cookieObject2);
755
+ * ```
756
+ */
638
757
  async setCookie(...cookies) {
639
758
  const pageURL = this.url();
640
759
  const startsWithHTTP = pageURL.startsWith('http');
@@ -650,12 +769,84 @@ export class Page extends EventEmitter {
650
769
  if (items.length)
651
770
  await this._client.send('Network.setCookies', { cookies: items });
652
771
  }
772
+ /**
773
+ * Adds a `<script>` tag into the page with the desired URL or content.
774
+ * @remarks
775
+ * Shortcut for {@link Frame.addScriptTag | page.mainFrame().addScriptTag(options) }.
776
+ * @returns Promise which resolves to the added tag when the script's onload fires or
777
+ * when the script content was injected into frame.
778
+ */
653
779
  async addScriptTag(options) {
654
780
  return this.mainFrame().addScriptTag(options);
655
781
  }
782
+ /**
783
+ * Adds a `<link rel="stylesheet">` tag into the page with the desired URL or a
784
+ * `<style type="text/css">` tag with the content.
785
+ * @returns Promise which resolves to the added tag when the stylesheet's
786
+ * onload fires or when the CSS content was injected into frame.
787
+ */
656
788
  async addStyleTag(options) {
657
789
  return this.mainFrame().addStyleTag(options);
658
790
  }
791
+ /**
792
+ * The method adds a function called `name` on the page's `window` object. When
793
+ * called, the function executes `puppeteerFunction` in node.js and returns a
794
+ * `Promise` which resolves to the return value of `puppeteerFunction`.
795
+ *
796
+ * If the puppeteerFunction returns a `Promise`, it will be awaited.
797
+ *
798
+ * NOTE: Functions installed via `page.exposeFunction` survive navigations.
799
+ * @param name - Name of the function on the window object
800
+ * @param puppeteerFunction - Callback function which will be called in
801
+ * Puppeteer's context.
802
+ * @example
803
+ * An example of adding an `md5` function into the page:
804
+ * ```js
805
+ * const puppeteer = require('puppeteer');
806
+ * const crypto = require('crypto');
807
+ *
808
+ * (async () => {
809
+ * const browser = await puppeteer.launch();
810
+ * const page = await browser.newPage();
811
+ * page.on('console', (msg) => console.log(msg.text()));
812
+ * await page.exposeFunction('md5', (text) =>
813
+ * crypto.createHash('md5').update(text).digest('hex')
814
+ * );
815
+ * await page.evaluate(async () => {
816
+ * // use window.md5 to compute hashes
817
+ * const myString = 'PUPPETEER';
818
+ * const myHash = await window.md5(myString);
819
+ * console.log(`md5 of ${myString} is ${myHash}`);
820
+ * });
821
+ * await browser.close();
822
+ * })();
823
+ * ```
824
+ * An example of adding a `window.readfile` function into the page:
825
+ * ```js
826
+ * const puppeteer = require('puppeteer');
827
+ * const fs = require('fs');
828
+ *
829
+ * (async () => {
830
+ * const browser = await puppeteer.launch();
831
+ * const page = await browser.newPage();
832
+ * page.on('console', (msg) => console.log(msg.text()));
833
+ * await page.exposeFunction('readfile', async (filePath) => {
834
+ * return new Promise((resolve, reject) => {
835
+ * fs.readFile(filePath, 'utf8', (err, text) => {
836
+ * if (err) reject(err);
837
+ * else resolve(text);
838
+ * });
839
+ * });
840
+ * });
841
+ * await page.evaluate(async () => {
842
+ * // use window.readfile to read contents of a file
843
+ * const content = await window.readfile('/etc/hosts');
844
+ * console.log(content);
845
+ * });
846
+ * await browser.close();
847
+ * })();
848
+ * ```
849
+ */
659
850
  async exposeFunction(name, puppeteerFunction) {
660
851
  if (this._pageBindings.has(name))
661
852
  throw new Error(`Failed to add page binding with name ${name}: window['${name}'] already exists!`);
@@ -667,15 +858,71 @@ export class Page extends EventEmitter {
667
858
  });
668
859
  await Promise.all(this.frames().map((frame) => frame.evaluate(expression).catch(debugError)));
669
860
  }
861
+ /**
862
+ * Provide credentials for `HTTP authentication`.
863
+ * @remarks To disable authentication, pass `null`.
864
+ */
670
865
  async authenticate(credentials) {
671
866
  return this._frameManager.networkManager().authenticate(credentials);
672
867
  }
868
+ /**
869
+ * The extra HTTP headers will be sent with every request the page initiates.
870
+ * NOTE: All HTTP header names are lowercased. (HTTP headers are
871
+ * case-insensitive, so this shouldn’t impact your server code.)
872
+ * NOTE: page.setExtraHTTPHeaders does not guarantee the order of headers in
873
+ * the outgoing requests.
874
+ * @param headers - An object containing additional HTTP headers to be sent
875
+ * with every request. All header values must be strings.
876
+ * @returns
877
+ */
673
878
  async setExtraHTTPHeaders(headers) {
674
879
  return this._frameManager.networkManager().setExtraHTTPHeaders(headers);
675
880
  }
676
- async setUserAgent(userAgent) {
677
- return this._frameManager.networkManager().setUserAgent(userAgent);
881
+ /**
882
+ * @param userAgent - Specific user agent to use in this page
883
+ * @param userAgentData - Specific user agent client hint data to use in this
884
+ * page
885
+ * @returns Promise which resolves when the user agent is set.
886
+ */
887
+ async setUserAgent(userAgent, userAgentMetadata) {
888
+ return this._frameManager
889
+ .networkManager()
890
+ .setUserAgent(userAgent, userAgentMetadata);
678
891
  }
892
+ /**
893
+ * @returns Object containing metrics as key/value pairs.
894
+ *
895
+ * - `Timestamp` : The timestamp when the metrics sample was taken.
896
+ *
897
+ * - `Documents` : Number of documents in the page.
898
+ *
899
+ * - `Frames` : Number of frames in the page.
900
+ *
901
+ * - `JSEventListeners` : Number of events in the page.
902
+ *
903
+ * - `Nodes` : Number of DOM nodes in the page.
904
+ *
905
+ * - `LayoutCount` : Total number of full or partial page layout.
906
+ *
907
+ * - `RecalcStyleCount` : Total number of page style recalculations.
908
+ *
909
+ * - `LayoutDuration` : Combined durations of all page layouts.
910
+ *
911
+ * - `RecalcStyleDuration` : Combined duration of all page style
912
+ * recalculations.
913
+ *
914
+ * - `ScriptDuration` : Combined duration of JavaScript execution.
915
+ *
916
+ * - `TaskDuration` : Combined duration of all tasks performed by the browser.
917
+ *
918
+ *
919
+ * - `JSHeapUsedSize` : Used JavaScript heap size.
920
+ *
921
+ * - `JSHeapTotalSize` : Total JavaScript heap size.
922
+ * @remarks
923
+ * NOTE: All timestamps are in monotonic time: monotonically increasing time
924
+ * in seconds since an arbitrary point in the past.
925
+ */
679
926
  async metrics() {
680
927
  const response = await this._client.send('Performance.getMetrics');
681
928
  return this._buildMetricsObject(response.metrics);
@@ -807,18 +1054,134 @@ export class Page extends EventEmitter {
807
1054
  color: { r: 0, g: 0, b: 0, a: 0 },
808
1055
  });
809
1056
  }
1057
+ /**
1058
+ *
1059
+ * @returns
1060
+ * @remarks Shortcut for
1061
+ * {@link Frame.url | page.mainFrame().url()}.
1062
+ */
810
1063
  url() {
811
1064
  return this.mainFrame().url();
812
1065
  }
813
1066
  async content() {
814
1067
  return await this._frameManager.mainFrame().content();
815
1068
  }
1069
+ /**
1070
+ * @param html - HTML markup to assign to the page.
1071
+ * @param options - Parameters that has some properties.
1072
+ * @remarks
1073
+ * The parameter `options` might have the following options.
1074
+ *
1075
+ * - `timeout` : Maximum time in milliseconds for resources to load, defaults
1076
+ * to 30 seconds, pass `0` to disable timeout. The default value can be
1077
+ * changed by using the
1078
+ * {@link Page.setDefaultNavigationTimeout |
1079
+ * page.setDefaultNavigationTimeout(timeout)}
1080
+ * or {@link Page.setDefaultTimeout | page.setDefaultTimeout(timeout)}
1081
+ * methods.
1082
+ *
1083
+ * - `waitUntil`: When to consider setting markup succeeded, defaults to `load`.
1084
+ * Given an array of event strings, setting content is considered to be
1085
+ * successful after all events have been fired. Events can be either:<br/>
1086
+ * - `load` : consider setting content to be finished when the `load` event is
1087
+ * fired.<br/>
1088
+ * - `domcontentloaded` : consider setting content to be finished when the
1089
+ * `DOMContentLoaded` event is fired.<br/>
1090
+ * - `networkidle0` : consider setting content to be finished when there are no
1091
+ * more than 0 network connections for at least `500` ms.<br/>
1092
+ * - `networkidle2` : consider setting content to be finished when there are no
1093
+ * more than 2 network connections for at least `500` ms.
1094
+ */
816
1095
  async setContent(html, options = {}) {
817
1096
  await this._frameManager.mainFrame().setContent(html, options);
818
1097
  }
1098
+ /**
1099
+ * @param url - URL to navigate page to. The URL should include scheme, e.g.
1100
+ * `https://`
1101
+ * @param options - Navigation Parameter
1102
+ * @returns Promise which resolves to the main resource response. In case of
1103
+ * multiple redirects, the navigation will resolve with the response of the
1104
+ * last redirect.
1105
+ * @remarks
1106
+ * The argument `options` might have the following properties:
1107
+ *
1108
+ * - `timeout` : Maximum navigation time in milliseconds, defaults to 30
1109
+ * seconds, pass 0 to disable timeout. The default value can be changed by
1110
+ * using the
1111
+ * {@link Page.setDefaultNavigationTimeout |
1112
+ * page.setDefaultNavigationTimeout(timeout)}
1113
+ * or {@link Page.setDefaultTimeout | page.setDefaultTimeout(timeout)}
1114
+ * methods.
1115
+ *
1116
+ * - `waitUntil`:When to consider navigation succeeded, defaults to `load`.
1117
+ * Given an array of event strings, navigation is considered to be successful
1118
+ * after all events have been fired. Events can be either:<br/>
1119
+ * - `load` : consider navigation to be finished when the load event is
1120
+ * fired.<br/>
1121
+ * - `domcontentloaded` : consider navigation to be finished when the
1122
+ * DOMContentLoaded event is fired.<br/>
1123
+ * - `networkidle0` : consider navigation to be finished when there are no
1124
+ * more than 0 network connections for at least `500` ms.<br/>
1125
+ * - `networkidle2` : consider navigation to be finished when there are no
1126
+ * more than 2 network connections for at least `500` ms.
1127
+ *
1128
+ * - `referer` : Referer header value. If provided it will take preference
1129
+ * over the referer header value set by
1130
+ * {@link Page.setExtraHTTPHeaders |page.setExtraHTTPHeaders()}.
1131
+ *
1132
+ * `page.goto` will throw an error if:
1133
+ * - there's an SSL error (e.g. in case of self-signed certificates).
1134
+ * - target URL is invalid.
1135
+ * - the timeout is exceeded during navigation.
1136
+ * - the remote server does not respond or is unreachable.
1137
+ * - the main resource failed to load.
1138
+ *
1139
+ * `page.goto` will not throw an error when any valid HTTP status code is
1140
+ * returned by the remote server, including 404 "Not Found" and 500
1141
+ * "Internal Server Error". The status code for such responses can be
1142
+ * retrieved by calling response.status().
1143
+ *
1144
+ * NOTE: `page.goto` either throws an error or returns a main resource
1145
+ * response. The only exceptions are navigation to about:blank or navigation
1146
+ * to the same URL with a different hash, which would succeed and return null.
1147
+ *
1148
+ * NOTE: Headless mode doesn't support navigation to a PDF document. See the
1149
+ * {@link https://bugs.chromium.org/p/chromium/issues/detail?id=761295
1150
+ * | upstream issue}.
1151
+ *
1152
+ * Shortcut for {@link Frame.goto | page.mainFrame().goto(url, options)}.
1153
+ */
819
1154
  async goto(url, options = {}) {
820
1155
  return await this._frameManager.mainFrame().goto(url, options);
821
1156
  }
1157
+ /**
1158
+ * @param options - Navigation parameters which might have the following
1159
+ * properties:
1160
+ * @returns Promise which resolves to the main resource response. In case of
1161
+ * multiple redirects, the navigation will resolve with the response of the
1162
+ * last redirect.
1163
+ * @remarks
1164
+ * The argument `options` might have the following properties:
1165
+ *
1166
+ * - `timeout` : Maximum navigation time in milliseconds, defaults to 30
1167
+ * seconds, pass 0 to disable timeout. The default value can be changed by
1168
+ * using the
1169
+ * {@link Page.setDefaultNavigationTimeout |
1170
+ * page.setDefaultNavigationTimeout(timeout)}
1171
+ * or {@link Page.setDefaultTimeout | page.setDefaultTimeout(timeout)}
1172
+ * methods.
1173
+ *
1174
+ * - `waitUntil`: When to consider navigation succeeded, defaults to `load`.
1175
+ * Given an array of event strings, navigation is considered to be
1176
+ * successful after all events have been fired. Events can be either:<br/>
1177
+ * - `load` : consider navigation to be finished when the load event is fired.<br/>
1178
+ * - `domcontentloaded` : consider navigation to be finished when the
1179
+ * DOMContentLoaded event is fired.<br/>
1180
+ * - `networkidle0` : consider navigation to be finished when there are no
1181
+ * more than 0 network connections for at least `500` ms.<br/>
1182
+ * - `networkidle2` : consider navigation to be finished when there are no
1183
+ * more than 2 network connections for at least `500` ms.
1184
+ */
822
1185
  async reload(options) {
823
1186
  const result = await Promise.all([
824
1187
  this.waitForNavigation(options),
@@ -826,6 +1189,30 @@ export class Page extends EventEmitter {
826
1189
  ]);
827
1190
  return result[0];
828
1191
  }
1192
+ /**
1193
+ * This resolves when the page navigates to a new URL or reloads. It is useful
1194
+ * when you run code that will indirectly cause the page to navigate. Consider
1195
+ * this example:
1196
+ * ```js
1197
+ * const [response] = await Promise.all([
1198
+ * page.waitForNavigation(), // The promise resolves after navigation has finished
1199
+ * page.click('a.my-link'), // Clicking the link will indirectly cause a navigation
1200
+ * ]);
1201
+ * ```
1202
+ *
1203
+ * @param options - Navigation parameters which might have the following properties:
1204
+ * @returns Promise which resolves to the main resource response. In case of
1205
+ * multiple redirects, the navigation will resolve with the response of the
1206
+ * last redirect. In case of navigation to a different anchor or navigation
1207
+ * due to History API usage, the navigation will resolve with `null`.
1208
+ * @remarks
1209
+ * NOTE: Usage of the
1210
+ * {@link https://developer.mozilla.org/en-US/docs/Web/API/History_API | History API}
1211
+ * to change the URL is considered a navigation.
1212
+ *
1213
+ * Shortcut for
1214
+ * {@link Frame.waitForNavigation | page.mainFrame().waitForNavigation(options)}.
1215
+ */
829
1216
  async waitForNavigation(options = {}) {
830
1217
  return await this._frameManager.mainFrame().waitForNavigation(options);
831
1218
  }
@@ -834,6 +1221,31 @@ export class Page extends EventEmitter {
834
1221
  this._disconnectPromise = new Promise((fulfill) => this._client.once(CDPSessionEmittedEvents.Disconnected, () => fulfill(new Error('Target closed'))));
835
1222
  return this._disconnectPromise;
836
1223
  }
1224
+ /**
1225
+ * @param urlOrPredicate - A URL or predicate to wait for
1226
+ * @param options - Optional waiting parameters
1227
+ * @returns Promise which resolves to the matched response
1228
+ * @example
1229
+ * ```js
1230
+ * const firstResponse = await page.waitForResponse(
1231
+ * 'https://example.com/resource'
1232
+ * );
1233
+ * const finalResponse = await page.waitForResponse(
1234
+ * (response) =>
1235
+ * response.url() === 'https://example.com' && response.status() === 200
1236
+ * );
1237
+ * const finalResponse = await page.waitForResponse(async (response) => {
1238
+ * return (await response.text()).includes('<html>');
1239
+ * });
1240
+ * return finalResponse.ok();
1241
+ * ```
1242
+ * @remarks
1243
+ * Optional Waiting Parameters have:
1244
+ *
1245
+ * - `timeout`: Maximum wait time in milliseconds, defaults to `30` seconds, pass
1246
+ * `0` to disable the timeout. The default value can be changed by using the
1247
+ * {@link Page.setDefaultTimeout} method.
1248
+ */
837
1249
  async waitForRequest(urlOrPredicate, options = {}) {
838
1250
  const { timeout = this._timeoutSettings.timeout() } = options;
839
1251
  return helper.waitForEvent(this._frameManager.networkManager(), NetworkManagerEmittedEvents.Request, (request) => {
@@ -844,6 +1256,31 @@ export class Page extends EventEmitter {
844
1256
  return false;
845
1257
  }, timeout, this._sessionClosePromise());
846
1258
  }
1259
+ /**
1260
+ * @param urlOrPredicate - A URL or predicate to wait for.
1261
+ * @param options - Optional waiting parameters
1262
+ * @returns Promise which resolves to the matched response.
1263
+ * @example
1264
+ * ```js
1265
+ * const firstResponse = await page.waitForResponse(
1266
+ * 'https://example.com/resource'
1267
+ * );
1268
+ * const finalResponse = await page.waitForResponse(
1269
+ * (response) =>
1270
+ * response.url() === 'https://example.com' && response.status() === 200
1271
+ * );
1272
+ * const finalResponse = await page.waitForResponse(async (response) => {
1273
+ * return (await response.text()).includes('<html>');
1274
+ * });
1275
+ * return finalResponse.ok();
1276
+ * ```
1277
+ * @remarks
1278
+ * Optional Parameter have:
1279
+ *
1280
+ * - `timeout`: Maximum wait time in milliseconds, defaults to `30` seconds,
1281
+ * pass `0` to disable the timeout. The default value can be changed by using
1282
+ * the {@link Page.setDefaultTimeout} method.
1283
+ */
847
1284
  async waitForResponse(urlOrPredicate, options = {}) {
848
1285
  const { timeout = this._timeoutSettings.timeout() } = options;
849
1286
  return helper.waitForEvent(this._frameManager.networkManager(), NetworkManagerEmittedEvents.Response, async (response) => {
@@ -854,9 +1291,113 @@ export class Page extends EventEmitter {
854
1291
  return false;
855
1292
  }, timeout, this._sessionClosePromise());
856
1293
  }
1294
+ /**
1295
+ * @param options - Optional waiting parameters
1296
+ * @returns Promise which resolves when network is idle
1297
+ */
1298
+ async waitForNetworkIdle(options = {}) {
1299
+ const { idleTime = 500, timeout = this._timeoutSettings.timeout() } = options;
1300
+ const networkManager = this._frameManager.networkManager();
1301
+ let idleResolveCallback;
1302
+ const idlePromise = new Promise((resolve) => {
1303
+ idleResolveCallback = resolve;
1304
+ });
1305
+ let abortRejectCallback;
1306
+ const abortPromise = new Promise((_, reject) => {
1307
+ abortRejectCallback = reject;
1308
+ });
1309
+ let idleTimer;
1310
+ const onIdle = () => idleResolveCallback();
1311
+ const cleanup = () => {
1312
+ idleTimer && clearTimeout(idleTimer);
1313
+ abortRejectCallback(new Error('abort'));
1314
+ };
1315
+ const evaluate = () => {
1316
+ idleTimer && clearTimeout(idleTimer);
1317
+ if (networkManager.numRequestsInProgress() === 0)
1318
+ idleTimer = setTimeout(onIdle, idleTime);
1319
+ };
1320
+ evaluate();
1321
+ const eventHandler = () => {
1322
+ evaluate();
1323
+ return false;
1324
+ };
1325
+ const listenToEvent = (event) => helper.waitForEvent(networkManager, event, eventHandler, timeout, abortPromise);
1326
+ const eventPromises = [
1327
+ listenToEvent(NetworkManagerEmittedEvents.Request),
1328
+ listenToEvent(NetworkManagerEmittedEvents.Response),
1329
+ ];
1330
+ await Promise.race([
1331
+ idlePromise,
1332
+ ...eventPromises,
1333
+ this._sessionClosePromise(),
1334
+ ]).then((r) => {
1335
+ cleanup();
1336
+ return r;
1337
+ }, (error) => {
1338
+ cleanup();
1339
+ throw error;
1340
+ });
1341
+ }
1342
+ /**
1343
+ * This method navigate to the previous page in history.
1344
+ * @param options - Navigation parameters
1345
+ * @returns Promise which resolves to the main resource response. In case of
1346
+ * multiple redirects, the navigation will resolve with the response of the
1347
+ * last redirect. If can not go back, resolves to `null`.
1348
+ * @remarks
1349
+ * The argument `options` might have the following properties:
1350
+ *
1351
+ * - `timeout` : Maximum navigation time in milliseconds, defaults to 30
1352
+ * seconds, pass 0 to disable timeout. The default value can be changed by
1353
+ * using the
1354
+ * {@link Page.setDefaultNavigationTimeout
1355
+ * | page.setDefaultNavigationTimeout(timeout)}
1356
+ * or {@link Page.setDefaultTimeout | page.setDefaultTimeout(timeout)}
1357
+ * methods.
1358
+ *
1359
+ * - `waitUntil` : When to consider navigation succeeded, defaults to `load`.
1360
+ * Given an array of event strings, navigation is considered to be
1361
+ * successful after all events have been fired. Events can be either:<br/>
1362
+ * - `load` : consider navigation to be finished when the load event is fired.<br/>
1363
+ * - `domcontentloaded` : consider navigation to be finished when the
1364
+ * DOMContentLoaded event is fired.<br/>
1365
+ * - `networkidle0` : consider navigation to be finished when there are no
1366
+ * more than 0 network connections for at least `500` ms.<br/>
1367
+ * - `networkidle2` : consider navigation to be finished when there are no
1368
+ * more than 2 network connections for at least `500` ms.
1369
+ */
857
1370
  async goBack(options = {}) {
858
1371
  return this._go(-1, options);
859
1372
  }
1373
+ /**
1374
+ * This method navigate to the next page in history.
1375
+ * @param options - Navigation Parameter
1376
+ * @returns Promise which resolves to the main resource response. In case of
1377
+ * multiple redirects, the navigation will resolve with the response of the
1378
+ * last redirect. If can not go forward, resolves to `null`.
1379
+ * @remarks
1380
+ * The argument `options` might have the following properties:
1381
+ *
1382
+ * - `timeout` : Maximum navigation time in milliseconds, defaults to 30
1383
+ * seconds, pass 0 to disable timeout. The default value can be changed by
1384
+ * using the
1385
+ * {@link Page.setDefaultNavigationTimeout
1386
+ * | page.setDefaultNavigationTimeout(timeout)}
1387
+ * or {@link Page.setDefaultTimeout | page.setDefaultTimeout(timeout)}
1388
+ * methods.
1389
+ *
1390
+ * - `waitUntil`: When to consider navigation succeeded, defaults to `load`.
1391
+ * Given an array of event strings, navigation is considered to be
1392
+ * successful after all events have been fired. Events can be either:<br/>
1393
+ * - `load` : consider navigation to be finished when the load event is fired.<br/>
1394
+ * - `domcontentloaded` : consider navigation to be finished when the
1395
+ * DOMContentLoaded event is fired.<br/>
1396
+ * - `networkidle0` : consider navigation to be finished when there are no
1397
+ * more than 0 network connections for at least `500` ms.<br/>
1398
+ * - `networkidle2` : consider navigation to be finished when there are no
1399
+ * more than 2 network connections for at least `500` ms.
1400
+ */
860
1401
  async goForward(options = {}) {
861
1402
  return this._go(+1, options);
862
1403
  }
@@ -871,15 +1412,48 @@ export class Page extends EventEmitter {
871
1412
  ]);
872
1413
  return result[0];
873
1414
  }
1415
+ /**
1416
+ * Brings page to front (activates tab).
1417
+ */
874
1418
  async bringToFront() {
875
1419
  await this._client.send('Page.bringToFront');
876
1420
  }
1421
+ /**
1422
+ * Emulates given device metrics and user agent. This method is a shortcut for
1423
+ * calling two methods: {@link Page.setUserAgent} and {@link Page.setViewport}
1424
+ * To aid emulation, Puppeteer provides a list of device descriptors that can
1425
+ * be obtained via the {@link Puppeteer.devices} `page.emulate` will resize
1426
+ * the page. A lot of websites don't expect phones to change size, so you
1427
+ * should emulate before navigating to the page.
1428
+ * @example
1429
+ * ```js
1430
+ * const puppeteer = require('puppeteer');
1431
+ * const iPhone = puppeteer.devices['iPhone 6'];
1432
+ * (async () => {
1433
+ * const browser = await puppeteer.launch();
1434
+ * const page = await browser.newPage();
1435
+ * await page.emulate(iPhone);
1436
+ * await page.goto('https://www.google.com');
1437
+ * // other actions...
1438
+ * await browser.close();
1439
+ * })();
1440
+ * ```
1441
+ * @remarks List of all available devices is available in the source code:
1442
+ * {@link https://github.com/puppeteer/puppeteer/blob/main/src/common/DeviceDescriptors.ts | src/common/DeviceDescriptors.ts}.
1443
+ */
877
1444
  async emulate(options) {
878
1445
  await Promise.all([
879
1446
  this.setViewport(options.viewport),
880
1447
  this.setUserAgent(options.userAgent),
881
1448
  ]);
882
1449
  }
1450
+ /**
1451
+ * @param enabled - Whether or not to enable JavaScript on the page.
1452
+ * @returns
1453
+ * @remarks
1454
+ * NOTE: changing this value won't affect scripts that have already been run.
1455
+ * It will take full effect on the next navigation.
1456
+ */
883
1457
  async setJavaScriptEnabled(enabled) {
884
1458
  if (this._javascriptEnabled === enabled)
885
1459
  return;
@@ -888,15 +1462,105 @@ export class Page extends EventEmitter {
888
1462
  value: !enabled,
889
1463
  });
890
1464
  }
1465
+ /**
1466
+ * Toggles bypassing page's Content-Security-Policy.
1467
+ * @param enabled - sets bypassing of page's Content-Security-Policy.
1468
+ * @remarks
1469
+ * NOTE: CSP bypassing happens at the moment of CSP initialization rather than
1470
+ * evaluation. Usually, this means that `page.setBypassCSP` should be called
1471
+ * before navigating to the domain.
1472
+ */
891
1473
  async setBypassCSP(enabled) {
892
1474
  await this._client.send('Page.setBypassCSP', { enabled });
893
1475
  }
1476
+ /**
1477
+ * @param type - Changes the CSS media type of the page. The only allowed
1478
+ * values are `screen`, `print` and `null`. Passing `null` disables CSS media
1479
+ * emulation.
1480
+ * @example
1481
+ * ```
1482
+ * await page.evaluate(() => matchMedia('screen').matches);
1483
+ * // → true
1484
+ * await page.evaluate(() => matchMedia('print').matches);
1485
+ * // → false
1486
+ *
1487
+ * await page.emulateMediaType('print');
1488
+ * await page.evaluate(() => matchMedia('screen').matches);
1489
+ * // → false
1490
+ * await page.evaluate(() => matchMedia('print').matches);
1491
+ * // → true
1492
+ *
1493
+ * await page.emulateMediaType(null);
1494
+ * await page.evaluate(() => matchMedia('screen').matches);
1495
+ * // → true
1496
+ * await page.evaluate(() => matchMedia('print').matches);
1497
+ * // → false
1498
+ * ```
1499
+ */
894
1500
  async emulateMediaType(type) {
895
1501
  assert(type === 'screen' || type === 'print' || type === null, 'Unsupported media type: ' + type);
896
1502
  await this._client.send('Emulation.setEmulatedMedia', {
897
1503
  media: type || '',
898
1504
  });
899
1505
  }
1506
+ async emulateCPUThrottling(factor) {
1507
+ assert(factor === null || factor >= 1, 'Throttling rate should be greater or equal to 1');
1508
+ await this._client.send('Emulation.setCPUThrottlingRate', {
1509
+ rate: factor !== null ? factor : 1,
1510
+ });
1511
+ }
1512
+ /**
1513
+ * @param features - `<?Array<Object>>` Given an array of media feature
1514
+ * objects, emulates CSS media features on the page. Each media feature object
1515
+ * must have the following properties:
1516
+ * @example
1517
+ * ```js
1518
+ * await page.emulateMediaFeatures([
1519
+ * { name: 'prefers-color-scheme', value: 'dark' },
1520
+ * ]);
1521
+ * await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches);
1522
+ * // → true
1523
+ * await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches);
1524
+ * // → false
1525
+ *
1526
+ * await page.emulateMediaFeatures([
1527
+ * { name: 'prefers-reduced-motion', value: 'reduce' },
1528
+ * ]);
1529
+ * await page.evaluate(
1530
+ * () => matchMedia('(prefers-reduced-motion: reduce)').matches
1531
+ * );
1532
+ * // → true
1533
+ * await page.evaluate(
1534
+ * () => matchMedia('(prefers-reduced-motion: no-preference)').matches
1535
+ * );
1536
+ * // → false
1537
+ *
1538
+ * await page.emulateMediaFeatures([
1539
+ * { name: 'prefers-color-scheme', value: 'dark' },
1540
+ * { name: 'prefers-reduced-motion', value: 'reduce' },
1541
+ * ]);
1542
+ * await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches);
1543
+ * // → true
1544
+ * await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches);
1545
+ * // → false
1546
+ * await page.evaluate(
1547
+ * () => matchMedia('(prefers-reduced-motion: reduce)').matches
1548
+ * );
1549
+ * // → true
1550
+ * await page.evaluate(
1551
+ * () => matchMedia('(prefers-reduced-motion: no-preference)').matches
1552
+ * );
1553
+ * // → false
1554
+ *
1555
+ * await page.emulateMediaFeatures([{ name: 'color-gamut', value: 'p3' }]);
1556
+ * await page.evaluate(() => matchMedia('(color-gamut: srgb)').matches);
1557
+ * // → true
1558
+ * await page.evaluate(() => matchMedia('(color-gamut: p3)').matches);
1559
+ * // → true
1560
+ * await page.evaluate(() => matchMedia('(color-gamut: rec2020)').matches);
1561
+ * // → false
1562
+ * ```
1563
+ */
900
1564
  async emulateMediaFeatures(features) {
901
1565
  if (features === null)
902
1566
  await this._client.send('Emulation.setEmulatedMedia', { features: null });
@@ -911,6 +1575,12 @@ export class Page extends EventEmitter {
911
1575
  });
912
1576
  }
913
1577
  }
1578
+ /**
1579
+ * @param timezoneId - Changes the timezone of the page. See
1580
+ * {@link https://source.chromium.org/chromium/chromium/deps/icu.git/+/faee8bc70570192d82d2978a71e2a615788597d1:source/data/misc/metaZones.txt | ICU’s metaZones.txt}
1581
+ * for a list of supported timezone IDs. Passing
1582
+ * `null` disables timezone emulation.
1583
+ */
914
1584
  async emulateTimezone(timezoneId) {
915
1585
  try {
916
1586
  await this._client.send('Emulation.setTimezoneOverride', {
@@ -940,8 +1610,6 @@ export class Page extends EventEmitter {
940
1610
  * ```
941
1611
  *
942
1612
  * @param overrides - Mock idle state. If not set, clears idle overrides
943
- * @param isUserActive - Mock isUserActive
944
- * @param isScreenUnlocked - Mock isScreenUnlocked
945
1613
  */
946
1614
  async emulateIdleState(overrides) {
947
1615
  if (overrides) {
@@ -1000,12 +1668,70 @@ export class Page extends EventEmitter {
1000
1668
  throw error;
1001
1669
  }
1002
1670
  }
1671
+ /**
1672
+ * `page.setViewport` will resize the page. A lot of websites don't expect
1673
+ * phones to change size, so you should set the viewport before navigating to
1674
+ * the page.
1675
+ *
1676
+ * In the case of multiple pages in a single browser, each page can have its
1677
+ * own viewport size.
1678
+ * @example
1679
+ * ```js
1680
+ * const page = await browser.newPage();
1681
+ * await page.setViewport({
1682
+ * width: 640,
1683
+ * height: 480,
1684
+ * deviceScaleFactor: 1,
1685
+ * });
1686
+ * await page.goto('https://example.com');
1687
+ * ```
1688
+ *
1689
+ * @param viewport -
1690
+ * @remarks
1691
+ * Argument viewport have following properties:
1692
+ *
1693
+ * - `width`: page width in pixels. required
1694
+ *
1695
+ * - `height`: page height in pixels. required
1696
+ *
1697
+ * - `deviceScaleFactor`: Specify device scale factor (can be thought of as
1698
+ * DPR). Defaults to `1`.
1699
+ *
1700
+ * - `isMobile`: Whether the meta viewport tag is taken into account. Defaults
1701
+ * to `false`.
1702
+ *
1703
+ * - `hasTouch`: Specifies if viewport supports touch events. Defaults to `false`
1704
+ *
1705
+ * - `isLandScape`: Specifies if viewport is in landscape mode. Defaults to false.
1706
+ *
1707
+ * NOTE: in certain cases, setting viewport will reload the page in order to
1708
+ * set the isMobile or hasTouch properties.
1709
+ */
1003
1710
  async setViewport(viewport) {
1004
1711
  const needsReload = await this._emulationManager.emulateViewport(viewport);
1005
1712
  this._viewport = viewport;
1006
1713
  if (needsReload)
1007
1714
  await this.reload();
1008
1715
  }
1716
+ /**
1717
+ * @returns
1718
+ *
1719
+ * - `width`: page's width in pixels
1720
+ *
1721
+ * - `height`: page's height in pixels
1722
+ *
1723
+ * - `deviceScalarFactor`: Specify device scale factor (can be though of as
1724
+ * dpr). Defaults to `1`.
1725
+ *
1726
+ * - `isMobile`: Whether the meta viewport tag is taken into account. Defaults
1727
+ * to `false`.
1728
+ *
1729
+ * - `hasTouch`: Specifies if viewport supports touch events. Defaults to
1730
+ * `false`.
1731
+ *
1732
+ * - `isLandScape`: Specifies if viewport is in landscape mode. Defaults to
1733
+ * `false`.
1734
+ */
1009
1735
  viewport() {
1010
1736
  return this._viewport;
1011
1737
  }
@@ -1060,22 +1786,100 @@ export class Page extends EventEmitter {
1060
1786
  async evaluate(pageFunction, ...args) {
1061
1787
  return this._frameManager.mainFrame().evaluate(pageFunction, ...args);
1062
1788
  }
1789
+ /**
1790
+ * Adds a function which would be invoked in one of the following scenarios:
1791
+ *
1792
+ * - whenever the page is navigated
1793
+ *
1794
+ * - whenever the child frame is attached or navigated. In this case, the
1795
+ * function is invoked in the context of the newly attached frame.
1796
+ *
1797
+ * The function is invoked after the document was created but before any of
1798
+ * its scripts were run. This is useful to amend the JavaScript environment,
1799
+ * e.g. to seed `Math.random`.
1800
+ * @param pageFunction - Function to be evaluated in browser context
1801
+ * @param args - Arguments to pass to `pageFunction`
1802
+ * @example
1803
+ * An example of overriding the navigator.languages property before the page loads:
1804
+ * ```js
1805
+ * // preload.js
1806
+ *
1807
+ * // overwrite the `languages` property to use a custom getter
1808
+ * Object.defineProperty(navigator, 'languages', {
1809
+ * get: function () {
1810
+ * return ['en-US', 'en', 'bn'];
1811
+ * },
1812
+ * });
1813
+ *
1814
+ * // In your puppeteer script, assuming the preload.js file is
1815
+ * in same folder of our script
1816
+ * const preloadFile = fs.readFileSync('./preload.js', 'utf8');
1817
+ * await page.evaluateOnNewDocument(preloadFile);
1818
+ * ```
1819
+ */
1063
1820
  async evaluateOnNewDocument(pageFunction, ...args) {
1064
1821
  const source = helper.evaluationString(pageFunction, ...args);
1065
1822
  await this._client.send('Page.addScriptToEvaluateOnNewDocument', {
1066
1823
  source,
1067
1824
  });
1068
1825
  }
1826
+ /**
1827
+ * Toggles ignoring cache for each request based on the enabled state. By
1828
+ * default, caching is enabled.
1829
+ * @param enabled - sets the `enabled` state of cache
1830
+ */
1069
1831
  async setCacheEnabled(enabled = true) {
1070
1832
  await this._frameManager.networkManager().setCacheEnabled(enabled);
1071
1833
  }
1834
+ /**
1835
+ * @remarks
1836
+ * Options object which might have the following properties:
1837
+ *
1838
+ * - `path` : The file path to save the image to. The screenshot type
1839
+ * will be inferred from file extension. If `path` is a relative path, then
1840
+ * it is resolved relative to
1841
+ * {@link https://nodejs.org/api/process.html#process_process_cwd
1842
+ * | current working directory}.
1843
+ * If no path is provided, the image won't be saved to the disk.
1844
+ *
1845
+ * - `type` : Specify screenshot type, can be either `jpeg` or `png`.
1846
+ * Defaults to 'png'.
1847
+ *
1848
+ * - `quality` : The quality of the image, between 0-100. Not
1849
+ * applicable to `png` images.
1850
+ *
1851
+ * - `fullPage` : When true, takes a screenshot of the full
1852
+ * scrollable page. Defaults to `false`
1853
+ *
1854
+ * - `clip` : An object which specifies clipping region of the page.
1855
+ * Should have the following fields:<br/>
1856
+ * - `x` : x-coordinate of top-left corner of clip area.<br/>
1857
+ * - `y` : y-coordinate of top-left corner of clip area.<br/>
1858
+ * - `width` : width of clipping area.<br/>
1859
+ * - `height` : height of clipping area.
1860
+ *
1861
+ * - `omitBackground` : Hides default white background and allows
1862
+ * capturing screenshots with transparency. Defaults to `false`
1863
+ *
1864
+ * - `encoding` : The encoding of the image, can be either base64 or
1865
+ * binary. Defaults to `binary`.
1866
+ *
1867
+ *
1868
+ * NOTE: Screenshots take at least 1/6 second on OS X. See
1869
+ * {@link https://crbug.com/741689} for discussion.
1870
+ * @returns Promise which resolves to buffer or a base64 string (depending on
1871
+ * the value of `encoding`) with captured screenshot.
1872
+ */
1072
1873
  async screenshot(options = {}) {
1073
1874
  let screenshotType = null;
1074
1875
  // options.type takes precedence over inferring the type from options.path
1075
1876
  // because it may be a 0-length file with no extension created beforehand
1076
1877
  // (i.e. as a temp file).
1077
1878
  if (options.type) {
1078
- assert(options.type === 'png' || options.type === 'jpeg', 'Unknown options.type value: ' + options.type);
1879
+ const type = options.type;
1880
+ if (type !== 'png' && type !== 'jpeg' && type !== 'webp') {
1881
+ assertNever(type, 'Unknown options.type value: ' + type);
1882
+ }
1079
1883
  screenshotType = options.type;
1080
1884
  }
1081
1885
  else if (options.path) {
@@ -1087,6 +1891,8 @@ export class Page extends EventEmitter {
1087
1891
  screenshotType = 'png';
1088
1892
  else if (extension === 'jpg' || extension === 'jpeg')
1089
1893
  screenshotType = 'jpeg';
1894
+ else if (extension === 'webp')
1895
+ screenshotType = 'webp';
1090
1896
  assert(screenshotType, `Unsupported screenshot type for extension \`.${extension}\``);
1091
1897
  }
1092
1898
  if (!screenshotType)
@@ -1126,8 +1932,8 @@ export class Page extends EventEmitter {
1126
1932
  typeof captureBeyondViewport === 'boolean' ? captureBeyondViewport : true;
1127
1933
  if (options.fullPage) {
1128
1934
  const metrics = await this._client.send('Page.getLayoutMetrics');
1129
- const width = Math.ceil(metrics.contentSize.width);
1130
- const height = Math.ceil(metrics.contentSize.height);
1935
+ // Fallback to `contentSize` in case of using Firefox.
1936
+ const { width, height } = metrics.cssContentSize || metrics.contentSize;
1131
1937
  // Overwrite clip for full page.
1132
1938
  clip = { x: 0, y: 0, width, height, scale: 1 };
1133
1939
  if (!captureBeyondViewport) {
@@ -1144,7 +1950,7 @@ export class Page extends EventEmitter {
1144
1950
  });
1145
1951
  }
1146
1952
  }
1147
- const shouldSetDefaultBackground = options.omitBackground && format === 'png';
1953
+ const shouldSetDefaultBackground = options.omitBackground && (format === 'png' || format === 'webp');
1148
1954
  if (shouldSetDefaultBackground) {
1149
1955
  await this._setTransparentBackgroundColor();
1150
1956
  }
@@ -1182,7 +1988,7 @@ export class Page extends EventEmitter {
1182
1988
  * Generatees a PDF of the page with the `print` CSS media type.
1183
1989
  * @remarks
1184
1990
  *
1185
- * IMPORTANT: PDF generation is only supported in Chrome headless mode.
1991
+ * NOTE: PDF generation is only supported in Chrome headless mode.
1186
1992
  *
1187
1993
  * To generate a PDF with the `screen` media type, call
1188
1994
  * {@link Page.emulateMediaType | `page.emulateMediaType('screen')`} before
@@ -1196,8 +2002,8 @@ export class Page extends EventEmitter {
1196
2002
  *
1197
2003
  * @param options - options for generating the PDF.
1198
2004
  */
1199
- async pdf(options = {}) {
1200
- const { scale = 1, displayHeaderFooter = false, headerTemplate = '', footerTemplate = '', printBackground = false, landscape = false, pageRanges = '', preferCSSPageSize = false, margin = {}, path = null, omitBackground = false, } = options;
2005
+ async createPDFStream(options = {}) {
2006
+ const { scale = 1, displayHeaderFooter = false, headerTemplate = '', footerTemplate = '', printBackground = false, landscape = false, pageRanges = '', preferCSSPageSize = false, margin = {}, omitBackground = false, timeout = 30000, } = options;
1201
2007
  let paperWidth = 8.5;
1202
2008
  let paperHeight = 11;
1203
2009
  if (options.format) {
@@ -1218,7 +2024,7 @@ export class Page extends EventEmitter {
1218
2024
  if (omitBackground) {
1219
2025
  await this._setTransparentBackgroundColor();
1220
2026
  }
1221
- const result = await this._client.send('Page.printToPDF', {
2027
+ const printCommandPromise = this._client.send('Page.printToPDF', {
1222
2028
  transferMode: 'ReturnAsStream',
1223
2029
  landscape,
1224
2030
  displayHeaderFooter,
@@ -1235,11 +2041,26 @@ export class Page extends EventEmitter {
1235
2041
  pageRanges,
1236
2042
  preferCSSPageSize,
1237
2043
  });
2044
+ const result = await helper.waitWithTimeout(printCommandPromise, 'Page.printToPDF', timeout);
1238
2045
  if (omitBackground) {
1239
2046
  await this._resetDefaultBackgroundColor();
1240
2047
  }
1241
- return await helper.readProtocolStream(this._client, result.stream, path);
2048
+ return helper.getReadableFromProtocolStream(this._client, result.stream);
1242
2049
  }
2050
+ /**
2051
+ * @param options -
2052
+ * @returns
2053
+ */
2054
+ async pdf(options = {}) {
2055
+ const { path = undefined } = options;
2056
+ const readable = await this.createPDFStream(options);
2057
+ return await helper.getReadableAsBuffer(readable, path);
2058
+ }
2059
+ /**
2060
+ * @returns The page's title
2061
+ * @remarks
2062
+ * Shortcut for {@link Frame.title | page.mainFrame().title()}.
2063
+ */
1243
2064
  async title() {
1244
2065
  return this.mainFrame().title();
1245
2066
  }
@@ -1256,27 +2077,136 @@ export class Page extends EventEmitter {
1256
2077
  await this._target._isClosedPromise;
1257
2078
  }
1258
2079
  }
2080
+ /**
2081
+ * Indicates that the page has been closed.
2082
+ * @returns
2083
+ */
1259
2084
  isClosed() {
1260
2085
  return this._closed;
1261
2086
  }
1262
2087
  get mouse() {
1263
2088
  return this._mouse;
1264
2089
  }
2090
+ /**
2091
+ * This method fetches an element with `selector`, scrolls it into view if
2092
+ * needed, and then uses {@link Page.mouse} to click in the center of the
2093
+ * element. If there's no element matching `selector`, the method throws an
2094
+ * error.
2095
+ * @remarks Bear in mind that if `click()` triggers a navigation event and
2096
+ * there's a separate `page.waitForNavigation()` promise to be resolved, you
2097
+ * may end up with a race condition that yields unexpected results. The
2098
+ * correct pattern for click and wait for navigation is the following:
2099
+ * ```js
2100
+ * const [response] = await Promise.all([
2101
+ * page.waitForNavigation(waitOptions),
2102
+ * page.click(selector, clickOptions),
2103
+ * ]);
2104
+ * ```
2105
+ * Shortcut for {@link Frame.click | page.mainFrame().click(selector[, options]) }.
2106
+ * @param selector - A `selector` to search for element to click. If there are
2107
+ * multiple elements satisfying the `selector`, the first will be clicked
2108
+ * @param options - `Object`
2109
+ * @returns Promise which resolves when the element matching `selector` is
2110
+ * successfully clicked. The Promise will be rejected if there is no element
2111
+ * matching `selector`.
2112
+ */
1265
2113
  click(selector, options = {}) {
1266
2114
  return this.mainFrame().click(selector, options);
1267
2115
  }
2116
+ /**
2117
+ * This method fetches an element with `selector` and focuses it. If there's no
2118
+ * element matching `selector`, the method throws an error.
2119
+ * @param selector - A
2120
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | selector }
2121
+ * of an element to focus. If there are multiple elements satisfying the
2122
+ * selector, the first will be focused.
2123
+ * @returns Promise which resolves when the element matching selector is
2124
+ * successfully focused. The promise will be rejected if there is no element
2125
+ * matching selector.
2126
+ * @remarks
2127
+ * Shortcut for {@link Frame.focus | page.mainFrame().focus(selector)}.
2128
+ */
1268
2129
  focus(selector) {
1269
2130
  return this.mainFrame().focus(selector);
1270
2131
  }
2132
+ /**
2133
+ * This method fetches an element with `selector`, scrolls it into view if
2134
+ * needed, and then uses {@link Page.mouse} to hover over the center of the element.
2135
+ * If there's no element matching `selector`, the method throws an error.
2136
+ * @param selector - A
2137
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | selector}
2138
+ * to search for element to hover. If there are multiple elements satisfying
2139
+ * the selector, the first will be hovered.
2140
+ * @returns Promise which resolves when the element matching `selector` is
2141
+ * successfully hovered. Promise gets rejected if there's no element matching
2142
+ * `selector`.
2143
+ * @remarks
2144
+ * Shortcut for {@link Page.hover | page.mainFrame().hover(selector)}.
2145
+ */
1271
2146
  hover(selector) {
1272
2147
  return this.mainFrame().hover(selector);
1273
2148
  }
2149
+ /**
2150
+ * Triggers a `change` and `input` event once all the provided options have been
2151
+ * selected. If there's no `<select>` element matching `selector`, the method
2152
+ * throws an error.
2153
+ *
2154
+ * @example
2155
+ * ```js
2156
+ * page.select('select#colors', 'blue'); // single selection
2157
+ * page.select('select#colors', 'red', 'green', 'blue'); // multiple selections
2158
+ * ```
2159
+ * @param selector - A
2160
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | Selector}
2161
+ * to query the page for
2162
+ * @param values - Values of options to select. If the `<select>` has the
2163
+ * `multiple` attribute, all values are considered, otherwise only the first one
2164
+ * is taken into account.
2165
+ * @returns
2166
+ *
2167
+ * @remarks
2168
+ * Shortcut for {@link Frame.select | page.mainFrame().select()}
2169
+ */
1274
2170
  select(selector, ...values) {
1275
2171
  return this.mainFrame().select(selector, ...values);
1276
2172
  }
2173
+ /**
2174
+ * This method fetches an element with `selector`, scrolls it into view if
2175
+ * needed, and then uses {@link Page.touchscreen} to tap in the center of the element.
2176
+ * If there's no element matching `selector`, the method throws an error.
2177
+ * @param selector - A
2178
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | Selector}
2179
+ * to search for element to tap. If there are multiple elements satisfying the
2180
+ * selector, the first will be tapped.
2181
+ * @returns
2182
+ * @remarks
2183
+ * Shortcut for {@link Frame.tap | page.mainFrame().tap(selector)}.
2184
+ */
1277
2185
  tap(selector) {
1278
2186
  return this.mainFrame().tap(selector);
1279
2187
  }
2188
+ /**
2189
+ * Sends a `keydown`, `keypress/input`, and `keyup` event for each character
2190
+ * in the text.
2191
+ *
2192
+ * To press a special key, like `Control` or `ArrowDown`, use {@link Keyboard.press}.
2193
+ * @example
2194
+ * ```
2195
+ * await page.type('#mytextarea', 'Hello');
2196
+ * // Types instantly
2197
+ * await page.type('#mytextarea', 'World', { delay: 100 });
2198
+ * // Types slower, like a user
2199
+ * ```
2200
+ * @param selector - A
2201
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | selector}
2202
+ * of an element to type into. If there are multiple elements satisfying the
2203
+ * selector, the first will be used.
2204
+ * @param text - A text to type into a focused element.
2205
+ * @param options - have property `delay` which is the Time to wait between
2206
+ * key presses in milliseconds. Defaults to `0`.
2207
+ * @returns
2208
+ * @remarks
2209
+ */
1280
2210
  type(selector, text, options) {
1281
2211
  return this.mainFrame().type(selector, text, options);
1282
2212
  }
@@ -1330,12 +2260,174 @@ export class Page extends EventEmitter {
1330
2260
  waitForTimeout(milliseconds) {
1331
2261
  return this.mainFrame().waitForTimeout(milliseconds);
1332
2262
  }
2263
+ /**
2264
+ * Wait for the `selector` to appear in page. If at the moment of calling the
2265
+ * method the `selector` already exists, the method will return immediately. If
2266
+ * the `selector` doesn't appear after the `timeout` milliseconds of waiting, the
2267
+ * function will throw.
2268
+ *
2269
+ * This method works across navigations:
2270
+ * ```js
2271
+ * const puppeteer = require('puppeteer');
2272
+ * (async () => {
2273
+ * const browser = await puppeteer.launch();
2274
+ * const page = await browser.newPage();
2275
+ * let currentURL;
2276
+ * page
2277
+ * .waitForSelector('img')
2278
+ * .then(() => console.log('First URL with image: ' + currentURL));
2279
+ * for (currentURL of [
2280
+ * 'https://example.com',
2281
+ * 'https://google.com',
2282
+ * 'https://bbc.com',
2283
+ * ]) {
2284
+ * await page.goto(currentURL);
2285
+ * }
2286
+ * await browser.close();
2287
+ * })();
2288
+ * ```
2289
+ * @param selector - A
2290
+ * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors | selector}
2291
+ * of an element to wait for
2292
+ * @param options - Optional waiting parameters
2293
+ * @returns Promise which resolves when element specified by selector string
2294
+ * is added to DOM. Resolves to `null` if waiting for hidden: `true` and
2295
+ * selector is not found in DOM.
2296
+ * @remarks
2297
+ * The optional Parameter in Arguments `options` are :
2298
+ *
2299
+ * - `Visible`: A boolean wait for element to be present in DOM and to be
2300
+ * visible, i.e. to not have `display: none` or `visibility: hidden` CSS
2301
+ * properties. Defaults to `false`.
2302
+ *
2303
+ * - `hidden`: ait for element to not be found in the DOM or to be hidden,
2304
+ * i.e. have `display: none` or `visibility: hidden` CSS properties. Defaults to
2305
+ * `false`.
2306
+ *
2307
+ * - `timeout`: maximum time to wait for in milliseconds. Defaults to `30000`
2308
+ * (30 seconds). Pass `0` to disable timeout. The default value can be changed
2309
+ * by using the {@link Page.setDefaultTimeout} method.
2310
+ */
1333
2311
  waitForSelector(selector, options = {}) {
1334
2312
  return this.mainFrame().waitForSelector(selector, options);
1335
2313
  }
2314
+ /**
2315
+ * Wait for the `xpath` to appear in page. If at the moment of calling the
2316
+ * method the `xpath` already exists, the method will return immediately. If
2317
+ * the `xpath` doesn't appear after the `timeout` milliseconds of waiting, the
2318
+ * function will throw.
2319
+ *
2320
+ * This method works across navigation
2321
+ * ```js
2322
+ * const puppeteer = require('puppeteer');
2323
+ * (async () => {
2324
+ * const browser = await puppeteer.launch();
2325
+ * const page = await browser.newPage();
2326
+ * let currentURL;
2327
+ * page
2328
+ * .waitForXPath('//img')
2329
+ * .then(() => console.log('First URL with image: ' + currentURL));
2330
+ * for (currentURL of [
2331
+ * 'https://example.com',
2332
+ * 'https://google.com',
2333
+ * 'https://bbc.com',
2334
+ * ]) {
2335
+ * await page.goto(currentURL);
2336
+ * }
2337
+ * await browser.close();
2338
+ * })();
2339
+ * ```
2340
+ * @param xpath - A
2341
+ * {@link https://developer.mozilla.org/en-US/docs/Web/XPath | xpath} of an
2342
+ * element to wait for
2343
+ * @param options - Optional waiting parameters
2344
+ * @returns Promise which resolves when element specified by xpath string is
2345
+ * added to DOM. Resolves to `null` if waiting for `hidden: true` and xpath is
2346
+ * not found in DOM.
2347
+ * @remarks
2348
+ * The optional Argument `options` have properties:
2349
+ *
2350
+ * - `visible`: A boolean to wait for element to be present in DOM and to be
2351
+ * visible, i.e. to not have `display: none` or `visibility: hidden` CSS
2352
+ * properties. Defaults to `false`.
2353
+ *
2354
+ * - `hidden`: A boolean wait for element to not be found in the DOM or to be
2355
+ * hidden, i.e. have `display: none` or `visibility: hidden` CSS properties.
2356
+ * Defaults to `false`.
2357
+ *
2358
+ * - `timeout`: A number which is maximum time to wait for in milliseconds.
2359
+ * Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default
2360
+ * value can be changed by using the {@link Page.setDefaultTimeout} method.
2361
+ */
1336
2362
  waitForXPath(xpath, options = {}) {
1337
2363
  return this.mainFrame().waitForXPath(xpath, options);
1338
2364
  }
2365
+ /**
2366
+ * The `waitForFunction` can be used to observe viewport size change:
2367
+ *
2368
+ * ```
2369
+ * const puppeteer = require('puppeteer');
2370
+ * (async () => {
2371
+ * const browser = await puppeteer.launch();
2372
+ * const page = await browser.newPage();
2373
+ * const watchDog = page.waitForFunction('window.innerWidth < 100');
2374
+ * await page.setViewport({ width: 50, height: 50 });
2375
+ * await watchDog;
2376
+ * await browser.close();
2377
+ * })();
2378
+ * ```
2379
+ * To pass arguments from node.js to the predicate of `page.waitForFunction` function:
2380
+ * ```
2381
+ * const selector = '.foo';
2382
+ * await page.waitForFunction(
2383
+ * (selector) => !!document.querySelector(selector),
2384
+ * {},
2385
+ * selector
2386
+ * );
2387
+ * ```
2388
+ * The predicate of `page.waitForFunction` can be asynchronous too:
2389
+ * ```
2390
+ * const username = 'github-username';
2391
+ * await page.waitForFunction(
2392
+ * async (username) => {
2393
+ * const githubResponse = await fetch(
2394
+ * `https://api.github.com/users/${username}`
2395
+ * );
2396
+ * const githubUser = await githubResponse.json();
2397
+ * // show the avatar
2398
+ * const img = document.createElement('img');
2399
+ * img.src = githubUser.avatar_url;
2400
+ * // wait 3 seconds
2401
+ * await new Promise((resolve, reject) => setTimeout(resolve, 3000));
2402
+ * img.remove();
2403
+ * },
2404
+ * {},
2405
+ * username
2406
+ * );
2407
+ * ```
2408
+ * @param pageFunction - Function to be evaluated in browser context
2409
+ * @param options - Optional waiting parameters
2410
+ * @param args - Arguments to pass to `pageFunction`
2411
+ * @returns Promise which resolves when the `pageFunction` returns a truthy
2412
+ * value. It resolves to a JSHandle of the truthy value.
2413
+ *
2414
+ * The optional waiting parameter can be:
2415
+ *
2416
+ * - `Polling`: An interval at which the `pageFunction` is executed, defaults to
2417
+ * `raf`. If `polling` is a number, then it is treated as an interval in
2418
+ * milliseconds at which the function would be executed. If polling is a
2419
+ * string, then it can be one of the following values:<br/>
2420
+ * - `raf`: to constantly execute `pageFunction` in `requestAnimationFrame`
2421
+ * callback. This is the tightest polling mode which is suitable to
2422
+ * observe styling changes.<br/>
2423
+ * - `mutation`: to execute pageFunction on every DOM mutation.
2424
+ *
2425
+ * - `timeout`: maximum time to wait for in milliseconds. Defaults to `30000`
2426
+ * (30 seconds). Pass `0` to disable timeout. The default value can be changed
2427
+ * by using the
2428
+ * {@link Page.setDefaultTimeout | page.setDefaultTimeout(timeout)} method.
2429
+ *
2430
+ */
1339
2431
  waitForFunction(pageFunction, options = {}, ...args) {
1340
2432
  return this.mainFrame().waitForFunction(pageFunction, options, ...args);
1341
2433
  }