postdoc 0.2.0.beta4 → 0.2.0

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 (371) hide show
  1. checksums.yaml +4 -4
  2. data/lib/postdoc/postdoc_view_helper.rb +15 -0
  3. data/lib/postdoc.rb +34 -14
  4. metadata +20 -373
  5. data/lib/pdf.js +0 -27
  6. data/node_modules/agent-base/History.md +0 -113
  7. data/node_modules/agent-base/README.md +0 -145
  8. data/node_modules/agent-base/index.js +0 -160
  9. data/node_modules/agent-base/package.json +0 -35
  10. data/node_modules/agent-base/patch-core.js +0 -37
  11. data/node_modules/agent-base/test/ssl-cert-snakeoil.key +0 -15
  12. data/node_modules/agent-base/test/ssl-cert-snakeoil.pem +0 -12
  13. data/node_modules/agent-base/test/test.js +0 -673
  14. data/node_modules/async-limiter/LICENSE +0 -8
  15. data/node_modules/async-limiter/coverage/coverage.json +0 -1
  16. data/node_modules/async-limiter/coverage/lcov-report/async-throttle/index.html +0 -73
  17. data/node_modules/async-limiter/coverage/lcov-report/async-throttle/index.js.html +0 -246
  18. data/node_modules/async-limiter/coverage/lcov-report/base.css +0 -182
  19. data/node_modules/async-limiter/coverage/lcov-report/index.html +0 -73
  20. data/node_modules/async-limiter/coverage/lcov-report/prettify.css +0 -1
  21. data/node_modules/async-limiter/coverage/lcov-report/prettify.js +0 -1
  22. data/node_modules/async-limiter/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  23. data/node_modules/async-limiter/coverage/lcov-report/sorter.js +0 -156
  24. data/node_modules/async-limiter/coverage/lcov.info +0 -74
  25. data/node_modules/async-limiter/index.js +0 -67
  26. data/node_modules/async-limiter/package.json +0 -35
  27. data/node_modules/async-limiter/readme.md +0 -132
  28. data/node_modules/balanced-match/LICENSE.md +0 -21
  29. data/node_modules/balanced-match/README.md +0 -91
  30. data/node_modules/balanced-match/index.js +0 -59
  31. data/node_modules/balanced-match/package.json +0 -49
  32. data/node_modules/brace-expansion/LICENSE +0 -21
  33. data/node_modules/brace-expansion/README.md +0 -129
  34. data/node_modules/brace-expansion/index.js +0 -201
  35. data/node_modules/brace-expansion/package.json +0 -47
  36. data/node_modules/buffer-from/index.js +0 -69
  37. data/node_modules/buffer-from/package.json +0 -16
  38. data/node_modules/buffer-from/readme.md +0 -69
  39. data/node_modules/buffer-from/test.js +0 -12
  40. data/node_modules/concat-map/LICENSE +0 -18
  41. data/node_modules/concat-map/README.markdown +0 -62
  42. data/node_modules/concat-map/example/map.js +0 -6
  43. data/node_modules/concat-map/index.js +0 -13
  44. data/node_modules/concat-map/package.json +0 -43
  45. data/node_modules/concat-map/test/map.js +0 -39
  46. data/node_modules/concat-stream/LICENSE +0 -24
  47. data/node_modules/concat-stream/index.js +0 -144
  48. data/node_modules/concat-stream/package.json +0 -55
  49. data/node_modules/concat-stream/readme.md +0 -102
  50. data/node_modules/core-util-is/LICENSE +0 -19
  51. data/node_modules/core-util-is/README.md +0 -3
  52. data/node_modules/core-util-is/float.patch +0 -604
  53. data/node_modules/core-util-is/lib/util.js +0 -107
  54. data/node_modules/core-util-is/package.json +0 -32
  55. data/node_modules/core-util-is/test.js +0 -68
  56. data/node_modules/debug/CHANGELOG.md +0 -395
  57. data/node_modules/debug/LICENSE +0 -19
  58. data/node_modules/debug/Makefile +0 -58
  59. data/node_modules/debug/README.md +0 -368
  60. data/node_modules/debug/karma.conf.js +0 -70
  61. data/node_modules/debug/node.js +0 -1
  62. data/node_modules/debug/package.json +0 -43
  63. data/node_modules/debug/src/browser.js +0 -195
  64. data/node_modules/debug/src/debug.js +0 -225
  65. data/node_modules/debug/src/index.js +0 -10
  66. data/node_modules/debug/src/node.js +0 -186
  67. data/node_modules/es6-promise/CHANGELOG.md +0 -151
  68. data/node_modules/es6-promise/LICENSE +0 -19
  69. data/node_modules/es6-promise/README.md +0 -97
  70. data/node_modules/es6-promise/auto.js +0 -4
  71. data/node_modules/es6-promise/dist/es6-promise.auto.js +0 -1181
  72. data/node_modules/es6-promise/dist/es6-promise.auto.map +0 -1
  73. data/node_modules/es6-promise/dist/es6-promise.auto.min.js +0 -1
  74. data/node_modules/es6-promise/dist/es6-promise.auto.min.map +0 -1
  75. data/node_modules/es6-promise/dist/es6-promise.js +0 -1179
  76. data/node_modules/es6-promise/dist/es6-promise.map +0 -1
  77. data/node_modules/es6-promise/dist/es6-promise.min.js +0 -1
  78. data/node_modules/es6-promise/dist/es6-promise.min.map +0 -1
  79. data/node_modules/es6-promise/es6-promise.d.ts +0 -81
  80. data/node_modules/es6-promise/lib/es6-promise/-internal.js +0 -266
  81. data/node_modules/es6-promise/lib/es6-promise/asap.js +0 -119
  82. data/node_modules/es6-promise/lib/es6-promise/enumerator.js +0 -113
  83. data/node_modules/es6-promise/lib/es6-promise/polyfill.js +0 -35
  84. data/node_modules/es6-promise/lib/es6-promise/promise/all.js +0 -52
  85. data/node_modules/es6-promise/lib/es6-promise/promise/race.js +0 -84
  86. data/node_modules/es6-promise/lib/es6-promise/promise/reject.js +0 -46
  87. data/node_modules/es6-promise/lib/es6-promise/promise/resolve.js +0 -48
  88. data/node_modules/es6-promise/lib/es6-promise/promise.js +0 -427
  89. data/node_modules/es6-promise/lib/es6-promise/then.js +0 -32
  90. data/node_modules/es6-promise/lib/es6-promise/utils.js +0 -21
  91. data/node_modules/es6-promise/lib/es6-promise.auto.js +0 -3
  92. data/node_modules/es6-promise/lib/es6-promise.js +0 -7
  93. data/node_modules/es6-promise/package.json +0 -75
  94. data/node_modules/es6-promisify/README.md +0 -89
  95. data/node_modules/es6-promisify/dist/promise.js +0 -73
  96. data/node_modules/es6-promisify/dist/promisify.js +0 -85
  97. data/node_modules/es6-promisify/package.json +0 -41
  98. data/node_modules/extract-zip/CONTRIBUTING.md +0 -1
  99. data/node_modules/extract-zip/LICENSE +0 -23
  100. data/node_modules/extract-zip/cli.js +0 -20
  101. data/node_modules/extract-zip/index.js +0 -205
  102. data/node_modules/extract-zip/node_modules/debug/CHANGELOG.md +0 -362
  103. data/node_modules/extract-zip/node_modules/debug/LICENSE +0 -19
  104. data/node_modules/extract-zip/node_modules/debug/Makefile +0 -50
  105. data/node_modules/extract-zip/node_modules/debug/README.md +0 -312
  106. data/node_modules/extract-zip/node_modules/debug/component.json +0 -19
  107. data/node_modules/extract-zip/node_modules/debug/karma.conf.js +0 -70
  108. data/node_modules/extract-zip/node_modules/debug/node.js +0 -1
  109. data/node_modules/extract-zip/node_modules/debug/package.json +0 -49
  110. data/node_modules/extract-zip/node_modules/debug/src/browser.js +0 -185
  111. data/node_modules/extract-zip/node_modules/debug/src/debug.js +0 -202
  112. data/node_modules/extract-zip/node_modules/debug/src/index.js +0 -10
  113. data/node_modules/extract-zip/node_modules/debug/src/inspector-log.js +0 -15
  114. data/node_modules/extract-zip/node_modules/debug/src/node.js +0 -248
  115. data/node_modules/extract-zip/package.json +0 -35
  116. data/node_modules/extract-zip/readme.md +0 -49
  117. data/node_modules/fd-slicer/CHANGELOG.md +0 -49
  118. data/node_modules/fd-slicer/LICENSE +0 -21
  119. data/node_modules/fd-slicer/README.md +0 -189
  120. data/node_modules/fd-slicer/index.js +0 -277
  121. data/node_modules/fd-slicer/package.json +0 -36
  122. data/node_modules/fd-slicer/test/test.js +0 -350
  123. data/node_modules/fs.realpath/LICENSE +0 -43
  124. data/node_modules/fs.realpath/README.md +0 -33
  125. data/node_modules/fs.realpath/index.js +0 -66
  126. data/node_modules/fs.realpath/old.js +0 -303
  127. data/node_modules/fs.realpath/package.json +0 -26
  128. data/node_modules/glob/LICENSE +0 -15
  129. data/node_modules/glob/README.md +0 -368
  130. data/node_modules/glob/changelog.md +0 -67
  131. data/node_modules/glob/common.js +0 -240
  132. data/node_modules/glob/glob.js +0 -790
  133. data/node_modules/glob/package.json +0 -43
  134. data/node_modules/glob/sync.js +0 -486
  135. data/node_modules/https-proxy-agent/History.md +0 -124
  136. data/node_modules/https-proxy-agent/README.md +0 -137
  137. data/node_modules/https-proxy-agent/index.js +0 -229
  138. data/node_modules/https-proxy-agent/package.json +0 -35
  139. data/node_modules/https-proxy-agent/test/ssl-cert-snakeoil.key +0 -15
  140. data/node_modules/https-proxy-agent/test/ssl-cert-snakeoil.pem +0 -12
  141. data/node_modules/https-proxy-agent/test/test.js +0 -342
  142. data/node_modules/inflight/LICENSE +0 -15
  143. data/node_modules/inflight/README.md +0 -37
  144. data/node_modules/inflight/inflight.js +0 -54
  145. data/node_modules/inflight/package.json +0 -29
  146. data/node_modules/inherits/LICENSE +0 -16
  147. data/node_modules/inherits/README.md +0 -42
  148. data/node_modules/inherits/inherits.js +0 -7
  149. data/node_modules/inherits/inherits_browser.js +0 -23
  150. data/node_modules/inherits/package.json +0 -29
  151. data/node_modules/isarray/Makefile +0 -6
  152. data/node_modules/isarray/README.md +0 -60
  153. data/node_modules/isarray/component.json +0 -19
  154. data/node_modules/isarray/index.js +0 -5
  155. data/node_modules/isarray/package.json +0 -45
  156. data/node_modules/isarray/test.js +0 -20
  157. data/node_modules/mime/CHANGELOG.md +0 -225
  158. data/node_modules/mime/CONTRIBUTING.md +0 -5
  159. data/node_modules/mime/LICENSE +0 -21
  160. data/node_modules/mime/Mime.js +0 -89
  161. data/node_modules/mime/README.md +0 -188
  162. data/node_modules/mime/cli.js +0 -10
  163. data/node_modules/mime/index.js +0 -4
  164. data/node_modules/mime/lite.js +0 -4
  165. data/node_modules/mime/package.json +0 -43
  166. data/node_modules/mime/src/README_js.md +0 -179
  167. data/node_modules/mime/src/build.js +0 -71
  168. data/node_modules/mime/src/test.js +0 -257
  169. data/node_modules/mime/types/other.json +0 -1
  170. data/node_modules/mime/types/standard.json +0 -1
  171. data/node_modules/minimatch/LICENSE +0 -15
  172. data/node_modules/minimatch/README.md +0 -209
  173. data/node_modules/minimatch/minimatch.js +0 -923
  174. data/node_modules/minimatch/package.json +0 -30
  175. data/node_modules/minimist/LICENSE +0 -18
  176. data/node_modules/minimist/example/parse.js +0 -2
  177. data/node_modules/minimist/index.js +0 -187
  178. data/node_modules/minimist/package.json +0 -40
  179. data/node_modules/minimist/readme.markdown +0 -73
  180. data/node_modules/minimist/test/dash.js +0 -24
  181. data/node_modules/minimist/test/default_bool.js +0 -20
  182. data/node_modules/minimist/test/dotted.js +0 -16
  183. data/node_modules/minimist/test/long.js +0 -31
  184. data/node_modules/minimist/test/parse.js +0 -318
  185. data/node_modules/minimist/test/parse_modified.js +0 -9
  186. data/node_modules/minimist/test/short.js +0 -67
  187. data/node_modules/minimist/test/whitespace.js +0 -8
  188. data/node_modules/mkdirp/LICENSE +0 -21
  189. data/node_modules/mkdirp/bin/cmd.js +0 -33
  190. data/node_modules/mkdirp/bin/usage.txt +0 -12
  191. data/node_modules/mkdirp/examples/pow.js +0 -6
  192. data/node_modules/mkdirp/index.js +0 -98
  193. data/node_modules/mkdirp/package.json +0 -27
  194. data/node_modules/mkdirp/readme.markdown +0 -100
  195. data/node_modules/mkdirp/test/chmod.js +0 -41
  196. data/node_modules/mkdirp/test/clobber.js +0 -38
  197. data/node_modules/mkdirp/test/mkdirp.js +0 -28
  198. data/node_modules/mkdirp/test/opts_fs.js +0 -29
  199. data/node_modules/mkdirp/test/opts_fs_sync.js +0 -27
  200. data/node_modules/mkdirp/test/perm.js +0 -32
  201. data/node_modules/mkdirp/test/perm_sync.js +0 -36
  202. data/node_modules/mkdirp/test/race.js +0 -37
  203. data/node_modules/mkdirp/test/rel.js +0 -32
  204. data/node_modules/mkdirp/test/return.js +0 -25
  205. data/node_modules/mkdirp/test/return_sync.js +0 -24
  206. data/node_modules/mkdirp/test/root.js +0 -19
  207. data/node_modules/mkdirp/test/sync.js +0 -32
  208. data/node_modules/mkdirp/test/umask.js +0 -28
  209. data/node_modules/mkdirp/test/umask_sync.js +0 -32
  210. data/node_modules/ms/index.js +0 -152
  211. data/node_modules/ms/license.md +0 -21
  212. data/node_modules/ms/package.json +0 -37
  213. data/node_modules/ms/readme.md +0 -51
  214. data/node_modules/once/LICENSE +0 -15
  215. data/node_modules/once/README.md +0 -79
  216. data/node_modules/once/once.js +0 -42
  217. data/node_modules/once/package.json +0 -33
  218. data/node_modules/path-is-absolute/index.js +0 -20
  219. data/node_modules/path-is-absolute/license +0 -21
  220. data/node_modules/path-is-absolute/package.json +0 -43
  221. data/node_modules/path-is-absolute/readme.md +0 -59
  222. data/node_modules/pend/LICENSE +0 -23
  223. data/node_modules/pend/README.md +0 -41
  224. data/node_modules/pend/index.js +0 -55
  225. data/node_modules/pend/package.json +0 -18
  226. data/node_modules/pend/test.js +0 -137
  227. data/node_modules/process-nextick-args/index.js +0 -44
  228. data/node_modules/process-nextick-args/license.md +0 -19
  229. data/node_modules/process-nextick-args/package.json +0 -25
  230. data/node_modules/process-nextick-args/readme.md +0 -18
  231. data/node_modules/progress/CHANGELOG.md +0 -115
  232. data/node_modules/progress/LICENSE +0 -22
  233. data/node_modules/progress/Makefile +0 -8
  234. data/node_modules/progress/README.md +0 -146
  235. data/node_modules/progress/index.js +0 -1
  236. data/node_modules/progress/lib/node-progress.js +0 -231
  237. data/node_modules/progress/package.json +0 -25
  238. data/node_modules/proxy-from-env/README.md +0 -131
  239. data/node_modules/proxy-from-env/index.js +0 -103
  240. data/node_modules/proxy-from-env/package.json +0 -35
  241. data/node_modules/proxy-from-env/test.js +0 -393
  242. data/node_modules/puppeteer/CONTRIBUTING.md +0 -206
  243. data/node_modules/puppeteer/DeviceDescriptors.js +0 -704
  244. data/node_modules/puppeteer/LICENSE +0 -202
  245. data/node_modules/puppeteer/README.md +0 -306
  246. data/node_modules/puppeteer/index.js +0 -28
  247. data/node_modules/puppeteer/install.js +0 -122
  248. data/node_modules/puppeteer/lib/Browser.js +0 -186
  249. data/node_modules/puppeteer/lib/BrowserFetcher.js +0 -279
  250. data/node_modules/puppeteer/lib/Connection.js +0 -246
  251. data/node_modules/puppeteer/lib/Coverage.js +0 -301
  252. data/node_modules/puppeteer/lib/Dialog.js +0 -84
  253. data/node_modules/puppeteer/lib/ElementHandle.js +0 -328
  254. data/node_modules/puppeteer/lib/EmulationManager.js +0 -89
  255. data/node_modules/puppeteer/lib/ExecutionContext.js +0 -232
  256. data/node_modules/puppeteer/lib/FrameManager.js +0 -997
  257. data/node_modules/puppeteer/lib/Input.js +0 -309
  258. data/node_modules/puppeteer/lib/Launcher.js +0 -310
  259. data/node_modules/puppeteer/lib/Multimap.js +0 -95
  260. data/node_modules/puppeteer/lib/NavigatorWatcher.js +0 -137
  261. data/node_modules/puppeteer/lib/NetworkManager.js +0 -796
  262. data/node_modules/puppeteer/lib/Page.js +0 -1098
  263. data/node_modules/puppeteer/lib/Pipe.js +0 -69
  264. data/node_modules/puppeteer/lib/Puppeteer.js +0 -60
  265. data/node_modules/puppeteer/lib/Target.js +0 -88
  266. data/node_modules/puppeteer/lib/TaskQueue.js +0 -17
  267. data/node_modules/puppeteer/lib/Tracing.js +0 -99
  268. data/node_modules/puppeteer/lib/USKeyboardLayout.js +0 -281
  269. data/node_modules/puppeteer/lib/helper.js +0 -248
  270. data/node_modules/puppeteer/node6/lib/Browser.js +0 -394
  271. data/node_modules/puppeteer/node6/lib/BrowserFetcher.js +0 -357
  272. data/node_modules/puppeteer/node6/lib/Connection.js +0 -350
  273. data/node_modules/puppeteer/node6/lib/Coverage.js +0 -561
  274. data/node_modules/puppeteer/node6/lib/Dialog.js +0 -136
  275. data/node_modules/puppeteer/node6/lib/ElementHandle.js +0 -796
  276. data/node_modules/puppeteer/node6/lib/EmulationManager.js +0 -115
  277. data/node_modules/puppeteer/node6/lib/ExecutionContext.js +0 -414
  278. data/node_modules/puppeteer/node6/lib/FrameManager.js +0 -1621
  279. data/node_modules/puppeteer/node6/lib/Input.js +0 -569
  280. data/node_modules/puppeteer/node6/lib/Launcher.js +0 -362
  281. data/node_modules/puppeteer/node6/lib/Multimap.js +0 -95
  282. data/node_modules/puppeteer/node6/lib/NavigatorWatcher.js +0 -163
  283. data/node_modules/puppeteer/node6/lib/NetworkManager.js +0 -1108
  284. data/node_modules/puppeteer/node6/lib/Page.js +0 -2242
  285. data/node_modules/puppeteer/node6/lib/Pipe.js +0 -69
  286. data/node_modules/puppeteer/node6/lib/Puppeteer.js +0 -60
  287. data/node_modules/puppeteer/node6/lib/Target.js +0 -114
  288. data/node_modules/puppeteer/node6/lib/TaskQueue.js +0 -17
  289. data/node_modules/puppeteer/node6/lib/Tracing.js +0 -177
  290. data/node_modules/puppeteer/node6/lib/USKeyboardLayout.js +0 -281
  291. data/node_modules/puppeteer/node6/lib/helper.js +0 -274
  292. data/node_modules/puppeteer/package.json +0 -61
  293. data/node_modules/readable-stream/CONTRIBUTING.md +0 -38
  294. data/node_modules/readable-stream/GOVERNANCE.md +0 -136
  295. data/node_modules/readable-stream/LICENSE +0 -47
  296. data/node_modules/readable-stream/README.md +0 -58
  297. data/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +0 -60
  298. data/node_modules/readable-stream/duplex-browser.js +0 -1
  299. data/node_modules/readable-stream/duplex.js +0 -1
  300. data/node_modules/readable-stream/lib/_stream_duplex.js +0 -131
  301. data/node_modules/readable-stream/lib/_stream_passthrough.js +0 -47
  302. data/node_modules/readable-stream/lib/_stream_readable.js +0 -1019
  303. data/node_modules/readable-stream/lib/_stream_transform.js +0 -214
  304. data/node_modules/readable-stream/lib/_stream_writable.js +0 -687
  305. data/node_modules/readable-stream/lib/internal/streams/BufferList.js +0 -79
  306. data/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -74
  307. data/node_modules/readable-stream/lib/internal/streams/stream-browser.js +0 -1
  308. data/node_modules/readable-stream/lib/internal/streams/stream.js +0 -1
  309. data/node_modules/readable-stream/package.json +0 -52
  310. data/node_modules/readable-stream/passthrough.js +0 -1
  311. data/node_modules/readable-stream/readable-browser.js +0 -7
  312. data/node_modules/readable-stream/readable.js +0 -19
  313. data/node_modules/readable-stream/transform.js +0 -1
  314. data/node_modules/readable-stream/writable-browser.js +0 -1
  315. data/node_modules/readable-stream/writable.js +0 -8
  316. data/node_modules/rimraf/LICENSE +0 -15
  317. data/node_modules/rimraf/README.md +0 -101
  318. data/node_modules/rimraf/bin.js +0 -50
  319. data/node_modules/rimraf/package.json +0 -26
  320. data/node_modules/rimraf/rimraf.js +0 -364
  321. data/node_modules/safe-buffer/LICENSE +0 -21
  322. data/node_modules/safe-buffer/README.md +0 -584
  323. data/node_modules/safe-buffer/index.d.ts +0 -187
  324. data/node_modules/safe-buffer/index.js +0 -62
  325. data/node_modules/safe-buffer/package.json +0 -37
  326. data/node_modules/string_decoder/LICENSE +0 -48
  327. data/node_modules/string_decoder/README.md +0 -47
  328. data/node_modules/string_decoder/lib/string_decoder.js +0 -296
  329. data/node_modules/string_decoder/package.json +0 -31
  330. data/node_modules/typedarray/LICENSE +0 -35
  331. data/node_modules/typedarray/example/tarray.js +0 -4
  332. data/node_modules/typedarray/index.js +0 -630
  333. data/node_modules/typedarray/package.json +0 -55
  334. data/node_modules/typedarray/readme.markdown +0 -61
  335. data/node_modules/typedarray/test/server/undef_globals.js +0 -19
  336. data/node_modules/typedarray/test/tarray.js +0 -10
  337. data/node_modules/ultron/LICENSE +0 -22
  338. data/node_modules/ultron/README.md +0 -113
  339. data/node_modules/ultron/index.js +0 -136
  340. data/node_modules/ultron/package.json +0 -41
  341. data/node_modules/util-deprecate/History.md +0 -16
  342. data/node_modules/util-deprecate/LICENSE +0 -24
  343. data/node_modules/util-deprecate/README.md +0 -53
  344. data/node_modules/util-deprecate/browser.js +0 -67
  345. data/node_modules/util-deprecate/node.js +0 -6
  346. data/node_modules/util-deprecate/package.json +0 -27
  347. data/node_modules/wrappy/LICENSE +0 -15
  348. data/node_modules/wrappy/README.md +0 -36
  349. data/node_modules/wrappy/package.json +0 -29
  350. data/node_modules/wrappy/wrappy.js +0 -33
  351. data/node_modules/ws/LICENSE +0 -21
  352. data/node_modules/ws/README.md +0 -341
  353. data/node_modules/ws/index.js +0 -15
  354. data/node_modules/ws/lib/BufferUtil.js +0 -71
  355. data/node_modules/ws/lib/Constants.js +0 -10
  356. data/node_modules/ws/lib/ErrorCodes.js +0 -28
  357. data/node_modules/ws/lib/EventTarget.js +0 -151
  358. data/node_modules/ws/lib/Extensions.js +0 -203
  359. data/node_modules/ws/lib/PerMessageDeflate.js +0 -507
  360. data/node_modules/ws/lib/Receiver.js +0 -553
  361. data/node_modules/ws/lib/Sender.js +0 -412
  362. data/node_modules/ws/lib/Validation.js +0 -17
  363. data/node_modules/ws/lib/WebSocket.js +0 -717
  364. data/node_modules/ws/lib/WebSocketServer.js +0 -326
  365. data/node_modules/ws/package.json +0 -46
  366. data/node_modules/yauzl/LICENSE +0 -21
  367. data/node_modules/yauzl/README.md +0 -467
  368. data/node_modules/yauzl/index.js +0 -626
  369. data/node_modules/yauzl/package.json +0 -36
  370. data/package.json +0 -5
  371. data/yarn.lock +0 -240
@@ -1,997 +0,0 @@
1
- /**
2
- * Copyright 2017 Google Inc. All rights reserved.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- const fs = require('fs');
18
- const EventEmitter = require('events');
19
- const {helper} = require('./helper');
20
- const {ExecutionContext, JSHandle} = require('./ExecutionContext');
21
- const ElementHandle = require('./ElementHandle');
22
-
23
- const readFileAsync = helper.promisify(fs.readFile);
24
-
25
- class FrameManager extends EventEmitter {
26
- /**
27
- * @param {!Puppeteer.CDPSession} client
28
- * @param {!Protocol.Page.FrameTree} frameTree
29
- * @param {!Puppeteer.Page} page
30
- */
31
- constructor(client, frameTree, page) {
32
- super();
33
- this._client = client;
34
- this._page = page;
35
- /** @type {!Map<string, !Frame>} */
36
- this._frames = new Map();
37
- /** @type {!Map<number, !ExecutionContext>} */
38
- this._contextIdToContext = new Map();
39
-
40
- this._client.on('Page.frameAttached', event => this._onFrameAttached(event.frameId, event.parentFrameId));
41
- this._client.on('Page.frameNavigated', event => this._onFrameNavigated(event.frame));
42
- this._client.on('Page.navigatedWithinDocument', event => this._onFrameNavigatedWithinDocument(event.frameId, event.url));
43
- this._client.on('Page.frameDetached', event => this._onFrameDetached(event.frameId));
44
- this._client.on('Page.frameStoppedLoading', event => this._onFrameStoppedLoading(event.frameId));
45
- this._client.on('Runtime.executionContextCreated', event => this._onExecutionContextCreated(event.context));
46
- this._client.on('Runtime.executionContextDestroyed', event => this._onExecutionContextDestroyed(event.executionContextId));
47
- this._client.on('Runtime.executionContextsCleared', event => this._onExecutionContextsCleared());
48
- this._client.on('Page.lifecycleEvent', event => this._onLifecycleEvent(event));
49
-
50
- this._handleFrameTree(frameTree);
51
- }
52
-
53
- /**
54
- * @param {!Protocol.Page.lifecycleEventPayload} event
55
- */
56
- _onLifecycleEvent(event) {
57
- const frame = this._frames.get(event.frameId);
58
- if (!frame)
59
- return;
60
- frame._onLifecycleEvent(event.loaderId, event.name);
61
- this.emit(FrameManager.Events.LifecycleEvent, frame);
62
- }
63
-
64
- /**
65
- * @param {string} frameId
66
- */
67
- _onFrameStoppedLoading(frameId) {
68
- const frame = this._frames.get(frameId);
69
- if (!frame)
70
- return;
71
- frame._onLoadingStopped();
72
- this.emit(FrameManager.Events.LifecycleEvent, frame);
73
- }
74
-
75
- /**
76
- * @param {!Protocol.Page.FrameTree} frameTree
77
- */
78
- _handleFrameTree(frameTree) {
79
- if (frameTree.frame.parentId)
80
- this._onFrameAttached(frameTree.frame.id, frameTree.frame.parentId);
81
- this._onFrameNavigated(frameTree.frame);
82
- if (!frameTree.childFrames)
83
- return;
84
-
85
- for (const child of frameTree.childFrames)
86
- this._handleFrameTree(child);
87
- }
88
-
89
- /**
90
- * @return {!Frame}
91
- */
92
- mainFrame() {
93
- return this._mainFrame;
94
- }
95
-
96
- /**
97
- * @return {!Array<!Frame>}
98
- */
99
- frames() {
100
- return Array.from(this._frames.values());
101
- }
102
-
103
- /**
104
- * @param {!string} frameId
105
- * @return {?Frame}
106
- */
107
- frame(frameId) {
108
- return this._frames.get(frameId) || null;
109
- }
110
-
111
- /**
112
- * @param {string} frameId
113
- * @param {?string} parentFrameId
114
- * @return {?Frame}
115
- */
116
- _onFrameAttached(frameId, parentFrameId) {
117
- if (this._frames.has(frameId))
118
- return;
119
- console.assert(parentFrameId);
120
- const parentFrame = this._frames.get(parentFrameId);
121
- const frame = new Frame(this._client, this._page, parentFrame, frameId);
122
- this._frames.set(frame._id, frame);
123
- this.emit(FrameManager.Events.FrameAttached, frame);
124
- }
125
-
126
- /**
127
- * @param {!Protocol.Page.Frame} framePayload
128
- */
129
- _onFrameNavigated(framePayload) {
130
- const isMainFrame = !framePayload.parentId;
131
- let frame = isMainFrame ? this._mainFrame : this._frames.get(framePayload.id);
132
- console.assert(isMainFrame || frame, 'We either navigate top level or have old version of the navigated frame');
133
-
134
- // Detach all child frames first.
135
- if (frame) {
136
- for (const child of frame.childFrames())
137
- this._removeFramesRecursively(child);
138
- }
139
-
140
- // Update or create main frame.
141
- if (isMainFrame) {
142
- if (frame) {
143
- // Update frame id to retain frame identity on cross-process navigation.
144
- this._frames.delete(frame._id);
145
- frame._id = framePayload.id;
146
- } else {
147
- // Initial main frame navigation.
148
- frame = new Frame(this._client, this._page, null, framePayload.id);
149
- }
150
- this._frames.set(framePayload.id, frame);
151
- this._mainFrame = frame;
152
- }
153
-
154
- // Update frame payload.
155
- frame._navigated(framePayload);
156
-
157
- this.emit(FrameManager.Events.FrameNavigated, frame);
158
- }
159
-
160
- /**
161
- * @param {string} frameId
162
- * @param {string} url
163
- */
164
- _onFrameNavigatedWithinDocument(frameId, url) {
165
- const frame = this._frames.get(frameId);
166
- if (!frame)
167
- return;
168
- frame._navigatedWithinDocument(url);
169
- this.emit(FrameManager.Events.FrameNavigatedWithinDocument, frame);
170
- this.emit(FrameManager.Events.FrameNavigated, frame);
171
- }
172
-
173
- /**
174
- * @param {string} frameId
175
- */
176
- _onFrameDetached(frameId) {
177
- const frame = this._frames.get(frameId);
178
- if (frame)
179
- this._removeFramesRecursively(frame);
180
- }
181
-
182
- _onExecutionContextCreated(contextPayload) {
183
- const frameId = contextPayload.auxData && contextPayload.auxData.isDefault ? contextPayload.auxData.frameId : null;
184
- const frame = frameId ? this._frames.get(frameId) : null;
185
- const context = new ExecutionContext(this._client, contextPayload, this.createJSHandle.bind(this, contextPayload.id), frame);
186
- this._contextIdToContext.set(contextPayload.id, context);
187
- if (frame)
188
- frame._setDefaultContext(context);
189
- }
190
-
191
- /**
192
- * @param {!ExecutionContext} context
193
- */
194
- _removeContext(context) {
195
- if (context.frame())
196
- context.frame()._setDefaultContext(null);
197
- }
198
-
199
- /**
200
- * @param {number} executionContextId
201
- */
202
- _onExecutionContextDestroyed(executionContextId) {
203
- const context = this._contextIdToContext.get(executionContextId);
204
- if (!context)
205
- return;
206
- this._contextIdToContext.delete(executionContextId);
207
- this._removeContext(context);
208
- }
209
-
210
- _onExecutionContextsCleared() {
211
- for (const context of this._contextIdToContext.values())
212
- this._removeContext(context);
213
- this._contextIdToContext.clear();
214
- }
215
-
216
- /**
217
- * @param {number} contextId
218
- * @param {*} remoteObject
219
- * @return {!JSHandle}
220
- */
221
- createJSHandle(contextId, remoteObject) {
222
- const context = this._contextIdToContext.get(contextId);
223
- console.assert(context, 'INTERNAL ERROR: missing context with id = ' + contextId);
224
- if (remoteObject.subtype === 'node')
225
- return new ElementHandle(context, this._client, remoteObject, this._page, this);
226
- return new JSHandle(context, this._client, remoteObject);
227
- }
228
-
229
- /**
230
- * @param {!Frame} frame
231
- */
232
- _removeFramesRecursively(frame) {
233
- for (const child of frame.childFrames())
234
- this._removeFramesRecursively(child);
235
- frame._detach();
236
- this._frames.delete(frame._id);
237
- this.emit(FrameManager.Events.FrameDetached, frame);
238
- }
239
- }
240
-
241
- /** @enum {string} */
242
- FrameManager.Events = {
243
- FrameAttached: 'frameattached',
244
- FrameNavigated: 'framenavigated',
245
- FrameDetached: 'framedetached',
246
- LifecycleEvent: 'lifecycleevent',
247
- FrameNavigatedWithinDocument: 'framenavigatedwithindocument'
248
- };
249
-
250
- /**
251
- * @unrestricted
252
- */
253
- class Frame {
254
- /**
255
- * @param {!Puppeteer.CDPSession} client
256
- * @param {?Frame} parentFrame
257
- * @param {string} frameId
258
- */
259
- constructor(client, page, parentFrame, frameId) {
260
- this._client = client;
261
- this._page = page;
262
- this._parentFrame = parentFrame;
263
- this._url = '';
264
- this._id = frameId;
265
-
266
- /** @type {?Promise<!ElementHandle>} */
267
- this._documentPromise = null;
268
- /** @type {?Promise<!ExecutionContext>} */
269
- this._contextPromise = null;
270
- this._contextResolveCallback = null;
271
- this._setDefaultContext(null);
272
-
273
- /** @type {!Set<!WaitTask>} */
274
- this._waitTasks = new Set();
275
- this._loaderId = '';
276
- /** @type {!Set<string>} */
277
- this._lifecycleEvents = new Set();
278
-
279
- /** @type {!Set<!Frame>} */
280
- this._childFrames = new Set();
281
- if (this._parentFrame)
282
- this._parentFrame._childFrames.add(this);
283
- }
284
-
285
- /**
286
- * @param {?ExecutionContext} context
287
- */
288
- _setDefaultContext(context) {
289
- if (context) {
290
- this._contextResolveCallback.call(null, context);
291
- this._contextResolveCallback = null;
292
- for (const waitTask of this._waitTasks)
293
- waitTask.rerun();
294
- } else {
295
- this._documentPromise = null;
296
- this._contextPromise = new Promise(fulfill => {
297
- this._contextResolveCallback = fulfill;
298
- });
299
- }
300
- }
301
-
302
- /**
303
- * @return {!Promise<!ExecutionContext>}
304
- */
305
- executionContext() {
306
- return this._contextPromise;
307
- }
308
-
309
- /**
310
- * @param {function()|string} pageFunction
311
- * @param {!Array<*>} args
312
- * @return {!Promise<!Puppeteer.JSHandle>}
313
- */
314
- async evaluateHandle(pageFunction, ...args) {
315
- const context = await this._contextPromise;
316
- return context.evaluateHandle(pageFunction, ...args);
317
- }
318
-
319
- /**
320
- * @param {Function|string} pageFunction
321
- * @param {!Array<*>} args
322
- * @return {!Promise<*>}
323
- */
324
- async evaluate(pageFunction, ...args) {
325
- const context = await this._contextPromise;
326
- return context.evaluate(pageFunction, ...args);
327
- }
328
-
329
- /**
330
- * @param {string} selector
331
- * @return {!Promise<?ElementHandle>}
332
- */
333
- async $(selector) {
334
- const document = await this._document();
335
- const value = await document.$(selector);
336
- return value;
337
- }
338
-
339
- /**
340
- * @return {!Promise<!ElementHandle>}
341
- */
342
- async _document() {
343
- if (this._documentPromise)
344
- return this._documentPromise;
345
- this._documentPromise = this._contextPromise.then(async context => {
346
- const document = await context.evaluateHandle('document');
347
- return document.asElement();
348
- });
349
- return this._documentPromise;
350
- }
351
-
352
- /**
353
- * @param {string} expression
354
- * @return {!Promise<!Array<!ElementHandle>>}
355
- */
356
- async $x(expression) {
357
- const document = await this._document();
358
- const value = await document.$x(expression);
359
- return value;
360
- }
361
-
362
- /**
363
- * @param {string} selector
364
- * @param {Function|string} pageFunction
365
- * @param {!Array<*>} args
366
- * @return {!Promise<(!Object|undefined)>}
367
- */
368
- async $eval(selector, pageFunction, ...args) {
369
- const document = await this._document();
370
- const value = await document.$eval(selector, pageFunction, ...args);
371
- return value;
372
- }
373
-
374
- /**
375
- * @param {string} selector
376
- * @param {Function|string} pageFunction
377
- * @param {!Array<*>} args
378
- * @return {!Promise<(!Object|undefined)>}
379
- */
380
- async $$eval(selector, pageFunction, ...args) {
381
- const context = await this._contextPromise;
382
- const arrayHandle = await context.evaluateHandle(selector => Array.from(document.querySelectorAll(selector)), selector);
383
- const result = await this.evaluate(pageFunction, arrayHandle, ...args);
384
- await arrayHandle.dispose();
385
- return result;
386
- }
387
-
388
- /**
389
- * @param {string} selector
390
- * @return {!Promise<!Array<!ElementHandle>>}
391
- */
392
- async $$(selector) {
393
- const document = await this._document();
394
- const value = await document.$$(selector);
395
- return value;
396
- }
397
-
398
- /**
399
- * @return {!Promise<String>}
400
- */
401
- async content() {
402
- return await this.evaluate(() => {
403
- let retVal = '';
404
- if (document.doctype)
405
- retVal = new XMLSerializer().serializeToString(document.doctype);
406
- if (document.documentElement)
407
- retVal += document.documentElement.outerHTML;
408
- return retVal;
409
- });
410
- }
411
-
412
- /**
413
- * @param {string} html
414
- */
415
- async setContent(html) {
416
- await this.evaluate(html => {
417
- document.open();
418
- document.write(html);
419
- document.close();
420
- }, html);
421
- }
422
-
423
- /**
424
- * @return {string}
425
- */
426
- name() {
427
- return this._name || '';
428
- }
429
-
430
- /**
431
- * @return {string}
432
- */
433
- url() {
434
- return this._url;
435
- }
436
-
437
- /**
438
- * @return {?Frame}
439
- */
440
- parentFrame() {
441
- return this._parentFrame;
442
- }
443
-
444
- /**
445
- * @return {!Array.<!Frame>}
446
- */
447
- childFrames() {
448
- return Array.from(this._childFrames);
449
- }
450
-
451
- /**
452
- * @return {boolean}
453
- */
454
- isDetached() {
455
- return this._detached;
456
- }
457
-
458
- /**
459
- * @param {Object} options
460
- * @return {!Promise<!ElementHandle>}
461
- */
462
- async addScriptTag(options) {
463
- if (typeof options.url === 'string') {
464
- const url = options.url;
465
- try {
466
- const context = await this._contextPromise;
467
- return (await context.evaluateHandle(addScriptUrl, url, options.type)).asElement();
468
- } catch (error) {
469
- throw new Error(`Loading script from ${url} failed`);
470
- }
471
- }
472
-
473
- if (typeof options.path === 'string') {
474
- let contents = await readFileAsync(options.path, 'utf8');
475
- contents += '//# sourceURL=' + options.path.replace(/\n/g, '');
476
- const context = await this._contextPromise;
477
- return (await context.evaluateHandle(addScriptContent, contents, options.type)).asElement();
478
- }
479
-
480
- if (typeof options.content === 'string') {
481
- const context = await this._contextPromise;
482
- return (await context.evaluateHandle(addScriptContent, options.content, options.type)).asElement();
483
- }
484
-
485
- throw new Error('Provide an object with a `url`, `path` or `content` property');
486
-
487
- /**
488
- * @param {string} url
489
- * @param {string} type
490
- * @return {!Promise<!HTMLElement>}
491
- */
492
- async function addScriptUrl(url, type) {
493
- const script = document.createElement('script');
494
- script.src = url;
495
- if (type)
496
- script.type = type;
497
- const promise = new Promise((res, rej) => {
498
- script.onload = res;
499
- script.onerror = rej;
500
- });
501
- document.head.appendChild(script);
502
- await promise;
503
- return script;
504
- }
505
-
506
- /**
507
- * @param {string} content
508
- * @param {string} type
509
- * @return {!HTMLElement}
510
- */
511
- function addScriptContent(content, type = 'text/javascript') {
512
- const script = document.createElement('script');
513
- script.type = type;
514
- script.text = content;
515
- let error = null;
516
- script.onerror = e => error = e;
517
- document.head.appendChild(script);
518
- if (error)
519
- throw error;
520
- return script;
521
- }
522
- }
523
-
524
- /**
525
- * @param {Object} options
526
- * @return {!Promise<!ElementHandle>}
527
- */
528
- async addStyleTag(options) {
529
- if (typeof options.url === 'string') {
530
- const url = options.url;
531
- try {
532
- const context = await this._contextPromise;
533
- return (await context.evaluateHandle(addStyleUrl, url)).asElement();
534
- } catch (error) {
535
- throw new Error(`Loading style from ${url} failed`);
536
- }
537
- }
538
-
539
- if (typeof options.path === 'string') {
540
- let contents = await readFileAsync(options.path, 'utf8');
541
- contents += '/*# sourceURL=' + options.path.replace(/\n/g, '') + '*/';
542
- const context = await this._contextPromise;
543
- return (await context.evaluateHandle(addStyleContent, contents)).asElement();
544
- }
545
-
546
- if (typeof options.content === 'string') {
547
- const context = await this._contextPromise;
548
- return (await context.evaluateHandle(addStyleContent, options.content)).asElement();
549
- }
550
-
551
- throw new Error('Provide an object with a `url`, `path` or `content` property');
552
-
553
- /**
554
- * @param {string} url
555
- * @return {!Promise<!HTMLElement>}
556
- */
557
- async function addStyleUrl(url) {
558
- const link = document.createElement('link');
559
- link.rel = 'stylesheet';
560
- link.href = url;
561
- const promise = new Promise((res, rej) => {
562
- link.onload = res;
563
- link.onerror = rej;
564
- });
565
- document.head.appendChild(link);
566
- await promise;
567
- return link;
568
- }
569
-
570
- /**
571
- * @param {string} content
572
- * @return {!Promise<!HTMLElement>}
573
- */
574
- async function addStyleContent(content) {
575
- const style = document.createElement('style');
576
- style.type = 'text/css';
577
- style.appendChild(document.createTextNode(content));
578
- const promise = new Promise((res, rej) => {
579
- style.onload = res;
580
- style.onerror = rej;
581
- });
582
- document.head.appendChild(style);
583
- await promise;
584
- return style;
585
- }
586
- }
587
-
588
- /**
589
- * @param {string} selector
590
- * @param {!Object=} options
591
- */
592
- async click(selector, options = {}) {
593
- const handle = await this.$(selector);
594
- console.assert(handle, 'No node found for selector: ' + selector);
595
- await handle.click(options);
596
- await handle.dispose();
597
- }
598
-
599
- /**
600
- * @param {string} selector
601
- */
602
- async focus(selector) {
603
- const handle = await this.$(selector);
604
- console.assert(handle, 'No node found for selector: ' + selector);
605
- await handle.focus();
606
- await handle.dispose();
607
- }
608
-
609
- /**
610
- * @param {string} selector
611
- */
612
- async hover(selector) {
613
- const handle = await this.$(selector);
614
- console.assert(handle, 'No node found for selector: ' + selector);
615
- await handle.hover();
616
- await handle.dispose();
617
- }
618
-
619
- /**
620
- * @param {string} selector
621
- * @param {!Array<string>} values
622
- * @return {!Promise<!Array<string>>}
623
- */
624
- select(selector, ...values){
625
- for (const value of values)
626
- console.assert(helper.isString(value), 'Values must be strings. Found value "' + value + '" of type "' + (typeof value) + '"');
627
- return this.$eval(selector, (element, values) => {
628
- if (element.nodeName.toLowerCase() !== 'select')
629
- throw new Error('Element is not a <select> element.');
630
-
631
- const options = Array.from(element.options);
632
- element.value = undefined;
633
- for (const option of options) {
634
- option.selected = values.includes(option.value);
635
- if (option.selected && !element.multiple)
636
- break;
637
- }
638
- element.dispatchEvent(new Event('input', { 'bubbles': true }));
639
- element.dispatchEvent(new Event('change', { 'bubbles': true }));
640
- return options.filter(option => option.selected).map(option => option.value);
641
- }, values);
642
- }
643
-
644
- /**
645
- * @param {string} selector
646
- */
647
- async tap(selector) {
648
- const handle = await this.$(selector);
649
- console.assert(handle, 'No node found for selector: ' + selector);
650
- await handle.tap();
651
- await handle.dispose();
652
- }
653
-
654
- /**
655
- * @param {string} selector
656
- * @param {string} text
657
- * @param {{delay: (number|undefined)}=} options
658
- */
659
- async type(selector, text, options) {
660
- const handle = await this.$(selector);
661
- console.assert(handle, 'No node found for selector: ' + selector);
662
- await handle.type(text, options);
663
- await handle.dispose();
664
- }
665
-
666
- /**
667
- * @param {(string|number|Function)} selectorOrFunctionOrTimeout
668
- * @param {!Object=} options
669
- * @param {!Array<*>} args
670
- * @return {!Promise}
671
- */
672
- waitFor(selectorOrFunctionOrTimeout, options = {}, ...args) {
673
- const xPathPattern = '//';
674
-
675
- if (helper.isString(selectorOrFunctionOrTimeout)) {
676
- const string = /** @type {string} */ (selectorOrFunctionOrTimeout);
677
- if (string.startsWith(xPathPattern))
678
- return this.waitForXPath(string, options);
679
- return this.waitForSelector(string, options);
680
- }
681
- if (helper.isNumber(selectorOrFunctionOrTimeout))
682
- return new Promise(fulfill => setTimeout(fulfill, selectorOrFunctionOrTimeout));
683
- if (typeof selectorOrFunctionOrTimeout === 'function')
684
- return this.waitForFunction(selectorOrFunctionOrTimeout, options, ...args);
685
- return Promise.reject(new Error('Unsupported target type: ' + (typeof selectorOrFunctionOrTimeout)));
686
- }
687
-
688
- /**
689
- * @param {string} selector
690
- * @param {!Object=} options
691
- * @return {!Promise}
692
- */
693
- waitForSelector(selector, options = {}) {
694
- return this._waitForSelectorOrXPath(selector, false, options);
695
- }
696
-
697
- /**
698
- * @param {string} xpath
699
- * @param {!Object=} options
700
- * @return {!Promise}
701
- */
702
- waitForXPath(xpath, options = {}) {
703
- return this._waitForSelectorOrXPath(xpath, true, options);
704
- }
705
-
706
- /**
707
- * @param {Function|string} pageFunction
708
- * @param {!Object=} options
709
- * @return {!Promise}
710
- */
711
- waitForFunction(pageFunction, options = {}, ...args) {
712
- const timeout = helper.isNumber(options.timeout) ? options.timeout : 30000;
713
- const polling = options.polling || 'raf';
714
- return new WaitTask(this, pageFunction, 'function', polling, timeout, ...args).promise;
715
- }
716
-
717
- /**
718
- * @return {!Promise<string>}
719
- */
720
- async title() {
721
- return this.evaluate(() => document.title);
722
- }
723
-
724
- /**
725
- * @param {string} selectorOrXPath
726
- * @param {boolean} isXPath
727
- * @param {!Object=} options
728
- * @return {!Promise}
729
- */
730
- _waitForSelectorOrXPath(selectorOrXPath, isXPath, options = {}) {
731
- const waitForVisible = !!options.visible;
732
- const waitForHidden = !!options.hidden;
733
- const polling = waitForVisible || waitForHidden ? 'raf' : 'mutation';
734
- const timeout = helper.isNumber(options.timeout) ? options.timeout : 30000;
735
- return new WaitTask(this, predicate, `${isXPath ? 'XPath' : 'selector'} "${selectorOrXPath}"`, polling, timeout, selectorOrXPath, isXPath, waitForVisible, waitForHidden).promise;
736
-
737
- /**
738
- * @param {string} selectorOrXPath
739
- * @param {boolean} isXPath
740
- * @param {boolean} waitForVisible
741
- * @param {boolean} waitForHidden
742
- * @return {?Node|boolean}
743
- */
744
- function predicate(selectorOrXPath, isXPath, waitForVisible, waitForHidden) {
745
- const node = isXPath
746
- ? document.evaluate(selectorOrXPath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue
747
- : document.querySelector(selectorOrXPath);
748
- if (!node)
749
- return waitForHidden;
750
- if (!waitForVisible && !waitForHidden)
751
- return node;
752
- const element = /** @type {Element} */ (node.nodeType === Node.TEXT_NODE ? node.parentElement : node);
753
-
754
- const style = window.getComputedStyle(element);
755
- const isVisible = style && style.visibility !== 'hidden' && hasVisibleBoundingBox();
756
- const success = (waitForVisible === isVisible || waitForHidden === !isVisible);
757
- return success ? node : null;
758
-
759
- /**
760
- * @return {boolean}
761
- */
762
- function hasVisibleBoundingBox() {
763
- const rect = element.getBoundingClientRect();
764
- return !!(rect.top || rect.bottom || rect.width || rect.height);
765
- }
766
- }
767
- }
768
-
769
- /**
770
- * @param {!Protocol.Page.Frame} framePayload
771
- */
772
- _navigated(framePayload) {
773
- this._name = framePayload.name;
774
- // TODO(lushnikov): remove this once requestInterception has loaderId exposed.
775
- this._navigationURL = framePayload.url;
776
- this._url = framePayload.url;
777
- }
778
-
779
- /**
780
- * @param {string} url
781
- */
782
- _navigatedWithinDocument(url) {
783
- this._url = url;
784
- }
785
-
786
- /**
787
- * @param {string} loaderId
788
- * @param {string} name
789
- */
790
- _onLifecycleEvent(loaderId, name) {
791
- if (name === 'init') {
792
- this._loaderId = loaderId;
793
- this._lifecycleEvents.clear();
794
- }
795
- this._lifecycleEvents.add(name);
796
- }
797
-
798
- _onLoadingStopped() {
799
- this._lifecycleEvents.add('DOMContentLoaded');
800
- this._lifecycleEvents.add('load');
801
- }
802
-
803
- _detach() {
804
- for (const waitTask of this._waitTasks)
805
- waitTask.terminate(new Error('waitForFunction failed: frame got detached.'));
806
- this._detached = true;
807
- if (this._parentFrame)
808
- this._parentFrame._childFrames.delete(this);
809
- this._parentFrame = null;
810
- }
811
- }
812
- helper.tracePublicAPI(Frame);
813
-
814
- class WaitTask {
815
- /**
816
- * @param {!Frame} frame
817
- * @param {Function|string} predicateBody
818
- * @param {string|number} polling
819
- * @param {number} timeout
820
- * @param {!Array<*>} args
821
- */
822
- constructor(frame, predicateBody, title, polling, timeout, ...args) {
823
- if (helper.isString(polling))
824
- console.assert(polling === 'raf' || polling === 'mutation', 'Unknown polling option: ' + polling);
825
- else if (helper.isNumber(polling))
826
- console.assert(polling > 0, 'Cannot poll with non-positive interval: ' + polling);
827
- else
828
- throw new Error('Unknown polling options: ' + polling);
829
-
830
- this._frame = frame;
831
- this._polling = polling;
832
- this._timeout = timeout;
833
- this._predicateBody = helper.isString(predicateBody) ? 'return ' + predicateBody : 'return (' + predicateBody + ')(...args)';
834
- this._args = args;
835
- this._runCount = 0;
836
- frame._waitTasks.add(this);
837
- this.promise = new Promise((resolve, reject) => {
838
- this._resolve = resolve;
839
- this._reject = reject;
840
- });
841
- // Since page navigation requires us to re-install the pageScript, we should track
842
- // timeout on our end.
843
- if (timeout)
844
- this._timeoutTimer = setTimeout(() => this.terminate(new Error(`waiting for ${title} failed: timeout ${timeout}ms exceeded`)), timeout);
845
- this.rerun();
846
- }
847
-
848
- /**
849
- * @param {!Error} error
850
- */
851
- terminate(error) {
852
- this._terminated = true;
853
- this._reject(error);
854
- this._cleanup();
855
- }
856
-
857
- async rerun() {
858
- const runCount = ++this._runCount;
859
- /** @type {?JSHandle} */
860
- let success = null;
861
- let error = null;
862
- try {
863
- success = await (await this._frame.executionContext()).evaluateHandle(waitForPredicatePageFunction, this._predicateBody, this._polling, this._timeout, ...this._args);
864
- } catch (e) {
865
- error = e;
866
- }
867
-
868
- if (this._terminated || runCount !== this._runCount) {
869
- if (success)
870
- await success.dispose();
871
- return;
872
- }
873
-
874
- // Ignore timeouts in pageScript - we track timeouts ourselves.
875
- if (!error && await this._frame.evaluate(s => !s, success)) {
876
- await success.dispose();
877
- return;
878
- }
879
-
880
- // When the page is navigated, the promise is rejected.
881
- // We will try again in the new execution context.
882
- if (error && error.message.includes('Execution context was destroyed'))
883
- return;
884
-
885
- // We could have tried to evaluate in a context which was already
886
- // destroyed.
887
- if (error && error.message.includes('Cannot find context with specified id'))
888
- return;
889
-
890
- if (error)
891
- this._reject(error);
892
- else
893
- this._resolve(success);
894
-
895
- this._cleanup();
896
- }
897
-
898
- _cleanup() {
899
- clearTimeout(this._timeoutTimer);
900
- this._frame._waitTasks.delete(this);
901
- this._runningTask = null;
902
- }
903
- }
904
-
905
- /**
906
- * @param {string} predicateBody
907
- * @param {string} polling
908
- * @param {number} timeout
909
- * @return {!Promise<*>}
910
- */
911
- async function waitForPredicatePageFunction(predicateBody, polling, timeout, ...args) {
912
- const predicate = new Function('...args', predicateBody);
913
- let timedOut = false;
914
- setTimeout(() => timedOut = true, timeout);
915
- if (polling === 'raf')
916
- return await pollRaf();
917
- if (polling === 'mutation')
918
- return await pollMutation();
919
- if (typeof polling === 'number')
920
- return await pollInterval(polling);
921
-
922
- /**
923
- * @return {!Promise<*>}
924
- */
925
- function pollMutation() {
926
- const success = predicate.apply(null, args);
927
- if (success)
928
- return Promise.resolve(success);
929
-
930
- let fulfill;
931
- const result = new Promise(x => fulfill = x);
932
- const observer = new MutationObserver(mutations => {
933
- if (timedOut) {
934
- observer.disconnect();
935
- fulfill();
936
- }
937
- const success = predicate.apply(null, args);
938
- if (success) {
939
- observer.disconnect();
940
- fulfill(success);
941
- }
942
- });
943
- observer.observe(document, {
944
- childList: true,
945
- subtree: true,
946
- attributes: true
947
- });
948
- return result;
949
- }
950
-
951
- /**
952
- * @return {!Promise<*>}
953
- */
954
- function pollRaf() {
955
- let fulfill;
956
- const result = new Promise(x => fulfill = x);
957
- onRaf();
958
- return result;
959
-
960
- function onRaf() {
961
- if (timedOut) {
962
- fulfill();
963
- return;
964
- }
965
- const success = predicate.apply(null, args);
966
- if (success)
967
- fulfill(success);
968
- else
969
- requestAnimationFrame(onRaf);
970
- }
971
- }
972
-
973
- /**
974
- * @param {number} pollInterval
975
- * @return {!Promise<*>}
976
- */
977
- function pollInterval(pollInterval) {
978
- let fulfill;
979
- const result = new Promise(x => fulfill = x);
980
- onTimeout();
981
- return result;
982
-
983
- function onTimeout() {
984
- if (timedOut) {
985
- fulfill();
986
- return;
987
- }
988
- const success = predicate.apply(null, args);
989
- if (success)
990
- fulfill(success);
991
- else
992
- setTimeout(onTimeout, pollInterval);
993
- }
994
- }
995
- }
996
-
997
- module.exports = {FrameManager, Frame};