rx-player 4.5.0-dev.2026031700 → 4.5.0-dev.2026033100
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.
- package/CHANGELOG.md +3 -1
- package/VERSION +1 -1
- package/dist/commonjs/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
- package/dist/commonjs/__GENERATED_CODE/embedded_worker.js +1 -1
- package/dist/commonjs/compat/browser_compatibility_types.d.ts +16 -14
- package/dist/commonjs/compat/browser_compatibility_types.d.ts.map +1 -1
- package/dist/commonjs/compat/browser_compatibility_types.js +7 -4
- package/dist/commonjs/compat/browser_version.d.ts +2 -1
- package/dist/commonjs/compat/browser_version.d.ts.map +1 -1
- package/dist/commonjs/compat/browser_version.js +13 -0
- package/dist/commonjs/compat/disable_remote_playback_on_managed_media_source.d.ts.map +1 -1
- package/dist/commonjs/compat/disable_remote_playback_on_managed_media_source.js +1 -1
- package/dist/commonjs/compat/is_codec_supported.d.ts.map +1 -1
- package/dist/commonjs/compat/is_codec_supported.js +4 -3
- package/dist/commonjs/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts +26 -0
- package/dist/commonjs/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts.map +1 -0
- package/dist/commonjs/compat/should_patch_out_dolby_vision_config_data_from_mp4.js +45 -0
- package/dist/commonjs/core/entry/utils.js +3 -3
- package/dist/commonjs/core/fetchers/segment/segment_fetcher.d.ts.map +1 -1
- package/dist/commonjs/core/fetchers/segment/segment_fetcher.js +2 -1
- package/dist/commonjs/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.d.ts.map +1 -1
- package/dist/commonjs/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +2 -1
- package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.d.ts.map +1 -1
- package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.js +8 -6
- package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.d.ts.map +1 -1
- package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +4 -3
- package/dist/commonjs/initialize_worker.js +1 -1
- package/dist/commonjs/main_thread/api/debug/modules/segment_buffer_content.js +3 -3
- package/dist/commonjs/main_thread/api/public_api.js +2 -2
- package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
- package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.js +24 -12
- package/dist/commonjs/manifest/classes/adaptation.d.ts.map +1 -1
- package/dist/commonjs/manifest/classes/adaptation.js +3 -1
- package/dist/commonjs/manifest/classes/representation.d.ts +6 -2
- package/dist/commonjs/manifest/classes/representation.d.ts.map +1 -1
- package/dist/commonjs/manifest/classes/representation.js +45 -23
- package/dist/commonjs/manifest/types.d.ts +14 -6
- package/dist/commonjs/manifest/types.d.ts.map +1 -1
- package/dist/commonjs/manifest/utils.js +4 -4
- package/dist/commonjs/mse/main_media_source_interface.d.ts.map +1 -1
- package/dist/commonjs/mse/main_media_source_interface.js +3 -2
- package/dist/commonjs/mse/worker_media_source_interface.d.ts.map +1 -1
- package/dist/commonjs/parsers/containers/isobmff/get_box.d.ts +12 -1
- package/dist/commonjs/parsers/containers/isobmff/get_box.d.ts.map +1 -1
- package/dist/commonjs/parsers/containers/isobmff/get_box.js +16 -0
- package/dist/commonjs/parsers/containers/isobmff/index.d.ts +2 -1
- package/dist/commonjs/parsers/containers/isobmff/index.d.ts.map +1 -1
- package/dist/commonjs/parsers/containers/isobmff/index.js +3 -1
- package/dist/commonjs/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts +13 -0
- package/dist/commonjs/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts.map +1 -0
- package/dist/commonjs/parsers/containers/isobmff/remove_dolby_vision_config_data.js +180 -0
- package/dist/commonjs/parsers/manifest/metaplaylist/metaplaylist_parser.js +4 -4
- package/dist/commonjs/transports/dash/segment_parser.d.ts.map +1 -1
- package/dist/commonjs/transports/dash/segment_parser.js +6 -0
- package/dist/commonjs/transports/dash/text_parser.d.ts.map +1 -1
- package/dist/commonjs/transports/dash/text_parser.js +5 -1
- package/dist/commonjs/transports/local/text_parser.d.ts.map +1 -1
- package/dist/commonjs/transports/local/text_parser.js +5 -1
- package/dist/commonjs/transports/metaplaylist/pipelines.d.ts.map +1 -1
- package/dist/commonjs/transports/metaplaylist/pipelines.js +2 -1
- package/dist/commonjs/transports/smooth/pipelines.js +3 -3
- package/dist/commonjs/transports/types.d.ts +28 -2
- package/dist/commonjs/transports/types.d.ts.map +1 -1
- package/dist/commonjs/transports/utils/parse_text_track.d.ts +9 -2
- package/dist/commonjs/transports/utils/parse_text_track.d.ts.map +1 -1
- package/dist/commonjs/transports/utils/parse_text_track.js +1 -1
- package/dist/es2017/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
- package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
- package/dist/es2017/compat/browser_compatibility_types.d.ts +16 -14
- package/dist/es2017/compat/browser_compatibility_types.d.ts.map +1 -1
- package/dist/es2017/compat/browser_compatibility_types.js +7 -1
- package/dist/es2017/compat/browser_version.d.ts +2 -1
- package/dist/es2017/compat/browser_version.d.ts.map +1 -1
- package/dist/es2017/compat/browser_version.js +13 -1
- package/dist/es2017/compat/disable_remote_playback_on_managed_media_source.d.ts.map +1 -1
- package/dist/es2017/compat/disable_remote_playback_on_managed_media_source.js +2 -2
- package/dist/es2017/compat/is_codec_supported.d.ts.map +1 -1
- package/dist/es2017/compat/is_codec_supported.js +2 -1
- package/dist/es2017/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts +26 -0
- package/dist/es2017/compat/should_patch_out_dolby_vision_config_data_from_mp4.d.ts.map +1 -0
- package/dist/es2017/compat/should_patch_out_dolby_vision_config_data_from_mp4.js +42 -0
- package/dist/es2017/core/entry/utils.js +4 -4
- package/dist/es2017/core/fetchers/segment/segment_fetcher.d.ts.map +1 -1
- package/dist/es2017/core/fetchers/segment/segment_fetcher.js +2 -1
- package/dist/es2017/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.d.ts.map +1 -1
- package/dist/es2017/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +2 -1
- package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.d.ts.map +1 -1
- package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.js +3 -1
- package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.d.ts.map +1 -1
- package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +2 -1
- package/dist/es2017/initialize_worker.js +1 -1
- package/dist/es2017/main_thread/api/debug/modules/segment_buffer_content.js +3 -3
- package/dist/es2017/main_thread/api/public_api.js +2 -2
- package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -1
- package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.js +9 -7
- package/dist/es2017/manifest/classes/adaptation.d.ts.map +1 -1
- package/dist/es2017/manifest/classes/adaptation.js +3 -1
- package/dist/es2017/manifest/classes/representation.d.ts +6 -2
- package/dist/es2017/manifest/classes/representation.d.ts.map +1 -1
- package/dist/es2017/manifest/classes/representation.js +45 -23
- package/dist/es2017/manifest/types.d.ts +14 -6
- package/dist/es2017/manifest/types.d.ts.map +1 -1
- package/dist/es2017/manifest/utils.js +4 -4
- package/dist/es2017/mse/main_media_source_interface.d.ts.map +1 -1
- package/dist/es2017/mse/main_media_source_interface.js +2 -1
- package/dist/es2017/mse/worker_media_source_interface.d.ts.map +1 -1
- package/dist/es2017/parsers/containers/isobmff/get_box.d.ts +12 -1
- package/dist/es2017/parsers/containers/isobmff/get_box.d.ts.map +1 -1
- package/dist/es2017/parsers/containers/isobmff/get_box.js +16 -1
- package/dist/es2017/parsers/containers/isobmff/index.d.ts +2 -1
- package/dist/es2017/parsers/containers/isobmff/index.d.ts.map +1 -1
- package/dist/es2017/parsers/containers/isobmff/index.js +2 -1
- package/dist/es2017/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts +13 -0
- package/dist/es2017/parsers/containers/isobmff/remove_dolby_vision_config_data.d.ts.map +1 -0
- package/dist/es2017/parsers/containers/isobmff/remove_dolby_vision_config_data.js +155 -0
- package/dist/es2017/parsers/manifest/metaplaylist/metaplaylist_parser.js +4 -4
- package/dist/es2017/transports/dash/segment_parser.d.ts.map +1 -1
- package/dist/es2017/transports/dash/segment_parser.js +7 -1
- package/dist/es2017/transports/dash/text_parser.d.ts.map +1 -1
- package/dist/es2017/transports/dash/text_parser.js +5 -1
- package/dist/es2017/transports/local/text_parser.d.ts.map +1 -1
- package/dist/es2017/transports/local/text_parser.js +5 -1
- package/dist/es2017/transports/metaplaylist/pipelines.d.ts.map +1 -1
- package/dist/es2017/transports/metaplaylist/pipelines.js +2 -1
- package/dist/es2017/transports/smooth/pipelines.js +3 -3
- package/dist/es2017/transports/types.d.ts +28 -2
- package/dist/es2017/transports/types.d.ts.map +1 -1
- package/dist/es2017/transports/utils/parse_text_track.d.ts +9 -2
- package/dist/es2017/transports/utils/parse_text_track.d.ts.map +1 -1
- package/dist/es2017/transports/utils/parse_text_track.js +1 -1
- package/dist/worker.js +6 -6
- package/eslint.config.mjs +1 -14
- package/package.json +1 -1
- package/src/__GENERATED_CODE/embedded_worker.ts +1 -1
- package/src/compat/__tests__/browser_compatibility_types.test.ts +15 -26
- package/src/compat/__tests__/browser_version.test.ts +57 -18
- package/src/compat/__tests__/clear_element_src.test.ts +20 -40
- package/src/compat/__tests__/is_codec_supported.test.ts +39 -44
- package/src/compat/__tests__/is_vtt_cue.test.ts +5 -8
- package/src/compat/__tests__/make_vtt_cue.test.ts +20 -31
- package/src/compat/__tests__/remove_cue.test.ts +8 -20
- package/src/compat/__tests__/should_patch_out_dolby_vision_config_data_from_mp4.test.ts +78 -0
- package/src/compat/browser_compatibility_types.ts +8 -1
- package/src/compat/browser_version.ts +17 -1
- package/src/compat/disable_remote_playback_on_managed_media_source.ts +2 -2
- package/src/compat/is_codec_supported.ts +2 -1
- package/src/compat/should_patch_out_dolby_vision_config_data_from_mp4.ts +50 -0
- package/src/core/adaptive/__tests__/adaptive_representation_selector.test.ts +68 -28
- package/src/core/adaptive/__tests__/buffer_based_chooser.test.ts +26 -84
- package/src/core/entry/__tests__/utils.test.ts +7 -1
- package/src/core/entry/utils.ts +4 -4
- package/src/core/fetchers/segment/segment_fetcher.ts +2 -1
- package/src/errors/__tests__/format_error.test.ts +23 -24
- package/src/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.ts +2 -1
- package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/mediaDisplayInfos.test.ts +106 -0
- package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/HDCPPolicy.test.ts +19 -42
- package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/decodingInfo.test.ts +33 -40
- package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/defaultCodecsFinder.test.ts +44 -68
- package/src/experimental/tools/mediaCapabilitiesProber/probers/__tests__/mediaContentType.test.ts +45 -80
- package/src/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.ts +3 -1
- package/src/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.ts +2 -1
- package/src/features/__tests__/add_features.test.ts +12 -27
- package/src/initialize_worker.ts +1 -1
- package/src/main_thread/api/__tests__/option_utils.test.ts +38 -67
- package/src/main_thread/api/__tests__/public_api.test.ts +56 -138
- package/src/main_thread/api/debug/modules/segment_buffer_content.ts +3 -3
- package/src/main_thread/api/public_api.ts +2 -2
- package/src/main_thread/decrypt/__tests__/__global__/find_key_system.test.ts +46 -28
- package/src/main_thread/decrypt/__tests__/__global__/get_license.test.ts +40 -10
- package/src/main_thread/decrypt/__tests__/__global__/init_data.test.ts +112 -129
- package/src/main_thread/decrypt/__tests__/__global__/media_key_system_access.test.ts +282 -377
- package/src/main_thread/decrypt/__tests__/__global__/media_keys.test.ts +70 -63
- package/src/main_thread/decrypt/__tests__/__global__/server_certificate.test.ts +73 -54
- package/src/main_thread/decrypt/__tests__/__global__/utils.ts +43 -83
- package/src/main_thread/decrypt/__tests__/find_key_system.test.ts +36 -17
- package/src/main_thread/decrypt/utils/__tests__/clean_old_stored_persistent_info.test.ts +44 -48
- package/src/main_thread/init/utils/__tests__/are_same_stream_events.test.ts +7 -22
- package/src/main_thread/init/utils/__tests__/refresh_scheduled_events_list.test.ts +3 -6
- package/src/main_thread/init/utils/__tests__/update_manifest_codec_support.test.ts +42 -19
- package/src/main_thread/init/utils/update_manifest_codec_support.ts +8 -6
- package/src/manifest/classes/__tests__/adaptation.test.ts +69 -125
- package/src/manifest/classes/__tests__/manifest.test.ts +88 -95
- package/src/manifest/classes/__tests__/period.test.ts +167 -117
- package/src/manifest/classes/__tests__/representation.test.ts +84 -25
- package/src/manifest/classes/__tests__/update_periods.test.ts +96 -225
- package/src/manifest/classes/adaptation.ts +4 -1
- package/src/manifest/classes/representation.ts +59 -27
- package/src/manifest/types.ts +14 -6
- package/src/manifest/utils.ts +4 -4
- package/src/mse/__tests__/main_media_source_interface.test.ts +3 -1
- package/src/mse/__tests__/worker_media_source_interface.test.ts +608 -0
- package/src/mse/main_media_source_interface.ts +2 -1
- package/src/mse/worker_media_source_interface.ts +2 -2
- package/src/parsers/containers/isobmff/__tests__/get_box.test.ts +449 -0
- package/src/parsers/containers/isobmff/__tests__/remove_dolby_vision_config_data.test.ts +282 -0
- package/src/parsers/containers/isobmff/get_box.ts +17 -0
- package/src/parsers/containers/isobmff/index.ts +8 -1
- package/src/parsers/containers/isobmff/remove_dolby_vision_config_data.ts +179 -0
- package/src/parsers/manifest/dash/common/__tests__/get_clock_offset.test.ts +19 -25
- package/src/parsers/manifest/dash/common/__tests__/get_http_utc-timing_url.test.ts +7 -19
- package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/ContentProtection.test.ts +26 -37
- package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/Initialization.test.ts +24 -53
- package/src/parsers/manifest/dash/js-parser/node_parsers/__tests__/SegmentURL.test.ts +31 -78
- package/src/parsers/manifest/metaplaylist/metaplaylist_parser.ts +6 -4
- package/src/parsers/manifest/utils/__tests__/update_segment_timeline.test.ts +79 -87
- package/src/parsers/texttracks/ttml/__tests__/resolve_styles_inheritance.test.ts +20 -26
- package/src/parsers/texttracks/ttml/html/__tests__/__global__/html_ttml_parser.test.ts +2 -7
- package/src/parsers/texttracks/webvtt/__tests__/parse_cue_block.test.ts +33 -30
- package/src/parsers/texttracks/webvtt/__tests__/parse_style_block.test.ts +33 -100
- package/src/parsers/texttracks/webvtt/html/__tests__/convert_payload_to_html.test.ts +16 -18
- package/src/parsers/texttracks/webvtt/html/__tests__/parse_webvtt_to_div.test.ts +73 -78
- package/src/parsers/texttracks/webvtt/html/__tests__/to_html.test.ts +36 -37
- package/src/transports/dash/segment_parser.ts +13 -0
- package/src/transports/dash/text_parser.ts +5 -1
- package/src/transports/local/text_parser.ts +5 -1
- package/src/transports/metaplaylist/pipelines.ts +2 -1
- package/src/transports/smooth/isobmff/__tests__/create_boxes.test.ts +150 -127
- package/src/transports/smooth/pipelines.ts +3 -3
- package/src/transports/types.ts +28 -2
- package/src/transports/utils/__tests__/check_isobmff_integrity.test.ts +49 -75
- package/src/transports/utils/parse_text_track.ts +10 -3
- package/src/utils/__tests__/object_assign.test.ts +2 -2
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { describe, beforeEach, it, expect, vi } from "vitest";
|
|
2
2
|
import globalScope from "../../utils/global_scope";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// FIXME: fix that one. Mocking properties used in global scope doesn't seem to
|
|
5
|
+
// work: each `importActual` does not seem to trigger a file execution, only the
|
|
6
|
+
// first one does.
|
|
7
|
+
// Only in vitest's browser mode.
|
|
8
|
+
describe.skip("compat - browser compatibility types", () => {
|
|
5
9
|
interface IFakeWindow {
|
|
6
10
|
MediaSource?: unknown;
|
|
7
11
|
MozMediaSource?: unknown;
|
|
@@ -15,10 +19,6 @@ describe("compat - browser compatibility types", () => {
|
|
|
15
19
|
});
|
|
16
20
|
|
|
17
21
|
it("should use the native MediaSource if defined", async () => {
|
|
18
|
-
vi.doMock("../../utils/is_node", () => ({
|
|
19
|
-
default: false,
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
22
|
const origMediaSource = gs.MediaSource;
|
|
23
23
|
const origMozMediaSource = gs.MozMediaSource;
|
|
24
24
|
const origWebKitMediaSource = gs.WebKitMediaSource;
|
|
@@ -31,7 +31,8 @@ describe("compat - browser compatibility types", () => {
|
|
|
31
31
|
gs.MSMediaSource = { a: 4 };
|
|
32
32
|
gs.ManagedMediaSource = { a: 5 };
|
|
33
33
|
|
|
34
|
-
const
|
|
34
|
+
const MediaSource_ = (await vi.importActual("../browser_compatibility_types.ts"))
|
|
35
|
+
.MediaSource_ as typeof MediaSource;
|
|
35
36
|
expect(MediaSource_).toEqual({ a: 1 });
|
|
36
37
|
|
|
37
38
|
gs.MediaSource = origMediaSource;
|
|
@@ -42,10 +43,6 @@ describe("compat - browser compatibility types", () => {
|
|
|
42
43
|
});
|
|
43
44
|
|
|
44
45
|
it("should use MozMediaSource if defined and MediaSource is not", async () => {
|
|
45
|
-
vi.doMock("../../utils/is_node", () => ({
|
|
46
|
-
default: false,
|
|
47
|
-
}));
|
|
48
|
-
|
|
49
46
|
const origMediaSource = gs.MediaSource;
|
|
50
47
|
const origMozMediaSource = gs.MozMediaSource;
|
|
51
48
|
const origWebKitMediaSource = gs.WebKitMediaSource;
|
|
@@ -57,7 +54,8 @@ describe("compat - browser compatibility types", () => {
|
|
|
57
54
|
gs.WebKitMediaSource = undefined;
|
|
58
55
|
gs.MSMediaSource = undefined;
|
|
59
56
|
|
|
60
|
-
const
|
|
57
|
+
const MediaSource_ = (await vi.importActual("../browser_compatibility_types.ts"))
|
|
58
|
+
.MediaSource_ as typeof MediaSource;
|
|
61
59
|
expect(MediaSource_).toEqual({ a: 2 });
|
|
62
60
|
|
|
63
61
|
gs.MediaSource = origMediaSource;
|
|
@@ -68,10 +66,6 @@ describe("compat - browser compatibility types", () => {
|
|
|
68
66
|
});
|
|
69
67
|
|
|
70
68
|
it("should use WebKitMediaSource if defined and MediaSource is not", async () => {
|
|
71
|
-
vi.doMock("../../utils/is_node", () => ({
|
|
72
|
-
default: false,
|
|
73
|
-
}));
|
|
74
|
-
|
|
75
69
|
const origMediaSource = gs.MediaSource;
|
|
76
70
|
const origMozMediaSource = gs.MozMediaSource;
|
|
77
71
|
const origWebKitMediaSource = gs.WebKitMediaSource;
|
|
@@ -83,7 +77,8 @@ describe("compat - browser compatibility types", () => {
|
|
|
83
77
|
gs.WebKitMediaSource = { a: 3 };
|
|
84
78
|
gs.MSMediaSource = undefined;
|
|
85
79
|
|
|
86
|
-
const
|
|
80
|
+
const MediaSource_ = (await vi.importActual("../browser_compatibility_types.ts"))
|
|
81
|
+
.MediaSource_ as typeof MediaSource;
|
|
87
82
|
expect(MediaSource_).toEqual({ a: 3 });
|
|
88
83
|
|
|
89
84
|
gs.MediaSource = origMediaSource;
|
|
@@ -94,10 +89,6 @@ describe("compat - browser compatibility types", () => {
|
|
|
94
89
|
});
|
|
95
90
|
|
|
96
91
|
it("should use MSMediaSource if defined and MediaSource is not", async () => {
|
|
97
|
-
vi.doMock("../../utils/is_node", () => ({
|
|
98
|
-
default: false,
|
|
99
|
-
}));
|
|
100
|
-
|
|
101
92
|
const origMediaSource = gs.MediaSource;
|
|
102
93
|
const origMozMediaSource = gs.MozMediaSource;
|
|
103
94
|
const origWebKitMediaSource = gs.WebKitMediaSource;
|
|
@@ -109,7 +100,8 @@ describe("compat - browser compatibility types", () => {
|
|
|
109
100
|
gs.WebKitMediaSource = undefined;
|
|
110
101
|
gs.MSMediaSource = { a: 4 };
|
|
111
102
|
|
|
112
|
-
const
|
|
103
|
+
const MediaSource_ = (await vi.importActual("../browser_compatibility_types.ts"))
|
|
104
|
+
.MediaSource_ as typeof MediaSource;
|
|
113
105
|
expect(MediaSource_).toEqual({ a: 4 });
|
|
114
106
|
|
|
115
107
|
gs.MediaSource = origMediaSource;
|
|
@@ -120,10 +112,6 @@ describe("compat - browser compatibility types", () => {
|
|
|
120
112
|
});
|
|
121
113
|
|
|
122
114
|
it("should use ManagedMediaSource if defined and MediaSource is not", async () => {
|
|
123
|
-
vi.doMock("../../utils/is_node", () => ({
|
|
124
|
-
default: false,
|
|
125
|
-
}));
|
|
126
|
-
|
|
127
115
|
const origMediaSource = gs.MediaSource;
|
|
128
116
|
const origMozMediaSource = gs.MozMediaSource;
|
|
129
117
|
const origWebKitMediaSource = gs.WebKitMediaSource;
|
|
@@ -136,7 +124,8 @@ describe("compat - browser compatibility types", () => {
|
|
|
136
124
|
gs.MSMediaSource = undefined;
|
|
137
125
|
gs.ManagedMediaSource = { a: 5 };
|
|
138
126
|
|
|
139
|
-
const
|
|
127
|
+
const MediaSource_ = (await vi.importActual("../browser_compatibility_types.ts"))
|
|
128
|
+
.MediaSource_ as typeof MediaSource;
|
|
140
129
|
expect(MediaSource_).toEqual({ a: 5 });
|
|
141
130
|
|
|
142
131
|
gs.MediaSource = origMediaSource;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { describe, afterEach, it, expect, vi } from "vitest";
|
|
2
|
-
import { getFirefoxVersion } from "../browser_version";
|
|
2
|
+
import { getChromeVersion, getFirefoxVersion } from "../browser_version";
|
|
3
3
|
import EnvDetector, { mockEnvironment, resetEnvironment } from "../env_detector";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
);
|
|
5
|
+
const origUserAgent = navigator.userAgent;
|
|
6
|
+
Object.defineProperty(
|
|
7
|
+
navigator,
|
|
8
|
+
"userAgent",
|
|
9
|
+
((initVal: string) => {
|
|
10
|
+
let value = initVal;
|
|
11
|
+
return {
|
|
12
|
+
get() {
|
|
13
|
+
return value;
|
|
14
|
+
},
|
|
15
|
+
set(v: string) {
|
|
16
|
+
value = v;
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
})(navigator.userAgent),
|
|
20
|
+
);
|
|
22
21
|
|
|
22
|
+
describe("Compat - Browser version", () => {
|
|
23
23
|
const nav = navigator as {
|
|
24
24
|
userAgent: string;
|
|
25
25
|
};
|
|
@@ -57,3 +57,42 @@ describe("Compat - Browser version", () => {
|
|
|
57
57
|
expect(version).toBe(-1);
|
|
58
58
|
});
|
|
59
59
|
});
|
|
60
|
+
|
|
61
|
+
describe("Compat - Chrome version", () => {
|
|
62
|
+
const nav = navigator as {
|
|
63
|
+
userAgent: string;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
afterEach(() => {
|
|
67
|
+
nav.userAgent = origUserAgent;
|
|
68
|
+
vi.resetModules();
|
|
69
|
+
resetEnvironment();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("Should return correct Chrome version (60)", () => {
|
|
73
|
+
mockEnvironment(EnvDetector.BROWSERS.Other, EnvDetector.DEVICES.Other);
|
|
74
|
+
nav.userAgent = "Chrome/60.0";
|
|
75
|
+
const version = getChromeVersion();
|
|
76
|
+
expect(version).toBe(60);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("Should return correct Chrome version (80)", () => {
|
|
80
|
+
mockEnvironment(EnvDetector.BROWSERS.Other, EnvDetector.DEVICES.Other);
|
|
81
|
+
nav.userAgent = "Chrome/80.0";
|
|
82
|
+
const version = getChromeVersion();
|
|
83
|
+
expect(version).toBe(80);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("Should return null when not on Chrome", () => {
|
|
87
|
+
mockEnvironment(EnvDetector.BROWSERS.Ie11, EnvDetector.DEVICES.Other);
|
|
88
|
+
const version = getChromeVersion();
|
|
89
|
+
expect(version).toBe(null);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("Should return null with invalid Chrome user agent", () => {
|
|
93
|
+
mockEnvironment(EnvDetector.BROWSERS.Other, EnvDetector.DEVICES.Other);
|
|
94
|
+
nav.userAgent = "Toto/80.0";
|
|
95
|
+
const version = getChromeVersion();
|
|
96
|
+
expect(version).toBe(null);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
import { describe, beforeEach, it, expect, vi } from "vitest";
|
|
1
|
+
import { describe, beforeEach, it, expect, vi, afterEach } from "vitest";
|
|
2
|
+
import log from "../../log";
|
|
2
3
|
import arrayFindIndex from "../../utils/array_find_index";
|
|
3
4
|
import type { IMediaElement } from "../browser_compatibility_types";
|
|
4
|
-
import
|
|
5
|
+
import clearElementSrc from "../clear_element_src";
|
|
6
|
+
|
|
7
|
+
const logWarn = vi.spyOn(log, "warn").mockImplementation(() => {
|
|
8
|
+
/* noop */
|
|
9
|
+
});
|
|
5
10
|
|
|
6
11
|
describe("Compat - clearElementSrc", () => {
|
|
7
12
|
beforeEach(() => {
|
|
8
13
|
vi.resetModules();
|
|
9
14
|
});
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
logWarn.mockClear();
|
|
17
|
+
});
|
|
10
18
|
|
|
11
|
-
it("should empty the src and remove the Attribute for a given Element",
|
|
19
|
+
it("should empty the src and remove the Attribute for a given Element", () => {
|
|
12
20
|
const fakeElement = {
|
|
13
21
|
src: "foo",
|
|
14
22
|
removeAttribute() {
|
|
15
23
|
return null;
|
|
16
24
|
},
|
|
17
25
|
} as unknown as IMediaElement;
|
|
18
|
-
const clearElementSrc = (await vi.importActual("../clear_element_src"))
|
|
19
|
-
.default as typeof IClearElementSrc;
|
|
20
|
-
|
|
21
26
|
const spyRemoveAttribute = vi.spyOn(fakeElement, "removeAttribute");
|
|
22
27
|
clearElementSrc(fakeElement);
|
|
23
28
|
expect(fakeElement.src).toBe("");
|
|
@@ -25,17 +30,14 @@ describe("Compat - clearElementSrc", () => {
|
|
|
25
30
|
expect(spyRemoveAttribute).toHaveBeenCalledWith("src");
|
|
26
31
|
});
|
|
27
32
|
|
|
28
|
-
it("should throw if failed to remove the Attribute for a given Element",
|
|
33
|
+
it("should throw if failed to remove the Attribute for a given Element", () => {
|
|
29
34
|
const fakeElement = {
|
|
30
35
|
src: "foo",
|
|
31
36
|
removeAttribute() {
|
|
32
37
|
throw new Error("Oups, can't remove attribute.");
|
|
33
38
|
},
|
|
34
39
|
} as unknown as IMediaElement;
|
|
35
|
-
const clearElementSrc = (await vi.importActual("../clear_element_src"))
|
|
36
|
-
.default as typeof IClearElementSrc;
|
|
37
40
|
const spyRemoveAttribute = vi.spyOn(fakeElement, "removeAttribute");
|
|
38
|
-
|
|
39
41
|
expect(() => clearElementSrc(fakeElement)).toThrowError(
|
|
40
42
|
"Oups, can't remove attribute.",
|
|
41
43
|
);
|
|
@@ -43,7 +45,7 @@ describe("Compat - clearElementSrc", () => {
|
|
|
43
45
|
expect(spyRemoveAttribute).toHaveBeenCalledTimes(1);
|
|
44
46
|
});
|
|
45
47
|
|
|
46
|
-
it("should disable text tracks and remove childs",
|
|
48
|
+
it("should disable text tracks and remove childs", () => {
|
|
47
49
|
const fakeElement = {
|
|
48
50
|
src: "foo",
|
|
49
51
|
removeAttribute() {
|
|
@@ -59,9 +61,6 @@ describe("Compat - clearElementSrc", () => {
|
|
|
59
61
|
},
|
|
60
62
|
} as unknown as IMediaElement;
|
|
61
63
|
|
|
62
|
-
const clearElementSrc = (await vi.importActual("../clear_element_src"))
|
|
63
|
-
.default as typeof IClearElementSrc;
|
|
64
|
-
|
|
65
64
|
const spyRemoveAttribute = vi.spyOn(fakeElement, "removeAttribute");
|
|
66
65
|
const spyHasChildNodes = vi.spyOn(fakeElement, "hasChildNodes");
|
|
67
66
|
const spyRemoveChild = vi.spyOn(fakeElement, "removeChild");
|
|
@@ -79,7 +78,7 @@ describe("Compat - clearElementSrc", () => {
|
|
|
79
78
|
expect(spyRemoveChild).toHaveBeenCalledWith({ nodeName: "track" });
|
|
80
79
|
});
|
|
81
80
|
|
|
82
|
-
it("should log when failed to remove text track child node",
|
|
81
|
+
it("should log when failed to remove text track child node", () => {
|
|
83
82
|
const fakeElement = {
|
|
84
83
|
src: "foo",
|
|
85
84
|
removeAttribute() {
|
|
@@ -93,13 +92,6 @@ describe("Compat - clearElementSrc", () => {
|
|
|
93
92
|
},
|
|
94
93
|
} as unknown as IMediaElement;
|
|
95
94
|
|
|
96
|
-
const mockLogWarn = vi.fn((message: unknown) => message);
|
|
97
|
-
vi.doMock("../../log", () => ({
|
|
98
|
-
default: { warn: mockLogWarn },
|
|
99
|
-
}));
|
|
100
|
-
const clearElementSrc = (await vi.importActual("../clear_element_src"))
|
|
101
|
-
.default as typeof IClearElementSrc;
|
|
102
|
-
|
|
103
95
|
const spyRemoveAttribute = vi.spyOn(fakeElement, "removeAttribute");
|
|
104
96
|
const spyHasChildNodes = vi.spyOn(fakeElement, "hasChildNodes");
|
|
105
97
|
const spyRemoveChild = vi.spyOn(fakeElement, "removeChild");
|
|
@@ -118,14 +110,14 @@ describe("Compat - clearElementSrc", () => {
|
|
|
118
110
|
expect(spyRemoveAttribute).toHaveBeenCalledWith("src");
|
|
119
111
|
expect(spyHasChildNodes).toHaveBeenCalledTimes(1);
|
|
120
112
|
expect(spyRemoveChild).toHaveBeenCalledTimes(2);
|
|
121
|
-
expect(
|
|
122
|
-
expect(
|
|
113
|
+
expect(logWarn).toHaveBeenCalledTimes(2);
|
|
114
|
+
expect(logWarn).toHaveBeenCalledWith(
|
|
123
115
|
"media",
|
|
124
116
|
"Could not remove text track child from element.",
|
|
125
117
|
);
|
|
126
118
|
});
|
|
127
119
|
|
|
128
|
-
it("should not remove audio child node if on firefox and no text tracks",
|
|
120
|
+
it("should not remove audio child node if on firefox and no text tracks", () => {
|
|
129
121
|
const fakeElement = {
|
|
130
122
|
src: "foo",
|
|
131
123
|
removeAttribute() {
|
|
@@ -137,9 +129,6 @@ describe("Compat - clearElementSrc", () => {
|
|
|
137
129
|
removeChild: () => null,
|
|
138
130
|
} as unknown as IMediaElement;
|
|
139
131
|
|
|
140
|
-
const clearElementSrc = (await vi.importActual("../clear_element_src"))
|
|
141
|
-
.default as typeof IClearElementSrc;
|
|
142
|
-
|
|
143
132
|
const spyRemoveAttribute = vi.spyOn(fakeElement, "removeAttribute");
|
|
144
133
|
const spyHasChildNodes = vi.spyOn(fakeElement, "hasChildNodes");
|
|
145
134
|
const spyRemoveChild = vi.spyOn(fakeElement, "removeChild");
|
|
@@ -154,7 +143,7 @@ describe("Compat - clearElementSrc", () => {
|
|
|
154
143
|
expect(spyRemoveChild).not.toHaveBeenCalled();
|
|
155
144
|
});
|
|
156
145
|
|
|
157
|
-
it("should not handle text tracks nodes is has no child nodes",
|
|
146
|
+
it("should not handle text tracks nodes is has no child nodes", () => {
|
|
158
147
|
const fakeElement = {
|
|
159
148
|
src: "foo",
|
|
160
149
|
removeAttribute() {
|
|
@@ -166,9 +155,6 @@ describe("Compat - clearElementSrc", () => {
|
|
|
166
155
|
removeChild: () => null,
|
|
167
156
|
} as unknown as IMediaElement;
|
|
168
157
|
|
|
169
|
-
const clearElementSrc = (await vi.importActual("../clear_element_src"))
|
|
170
|
-
.default as typeof IClearElementSrc;
|
|
171
|
-
|
|
172
158
|
const spyRemoveAttribute = vi.spyOn(fakeElement, "removeAttribute");
|
|
173
159
|
const spyHasChildNodes = vi.spyOn(fakeElement, "hasChildNodes");
|
|
174
160
|
const spyRemoveChild = vi.spyOn(fakeElement, "removeChild");
|
|
@@ -183,7 +169,7 @@ describe("Compat - clearElementSrc", () => {
|
|
|
183
169
|
expect(spyRemoveChild).not.toHaveBeenCalled();
|
|
184
170
|
});
|
|
185
171
|
|
|
186
|
-
it("should not throw if the textTracks attribute is `null`",
|
|
172
|
+
it("should not throw if the textTracks attribute is `null`", () => {
|
|
187
173
|
const fakeElement = {
|
|
188
174
|
src: "foo",
|
|
189
175
|
removeAttribute() {
|
|
@@ -195,9 +181,6 @@ describe("Compat - clearElementSrc", () => {
|
|
|
195
181
|
removeChild: () => null,
|
|
196
182
|
} as unknown as IMediaElement;
|
|
197
183
|
|
|
198
|
-
const clearElementSrc = (await vi.importActual("../clear_element_src"))
|
|
199
|
-
.default as typeof IClearElementSrc;
|
|
200
|
-
|
|
201
184
|
const spyRemoveAttribute = vi.spyOn(fakeElement, "removeAttribute");
|
|
202
185
|
const spyHasChildNodes = vi.spyOn(fakeElement, "hasChildNodes");
|
|
203
186
|
const spyRemoveChild = vi.spyOn(fakeElement, "removeChild");
|
|
@@ -212,7 +195,7 @@ describe("Compat - clearElementSrc", () => {
|
|
|
212
195
|
expect(spyRemoveChild).not.toHaveBeenCalled();
|
|
213
196
|
});
|
|
214
197
|
|
|
215
|
-
it("should not throw if the textTracks attribute is `undefined`",
|
|
198
|
+
it("should not throw if the textTracks attribute is `undefined`", () => {
|
|
216
199
|
const fakeElement = {
|
|
217
200
|
src: "foo",
|
|
218
201
|
removeAttribute() {
|
|
@@ -224,9 +207,6 @@ describe("Compat - clearElementSrc", () => {
|
|
|
224
207
|
removeChild: () => null,
|
|
225
208
|
} as unknown as IMediaElement;
|
|
226
209
|
|
|
227
|
-
const clearElementSrc = (await vi.importActual("../clear_element_src"))
|
|
228
|
-
.default as typeof IClearElementSrc;
|
|
229
|
-
|
|
230
210
|
const spyRemoveAttribute = vi.spyOn(fakeElement, "removeAttribute");
|
|
231
211
|
const spyHasChildNodes = vi.spyOn(fakeElement, "hasChildNodes");
|
|
232
212
|
const spyRemoveChild = vi.spyOn(fakeElement, "removeChild");
|
|
@@ -1,64 +1,59 @@
|
|
|
1
|
-
import { describe, beforeEach, it, expect, vi } from "vitest";
|
|
2
|
-
import
|
|
1
|
+
import { describe, beforeEach, it, expect, vi, afterEach } from "vitest";
|
|
2
|
+
import isCodecSupported from "../is_codec_supported";
|
|
3
|
+
|
|
4
|
+
const mocks = vi.hoisted(() => {
|
|
5
|
+
return {
|
|
6
|
+
default: {
|
|
7
|
+
MediaSource_: {} as unknown,
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
vi.mock("../browser_compatibility_types", () => {
|
|
13
|
+
return mocks;
|
|
14
|
+
});
|
|
3
15
|
|
|
4
16
|
describe("Compat - isCodecSupported", () => {
|
|
5
17
|
beforeEach(() => {
|
|
6
18
|
vi.resetModules();
|
|
7
19
|
});
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
mocks.default.MediaSource_ = {};
|
|
22
|
+
});
|
|
8
23
|
|
|
9
|
-
it("should return false if MediaSource is not supported in the current device",
|
|
10
|
-
|
|
11
|
-
return {
|
|
12
|
-
MediaSource_: undefined,
|
|
13
|
-
};
|
|
14
|
-
});
|
|
15
|
-
const isCodecSupported = (await vi.importActual("../is_codec_supported"))
|
|
16
|
-
.default as typeof IIsCodecSupported;
|
|
24
|
+
it("should return false if MediaSource is not supported in the current device", () => {
|
|
25
|
+
mocks.default.MediaSource_ = undefined;
|
|
17
26
|
expect(isCodecSupported(document.createElement("video"), "foo")).toEqual(false);
|
|
18
27
|
expect(isCodecSupported(document.createElement("video"), "")).toEqual(false);
|
|
19
28
|
});
|
|
20
29
|
|
|
21
|
-
it("should return true in any case if the MediaSource does not have the right function",
|
|
22
|
-
|
|
23
|
-
return {
|
|
24
|
-
MediaSource_: { isTypeSupported: undefined },
|
|
25
|
-
};
|
|
26
|
-
});
|
|
27
|
-
const isCodecSupported = (await vi.importActual("../is_codec_supported"))
|
|
28
|
-
.default as typeof IIsCodecSupported;
|
|
30
|
+
it("should return true in any case if the MediaSource does not have the right function", () => {
|
|
31
|
+
mocks.default.MediaSource_ = { isTypeSupported: undefined };
|
|
29
32
|
expect(isCodecSupported(document.createElement("video"), "foo")).toEqual(true);
|
|
30
33
|
expect(isCodecSupported(document.createElement("video"), "")).toEqual(true);
|
|
31
34
|
});
|
|
32
35
|
|
|
33
|
-
it("should return true if MediaSource.isTypeSupported returns true",
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
});
|
|
43
|
-
const isCodecSupported = (await vi.importActual("../is_codec_supported"))
|
|
44
|
-
.default as typeof IIsCodecSupported;
|
|
36
|
+
it("should return true if MediaSource.isTypeSupported returns true", () => {
|
|
37
|
+
mocks.default.MediaSource_ = {
|
|
38
|
+
isTypeSupported(_codec: string) {
|
|
39
|
+
return true;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
45
42
|
expect(isCodecSupported(document.createElement("video"), "foo")).toEqual(true);
|
|
46
43
|
expect(isCodecSupported(document.createElement("video"), "")).toEqual(true);
|
|
47
44
|
});
|
|
48
45
|
|
|
49
|
-
it("should return false if MediaSource.isTypeSupported returns false",
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
expect(isCodecSupported(document.createElement("video"), "foo")).toEqual(false);
|
|
62
|
-
expect(isCodecSupported(document.createElement("video"), "")).toEqual(false);
|
|
46
|
+
it("should return false if MediaSource.isTypeSupported returns false", () => {
|
|
47
|
+
mocks.default.MediaSource_ = {
|
|
48
|
+
isTypeSupported(_codec: string) {
|
|
49
|
+
return false;
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
expect(
|
|
53
|
+
isCodecSupported(document.createElement("video"), "oohjustlikeweneversaidgoodbye"),
|
|
54
|
+
).toEqual(false);
|
|
55
|
+
expect(
|
|
56
|
+
isCodecSupported(document.createElement("video"), "ontheinternetwaitingtosayhi"),
|
|
57
|
+
).toEqual(false);
|
|
63
58
|
});
|
|
64
59
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { describe, it, expect
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
2
|
import globalScope from "../../utils/global_scope";
|
|
3
|
-
import
|
|
3
|
+
import isVTTCue from "../is_vtt_cue";
|
|
4
4
|
|
|
5
5
|
describe("Compat - isVTTCue", () => {
|
|
6
6
|
interface IFakeWindow {
|
|
@@ -18,16 +18,15 @@ describe("Compat - isVTTCue", () => {
|
|
|
18
18
|
}
|
|
19
19
|
const gs = globalScope as IFakeWindow;
|
|
20
20
|
|
|
21
|
-
it("should return true if the given cue is an instance of a vtt cue",
|
|
21
|
+
it("should return true if the given cue is an instance of a vtt cue", () => {
|
|
22
22
|
const originalVTTCue = globalScope.VTTCue;
|
|
23
23
|
gs.VTTCue = MockVTTCue;
|
|
24
24
|
const cue = new VTTCue(0, 10, "");
|
|
25
|
-
const isVTTCue = (await vi.importActual("../is_vtt_cue")).default as typeof IIsVTTCue;
|
|
26
25
|
expect(isVTTCue(cue)).toEqual(true);
|
|
27
26
|
globalScope.VTTCue = originalVTTCue;
|
|
28
27
|
});
|
|
29
28
|
|
|
30
|
-
it("should return false if the given cue is not an instance of a vtt cue",
|
|
29
|
+
it("should return false if the given cue is not an instance of a vtt cue", () => {
|
|
31
30
|
const originalVTTCue = globalScope.VTTCue;
|
|
32
31
|
gs.VTTCue = MockVTTCue;
|
|
33
32
|
const cue = {
|
|
@@ -35,17 +34,15 @@ describe("Compat - isVTTCue", () => {
|
|
|
35
34
|
endTime: 10,
|
|
36
35
|
text: "toto",
|
|
37
36
|
} as unknown as VTTCue;
|
|
38
|
-
const isVTTCue = (await vi.importActual("../is_vtt_cue")).default as typeof IIsVTTCue;
|
|
39
37
|
expect(isVTTCue(cue)).toEqual(false);
|
|
40
38
|
globalScope.VTTCue = originalVTTCue;
|
|
41
39
|
});
|
|
42
40
|
|
|
43
|
-
it("should return false in any case if the global scope does not define a VTTCue",
|
|
41
|
+
it("should return false in any case if the global scope does not define a VTTCue", () => {
|
|
44
42
|
const originalVTTCue = globalScope.VTTCue;
|
|
45
43
|
gs.VTTCue = MockVTTCue;
|
|
46
44
|
const cue = new VTTCue(0, 10, "");
|
|
47
45
|
delete gs.VTTCue;
|
|
48
|
-
const isVTTCue = (await vi.importActual("../is_vtt_cue")).default as typeof IIsVTTCue;
|
|
49
46
|
expect(isVTTCue(cue)).toEqual(false);
|
|
50
47
|
globalScope.VTTCue = originalVTTCue;
|
|
51
48
|
});
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import { describe, beforeEach, it, expect, vi } from "vitest";
|
|
1
|
+
import { describe, beforeEach, it, expect, vi, afterEach } from "vitest";
|
|
2
|
+
import log from "../../log";
|
|
2
3
|
import globalScope from "../../utils/global_scope";
|
|
3
|
-
import
|
|
4
|
+
import makeCue from "../make_vtt_cue";
|
|
5
|
+
|
|
6
|
+
const logWarn = vi.spyOn(log, "warn").mockImplementation(() => {
|
|
7
|
+
/* noop */
|
|
8
|
+
});
|
|
4
9
|
|
|
5
10
|
describe("Compat - makeVTTCue", () => {
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
logWarn.mockClear();
|
|
13
|
+
});
|
|
6
14
|
class MockVTTCue {
|
|
7
15
|
public startTime: number;
|
|
8
16
|
public endTime: number;
|
|
@@ -27,14 +35,9 @@ describe("Compat - makeVTTCue", () => {
|
|
|
27
35
|
gs.TextTrackCue = ogTextTrackCue;
|
|
28
36
|
});
|
|
29
37
|
|
|
30
|
-
it("should throw if nor VTTCue nor TextTrackCue is available",
|
|
31
|
-
const mockLog = { warn: vi.fn() };
|
|
38
|
+
it("should throw if nor VTTCue nor TextTrackCue is available", () => {
|
|
32
39
|
gs.VTTCue = undefined;
|
|
33
40
|
gs.TextTrackCue = undefined;
|
|
34
|
-
vi.doMock("../../log", () => ({
|
|
35
|
-
default: mockLog,
|
|
36
|
-
}));
|
|
37
|
-
const makeCue = (await vi.importActual("../make_vtt_cue")).default as typeof IMakeCue;
|
|
38
41
|
let result: unknown;
|
|
39
42
|
let error: unknown;
|
|
40
43
|
try {
|
|
@@ -45,38 +48,24 @@ describe("Compat - makeVTTCue", () => {
|
|
|
45
48
|
expect(error).toBeInstanceOf(Error);
|
|
46
49
|
expect((error as Error).message).toEqual("VTT cues not supported in your target");
|
|
47
50
|
expect(result).toBe(undefined);
|
|
48
|
-
expect(
|
|
51
|
+
expect(logWarn).not.toHaveBeenCalled();
|
|
49
52
|
});
|
|
50
53
|
|
|
51
|
-
it("should warn and not create anything if start time is after end time",
|
|
52
|
-
const mockLog = { warn: vi.fn() };
|
|
54
|
+
it("should warn and not create anything if start time is after end time", () => {
|
|
53
55
|
gs.VTTCue = MockVTTCue;
|
|
54
|
-
vi.doMock("../../log", () => ({
|
|
55
|
-
default: mockLog,
|
|
56
|
-
}));
|
|
57
|
-
const makeCue = (await vi.importActual("../make_vtt_cue")).default as typeof IMakeCue;
|
|
58
56
|
const result = makeCue(12, 10, "toto");
|
|
59
57
|
expect(result).toBeNull();
|
|
60
|
-
expect(
|
|
61
|
-
expect(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
endTime: 10,
|
|
66
|
-
startTime: 12,
|
|
67
|
-
},
|
|
68
|
-
);
|
|
58
|
+
expect(logWarn).toHaveBeenCalledTimes(1);
|
|
59
|
+
expect(logWarn).toHaveBeenCalledWith("text", "Invalid cue times: start after end.", {
|
|
60
|
+
endTime: 10,
|
|
61
|
+
startTime: 12,
|
|
62
|
+
});
|
|
69
63
|
});
|
|
70
64
|
|
|
71
|
-
it("should create a new VTT Cue in other cases",
|
|
72
|
-
const mockLog = { warn: vi.fn() };
|
|
65
|
+
it("should create a new VTT Cue in other cases", () => {
|
|
73
66
|
gs.VTTCue = MockVTTCue;
|
|
74
|
-
vi.doMock("../../log", () => ({
|
|
75
|
-
default: mockLog,
|
|
76
|
-
}));
|
|
77
|
-
const makeCue = (await vi.importActual("../make_vtt_cue")).default as typeof IMakeCue;
|
|
78
67
|
const result = makeCue(10, 12, "toto");
|
|
79
68
|
expect(result).toEqual(new MockVTTCue(10, 12, "toto"));
|
|
80
|
-
expect(
|
|
69
|
+
expect(logWarn).not.toHaveBeenCalled();
|
|
81
70
|
});
|
|
82
71
|
});
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import { describe, beforeEach, afterEach, it, expect, vi } from "vitest";
|
|
2
|
+
import log from "../../log";
|
|
2
3
|
import arrayFindIndex from "../../utils/array_find_index";
|
|
3
4
|
import EnvDetector, { mockEnvironment, resetEnvironment } from "../env_detector";
|
|
4
5
|
import removeCue from "../remove_cue";
|
|
5
6
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
logWarn: vi.fn(),
|
|
9
|
-
};
|
|
7
|
+
const logWarn = vi.spyOn(log, "warn").mockImplementation(() => {
|
|
8
|
+
/* noop */
|
|
10
9
|
});
|
|
11
|
-
vi.mock("../../log", () => ({
|
|
12
|
-
default: {
|
|
13
|
-
warn: mocks.logWarn,
|
|
14
|
-
},
|
|
15
|
-
}));
|
|
16
10
|
|
|
17
11
|
describe("compat - removeCue", () => {
|
|
18
12
|
beforeEach(() => {
|
|
@@ -20,7 +14,7 @@ describe("compat - removeCue", () => {
|
|
|
20
14
|
});
|
|
21
15
|
afterEach(() => {
|
|
22
16
|
resetEnvironment();
|
|
23
|
-
|
|
17
|
+
logWarn.mockClear();
|
|
24
18
|
});
|
|
25
19
|
|
|
26
20
|
it("should remove cue from track if not on firefox", () => {
|
|
@@ -169,11 +163,8 @@ describe("compat - removeCue", () => {
|
|
|
169
163
|
|
|
170
164
|
expect(fakeTrack.cues?.length).toBe(1);
|
|
171
165
|
expect(fakeTrack.mode).toBe("showing");
|
|
172
|
-
expect(
|
|
173
|
-
expect(
|
|
174
|
-
"text",
|
|
175
|
-
"Could not remove cue from text track.",
|
|
176
|
-
);
|
|
166
|
+
expect(logWarn).toHaveBeenCalledTimes(1);
|
|
167
|
+
expect(logWarn).toHaveBeenCalledWith("text", "Could not remove cue from text track.");
|
|
177
168
|
expect(mockRemoveCue).toHaveBeenCalledTimes(1);
|
|
178
169
|
expect(mockRemoveCue).toHaveBeenLastCalledWith(fakeCue);
|
|
179
170
|
});
|
|
@@ -195,11 +186,8 @@ describe("compat - removeCue", () => {
|
|
|
195
186
|
|
|
196
187
|
expect(fakeTrack.cues?.length).toBe(1);
|
|
197
188
|
expect(fakeTrack.mode).toBe("showing");
|
|
198
|
-
expect(
|
|
199
|
-
expect(
|
|
200
|
-
"text",
|
|
201
|
-
"Could not remove cue from text track.",
|
|
202
|
-
);
|
|
189
|
+
expect(logWarn).toHaveBeenCalledTimes(1);
|
|
190
|
+
expect(logWarn).toHaveBeenCalledWith("text", "Could not remove cue from text track.");
|
|
203
191
|
expect(mockRemoveCue).toHaveBeenCalledTimes(1);
|
|
204
192
|
expect(mockRemoveCue).toHaveBeenLastCalledWith({ id: "1" });
|
|
205
193
|
});
|