shaka-player 4.6.4 → 4.7.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 (598) hide show
  1. package/README.md +1 -0
  2. package/dist/controls.css +1 -1
  3. package/dist/controls.css.map +1 -1
  4. package/dist/deps.js +9 -5
  5. package/dist/locales.js +29 -29
  6. package/dist/shaka-player.compiled.d.ts +46 -3
  7. package/dist/shaka-player.compiled.debug.d.ts +46 -3
  8. package/dist/shaka-player.compiled.debug.externs.js +45 -0
  9. package/dist/shaka-player.compiled.debug.js +382 -351
  10. package/dist/shaka-player.compiled.debug.map +4 -4
  11. package/dist/shaka-player.compiled.externs.js +45 -0
  12. package/dist/shaka-player.compiled.js +1135 -1121
  13. package/dist/shaka-player.compiled.map +4 -4
  14. package/dist/shaka-player.ui.d.ts +68 -4
  15. package/dist/shaka-player.ui.debug.d.ts +68 -4
  16. package/dist/shaka-player.ui.debug.externs.js +77 -0
  17. package/dist/shaka-player.ui.debug.js +428 -392
  18. package/dist/shaka-player.ui.debug.map +4 -4
  19. package/dist/shaka-player.ui.externs.js +77 -0
  20. package/dist/shaka-player.ui.js +1304 -1290
  21. package/dist/shaka-player.ui.map +4 -4
  22. package/externs/mediasession.js +7 -0
  23. package/externs/shaka/abr_manager.js +8 -0
  24. package/externs/shaka/manifest.js +3 -3
  25. package/externs/shaka/player.js +59 -4
  26. package/lib/abr/simple_abr_manager.js +41 -15
  27. package/lib/cea/cea708_service.js +1 -1
  28. package/lib/cea/cea708_window.js +95 -7
  29. package/lib/dash/dash_parser.js +55 -11
  30. package/lib/media/adaptation_set_criteria.js +76 -10
  31. package/lib/media/media_source_engine.js +42 -18
  32. package/lib/media/segment_reference.js +12 -0
  33. package/lib/media/streaming_engine.js +55 -3
  34. package/lib/player.js +92 -6
  35. package/lib/util/cmsd_manager.js +269 -0
  36. package/lib/util/content_steering_manager.js +5 -1
  37. package/lib/util/mime_utils.js +6 -2
  38. package/lib/util/periods.js +108 -39
  39. package/lib/util/player_configuration.js +19 -5
  40. package/lib/util/stream_utils.js +82 -13
  41. package/package.json +1 -1
  42. package/ui/audio_language_selection.js +3 -0
  43. package/ui/controls.js +60 -0
  44. package/ui/externs/ui.js +12 -1
  45. package/ui/hidden_fast_forward_button.js +32 -0
  46. package/ui/hidden_rewind_button.js +32 -0
  47. package/ui/hidden_seek_button.js +121 -0
  48. package/ui/less/buttons.less +50 -0
  49. package/ui/less/containers.less +18 -0
  50. package/ui/resolution_selection.js +2 -0
  51. package/ui/ui.js +2 -0
  52. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -75
  53. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -26
  54. package/.github/ISSUE_TEMPLATE/question.md +0 -26
  55. package/.github/config.yml +0 -1
  56. package/.github/workflows/appspot.yaml +0 -39
  57. package/.github/workflows/build-and-test.yaml +0 -222
  58. package/.github/workflows/compute-incremental-coverage.py +0 -265
  59. package/.github/workflows/custom-actions/prep-for-appspot/action.yaml +0 -56
  60. package/.github/workflows/custom-actions/set-commit-status/action.yaml +0 -37
  61. package/.github/workflows/deflake.yaml +0 -31
  62. package/.github/workflows/demo-version-index.yaml +0 -43
  63. package/.github/workflows/nightly-demo.yaml +0 -42
  64. package/.github/workflows/release-please.yaml +0 -193
  65. package/.github/workflows/report-incremental-coverage.yaml +0 -39
  66. package/.github/workflows/safari-homedir-launcher.sh +0 -18
  67. package/.github/workflows/selenium-lab-tests.yaml +0 -370
  68. package/.github/workflows/shaka-bot-commands/command-help.sh +0 -27
  69. package/.github/workflows/shaka-bot-commands/command-test.sh +0 -56
  70. package/.github/workflows/shaka-bot-commands/lib.sh +0 -83
  71. package/.github/workflows/shaka-bot-commands/main.sh +0 -51
  72. package/.github/workflows/sync-labels.yaml +0 -33
  73. package/.github/workflows/talk-to-shaka-bot.yaml +0 -29
  74. package/.github/workflows/update-issues.yaml +0 -31
  75. package/.github/workflows/update-screenshots.yaml +0 -142
  76. package/.github/workflows/validate-pr-title.yaml +0 -27
  77. package/CHANGELOG.md +0 -5774
  78. package/CODE_OF_CONDUCT.md +0 -93
  79. package/CONTRIBUTING.md +0 -76
  80. package/demo/TengwarTelcontar.woff2 +0 -0
  81. package/demo/app_logo_144.png +0 -0
  82. package/demo/app_logo_192.png +0 -0
  83. package/demo/app_logo_256.png +0 -0
  84. package/demo/app_logo_384.png +0 -0
  85. package/demo/app_logo_512.png +0 -0
  86. package/demo/app_manifest.json +0 -29
  87. package/demo/asset_card.js +0 -410
  88. package/demo/autoTemplate.txt +0 -61
  89. package/demo/cast_receiver/idle1.jpg +0 -0
  90. package/demo/cast_receiver/idle2.jpg +0 -0
  91. package/demo/cast_receiver/idle3.jpg +0 -0
  92. package/demo/cast_receiver/index.html +0 -75
  93. package/demo/cast_receiver/receiver_app.css +0 -111
  94. package/demo/cast_receiver/receiver_app.js +0 -158
  95. package/demo/close_button.js +0 -60
  96. package/demo/common/asset.js +0 -510
  97. package/demo/common/assets.js +0 -1634
  98. package/demo/config.js +0 -859
  99. package/demo/custom.js +0 -907
  100. package/demo/customWarning.txt +0 -8
  101. package/demo/demo.less +0 -591
  102. package/demo/demo_uncompiled.js +0 -11
  103. package/demo/demo_utils.js +0 -113
  104. package/demo/favicon.ico +0 -0
  105. package/demo/front.js +0 -156
  106. package/demo/icons/README.md +0 -4
  107. package/demo/icons/baseline-audiotrack-24px.svg +0 -1
  108. package/demo/icons/baseline-closed_caption-24px.svg +0 -1
  109. package/demo/icons/baseline-fast_forward-24px.svg +0 -1
  110. package/demo/icons/baseline-language-24px.svg +0 -1
  111. package/demo/icons/baseline-live_tv-24px.svg +0 -1
  112. package/demo/icons/baseline-subtitles-24px.svg +0 -1
  113. package/demo/icons/baseline-surround_sound-24px.svg +0 -1
  114. package/demo/icons/custom_ad.svg +0 -1
  115. package/demo/icons/custom_box_with_text.svg +0 -1
  116. package/demo/icons/custom_clear_key.svg +0 -1
  117. package/demo/icons/custom_high_definition.svg +0 -1
  118. package/demo/icons/custom_playready.svg +0 -1
  119. package/demo/icons/custom_ultra_high_definition.svg +0 -1
  120. package/demo/icons/custom_widevine.svg +0 -1
  121. package/demo/index.html +0 -173
  122. package/demo/input.js +0 -270
  123. package/demo/input_container.js +0 -218
  124. package/demo/load.js +0 -156
  125. package/demo/main.js +0 -1854
  126. package/demo/search.js +0 -452
  127. package/demo/service_worker.js +0 -355
  128. package/demo/shaka_logo_trans.png +0 -0
  129. package/demo/tooltip.js +0 -29
  130. package/demo/visualizer.js +0 -335
  131. package/demo/visualizer_button.js +0 -84
  132. package/dist/demo.compiled.debug.js +0 -340
  133. package/dist/demo.compiled.debug.map +0 -8
  134. package/dist/demo.compiled.js +0 -340
  135. package/dist/demo.compiled.map +0 -8
  136. package/dist/demo.css +0 -6
  137. package/dist/demo.css.map +0 -1
  138. package/dist/receiver.compiled.debug.js +0 -187
  139. package/dist/receiver.compiled.debug.map +0 -8
  140. package/dist/receiver.compiled.js +0 -187
  141. package/dist/receiver.compiled.map +0 -8
  142. package/docs/announcement-list-join-group.png +0 -0
  143. package/docs/api-mainpage.md +0 -28
  144. package/docs/design/REDESIGN.md +0 -283
  145. package/docs/design/architecture.md +0 -13
  146. package/docs/design/bg-fetch-after.gv +0 -29
  147. package/docs/design/bg-fetch-after.gv.png +0 -0
  148. package/docs/design/bg-fetch-before.gv +0 -18
  149. package/docs/design/bg-fetch-before.gv.png +0 -0
  150. package/docs/design/bg-fetch.md +0 -134
  151. package/docs/design/cast.gv +0 -35
  152. package/docs/design/cast.gv.png +0 -0
  153. package/docs/design/chromecast.md +0 -151
  154. package/docs/design/codec_preferences.md +0 -158
  155. package/docs/design/dash-audio-channels.md +0 -123
  156. package/docs/design/dash-manifests.md +0 -248
  157. package/docs/design/dash-timeline.svg +0 -4
  158. package/docs/design/dataflow.gv +0 -66
  159. package/docs/design/dataflow.gv.png +0 -0
  160. package/docs/design/export.md +0 -70
  161. package/docs/design/fuzzy-locale-matching.md +0 -40
  162. package/docs/design/gap-jumping.md +0 -151
  163. package/docs/design/lcevc-architecture.png +0 -0
  164. package/docs/design/lcevc-demo.png +0 -0
  165. package/docs/design/lcevc-integration.md +0 -72
  166. package/docs/design/locale_compatibility.svg +0 -1
  167. package/docs/design/locales_tree.svg +0 -1
  168. package/docs/design/localization-design-principles.md +0 -158
  169. package/docs/design/newdemo.gv +0 -83
  170. package/docs/design/newdemo.gv.png +0 -0
  171. package/docs/design/offline.gv +0 -43
  172. package/docs/design/offline.gv.png +0 -0
  173. package/docs/design/offline.md +0 -153
  174. package/docs/design/ownership.gv +0 -76
  175. package/docs/design/ownership.gv.png +0 -0
  176. package/docs/design/preload.md +0 -299
  177. package/docs/design/preload.png +0 -0
  178. package/docs/design/talking-about-languages.md +0 -46
  179. package/docs/design/timeline.svg +0 -152
  180. package/docs/design/ui.md +0 -31
  181. package/docs/design/ui_player_relationships.svg +0 -1
  182. package/docs/jsdoc-plugin.js +0 -74
  183. package/docs/jsdoc-template/README.md +0 -1
  184. package/docs/jsdoc-template/publish.js +0 -879
  185. package/docs/jsdoc-template/static/fonts/OpenSans-Bold-webfont.eot +0 -0
  186. package/docs/jsdoc-template/static/fonts/OpenSans-Bold-webfont.svg +0 -1830
  187. package/docs/jsdoc-template/static/fonts/OpenSans-Bold-webfont.woff +0 -0
  188. package/docs/jsdoc-template/static/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  189. package/docs/jsdoc-template/static/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
  190. package/docs/jsdoc-template/static/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  191. package/docs/jsdoc-template/static/fonts/OpenSans-Italic-webfont.eot +0 -0
  192. package/docs/jsdoc-template/static/fonts/OpenSans-Italic-webfont.svg +0 -1830
  193. package/docs/jsdoc-template/static/fonts/OpenSans-Italic-webfont.woff +0 -0
  194. package/docs/jsdoc-template/static/fonts/OpenSans-Light-webfont.eot +0 -0
  195. package/docs/jsdoc-template/static/fonts/OpenSans-Light-webfont.svg +0 -1831
  196. package/docs/jsdoc-template/static/fonts/OpenSans-Light-webfont.woff +0 -0
  197. package/docs/jsdoc-template/static/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  198. package/docs/jsdoc-template/static/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
  199. package/docs/jsdoc-template/static/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  200. package/docs/jsdoc-template/static/fonts/OpenSans-Regular-webfont.eot +0 -0
  201. package/docs/jsdoc-template/static/fonts/OpenSans-Regular-webfont.svg +0 -1831
  202. package/docs/jsdoc-template/static/fonts/OpenSans-Regular-webfont.woff +0 -0
  203. package/docs/jsdoc-template/static/scripts/linenumber.js +0 -44
  204. package/docs/jsdoc-template/static/scripts/show-widget.js +0 -55
  205. package/docs/jsdoc-template/static/styles/jsdoc-default.css +0 -438
  206. package/docs/jsdoc-template/tmpl/augments.tmpl +0 -10
  207. package/docs/jsdoc-template/tmpl/container.tmpl +0 -205
  208. package/docs/jsdoc-template/tmpl/details.tmpl +0 -152
  209. package/docs/jsdoc-template/tmpl/example.tmpl +0 -2
  210. package/docs/jsdoc-template/tmpl/examples.tmpl +0 -13
  211. package/docs/jsdoc-template/tmpl/exceptions.tmpl +0 -32
  212. package/docs/jsdoc-template/tmpl/layout.tmpl +0 -50
  213. package/docs/jsdoc-template/tmpl/mainpage.tmpl +0 -14
  214. package/docs/jsdoc-template/tmpl/members.tmpl +0 -47
  215. package/docs/jsdoc-template/tmpl/method.tmpl +0 -140
  216. package/docs/jsdoc-template/tmpl/modifies.tmpl +0 -14
  217. package/docs/jsdoc-template/tmpl/params.tmpl +0 -131
  218. package/docs/jsdoc-template/tmpl/properties.tmpl +0 -125
  219. package/docs/jsdoc-template/tmpl/returns.tmpl +0 -19
  220. package/docs/jsdoc-template/tmpl/source.tmpl +0 -8
  221. package/docs/jsdoc-template/tmpl/tutorial.tmpl +0 -21
  222. package/docs/jsdoc-template/tmpl/type.tmpl +0 -7
  223. package/docs/jsdoc.conf.json +0 -38
  224. package/docs/shaka-player-logo.png +0 -0
  225. package/docs/style.md +0 -174
  226. package/docs/tutorials/a11y.md +0 -64
  227. package/docs/tutorials/ad_monetization.md +0 -292
  228. package/docs/tutorials/application-level-redirects.md +0 -94
  229. package/docs/tutorials/architecture.md +0 -32
  230. package/docs/tutorials/basic-usage.md +0 -89
  231. package/docs/tutorials/blob-url.md +0 -15
  232. package/docs/tutorials/config.md +0 -148
  233. package/docs/tutorials/debugging.md +0 -189
  234. package/docs/tutorials/drm-config.md +0 -274
  235. package/docs/tutorials/errors.md +0 -95
  236. package/docs/tutorials/fairplay.md +0 -242
  237. package/docs/tutorials/faq.md +0 -252
  238. package/docs/tutorials/index.json +0 -29
  239. package/docs/tutorials/lcevc.md +0 -118
  240. package/docs/tutorials/license-server-auth.md +0 -248
  241. package/docs/tutorials/license-wrapping.md +0 -168
  242. package/docs/tutorials/manifest-parser.md +0 -365
  243. package/docs/tutorials/network-and-buffering-config.md +0 -119
  244. package/docs/tutorials/offline.md +0 -683
  245. package/docs/tutorials/plugins.md +0 -184
  246. package/docs/tutorials/selenium-grid-config.md +0 -174
  247. package/docs/tutorials/service-worker.md +0 -106
  248. package/docs/tutorials/ui-customization.md +0 -288
  249. package/docs/tutorials/ui.md +0 -232
  250. package/docs/tutorials/upgrade-manifest.md +0 -281
  251. package/docs/tutorials/upgrade.md +0 -104
  252. package/docs/tutorials/welcome.md +0 -108
  253. package/docs/tutorials/widevine-service-certs.md +0 -45
  254. package/karma.conf.js +0 -879
  255. package/maintained-branches.md +0 -15
  256. package/roadmap.md +0 -186
  257. package/test/abr/simple_abr_manager_unit.js +0 -398
  258. package/test/ads/ad_manager_unit.js +0 -260
  259. package/test/assumptions/uint8_array_unit.js +0 -22
  260. package/test/cast/cast_proxy_unit.js +0 -736
  261. package/test/cast/cast_receiver_integration.js +0 -488
  262. package/test/cast/cast_receiver_unit.js +0 -1183
  263. package/test/cast/cast_sender_unit.js +0 -973
  264. package/test/cast/cast_utils_unit.js +0 -311
  265. package/test/cea/cea608_memory_unit.js +0 -411
  266. package/test/cea/cea708_service_unit.js +0 -674
  267. package/test/cea/cea708_window_unit.js +0 -373
  268. package/test/cea/cea_decoder_unit.js +0 -615
  269. package/test/cea/dtvcc_packet_builder_unit.js +0 -158
  270. package/test/cea/dtvcc_packet_unit.js +0 -60
  271. package/test/cea/mp4_cea_parser_unit.js +0 -127
  272. package/test/codec_switching/codec_switching_integration.js +0 -182
  273. package/test/dash/dash_parser_content_protection_unit.js +0 -998
  274. package/test/dash/dash_parser_integration.js +0 -74
  275. package/test/dash/dash_parser_live_unit.js +0 -1542
  276. package/test/dash/dash_parser_manifest_unit.js +0 -3121
  277. package/test/dash/dash_parser_segment_base_unit.js +0 -421
  278. package/test/dash/dash_parser_segment_list_unit.js +0 -380
  279. package/test/dash/dash_parser_segment_template_unit.js +0 -910
  280. package/test/dash/mpd_utils_unit.js +0 -794
  281. package/test/demo/demo_unit.js +0 -108
  282. package/test/deprecate/enforcer_unit.js +0 -74
  283. package/test/deprecate/version_unit.js +0 -57
  284. package/test/hls/hls_live_unit.js +0 -1330
  285. package/test/hls/hls_parser_unit.js +0 -5276
  286. package/test/hls/manifest_text_parser_unit.js +0 -545
  287. package/test/media/adaptation_set_criteria_unit.js +0 -806
  288. package/test/media/adaptation_set_unit.js +0 -229
  289. package/test/media/buffering_observer_unit.js +0 -143
  290. package/test/media/closed_caption_parser_unit.js +0 -18
  291. package/test/media/content_workarounds_unit.js +0 -43
  292. package/test/media/drm_engine_integration.js +0 -356
  293. package/test/media/drm_engine_unit.js +0 -2805
  294. package/test/media/media_source_engine_integration.js +0 -691
  295. package/test/media/media_source_engine_unit.js +0 -1512
  296. package/test/media/mp4_segment_index_parser_unit.js +0 -80
  297. package/test/media/play_rate_controller_unit.js +0 -69
  298. package/test/media/playhead_unit.js +0 -1394
  299. package/test/media/presentation_timeline_unit.js +0 -477
  300. package/test/media/quality_observer_unit.js +0 -138
  301. package/test/media/region_observer_unit.js +0 -374
  302. package/test/media/region_timeline_unit.js +0 -139
  303. package/test/media/segment_index_unit.js +0 -1080
  304. package/test/media/segment_prefetch_unit.js +0 -243
  305. package/test/media/segment_reference_unit.js +0 -63
  306. package/test/media/stall_detector_unit.js +0 -184
  307. package/test/media/streaming_engine_integration.js +0 -632
  308. package/test/media/streaming_engine_unit.js +0 -4211
  309. package/test/media/time_ranges_utils_unit.js +0 -123
  310. package/test/media/webm_segment_index_parser_unit.js +0 -90
  311. package/test/mss/mss_parser_content_protection_unit.js +0 -49
  312. package/test/mss/mss_parser_unit.js +0 -474
  313. package/test/mss/mss_player_integration.js +0 -124
  314. package/test/net/data_uri_plugin_unit.js +0 -105
  315. package/test/net/http_plugin_unit.js +0 -439
  316. package/test/net/networking_engine_unit.js +0 -1236
  317. package/test/net/networking_utils_unit.js +0 -37
  318. package/test/offline/download_progress_estimator_unit.js +0 -90
  319. package/test/offline/indexeddb_storage_unit.js +0 -192
  320. package/test/offline/manifest_convert_unit.js +0 -622
  321. package/test/offline/offline_integration.js +0 -168
  322. package/test/offline/offline_manifest_parser_unit.js +0 -231
  323. package/test/offline/offline_scheme_unit.js +0 -154
  324. package/test/offline/offline_uri_unit.js +0 -59
  325. package/test/offline/storage_compatibility_unit.js +0 -344
  326. package/test/offline/storage_integration.js +0 -1858
  327. package/test/player_external.js +0 -237
  328. package/test/player_integration.js +0 -1371
  329. package/test/player_load_graph_integration.js +0 -865
  330. package/test/player_src_equals_external.js +0 -154
  331. package/test/player_src_equals_integration.js +0 -527
  332. package/test/player_unit.js +0 -4434
  333. package/test/polyfill/media_capabilities_unit.js +0 -277
  334. package/test/polyfill/patchedmediakeys_apple_unit.js +0 -130
  335. package/test/test/assets/3675/chunk-stream0-00001.m4s +0 -0
  336. package/test/test/assets/3675/chunk-stream0-00002.m4s +0 -0
  337. package/test/test/assets/3675/chunk-stream0-00003.m4s +0 -0
  338. package/test/test/assets/3675/chunk-stream0-00004.m4s +0 -0
  339. package/test/test/assets/3675/chunk-stream0-00005.m4s +0 -0
  340. package/test/test/assets/3675/chunk-stream0-00006.m4s +0 -0
  341. package/test/test/assets/3675/chunk-stream0-00007.m4s +0 -0
  342. package/test/test/assets/3675/dash_0.mpd +0 -30
  343. package/test/test/assets/3675/dash_1.mpd +0 -30
  344. package/test/test/assets/3675/dash_2.mpd +0 -30
  345. package/test/test/assets/3675/dash_3.mpd +0 -30
  346. package/test/test/assets/3675/dash_4.mpd +0 -30
  347. package/test/test/assets/3675/dash_5.mpd +0 -26
  348. package/test/test/assets/3675/init-stream0.m4s +0 -0
  349. package/test/test/assets/audio-xhe-aac.mp4 +0 -0
  350. package/test/test/assets/audio.ts +0 -0
  351. package/test/test/assets/captions-test.ts +0 -0
  352. package/test/test/assets/cea-init.mp4 +0 -0
  353. package/test/test/assets/cea-segment.mp4 +0 -0
  354. package/test/test/assets/chapters.srt +0 -11
  355. package/test/test/assets/chapters.vtt +0 -10
  356. package/test/test/assets/chapters2.vtt +0 -10
  357. package/test/test/assets/dash-aes-128/Fragments(video=0,format=mpd-time-csf) +0 -0
  358. package/test/test/assets/dash-aes-128/Fragments(video=20000000,format=mpd-time-csf) +0 -0
  359. package/test/test/assets/dash-aes-128/Fragments(video=40000000,format=mpd-time-csf) +0 -0
  360. package/test/test/assets/dash-aes-128/Fragments(video=60000000,format=mpd-time-csf) +0 -0
  361. package/test/test/assets/dash-aes-128/Fragments(video=i,format=mpd-time-csf) +0 -0
  362. package/test/test/assets/dash-aes-128/dash.mpd +0 -18
  363. package/test/test/assets/dash-aes-128/license +0 -1
  364. package/test/test/assets/dash-multi-codec/audio_en_2c_128k_aac.mp4 +0 -0
  365. package/test/test/assets/dash-multi-codec/audio_es_2c_64k_opus.webm +0 -0
  366. package/test/test/assets/dash-multi-codec/dash.mpd +0 -32
  367. package/test/test/assets/dash-multi-codec/video_144p_108k_h264.mp4 +0 -0
  368. package/test/test/assets/db-dump-v1.json +0 -1
  369. package/test/test/assets/db-dump-v2-broken.json +0 -1
  370. package/test/test/assets/db-dump-v2-clean.json +0 -1
  371. package/test/test/assets/db-dump-v3.json +0 -1
  372. package/test/test/assets/db-dump-v4-broken.json +0 -1
  373. package/test/test/assets/db-dump-v5.json +0 -1
  374. package/test/test/assets/empty_caption_video_init.mp4 +0 -0
  375. package/test/test/assets/empty_caption_video_segment.mp4 +0 -0
  376. package/test/test/assets/encrypted-sintel-audio-init.mp4 +0 -0
  377. package/test/test/assets/encrypted-sintel-audio-segment.mp4 +0 -0
  378. package/test/test/assets/encrypted-sintel-video-init.mp4 +0 -0
  379. package/test/test/assets/encrypted-sintel-video-segment.mp4 +0 -0
  380. package/test/test/assets/green-pixel.mp4 +0 -0
  381. package/test/test/assets/green-pixel.txt +0 -15
  382. package/test/test/assets/h265-cea-init.mp4 +0 -0
  383. package/test/test/assets/h265-cea-segment.mp4 +0 -0
  384. package/test/test/assets/hls-raw-aac/fileSequence0.aac +0 -0
  385. package/test/test/assets/hls-raw-aac/fileSequence1.aac +0 -0
  386. package/test/test/assets/hls-raw-aac/fileSequence2.aac +0 -0
  387. package/test/test/assets/hls-raw-aac/fileSequence3.aac +0 -0
  388. package/test/test/assets/hls-raw-aac/manifest.m3u8 +0 -4
  389. package/test/test/assets/hls-raw-aac/stream.m4a.m3u8 +0 -14
  390. package/test/test/assets/hls-raw-ac3/fileSequence0.ac3 +0 -0
  391. package/test/test/assets/hls-raw-ac3/fileSequence1.ac3 +0 -0
  392. package/test/test/assets/hls-raw-ac3/fileSequence2.ac3 +0 -0
  393. package/test/test/assets/hls-raw-ac3/fileSequence3.ac3 +0 -0
  394. package/test/test/assets/hls-raw-ac3/fileSequence4.ac3 +0 -0
  395. package/test/test/assets/hls-raw-ac3/fileSequence5.ac3 +0 -0
  396. package/test/test/assets/hls-raw-ac3/fileSequence6.ac3 +0 -0
  397. package/test/test/assets/hls-raw-ac3/fileSequence7.ac3 +0 -0
  398. package/test/test/assets/hls-raw-ac3/prog_index.m3u8 +0 -31
  399. package/test/test/assets/hls-raw-ec3/fileSequence0.ec3 +0 -0
  400. package/test/test/assets/hls-raw-ec3/fileSequence1.ec3 +0 -0
  401. package/test/test/assets/hls-raw-ec3/fileSequence2.ec3 +0 -0
  402. package/test/test/assets/hls-raw-ec3/fileSequence3.ec3 +0 -0
  403. package/test/test/assets/hls-raw-ec3/fileSequence4.ec3 +0 -0
  404. package/test/test/assets/hls-raw-ec3/fileSequence5.ec3 +0 -0
  405. package/test/test/assets/hls-raw-ec3/fileSequence6.ec3 +0 -0
  406. package/test/test/assets/hls-raw-ec3/fileSequence7.ec3 +0 -0
  407. package/test/test/assets/hls-raw-ec3/prog_index.m3u8 +0 -31
  408. package/test/test/assets/hls-raw-mp3/chunklist_w905519204.m3u8 +0 -13
  409. package/test/test/assets/hls-raw-mp3/media_w905519204_0.mp3 +0 -0
  410. package/test/test/assets/hls-raw-mp3/media_w905519204_1.mp3 +0 -0
  411. package/test/test/assets/hls-raw-mp3/media_w905519204_2.mp3 +0 -0
  412. package/test/test/assets/hls-raw-mp3/media_w905519204_3.mp3 +0 -0
  413. package/test/test/assets/hls-raw-mp3/playlist.m3u8 +0 -4
  414. package/test/test/assets/hls-ts-aac/playlist.m3u8 +0 -23
  415. package/test/test/assets/hls-ts-aac/segment_0.ts +0 -0
  416. package/test/test/assets/hls-ts-aac/segment_1.ts +0 -0
  417. package/test/test/assets/hls-ts-aac/segment_2.ts +0 -0
  418. package/test/test/assets/hls-ts-aac/segment_3.ts +0 -0
  419. package/test/test/assets/hls-ts-aac/segment_4.ts +0 -0
  420. package/test/test/assets/hls-ts-aac/segment_5.ts +0 -0
  421. package/test/test/assets/hls-ts-aac/segment_6.ts +0 -0
  422. package/test/test/assets/hls-ts-aac/segment_7.ts +0 -0
  423. package/test/test/assets/hls-ts-ac3/ChID_voices_6ch_640kbps_dd_sub_0000.ts +0 -0
  424. package/test/test/assets/hls-ts-ac3/ChID_voices_6ch_640kbps_dd_sub_0001.ts +0 -0
  425. package/test/test/assets/hls-ts-ac3/ChID_voices_6ch_640kbps_dd_sub_0002.ts +0 -0
  426. package/test/test/assets/hls-ts-ac3/ChID_voices_6ch_640kbps_dd_sub_0003.ts +0 -0
  427. package/test/test/assets/hls-ts-ac3/ChID_voices_6ch_640kbps_dd_sub_0004.ts +0 -0
  428. package/test/test/assets/hls-ts-ac3/ChID_voices_6ch_640kbps_dd_sub_0005.ts +0 -0
  429. package/test/test/assets/hls-ts-ac3/prog_index.m3u8 +0 -19
  430. package/test/test/assets/hls-ts-ec3/ChID_voices_6ch_256kbps_ddp_sub_0000.ts +0 -0
  431. package/test/test/assets/hls-ts-ec3/ChID_voices_6ch_256kbps_ddp_sub_0001.ts +0 -0
  432. package/test/test/assets/hls-ts-ec3/ChID_voices_6ch_256kbps_ddp_sub_0002.ts +0 -0
  433. package/test/test/assets/hls-ts-ec3/ChID_voices_6ch_256kbps_ddp_sub_0003.ts +0 -0
  434. package/test/test/assets/hls-ts-ec3/ChID_voices_6ch_256kbps_ddp_sub_0004.ts +0 -0
  435. package/test/test/assets/hls-ts-ec3/ChID_voices_6ch_256kbps_ddp_sub_0005.ts +0 -0
  436. package/test/test/assets/hls-ts-ec3/prog_index.m3u8 +0 -19
  437. package/test/test/assets/hls-ts-h264/fileSequence0.ts +0 -0
  438. package/test/test/assets/hls-ts-h264/fileSequence1.ts +0 -0
  439. package/test/test/assets/hls-ts-h264/fileSequence2.ts +0 -0
  440. package/test/test/assets/hls-ts-h264/fileSequence3.ts +0 -0
  441. package/test/test/assets/hls-ts-h264/fileSequence4.ts +0 -0
  442. package/test/test/assets/hls-ts-h264/fileSequence5.ts +0 -0
  443. package/test/test/assets/hls-ts-h264/prog_index.m3u8 +0 -25
  444. package/test/test/assets/hls-ts-h265/0.ts +0 -0
  445. package/test/test/assets/hls-ts-h265/hevc.m3u8 +0 -6
  446. package/test/test/assets/hls-ts-h265/index.m3u8 +0 -7
  447. package/test/test/assets/hls-ts-mp3/manifest.m3u8 +0 -13
  448. package/test/test/assets/hls-ts-mp3/media_w239891843_0.ts +0 -0
  449. package/test/test/assets/hls-ts-mp3/media_w239891843_1.ts +0 -0
  450. package/test/test/assets/hls-ts-mp3/media_w239891843_2.ts +0 -0
  451. package/test/test/assets/hls-ts-mp3/media_w239891843_3.ts +0 -0
  452. package/test/test/assets/hls-ts-muxed-aac-h264/chunk.m3u8 +0 -17
  453. package/test/test/assets/hls-ts-muxed-aac-h264/n_0_0_0.ts +0 -0
  454. package/test/test/assets/hls-ts-muxed-aac-h264/n_1_0_0.ts +0 -0
  455. package/test/test/assets/hls-ts-muxed-aac-h264/n_2_0_0.ts +0 -0
  456. package/test/test/assets/hls-ts-muxed-aac-h264/n_3_0_0.ts +0 -0
  457. package/test/test/assets/hls-ts-muxed-aac-h264/n_4_0_0.ts +0 -0
  458. package/test/test/assets/hls-ts-muxed-aac-h264/n_5_0_0.ts +0 -0
  459. package/test/test/assets/hls-ts-muxed-aac-h264/playlist.m3u8 +0 -4
  460. package/test/test/assets/hls-ts-muxed-aac-h265/0.ts +0 -0
  461. package/test/test/assets/hls-ts-muxed-aac-h265/1.ts +0 -0
  462. package/test/test/assets/hls-ts-muxed-aac-h265/media.m3u8 +0 -9
  463. package/test/test/assets/hls-ts-muxed-ac3-h264/media.m3u8 +0 -24
  464. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00000.ts +0 -0
  465. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00001.ts +0 -0
  466. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00002.ts +0 -0
  467. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00003.ts +0 -0
  468. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00004.ts +0 -0
  469. package/test/test/assets/hls-ts-muxed-ac3-h264/s_00005.ts +0 -0
  470. package/test/test/assets/hls-ts-muxed-ec3-h264/ChID_voices_1280x720p_25fps_h264_6ch_256kbps_ddp_sub_0000.ts +0 -0
  471. package/test/test/assets/hls-ts-muxed-ec3-h264/ChID_voices_1280x720p_25fps_h264_6ch_256kbps_ddp_sub_0001.ts +0 -0
  472. package/test/test/assets/hls-ts-muxed-ec3-h264/ChID_voices_1280x720p_25fps_h264_6ch_256kbps_ddp_sub_0002.ts +0 -0
  473. package/test/test/assets/hls-ts-muxed-ec3-h264/ChID_voices_1280x720p_25fps_h264_6ch_256kbps_ddp_sub_0003.ts +0 -0
  474. package/test/test/assets/hls-ts-muxed-ec3-h264/prog_index.m3u8 +0 -14
  475. package/test/test/assets/hls-ts-muxed-mp3-h264/index.m3u8 +0 -23
  476. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-1-v1-a1.ts +0 -0
  477. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-2-v1-a1.ts +0 -0
  478. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-3-v1-a1.ts +0 -0
  479. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-4-v1-a1.ts +0 -0
  480. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-5-v1-a1.ts +0 -0
  481. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-6-v1-a1.ts +0 -0
  482. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-7-v1-a1.ts +0 -0
  483. package/test/test/assets/hls-ts-muxed-mp3-h264/seg-8-v1-a1.ts +0 -0
  484. package/test/test/assets/id3-metadata.aac +0 -0
  485. package/test/test/assets/id3-metadata.ts +0 -0
  486. package/test/test/assets/index-segment.mp4 +0 -0
  487. package/test/test/assets/index-segment.webm +0 -0
  488. package/test/test/assets/init-segment.webm +0 -0
  489. package/test/test/assets/large_file.mpd +0 -4930
  490. package/test/test/assets/multidrm-audio-init.mp4 +0 -0
  491. package/test/test/assets/multidrm-audio-segment.mp4 +0 -0
  492. package/test/test/assets/multidrm-video-init.mp4 +0 -0
  493. package/test/test/assets/multidrm-video-segment.mp4 +0 -0
  494. package/test/test/assets/multiple-trun-init.mp4 +0 -0
  495. package/test/test/assets/multiple-trun-segment.mp4 +0 -0
  496. package/test/test/assets/sintel-audio-init.mp4 +0 -0
  497. package/test/test/assets/sintel-audio-segment.mp4 +0 -0
  498. package/test/test/assets/sintel-video-init.mp4 +0 -0
  499. package/test/test/assets/sintel-video-segment.mp4 +0 -0
  500. package/test/test/assets/small.mp4 +0 -0
  501. package/test/test/assets/text-clip-alt.vtt +0 -63
  502. package/test/test/assets/text-clip.vtt +0 -63
  503. package/test/test/assets/thumbnails-sprites.vtt +0 -10
  504. package/test/test/assets/thumbnails.vtt +0 -10
  505. package/test/test/assets/ttml-init.mp4 +0 -0
  506. package/test/test/assets/ttml-segment-multiplemdat.mp4 +0 -0
  507. package/test/test/assets/ttml-segment.mp4 +0 -0
  508. package/test/test/assets/video.ts +0 -0
  509. package/test/test/assets/vtt-init.mp4 +0 -0
  510. package/test/test/assets/vtt-segment-multi-payload.mp4 +0 -0
  511. package/test/test/assets/vtt-segment-no-duration.mp4 +0 -0
  512. package/test/test/assets/vtt-segment-settings.mp4 +0 -0
  513. package/test/test/assets/vtt-segment.mp4 +0 -0
  514. package/test/test/boot.js +0 -495
  515. package/test/test/externs/filters.js +0 -44
  516. package/test/test/externs/fontfaceonload.js +0 -29
  517. package/test/test/externs/jasmine.js +0 -670
  518. package/test/test/externs/karma.js +0 -26
  519. package/test/test/externs/require.js +0 -21
  520. package/test/test/externs/sprintf.js +0 -18
  521. package/test/test/namespace.js +0 -10
  522. package/test/test/util/canned_idb.js +0 -379
  523. package/test/test/util/cea_utils.js +0 -60
  524. package/test/test/util/dash_parser_util.js +0 -329
  525. package/test/test/util/fake_ad.js +0 -321
  526. package/test/test/util/fake_ad_manager.js +0 -122
  527. package/test/test/util/fake_demo_main.js +0 -144
  528. package/test/test/util/fake_drm_engine.js +0 -103
  529. package/test/test/util/fake_media_source_engine.js +0 -464
  530. package/test/test/util/fake_networking_engine.js +0 -381
  531. package/test/test/util/fake_segment_prefetch.js +0 -84
  532. package/test/test/util/fake_text_displayer.js +0 -60
  533. package/test/test/util/id3_generator.js +0 -100
  534. package/test/test/util/indexeddb_utils.js +0 -124
  535. package/test/test/util/jasmine_fetch.js +0 -382
  536. package/test/test/util/layout_tests.js +0 -435
  537. package/test/test/util/loader.js +0 -88
  538. package/test/test/util/manifest_generator.js +0 -705
  539. package/test/test/util/manifest_parser_util.js +0 -101
  540. package/test/test/util/mss_parser_util.js +0 -119
  541. package/test/test/util/offline_utils.js +0 -105
  542. package/test/test/util/simple_fakes.js +0 -535
  543. package/test/test/util/stream_generator.js +0 -676
  544. package/test/test/util/streaming_engine_util.js +0 -506
  545. package/test/test/util/test_scheme.js +0 -778
  546. package/test/test/util/ttml_utils.js +0 -77
  547. package/test/test/util/ui_utils.js +0 -183
  548. package/test/test/util/util.js +0 -374
  549. package/test/test/util/waiter.js +0 -406
  550. package/test/text/cue_integration.js +0 -51
  551. package/test/text/lrc_text_parser_unit.js +0 -98
  552. package/test/text/mp4_ttml_parser_unit.js +0 -171
  553. package/test/text/mp4_vtt_parser_unit.js +0 -195
  554. package/test/text/sbv_text_parser_unit.js +0 -81
  555. package/test/text/simple_text_displayer_unit.js +0 -468
  556. package/test/text/srt_text_parser_unit.js +0 -163
  557. package/test/text/ssa_text_parser_unit.js +0 -382
  558. package/test/text/text_displayer_layout_unit.js +0 -323
  559. package/test/text/text_engine_unit.js +0 -500
  560. package/test/text/text_track_integration.js +0 -186
  561. package/test/text/ttml_text_parser_unit.js +0 -2176
  562. package/test/text/ui_text_displayer_unit.js +0 -608
  563. package/test/text/vtt_text_parser_unit.js +0 -1363
  564. package/test/text/web_vtt_generator_unit.js +0 -144
  565. package/test/text/web_vtt_layout_integration.js +0 -524
  566. package/test/transmuxer/transmuxer_engine_integration.js +0 -69
  567. package/test/transmuxer/transmuxer_integration.js +0 -443
  568. package/test/ui/ad_ui_unit.js +0 -369
  569. package/test/ui/localization_unit.js +0 -508
  570. package/test/ui/ui_customization_unit.js +0 -208
  571. package/test/ui/ui_integration.js +0 -669
  572. package/test/ui/ui_unit.js +0 -902
  573. package/test/util/abortable_operation_unit.js +0 -624
  574. package/test/util/array_utils_unit.js +0 -58
  575. package/test/util/buffer_utils_unit.js +0 -185
  576. package/test/util/cmcd_manager_unit.js +0 -440
  577. package/test/util/content_steering_manager_unit.js +0 -427
  578. package/test/util/data_view_reader_unit.js +0 -254
  579. package/test/util/ebml_parser_unit.js +0 -297
  580. package/test/util/event_manager_unit.js +0 -185
  581. package/test/util/fake_event_target_unit.js +0 -123
  582. package/test/util/id3_utils_unit.js +0 -168
  583. package/test/util/iterables_unit.js +0 -68
  584. package/test/util/language_utils_unit.js +0 -240
  585. package/test/util/manifest_parser_utils_unit.js +0 -55
  586. package/test/util/mime_utils_unit.js +0 -64
  587. package/test/util/mp4_box_parsers_unit.js +0 -246
  588. package/test/util/mp4_parser_unit.js +0 -373
  589. package/test/util/multi_map_unit.js +0 -94
  590. package/test/util/object_utils_unit.js +0 -79
  591. package/test/util/periods_unit.js +0 -1623
  592. package/test/util/pssh_unit.js +0 -226
  593. package/test/util/state_history_unit.js +0 -101
  594. package/test/util/stream_utils_unit.js +0 -1068
  595. package/test/util/string_utils_unit.js +0 -166
  596. package/test/util/text_parser_unit.js +0 -165
  597. package/test/util/ts_parser_unit.js +0 -77
  598. package/test/util/xml_utils_unit.js +0 -444
package/karma.conf.js DELETED
@@ -1,879 +0,0 @@
1
- /*! @license
2
- * Shaka Player
3
- * Copyright 2016 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- // Karma configuration
8
- // Install required modules by running "npm install"
9
-
10
- // lodash is an indirect dependency, depended on by Karma
11
- const _ = require('lodash');
12
- const fs = require('fs');
13
- const glob = require('glob');
14
- const Jimp = require('jimp');
15
- const path = require('path');
16
- const rimraf = require('rimraf');
17
- const {ssim} = require('ssim.js');
18
- const util = require('karma/common/util');
19
- const which = require('which');
20
- const yaml = require('js-yaml');
21
-
22
- /**
23
- * Like Object.assign, but recursive and doesn't clobber objects and arrays.
24
- * If two arrays are merged, they are concatenated.
25
- * Ex:
26
- * mergeConfigs({ foo: 'bar', args: [1, 2, 3] },
27
- * { baz: 'blah', args: [4, 5, 6] })
28
- * => { foo: 'bar', baz: 'blah', args: [1, 2, 3, 4, 5, 6] }
29
- *
30
- * @param {Object} first
31
- * @param {Object} second
32
- * @return {Object}
33
- */
34
- function mergeConfigs(first, second) {
35
- return _.mergeWith(
36
- first,
37
- second,
38
- (firstValue, secondValue) => {
39
- // Merge arrays by concatenation.
40
- if (Array.isArray(firstValue)) {
41
- return firstValue.concat(secondValue);
42
- }
43
- // Use lodash's default merge behavior for everything else.
44
- return undefined;
45
- });
46
- }
47
-
48
- /**
49
- * @param {Object} config
50
- */
51
- module.exports = (config) => {
52
- const SHAKA_LOG_MAP = {
53
- none: 0,
54
- error: 1,
55
- warning: 2,
56
- info: 3,
57
- debug: 4,
58
- v1: 5,
59
- v2: 6,
60
- };
61
-
62
- const KARMA_LOG_MAP = {
63
- disable: config.LOG_DISABLE,
64
- error: config.LOG_ERROR,
65
- warn: config.LOG_WARN,
66
- info: config.LOG_INFO,
67
- debug: config.LOG_DEBUG,
68
- };
69
-
70
- // Find the settings JSON object in the command arguments
71
- const args = process.argv;
72
- const settingsIndex = args.indexOf('--settings');
73
- const settings =
74
- settingsIndex >= 0 ? JSON.parse(args[settingsIndex + 1]) : {};
75
-
76
- if (settings.grid_config) {
77
- const gridBrowserMetadata =
78
- yaml.load(fs.readFileSync(settings.grid_config, 'utf8'));
79
- const customLaunchers = {};
80
- const [gridHostname, gridPort] = settings.grid_address.split(':');
81
- console.log(`Using Selenium grid at ${gridHostname}:${gridPort}`);
82
-
83
- // By default, run on all grid browsers instead of the platform-specific
84
- // default. This does not disable local browsers, though. Users can still
85
- // specify a mix of grid and local browsers explicitly.
86
- settings.default_browsers = [];
87
-
88
- for (const name in gridBrowserMetadata) {
89
- if (name == 'vars') {
90
- // Skip variable defs in the YAML file
91
- continue;
92
- }
93
-
94
- const metadata = gridBrowserMetadata[name];
95
-
96
- const launcher = {};
97
- customLaunchers[name] = launcher;
98
-
99
- // Disabled-by-default browsers are still defined, but not put in the
100
- // default list. A user can ask for one explicitly. This allows us to
101
- // disable a browser that is down for some reason in the lab, but still
102
- // ask for it manually if we want to test it before re-enabling it for
103
- // everyone.
104
- if (!metadata.disabled) {
105
- settings.default_browsers.push(name);
106
- }
107
-
108
- // Add standard WebDriver configs.
109
- mergeConfigs(launcher, {
110
- base: 'WebDriver',
111
- config: {hostname: gridHostname, port: gridPort},
112
- pseudoActivityInterval: 20000,
113
- browserName: metadata.browser,
114
- platform: metadata.os,
115
- version: metadata.version,
116
- });
117
-
118
- if (metadata.extra_configs) {
119
- for (const config of metadata.extra_configs) {
120
- mergeConfigs(launcher, config);
121
- }
122
- }
123
- }
124
-
125
- config.set({
126
- customLaunchers: customLaunchers,
127
- });
128
- }
129
-
130
- if (settings.browsers && settings.browsers.length == 1 &&
131
- settings.browsers[0] == 'help') {
132
- console.log('Available browsers:');
133
- console.log('===================');
134
- for (const name of allUsableBrowserLaunchers(config)) {
135
- console.log(' ' + name);
136
- }
137
- process.exit(1);
138
- }
139
-
140
- // Resolve the set of browsers we will use.
141
- const browserSet = new Set(settings.browsers && settings.browsers.length ?
142
- settings.browsers : settings.default_browsers);
143
- if (settings.exclude_browsers) {
144
- for (const excluded of settings.exclude_browsers) {
145
- browserSet.delete(excluded);
146
- }
147
- }
148
-
149
- let browsers = Array.from(browserSet).sort();
150
- if (settings.no_browsers) {
151
- console.warn(
152
- '--no-browsers: In this mode, you must connect browsers to Karma.');
153
- browsers = null;
154
- } else {
155
- console.warn('Running tests on: ' + browsers.join(', '));
156
- }
157
-
158
- config.set({
159
- // base path that will be used to resolve all patterns (eg. files, exclude)
160
- basePath: '.',
161
-
162
- // frameworks to use
163
- // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
164
- frameworks: [
165
- 'jasmine-ajax',
166
- 'jasmine',
167
- ],
168
-
169
- // An expressjs middleware, essentially a component that handles requests
170
- // in Karma's webserver. This one is custom, and will let us take
171
- // screenshots of browsers connected through WebDriver.
172
- middleware: ['webdriver-screenshot'],
173
-
174
- plugins: [
175
- 'karma-*', // default plugins
176
- '@*/karma-*', // default scoped plugins
177
-
178
- // An inline plugin which supplies the webdriver-screenshot middleware.
179
- {
180
- 'middleware:webdriver-screenshot': [
181
- 'factory', WebDriverScreenshotMiddlewareFactory,
182
- ],
183
- },
184
- ],
185
-
186
- // list of files / patterns to load in the browser
187
- files: [
188
- // Polyfills first, primarily for IE 11 and older TVs:
189
- // Promise polyfill, required since we test uncompiled code on IE11
190
- 'node_modules/es6-promise-polyfill/promise.js',
191
- // Babel polyfill, required for async/await
192
- 'node_modules/@babel/polyfill/dist/polyfill.js',
193
-
194
- // codem-isoboxer module next
195
- 'node_modules/codem-isoboxer/dist/iso_boxer.min.js',
196
-
197
- // EME encryption scheme polyfill, compiled into Shaka Player, but outside
198
- // of the Closure deps system, so not in shaka-player.uncompiled.js. This
199
- // is specifically the compiled, minified, cross-browser build of it.
200
- // eslint-disable-next-line max-len
201
- 'node_modules/eme-encryption-scheme-polyfill/dist/eme-encryption-scheme-polyfill.js',
202
-
203
- // load closure base, the deps tree, and the uncompiled library
204
- 'node_modules/google-closure-library/closure/goog/base.js',
205
- 'dist/deps.js',
206
- 'shaka-player.uncompiled.js',
207
-
208
- // the demo's config tab will register with shakaDemoMain, and will be
209
- // tested in test/demo/demo_unit.js
210
- 'demo/config.js',
211
-
212
- // cajon module (an AMD variant of requirejs) next
213
- 'node_modules/cajon/cajon.js',
214
-
215
- // define the test namespace next (shaka.test)
216
- 'test/test/namespace.js',
217
-
218
- // test utilities next, which fill in that namespace
219
- 'test/test/util/*.js',
220
-
221
- // bootstrapping for the test suite last; this will load the actual tests
222
- 'test/test/boot.js',
223
-
224
- // if --test-custom-asset *is not* present, we will add unit tests.
225
- // if --quick *is not* present, we will add integration tests.
226
- // if --external *is* present, we will add external asset tests.
227
-
228
- // source files - these are only watched and served.
229
- // anything not listed here can't be dynamically loaded by other scripts.
230
- {pattern: 'lib/**/*.js', included: false},
231
- {pattern: 'ui/**/*.js', included: false},
232
- {pattern: 'ui/**/*.less', included: false},
233
- {pattern: 'third_party/**/*.js', included: false},
234
- {pattern: 'test/**/*.js', included: false},
235
- {pattern: 'test/test/assets/*', included: false},
236
- {pattern: 'test/test/assets/dash-multi-codec/*', included: false},
237
- {pattern: 'test/test/assets/3675/*', included: false},
238
- {pattern: 'test/test/assets/dash-aes-128/*', included: false},
239
- {pattern: 'test/test/assets/hls-raw-aac/*', included: false},
240
- {pattern: 'test/test/assets/hls-raw-ac3/*', included: false},
241
- {pattern: 'test/test/assets/hls-raw-ec3/*', included: false},
242
- {pattern: 'test/test/assets/hls-raw-mp3/*', included: false},
243
- {pattern: 'test/test/assets/hls-ts-aac/*', included: false},
244
- {pattern: 'test/test/assets/hls-ts-ac3/*', included: false},
245
- {pattern: 'test/test/assets/hls-ts-ec3/*', included: false},
246
- {pattern: 'test/test/assets/hls-ts-h264/*', included: false},
247
- {pattern: 'test/test/assets/hls-ts-h265/*', included: false},
248
- {pattern: 'test/test/assets/hls-ts-mp3/*', included: false},
249
- {pattern: 'test/test/assets/hls-ts-muxed-aac-h264/*', included: false},
250
- {pattern: 'test/test/assets/hls-ts-muxed-aac-h265/*', included: false},
251
- {pattern: 'test/test/assets/hls-ts-muxed-ac3-h264/*', included: false},
252
- {pattern: 'test/test/assets/hls-ts-muxed-mp3-h264/*', included: false},
253
- {pattern: 'test/test/assets/hls-ts-muxed-ec3-h264/*', included: false},
254
- {pattern: 'dist/shaka-player.ui.js', included: false},
255
- {pattern: 'dist/locales.js', included: false},
256
- {pattern: 'demo/**/*.js', included: false},
257
- {pattern: 'demo/locales/en.json', included: false},
258
- {pattern: 'demo/locales/source.json', included: false},
259
- {pattern: 'node_modules/sprintf-js/src/sprintf.js', included: false},
260
- {pattern: 'node_modules/less/dist/less.js', included: false},
261
- {
262
- pattern: 'node_modules/fontfaceonload/dist/fontfaceonload.js',
263
- included: false,
264
- },
265
- ],
266
-
267
- // NOTE: Do not use proxies at all! They cannot be used with the --hostname
268
- // option, which is necessary for some of our lab testing.
269
- proxies: {},
270
-
271
- // to avoid DISCONNECTED messages on Safari:
272
- browserDisconnectTimeout: 10 * 1000, // 10s to reconnect
273
- browserDisconnectTolerance: 1, // max of 1 disconnect is OK
274
- browserNoActivityTimeout: 5 * 60 * 1000, // disconnect after 5m silence
275
- processKillTimeout: 5 * 1000, // allow up to 5s for process to shut down
276
- captureTimeout: settings.capture_timeout,
277
- // https://support.saucelabs.com/customer/en/portal/articles/2440724
278
-
279
- client: {
280
- // Hide the list of connected clients in Karma, to make screenshots more
281
- // stable.
282
- clientDisplayNone: true,
283
- // Only capture the client's logs if the settings want logging.
284
- captureConsole: !!settings.logging && settings.logging != 'none',
285
- // |args| must be an array; pass a key-value map as the sole client
286
- // argument.
287
- args: [{
288
- // Run Player integration tests against external assets.
289
- // Skipped by default.
290
- external: !!settings.external,
291
-
292
- // Run Player integration tests against DRM license servers.
293
- // Skipped by default.
294
- drm: !!settings.drm,
295
-
296
- // Run quarantined tests which do not consistently pass.
297
- // Skipped by default.
298
- quarantined: !!settings.quarantined,
299
-
300
- // Run Player integration tests with uncompiled code for debugging.
301
- uncompiled: !!settings.uncompiled,
302
-
303
- // Limit which tests to run. If undefined, all tests should run.
304
- filter: settings.filter,
305
-
306
- // Set what level of logs for the player to print.
307
- logLevel: SHAKA_LOG_MAP[settings.logging],
308
-
309
- // Delay tests to aid in debugging async failures that pollute
310
- // subsequent tests.
311
- delayTests: settings.delay_tests,
312
-
313
- // Run playback tests on a custom manifest URI.
314
- testCustomAsset: settings.test_custom_asset,
315
- testCustomLicenseServer: settings.test_custom_license_server,
316
-
317
- // Overrides the default test timeout value.
318
- testTimeout: settings.test_timeout,
319
- }],
320
- },
321
-
322
- // Specify the hostname to be used when capturing browsers.
323
- hostname: settings.hostname,
324
-
325
- // Specify the port where the server runs.
326
- port: settings.port,
327
-
328
- // Set which browsers to run on. If this is null, then Karma will wait for
329
- // an incoming connection.
330
- browsers,
331
-
332
- // Enable / disable colors in the output (reporters and logs). Defaults
333
- // to true.
334
- colors: settings.colors,
335
-
336
- // Set Karma's level of logging.
337
- logLevel: KARMA_LOG_MAP[settings.log_level],
338
-
339
- // Should Karma xecute tests whenever a file changes?
340
- autoWatch: settings.auto_watch,
341
-
342
- // Do a single run of the tests on captured browsers and then quit.
343
- // Defaults to true.
344
- singleRun: settings.single_run,
345
-
346
- // Set the time limit (ms) that should be used to identify slow tests.
347
- reportSlowerThan: settings.report_slower_than,
348
-
349
- // Force failure when running empty test-suites.
350
- failOnEmptyTestSuite: true,
351
-
352
- specReporter: {
353
- suppressSkipped: true,
354
- showBrowser: true,
355
- },
356
- });
357
-
358
- if (settings.babel) {
359
- config.set({
360
- preprocessors: {
361
- // Use babel to convert ES6 to ES5 so we can still run tests everywhere.
362
- // Use sourcemap to read inline source maps from babel into karma.
363
- 'demo/**/*.js': ['babel', 'sourcemap'],
364
- 'lib/**/*.js': ['babel', 'sourcemap'],
365
- 'ui/**/*.js': ['babel', 'sourcemap'],
366
- 'test/**/*.js': ['babel', 'sourcemap'],
367
- 'third_party/**/*.js': ['babel', 'sourcemap'],
368
- },
369
-
370
- babelPreprocessor: {
371
- // Cache results in .babel-cache
372
- cachePath: '.babel-cache',
373
- options: {
374
- presets: ['@babel/preset-env'],
375
- // Add source maps so that backtraces refer to the original code.
376
- // Babel will output inline source maps, and the 'sourcemap'
377
- // preprocessor will read them and feed them to Karma. Karma will
378
- // then use them to reformat stack traces in errors.
379
- sourceMap: 'inline',
380
- // Add instrumentation for code coverage.
381
- plugins: [
382
- ['istanbul', {
383
- // Don't instrument these parts of the codebase.
384
- exclude: [
385
- 'demo/**/*.js',
386
- 'lib/(debug|deprecate|polyfill)/*.js',
387
- 'test/**/*.js',
388
- 'third_party/**/*.js',
389
- ],
390
- }],
391
- ],
392
- },
393
- },
394
- });
395
- }
396
-
397
- const clientArgs = config.client.args[0];
398
- clientArgs.testFiles = [];
399
-
400
- if (settings.test_custom_asset) {
401
- // If testing custom assets, we don't serve other unit or integration tests.
402
- // External asset tests are the basis for custom asset testing, so this file
403
- // is automatically included.
404
- clientArgs.testFiles.push('demo/common/asset.js');
405
- clientArgs.testFiles.push('demo/common/assets.js');
406
- clientArgs.testFiles.push('test/player_external.js');
407
- } else {
408
- // In a normal test run, we serve unit tests.
409
- clientArgs.testFiles.push('test/**/*_unit.js');
410
-
411
- if (!settings.quick) {
412
- // If --quick is present, we don't serve integration tests.
413
- clientArgs.testFiles.push('test/**/*_integration.js');
414
- }
415
- if (settings.external) {
416
- // If --external is present, we serve external asset tests.
417
- clientArgs.testFiles.push('demo/common/asset.js');
418
- clientArgs.testFiles.push('demo/common/assets.js');
419
- clientArgs.testFiles.push('test/**/*_external.js');
420
- }
421
- }
422
-
423
- // These are the test files that will be dynamically loaded by boot.js.
424
- clientArgs.testFiles = resolveGlobs(clientArgs.testFiles);
425
-
426
- const reporters = [];
427
-
428
- if (settings.reporters) {
429
- // Explicit reporters, use these.
430
- reporters.push(...settings.reporters);
431
- } else if (settings.logging && settings.logging != 'none') {
432
- // With logging, default to 'spec', which makes logs easier to associate
433
- // with individual tests.
434
- reporters.push('spec');
435
- } else {
436
- // Without logging, default to 'progress'.
437
- reporters.push('progress');
438
- }
439
-
440
- if (settings.html_coverage_report) {
441
- // Wipe out any old coverage reports to avoid confusion.
442
- rimraf.sync('coverage', {}); // Like rm -rf
443
-
444
- config.set({
445
- coverageReporter: {
446
- includeAllSources: true,
447
- reporters: [
448
- {type: 'html', dir: 'coverage'},
449
- {type: 'cobertura', dir: 'coverage', file: 'coverage.xml'},
450
- {type: 'json-summary', dir: 'coverage', file: 'coverage.json'},
451
- {type: 'json', dir: 'coverage', file: 'coverage-details.json'},
452
- ],
453
- },
454
- });
455
-
456
- // The report requires the 'coverage' reporter to be added to the list.
457
- reporters.push('coverage');
458
- }
459
-
460
- config.set({reporters: reporters});
461
-
462
- if (reporters.includes('spec') && settings.spec_hide_passed) {
463
- config.set({specReporter: {suppressPassed: true}});
464
- }
465
-
466
- if (settings.random) {
467
- // If --seed was specified use that value, else generate a seed so that the
468
- // exact order can be reproduced if it catches an issue.
469
- const seed = settings.seed == null ? new Date().getTime() : settings.seed;
470
-
471
- // Run tests in a random order.
472
- clientArgs.random = true;
473
- clientArgs.seed = seed;
474
-
475
- console.log('Using a random test order (--random) with --seed=' + seed);
476
- }
477
-
478
- if (settings.tls_key && settings.tls_cert) {
479
- config.set({
480
- protocol: 'https',
481
- httpsServerOptions: {
482
- key: fs.readFileSync(settings.tls_key),
483
- cert: fs.readFileSync(settings.tls_cert),
484
- },
485
- });
486
- }
487
- };
488
-
489
- /**
490
- * Resolves a list of paths using globs into a list of explicit paths.
491
- * Paths are all relative to the source directory.
492
- *
493
- * @param {!Array.<string>} list
494
- * @return {!Array.<string>}
495
- */
496
- function resolveGlobs(list) {
497
- const options = {
498
- cwd: __dirname,
499
- };
500
-
501
- const resolved = [];
502
- for (const path of list) {
503
- for (const resolvedPath of glob.sync(path, options)) {
504
- resolved.push(resolvedPath);
505
- }
506
- }
507
- return resolved;
508
- }
509
-
510
- /**
511
- * Determines which launchers and customLaunchers can be used and returns an
512
- * array of strings.
513
- *
514
- * @param {!Object} config
515
- * @return {!Array.<string>}
516
- */
517
- function allUsableBrowserLaunchers(config) {
518
- const browsers = [];
519
-
520
- // Load all launcher plugins.
521
- // The format of the items in this list is something like:
522
- // {
523
- // 'launcher:foo1': ['type', Function],
524
- // 'launcher:foo2': ['type', Function],
525
- // }
526
- // Where the launchers grouped together into one item were defined by a single
527
- // plugin, and the Functions in the inner array are the constructors for those
528
- // launchers.
529
- const plugins = require('karma/lib/plugin').resolve(['karma-*-launcher']);
530
- for (const map of plugins) {
531
- for (const name in map) {
532
- // Launchers should all start with 'launcher:', but occasionally we also
533
- // see 'test' come up for some reason.
534
- if (!name.startsWith('launcher:')) {
535
- continue;
536
- }
537
-
538
- const browserName = name.split(':')[1];
539
- const pluginConstructor = map[name][1];
540
-
541
- // Most launchers requiring configuration through customLaunchers have
542
- // no DEFAULT_CMD. Some launchers have DEFAULT_CMD, but not for this
543
- // platform. Finally, WebDriver has DEFAULT_CMD, but still requires
544
- // configuration, so we simply reject it by name.
545
- // eslint-disable-next-line no-restricted-syntax
546
- const DEFAULT_CMD = pluginConstructor.prototype.DEFAULT_CMD;
547
- if (!DEFAULT_CMD || !DEFAULT_CMD[process.platform]) {
548
- continue;
549
- }
550
- if (browserName == 'WebDriver') {
551
- continue;
552
- }
553
-
554
- // Now that we've filtered out the browsers that can't be launched without
555
- // custom config or that can't be launched on this platform, we filter out
556
- // the browsers you don't have installed.
557
- // eslint-disable-next-line no-restricted-syntax
558
- const ENV_CMD = pluginConstructor.prototype.ENV_CMD;
559
- const browserPath = process.env[ENV_CMD] || DEFAULT_CMD[process.platform];
560
-
561
- if (!fs.existsSync(browserPath) &&
562
- !which.sync(browserPath, {nothrow: true})) {
563
- continue;
564
- }
565
-
566
- browsers.push(browserName);
567
- }
568
- }
569
-
570
- // Once we've found the names of all the standard launchers, add to that list
571
- // the names of any custom launcher configurations.
572
- if (config.customLaunchers) {
573
- browsers.push(...Object.keys(config.customLaunchers));
574
- }
575
-
576
- return browsers.sort();
577
- }
578
-
579
- /**
580
- * This is a factory for a "middleware" component that handles requests in
581
- * Karma's webserver. This one will let us take screenshots of browsers
582
- * connected through WebDriver. The factory uses Karma's dependency injection
583
- * system to get a reference to the launcher module, which we will use to get
584
- * access to the remote browsers.
585
- *
586
- * @param {karma.Launcher} launcher
587
- * @return {karma.Middleware}
588
- */
589
- function WebDriverScreenshotMiddlewareFactory(launcher) {
590
- return screenshotMiddleware;
591
-
592
- /**
593
- * Extract URL params from the request.
594
- *
595
- * @param {express.Request} request
596
- * @return {!Object.<string, string>}
597
- */
598
- function getParams(request) {
599
- // This can be null for manually-connected browsers.
600
- if (!request._parsedUrl.search) {
601
- return {};
602
- }
603
- return util.parseQueryParams(request._parsedUrl.search);
604
- }
605
-
606
- /**
607
- * Find the browser associated with the "id" parameter of the request.
608
- * This ID was assigned by Karma when the browser was launched, and passed to
609
- * the web server from the Jasmine tests.
610
- *
611
- * If the browser is not found, this function will return null.
612
- *
613
- * @param {?string} id
614
- * @return {karma.Launcher.Browser|null}
615
- */
616
- function getBrowser(id) {
617
- if (!id) {
618
- // No ID parameter? No such browser.
619
- return null;
620
- }
621
- const browser = launcher._browsers.find((b) => b.id == id);
622
- if (!browser) {
623
- return null;
624
- }
625
- return browser;
626
- }
627
-
628
- /**
629
- * @param {?karma.Launcher.Browser} browser
630
- * @return {wd.remote|null} A WebDriver client, an object from the "wd"
631
- * package, created by "wd.remote()".
632
- */
633
- function getWebDriverClient(browser) {
634
- if (!browser) {
635
- // If we didn't launch the browser, then there's definitely no WebDriver
636
- // client for it.
637
- return null;
638
- }
639
-
640
- // If this browser was launched by the WebDriver launcher, the launcher's
641
- // browser object has a WebDriver client in the "browser" field. Yes, this
642
- // looks weird.
643
- const webDriverClient = browser.browser;
644
-
645
- // To make sure we have an actual WebDriver client and to screen out other
646
- // launchers who may also have a "browser" field in their browser object,
647
- // we check to make sure it has a screenshot method.
648
- if (webDriverClient && webDriverClient.takeScreenshot) {
649
- return webDriverClient;
650
- }
651
- return null;
652
- }
653
-
654
- /**
655
- * @param {karma.Launcher.Browser.spec} spec
656
- * @param {wd.remote} webDriverClient A WebDriver client, an object from the
657
- * "wd" package, created by "wd.remote()".
658
- * @return {!Promise.<!Buffer>} A Buffer containing a PNG screenshot
659
- */
660
- function getScreenshot(spec, webDriverClient) {
661
- return new Promise((resolve, reject) => {
662
- webDriverClient.takeScreenshot((error, pngBase64) => {
663
- if (error) {
664
- reject(error);
665
- } else if (pngBase64.error) {
666
- // In some failure cases, pngBase64 is an object with "error",
667
- // "message", and "stacktrace" fields. This happens, for example,
668
- // with a timeout from the screenshot command. This is not an
669
- // expected situation, so log it. The extra newlines keep this from
670
- // being overwritten on the terminal when running tests against many
671
- // browsers at once.
672
- console.log('\n\nUnexpected screenshot failure:\n' +
673
- ` Error: ${JSON.stringify(pngBase64)}\n` +
674
- ` WebDriver spec: ${JSON.stringify(spec)}\n\n\n`);
675
- reject(pngBase64);
676
- } else {
677
- // Convert the screenshot to a binary buffer.
678
- resolve(Buffer.from(pngBase64, 'base64'));
679
- }
680
- });
681
- });
682
- }
683
-
684
- /**
685
- * Take a screenshot, write it to disk, and diff it against the old one.
686
- * Write the diff to disk, as well.
687
- *
688
- * @param {karma.Launcher.Browser} browser
689
- * @param {!Object.<string, string>} params
690
- * @return {!Promise.<number>} A similarity score between 0 and 1.
691
- */
692
- async function diffScreenshot(browser, params) {
693
- const webDriverClient = getWebDriverClient(browser);
694
- if (!webDriverClient) {
695
- throw new Error('No screenshot support!');
696
- }
697
-
698
- /** @type {!Buffer} */
699
- const fullPageScreenshotData =
700
- await getScreenshot(browser.spec, webDriverClient);
701
-
702
- // Crop the screenshot to the dimensions specified in the test.
703
- // Jimp is picky about types, so convert these strings to numbers.
704
- const x = parseFloat(params.x);
705
- const y = parseFloat(params.y);
706
- const width = parseFloat(params.width);
707
- const height = parseFloat(params.height);
708
- const bodyWidth = parseFloat(params.bodyWidth);
709
- const bodyHeight = parseFloat(params.bodyHeight);
710
-
711
- /** @type {!Jimp.image} */
712
- const fullScreenshot = (await Jimp.read(fullPageScreenshotData));
713
-
714
- // Because WebDriver may screenshot at a different resolution than we
715
- // saw in JS, convert the crop region coordinates to the screenshot scale,
716
- // then crop, then resize. This order produces the most accurate cropped
717
- // screenshot.
718
-
719
- // Scaling by height breaks everything on Android, which has screenshots
720
- // that are taller than expected based on the body size. So use width only.
721
- const scale = fullScreenshot.bitmap.width / bodyWidth;
722
-
723
- /** @type {!Jimp.image} */
724
- const newScreenshot = fullScreenshot.clone()
725
- .crop(
726
- // Sub-pixel rendering in browsers makes this much trickier than you
727
- // might expect. Offsets are not necessarily integers even before
728
- // we scale them, but the image has been quantized into pixels at
729
- // that scale. Experimentation with different rounding methods has
730
- // led to the conclusion that rounding up is the only way to get
731
- // consistent results.
732
- Math.ceil(x * scale),
733
- Math.ceil(y * scale),
734
- Math.ceil(width * scale),
735
- Math.ceil(height * scale))
736
- .resize(width, height, Jimp.RESIZE_BICUBIC);
737
-
738
- // Get the WebDriver spec (including browser name, platform, etc)
739
- const spec = browser.spec;
740
- // Compute the folder for the screenshots for this platform.
741
- const baseFolder = `${__dirname}/test/test/assets/screenshots`;
742
- let folder = `${baseFolder}/${spec.browserName}`;
743
- if (spec.platform) {
744
- folder += `-${spec.platform}`;
745
- }
746
-
747
- const oldScreenshotPath = `${folder}/${params.name}.png`;
748
- const fullScreenshotPath = `${folder}/${params.name}.png-full`;
749
- const newScreenshotPath = `${folder}/${params.name}.png-new`;
750
- const diffScreenshotPath = `${folder}/${params.name}.png-diff`;
751
-
752
- // Write the full screenshot to disk. This should be done early in case a
753
- // later stage fails and we need to analyze what happened.
754
- fs.mkdirSync(folder, {recursive: true});
755
- fs.writeFileSync(
756
- fullScreenshotPath, await fullScreenshot.getBufferAsync('image/png'));
757
-
758
- // Write the cropped screenshot to disk next. This is used in review
759
- // changes and to update the "official" screenshot when needed.
760
- fs.writeFileSync(
761
- newScreenshotPath, await newScreenshot.getBufferAsync('image/png'));
762
-
763
- /** @type {!Jimp.image} */
764
- let oldScreenshot;
765
- if (!fs.existsSync(oldScreenshotPath)) {
766
- // If the "official" screenshot doesn't exist yet, create a blank image
767
- // in memory.
768
- oldScreenshot = new Jimp(width, height);
769
- } else {
770
- oldScreenshot = await Jimp.read(oldScreenshotPath);
771
- }
772
-
773
- // Compare the new screenshot to the old one and produce a diff image.
774
- // Initially, the image data will be raw pixels, 4 bytes per pixel.
775
- // The threshold parameter affects the sensitivity of individual pixel
776
- // comparisons. This diff is only used for visual review, not for
777
- // automated similarity checks, so the threshold setting is not so critical
778
- // as it used to be.
779
- const threshold = 0.10;
780
- const diff = Jimp.diff(oldScreenshot, newScreenshot, threshold);
781
-
782
- // Write the diff to disk. This is used to review when there are changes.
783
- const fullSizeDiff =
784
- diff.image.clone().resize(width, height, Jimp.RESIZE_BICUBIC);
785
- fs.writeFileSync(
786
- diffScreenshotPath, await fullSizeDiff.getBufferAsync('image/png'));
787
-
788
- // Compare with a structural similarity algorithm. This produces a
789
- // similarity score that we will use to pass or fail the test.
790
- const ssimResult = ssim(oldScreenshot.bitmap, newScreenshot.bitmap);
791
- return ssimResult.mssim; // A score between 0 and 1.
792
- }
793
-
794
- /**
795
- * This function is the middleware. It gets request and response objects and
796
- * a next() callback which passes control off to the next middleware in the
797
- * system. This is similar to how expressjs works.
798
- *
799
- * @param {karma.MiddleWare.Request} request
800
- * @param {karma.MiddleWare.Response} response
801
- * @param {function()} next
802
- */
803
- async function screenshotMiddleware(request, response, next) {
804
- const pathname = request._parsedUrl.pathname;
805
-
806
- if (pathname == '/screenshot/isSupported') {
807
- const params = getParams(request);
808
- const browser = getBrowser(params.id);
809
- const webDriverClient = getWebDriverClient(browser);
810
-
811
- let isSupported = false;
812
- if (webDriverClient) {
813
- // Some platforms in our Selenium grid can't take screenshots. We don't
814
- // have a good way to check for this in the platform capabilities
815
- // reported by Selenium, so we have to take a screenshot to find out.
816
- // The result is cached for the sake of performance.
817
- if (webDriverClient.canTakeScreenshot === undefined) {
818
- try {
819
- await getScreenshot(browser.spec, webDriverClient);
820
- webDriverClient.canTakeScreenshot = true;
821
- } catch (error) {
822
- webDriverClient.canTakeScreenshot = false;
823
- }
824
- }
825
-
826
- isSupported = webDriverClient.canTakeScreenshot;
827
- }
828
-
829
- response.setHeader('Content-Type', 'application/json');
830
- response.end(JSON.stringify(isSupported));
831
- } else if (pathname == '/screenshot/diff') {
832
- const params = getParams(request);
833
- const browser = getBrowser(params.id);
834
- if (!browser) {
835
- response.writeHead(404);
836
- response.end('No such browser!');
837
- return;
838
- }
839
-
840
- // Check the URL parameters.
841
- const requiredParams = [
842
- 'x', 'y', 'width', 'height', 'bodyWidth', 'bodyHeight', 'name',
843
- ];
844
- for (const k of requiredParams) {
845
- if (!params[k]) {
846
- response.writeHead(400);
847
- response.end(`Screenshot param ${k} is missing!`);
848
- return;
849
- }
850
- }
851
-
852
- // To avoid creating an open HTTP endpoint where anyone can write to any
853
- // path on the filesystem, only accept alphanumeric names (plus
854
- // underscore and dash). No colons, periods, forward slashes, or
855
- // backslashes should ever be added to this regex, as any of those could
856
- // be used on some platform to write outside of the screenshots folder.
857
- if (!params.name.match(/[a-zA-Z0-9_-]+/)) {
858
- response.writeHead(400);
859
- response.end(`Screenshot name not valid: "${params.name}"`);
860
- return;
861
- }
862
-
863
- try {
864
- const pixelsChanged = await diffScreenshot(browser, params);
865
- response.setHeader('Content-Type', 'application/json');
866
- response.end(JSON.stringify(pixelsChanged));
867
- } catch (error) {
868
- console.error(error);
869
- response.writeHead(500);
870
- response.end('Screenshot error: ' + JSON.stringify(error));
871
- }
872
- } else {
873
- // Requests for paths that we don't handle are passed on to the next
874
- // middleware in the system.
875
- next();
876
- }
877
- }
878
- }
879
- WebDriverScreenshotMiddlewareFactory.$inject = ['launcher'];