postdoc 0.1.2 → 0.2.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (372) hide show
  1. checksums.yaml +5 -5
  2. data/lib/pdf.js +27 -0
  3. data/lib/postdoc.rb +3 -7
  4. data/node_modules/agent-base/History.md +113 -0
  5. data/node_modules/agent-base/README.md +145 -0
  6. data/node_modules/agent-base/index.js +160 -0
  7. data/node_modules/agent-base/package.json +35 -0
  8. data/node_modules/agent-base/patch-core.js +37 -0
  9. data/node_modules/agent-base/test/ssl-cert-snakeoil.key +15 -0
  10. data/node_modules/agent-base/test/ssl-cert-snakeoil.pem +12 -0
  11. data/node_modules/agent-base/test/test.js +673 -0
  12. data/node_modules/async-limiter/LICENSE +8 -0
  13. data/node_modules/async-limiter/coverage/coverage.json +1 -0
  14. data/node_modules/async-limiter/coverage/lcov-report/async-throttle/index.html +73 -0
  15. data/node_modules/async-limiter/coverage/lcov-report/async-throttle/index.js.html +246 -0
  16. data/node_modules/async-limiter/coverage/lcov-report/base.css +182 -0
  17. data/node_modules/async-limiter/coverage/lcov-report/index.html +73 -0
  18. data/node_modules/async-limiter/coverage/lcov-report/prettify.css +1 -0
  19. data/node_modules/async-limiter/coverage/lcov-report/prettify.js +1 -0
  20. data/node_modules/async-limiter/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  21. data/node_modules/async-limiter/coverage/lcov-report/sorter.js +156 -0
  22. data/node_modules/async-limiter/coverage/lcov.info +74 -0
  23. data/node_modules/async-limiter/index.js +67 -0
  24. data/node_modules/async-limiter/package.json +35 -0
  25. data/node_modules/async-limiter/readme.md +132 -0
  26. data/node_modules/balanced-match/LICENSE.md +21 -0
  27. data/node_modules/balanced-match/README.md +91 -0
  28. data/node_modules/balanced-match/index.js +59 -0
  29. data/node_modules/balanced-match/package.json +49 -0
  30. data/node_modules/brace-expansion/LICENSE +21 -0
  31. data/node_modules/brace-expansion/README.md +129 -0
  32. data/node_modules/brace-expansion/index.js +201 -0
  33. data/node_modules/brace-expansion/package.json +47 -0
  34. data/node_modules/buffer-from/index.js +69 -0
  35. data/node_modules/buffer-from/package.json +16 -0
  36. data/node_modules/buffer-from/readme.md +69 -0
  37. data/node_modules/buffer-from/test.js +12 -0
  38. data/node_modules/concat-map/LICENSE +18 -0
  39. data/node_modules/concat-map/README.markdown +62 -0
  40. data/node_modules/concat-map/example/map.js +6 -0
  41. data/node_modules/concat-map/index.js +13 -0
  42. data/node_modules/concat-map/package.json +43 -0
  43. data/node_modules/concat-map/test/map.js +39 -0
  44. data/node_modules/concat-stream/LICENSE +24 -0
  45. data/node_modules/concat-stream/index.js +144 -0
  46. data/node_modules/concat-stream/package.json +55 -0
  47. data/node_modules/concat-stream/readme.md +102 -0
  48. data/node_modules/core-util-is/LICENSE +19 -0
  49. data/node_modules/core-util-is/README.md +3 -0
  50. data/node_modules/core-util-is/float.patch +604 -0
  51. data/node_modules/core-util-is/lib/util.js +107 -0
  52. data/node_modules/core-util-is/package.json +32 -0
  53. data/node_modules/core-util-is/test.js +68 -0
  54. data/node_modules/debug/CHANGELOG.md +395 -0
  55. data/node_modules/debug/LICENSE +19 -0
  56. data/node_modules/debug/Makefile +58 -0
  57. data/node_modules/debug/README.md +368 -0
  58. data/node_modules/debug/karma.conf.js +70 -0
  59. data/node_modules/debug/node.js +1 -0
  60. data/node_modules/debug/package.json +43 -0
  61. data/node_modules/debug/src/browser.js +195 -0
  62. data/node_modules/debug/src/debug.js +225 -0
  63. data/node_modules/debug/src/index.js +10 -0
  64. data/node_modules/debug/src/node.js +186 -0
  65. data/node_modules/es6-promise/CHANGELOG.md +151 -0
  66. data/node_modules/es6-promise/LICENSE +19 -0
  67. data/node_modules/es6-promise/README.md +97 -0
  68. data/node_modules/es6-promise/auto.js +4 -0
  69. data/node_modules/es6-promise/dist/es6-promise.auto.js +1181 -0
  70. data/node_modules/es6-promise/dist/es6-promise.auto.map +1 -0
  71. data/node_modules/es6-promise/dist/es6-promise.auto.min.js +1 -0
  72. data/node_modules/es6-promise/dist/es6-promise.auto.min.map +1 -0
  73. data/node_modules/es6-promise/dist/es6-promise.js +1179 -0
  74. data/node_modules/es6-promise/dist/es6-promise.map +1 -0
  75. data/node_modules/es6-promise/dist/es6-promise.min.js +1 -0
  76. data/node_modules/es6-promise/dist/es6-promise.min.map +1 -0
  77. data/node_modules/es6-promise/es6-promise.d.ts +81 -0
  78. data/node_modules/es6-promise/lib/es6-promise/-internal.js +266 -0
  79. data/node_modules/es6-promise/lib/es6-promise/asap.js +119 -0
  80. data/node_modules/es6-promise/lib/es6-promise/enumerator.js +113 -0
  81. data/node_modules/es6-promise/lib/es6-promise/polyfill.js +35 -0
  82. data/node_modules/es6-promise/lib/es6-promise/promise/all.js +52 -0
  83. data/node_modules/es6-promise/lib/es6-promise/promise/race.js +84 -0
  84. data/node_modules/es6-promise/lib/es6-promise/promise/reject.js +46 -0
  85. data/node_modules/es6-promise/lib/es6-promise/promise/resolve.js +48 -0
  86. data/node_modules/es6-promise/lib/es6-promise/promise.js +427 -0
  87. data/node_modules/es6-promise/lib/es6-promise/then.js +32 -0
  88. data/node_modules/es6-promise/lib/es6-promise/utils.js +21 -0
  89. data/node_modules/es6-promise/lib/es6-promise.auto.js +3 -0
  90. data/node_modules/es6-promise/lib/es6-promise.js +7 -0
  91. data/node_modules/es6-promise/package.json +75 -0
  92. data/node_modules/es6-promisify/README.md +89 -0
  93. data/node_modules/es6-promisify/dist/promise.js +73 -0
  94. data/node_modules/es6-promisify/dist/promisify.js +85 -0
  95. data/node_modules/es6-promisify/package.json +41 -0
  96. data/node_modules/extract-zip/CONTRIBUTING.md +1 -0
  97. data/node_modules/extract-zip/LICENSE +23 -0
  98. data/node_modules/extract-zip/cli.js +20 -0
  99. data/node_modules/extract-zip/index.js +205 -0
  100. data/node_modules/extract-zip/node_modules/debug/CHANGELOG.md +362 -0
  101. data/node_modules/extract-zip/node_modules/debug/LICENSE +19 -0
  102. data/node_modules/extract-zip/node_modules/debug/Makefile +50 -0
  103. data/node_modules/extract-zip/node_modules/debug/README.md +312 -0
  104. data/node_modules/extract-zip/node_modules/debug/component.json +19 -0
  105. data/node_modules/extract-zip/node_modules/debug/karma.conf.js +70 -0
  106. data/node_modules/extract-zip/node_modules/debug/node.js +1 -0
  107. data/node_modules/extract-zip/node_modules/debug/package.json +49 -0
  108. data/node_modules/extract-zip/node_modules/debug/src/browser.js +185 -0
  109. data/node_modules/extract-zip/node_modules/debug/src/debug.js +202 -0
  110. data/node_modules/extract-zip/node_modules/debug/src/index.js +10 -0
  111. data/node_modules/extract-zip/node_modules/debug/src/inspector-log.js +15 -0
  112. data/node_modules/extract-zip/node_modules/debug/src/node.js +248 -0
  113. data/node_modules/extract-zip/package.json +35 -0
  114. data/node_modules/extract-zip/readme.md +49 -0
  115. data/node_modules/fd-slicer/CHANGELOG.md +49 -0
  116. data/node_modules/fd-slicer/LICENSE +21 -0
  117. data/node_modules/fd-slicer/README.md +189 -0
  118. data/node_modules/fd-slicer/index.js +277 -0
  119. data/node_modules/fd-slicer/package.json +36 -0
  120. data/node_modules/fd-slicer/test/test.js +350 -0
  121. data/node_modules/fs.realpath/LICENSE +43 -0
  122. data/node_modules/fs.realpath/README.md +33 -0
  123. data/node_modules/fs.realpath/index.js +66 -0
  124. data/node_modules/fs.realpath/old.js +303 -0
  125. data/node_modules/fs.realpath/package.json +26 -0
  126. data/node_modules/glob/LICENSE +15 -0
  127. data/node_modules/glob/README.md +368 -0
  128. data/node_modules/glob/changelog.md +67 -0
  129. data/node_modules/glob/common.js +240 -0
  130. data/node_modules/glob/glob.js +790 -0
  131. data/node_modules/glob/package.json +43 -0
  132. data/node_modules/glob/sync.js +486 -0
  133. data/node_modules/https-proxy-agent/History.md +124 -0
  134. data/node_modules/https-proxy-agent/README.md +137 -0
  135. data/node_modules/https-proxy-agent/index.js +229 -0
  136. data/node_modules/https-proxy-agent/package.json +35 -0
  137. data/node_modules/https-proxy-agent/test/ssl-cert-snakeoil.key +15 -0
  138. data/node_modules/https-proxy-agent/test/ssl-cert-snakeoil.pem +12 -0
  139. data/node_modules/https-proxy-agent/test/test.js +342 -0
  140. data/node_modules/inflight/LICENSE +15 -0
  141. data/node_modules/inflight/README.md +37 -0
  142. data/node_modules/inflight/inflight.js +54 -0
  143. data/node_modules/inflight/package.json +29 -0
  144. data/node_modules/inherits/LICENSE +16 -0
  145. data/node_modules/inherits/README.md +42 -0
  146. data/node_modules/inherits/inherits.js +7 -0
  147. data/node_modules/inherits/inherits_browser.js +23 -0
  148. data/node_modules/inherits/package.json +29 -0
  149. data/node_modules/isarray/Makefile +6 -0
  150. data/node_modules/isarray/README.md +60 -0
  151. data/node_modules/isarray/component.json +19 -0
  152. data/node_modules/isarray/index.js +5 -0
  153. data/node_modules/isarray/package.json +45 -0
  154. data/node_modules/isarray/test.js +20 -0
  155. data/node_modules/mime/CHANGELOG.md +225 -0
  156. data/node_modules/mime/CONTRIBUTING.md +5 -0
  157. data/node_modules/mime/LICENSE +21 -0
  158. data/node_modules/mime/Mime.js +89 -0
  159. data/node_modules/mime/README.md +188 -0
  160. data/node_modules/mime/cli.js +10 -0
  161. data/node_modules/mime/index.js +4 -0
  162. data/node_modules/mime/lite.js +4 -0
  163. data/node_modules/mime/package.json +43 -0
  164. data/node_modules/mime/src/README_js.md +179 -0
  165. data/node_modules/mime/src/build.js +71 -0
  166. data/node_modules/mime/src/test.js +257 -0
  167. data/node_modules/mime/types/other.json +1 -0
  168. data/node_modules/mime/types/standard.json +1 -0
  169. data/node_modules/minimatch/LICENSE +15 -0
  170. data/node_modules/minimatch/README.md +209 -0
  171. data/node_modules/minimatch/minimatch.js +923 -0
  172. data/node_modules/minimatch/package.json +30 -0
  173. data/node_modules/minimist/LICENSE +18 -0
  174. data/node_modules/minimist/example/parse.js +2 -0
  175. data/node_modules/minimist/index.js +187 -0
  176. data/node_modules/minimist/package.json +40 -0
  177. data/node_modules/minimist/readme.markdown +73 -0
  178. data/node_modules/minimist/test/dash.js +24 -0
  179. data/node_modules/minimist/test/default_bool.js +20 -0
  180. data/node_modules/minimist/test/dotted.js +16 -0
  181. data/node_modules/minimist/test/long.js +31 -0
  182. data/node_modules/minimist/test/parse.js +318 -0
  183. data/node_modules/minimist/test/parse_modified.js +9 -0
  184. data/node_modules/minimist/test/short.js +67 -0
  185. data/node_modules/minimist/test/whitespace.js +8 -0
  186. data/node_modules/mkdirp/LICENSE +21 -0
  187. data/node_modules/mkdirp/bin/cmd.js +33 -0
  188. data/node_modules/mkdirp/bin/usage.txt +12 -0
  189. data/node_modules/mkdirp/examples/pow.js +6 -0
  190. data/node_modules/mkdirp/index.js +98 -0
  191. data/node_modules/mkdirp/package.json +27 -0
  192. data/node_modules/mkdirp/readme.markdown +100 -0
  193. data/node_modules/mkdirp/test/chmod.js +41 -0
  194. data/node_modules/mkdirp/test/clobber.js +38 -0
  195. data/node_modules/mkdirp/test/mkdirp.js +28 -0
  196. data/node_modules/mkdirp/test/opts_fs.js +29 -0
  197. data/node_modules/mkdirp/test/opts_fs_sync.js +27 -0
  198. data/node_modules/mkdirp/test/perm.js +32 -0
  199. data/node_modules/mkdirp/test/perm_sync.js +36 -0
  200. data/node_modules/mkdirp/test/race.js +37 -0
  201. data/node_modules/mkdirp/test/rel.js +32 -0
  202. data/node_modules/mkdirp/test/return.js +25 -0
  203. data/node_modules/mkdirp/test/return_sync.js +24 -0
  204. data/node_modules/mkdirp/test/root.js +19 -0
  205. data/node_modules/mkdirp/test/sync.js +32 -0
  206. data/node_modules/mkdirp/test/umask.js +28 -0
  207. data/node_modules/mkdirp/test/umask_sync.js +32 -0
  208. data/node_modules/ms/index.js +152 -0
  209. data/node_modules/ms/license.md +21 -0
  210. data/node_modules/ms/package.json +37 -0
  211. data/node_modules/ms/readme.md +51 -0
  212. data/node_modules/once/LICENSE +15 -0
  213. data/node_modules/once/README.md +79 -0
  214. data/node_modules/once/once.js +42 -0
  215. data/node_modules/once/package.json +33 -0
  216. data/node_modules/path-is-absolute/index.js +20 -0
  217. data/node_modules/path-is-absolute/license +21 -0
  218. data/node_modules/path-is-absolute/package.json +43 -0
  219. data/node_modules/path-is-absolute/readme.md +59 -0
  220. data/node_modules/pend/LICENSE +23 -0
  221. data/node_modules/pend/README.md +41 -0
  222. data/node_modules/pend/index.js +55 -0
  223. data/node_modules/pend/package.json +18 -0
  224. data/node_modules/pend/test.js +137 -0
  225. data/node_modules/process-nextick-args/index.js +44 -0
  226. data/node_modules/process-nextick-args/license.md +19 -0
  227. data/node_modules/process-nextick-args/package.json +25 -0
  228. data/node_modules/process-nextick-args/readme.md +18 -0
  229. data/node_modules/progress/CHANGELOG.md +115 -0
  230. data/node_modules/progress/LICENSE +22 -0
  231. data/node_modules/progress/Makefile +8 -0
  232. data/node_modules/progress/README.md +146 -0
  233. data/node_modules/progress/index.js +1 -0
  234. data/node_modules/progress/lib/node-progress.js +231 -0
  235. data/node_modules/progress/package.json +25 -0
  236. data/node_modules/proxy-from-env/README.md +131 -0
  237. data/node_modules/proxy-from-env/index.js +103 -0
  238. data/node_modules/proxy-from-env/package.json +35 -0
  239. data/node_modules/proxy-from-env/test.js +393 -0
  240. data/node_modules/puppeteer/CONTRIBUTING.md +206 -0
  241. data/node_modules/puppeteer/DeviceDescriptors.js +704 -0
  242. data/node_modules/puppeteer/LICENSE +202 -0
  243. data/node_modules/puppeteer/README.md +306 -0
  244. data/node_modules/puppeteer/index.js +28 -0
  245. data/node_modules/puppeteer/install.js +122 -0
  246. data/node_modules/puppeteer/lib/Browser.js +186 -0
  247. data/node_modules/puppeteer/lib/BrowserFetcher.js +279 -0
  248. data/node_modules/puppeteer/lib/Connection.js +246 -0
  249. data/node_modules/puppeteer/lib/Coverage.js +301 -0
  250. data/node_modules/puppeteer/lib/Dialog.js +84 -0
  251. data/node_modules/puppeteer/lib/ElementHandle.js +328 -0
  252. data/node_modules/puppeteer/lib/EmulationManager.js +89 -0
  253. data/node_modules/puppeteer/lib/ExecutionContext.js +232 -0
  254. data/node_modules/puppeteer/lib/FrameManager.js +997 -0
  255. data/node_modules/puppeteer/lib/Input.js +309 -0
  256. data/node_modules/puppeteer/lib/Launcher.js +310 -0
  257. data/node_modules/puppeteer/lib/Multimap.js +95 -0
  258. data/node_modules/puppeteer/lib/NavigatorWatcher.js +137 -0
  259. data/node_modules/puppeteer/lib/NetworkManager.js +796 -0
  260. data/node_modules/puppeteer/lib/Page.js +1098 -0
  261. data/node_modules/puppeteer/lib/Pipe.js +69 -0
  262. data/node_modules/puppeteer/lib/Puppeteer.js +60 -0
  263. data/node_modules/puppeteer/lib/Target.js +88 -0
  264. data/node_modules/puppeteer/lib/TaskQueue.js +17 -0
  265. data/node_modules/puppeteer/lib/Tracing.js +99 -0
  266. data/node_modules/puppeteer/lib/USKeyboardLayout.js +281 -0
  267. data/node_modules/puppeteer/lib/helper.js +248 -0
  268. data/node_modules/puppeteer/node6/lib/Browser.js +394 -0
  269. data/node_modules/puppeteer/node6/lib/BrowserFetcher.js +357 -0
  270. data/node_modules/puppeteer/node6/lib/Connection.js +350 -0
  271. data/node_modules/puppeteer/node6/lib/Coverage.js +561 -0
  272. data/node_modules/puppeteer/node6/lib/Dialog.js +136 -0
  273. data/node_modules/puppeteer/node6/lib/ElementHandle.js +796 -0
  274. data/node_modules/puppeteer/node6/lib/EmulationManager.js +115 -0
  275. data/node_modules/puppeteer/node6/lib/ExecutionContext.js +414 -0
  276. data/node_modules/puppeteer/node6/lib/FrameManager.js +1621 -0
  277. data/node_modules/puppeteer/node6/lib/Input.js +569 -0
  278. data/node_modules/puppeteer/node6/lib/Launcher.js +362 -0
  279. data/node_modules/puppeteer/node6/lib/Multimap.js +95 -0
  280. data/node_modules/puppeteer/node6/lib/NavigatorWatcher.js +163 -0
  281. data/node_modules/puppeteer/node6/lib/NetworkManager.js +1108 -0
  282. data/node_modules/puppeteer/node6/lib/Page.js +2242 -0
  283. data/node_modules/puppeteer/node6/lib/Pipe.js +69 -0
  284. data/node_modules/puppeteer/node6/lib/Puppeteer.js +60 -0
  285. data/node_modules/puppeteer/node6/lib/Target.js +114 -0
  286. data/node_modules/puppeteer/node6/lib/TaskQueue.js +17 -0
  287. data/node_modules/puppeteer/node6/lib/Tracing.js +177 -0
  288. data/node_modules/puppeteer/node6/lib/USKeyboardLayout.js +281 -0
  289. data/node_modules/puppeteer/node6/lib/helper.js +274 -0
  290. data/node_modules/puppeteer/package.json +61 -0
  291. data/node_modules/readable-stream/CONTRIBUTING.md +38 -0
  292. data/node_modules/readable-stream/GOVERNANCE.md +136 -0
  293. data/node_modules/readable-stream/LICENSE +47 -0
  294. data/node_modules/readable-stream/README.md +58 -0
  295. data/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +60 -0
  296. data/node_modules/readable-stream/duplex-browser.js +1 -0
  297. data/node_modules/readable-stream/duplex.js +1 -0
  298. data/node_modules/readable-stream/lib/_stream_duplex.js +131 -0
  299. data/node_modules/readable-stream/lib/_stream_passthrough.js +47 -0
  300. data/node_modules/readable-stream/lib/_stream_readable.js +1019 -0
  301. data/node_modules/readable-stream/lib/_stream_transform.js +214 -0
  302. data/node_modules/readable-stream/lib/_stream_writable.js +687 -0
  303. data/node_modules/readable-stream/lib/internal/streams/BufferList.js +79 -0
  304. data/node_modules/readable-stream/lib/internal/streams/destroy.js +74 -0
  305. data/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
  306. data/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
  307. data/node_modules/readable-stream/package.json +52 -0
  308. data/node_modules/readable-stream/passthrough.js +1 -0
  309. data/node_modules/readable-stream/readable-browser.js +7 -0
  310. data/node_modules/readable-stream/readable.js +19 -0
  311. data/node_modules/readable-stream/transform.js +1 -0
  312. data/node_modules/readable-stream/writable-browser.js +1 -0
  313. data/node_modules/readable-stream/writable.js +8 -0
  314. data/node_modules/rimraf/LICENSE +15 -0
  315. data/node_modules/rimraf/README.md +101 -0
  316. data/node_modules/rimraf/bin.js +50 -0
  317. data/node_modules/rimraf/package.json +26 -0
  318. data/node_modules/rimraf/rimraf.js +364 -0
  319. data/node_modules/safe-buffer/LICENSE +21 -0
  320. data/node_modules/safe-buffer/README.md +584 -0
  321. data/node_modules/safe-buffer/index.d.ts +187 -0
  322. data/node_modules/safe-buffer/index.js +62 -0
  323. data/node_modules/safe-buffer/package.json +37 -0
  324. data/node_modules/string_decoder/LICENSE +48 -0
  325. data/node_modules/string_decoder/README.md +47 -0
  326. data/node_modules/string_decoder/lib/string_decoder.js +296 -0
  327. data/node_modules/string_decoder/package.json +31 -0
  328. data/node_modules/typedarray/LICENSE +35 -0
  329. data/node_modules/typedarray/example/tarray.js +4 -0
  330. data/node_modules/typedarray/index.js +630 -0
  331. data/node_modules/typedarray/package.json +55 -0
  332. data/node_modules/typedarray/readme.markdown +61 -0
  333. data/node_modules/typedarray/test/server/undef_globals.js +19 -0
  334. data/node_modules/typedarray/test/tarray.js +10 -0
  335. data/node_modules/ultron/LICENSE +22 -0
  336. data/node_modules/ultron/README.md +113 -0
  337. data/node_modules/ultron/index.js +136 -0
  338. data/node_modules/ultron/package.json +41 -0
  339. data/node_modules/util-deprecate/History.md +16 -0
  340. data/node_modules/util-deprecate/LICENSE +24 -0
  341. data/node_modules/util-deprecate/README.md +53 -0
  342. data/node_modules/util-deprecate/browser.js +67 -0
  343. data/node_modules/util-deprecate/node.js +6 -0
  344. data/node_modules/util-deprecate/package.json +27 -0
  345. data/node_modules/wrappy/LICENSE +15 -0
  346. data/node_modules/wrappy/README.md +36 -0
  347. data/node_modules/wrappy/package.json +29 -0
  348. data/node_modules/wrappy/wrappy.js +33 -0
  349. data/node_modules/ws/LICENSE +21 -0
  350. data/node_modules/ws/README.md +341 -0
  351. data/node_modules/ws/index.js +15 -0
  352. data/node_modules/ws/lib/BufferUtil.js +71 -0
  353. data/node_modules/ws/lib/Constants.js +10 -0
  354. data/node_modules/ws/lib/ErrorCodes.js +28 -0
  355. data/node_modules/ws/lib/EventTarget.js +151 -0
  356. data/node_modules/ws/lib/Extensions.js +203 -0
  357. data/node_modules/ws/lib/PerMessageDeflate.js +507 -0
  358. data/node_modules/ws/lib/Receiver.js +553 -0
  359. data/node_modules/ws/lib/Sender.js +412 -0
  360. data/node_modules/ws/lib/Validation.js +17 -0
  361. data/node_modules/ws/lib/WebSocket.js +717 -0
  362. data/node_modules/ws/lib/WebSocketServer.js +326 -0
  363. data/node_modules/ws/package.json +46 -0
  364. data/node_modules/yauzl/LICENSE +21 -0
  365. data/node_modules/yauzl/README.md +467 -0
  366. data/node_modules/yauzl/index.js +626 -0
  367. data/node_modules/yauzl/package.json +36 -0
  368. data/package.json +5 -0
  369. data/yarn.lock +240 -0
  370. metadata +372 -7
  371. data/app/assets/stylesheets/default.css +0 -4
  372. data/lib/postdoc/postdoc_view_helper.rb +0 -22
@@ -0,0 +1,997 @@
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};