diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/media-source/mediasource-detach.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/media-source/mediasource-detach.html')
-rw-r--r-- | testing/web-platform/tests/media-source/mediasource-detach.html | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/testing/web-platform/tests/media-source/mediasource-detach.html b/testing/web-platform/tests/media-source/mediasource-detach.html new file mode 100644 index 0000000000..3f87d9a3d5 --- /dev/null +++ b/testing/web-platform/tests/media-source/mediasource-detach.html @@ -0,0 +1,54 @@ +<!DOCTYPE html> +<!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). --> +<meta charset="utf-8"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="mediasource-util.js"></script> +<script> + function mediasource_detach_test(testFunction, description) + { + mediasource_test(function(test, mediaElement, mediaSource) + { + var segmentInfo = MediaSourceUtil.SEGMENT_INFO; + var sourceBuffer = mediaSource.addSourceBuffer(segmentInfo.type); + + assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_NOTHING); + assert_equals(mediaSource.readyState, 'open'); + + mediaSource.addEventListener('sourceclose', test.step_func(function (event) + { + assert_equals(mediaSource.sourceBuffers.length, 0, 'sourceBuffers is empty'); + assert_equals(mediaSource.activeSourceBuffers.length, 0, 'activeSourceBuffers is empty'); + assert_equals(mediaSource.readyState, 'closed', 'readyState is "closed"'); + assert_true(Number.isNaN(mediaSource.duration), 'duration is NaN'); + test.done(); + })); + + MediaSourceUtil.loadBinaryData(test, segmentInfo.url, function(mediaData) + { + testFunction(test, mediaElement, mediaSource, sourceBuffer, mediaData); + }); + }, description); + } + + mediasource_detach_test(function(test, mediaElement, mediaSource, sourceBuffer, mediaData) + { + mediaElement.load(); + }, 'Test media.load() before appending data will trigger MediaSource detaching from a media element.'); + + mediasource_detach_test(function(test, mediaElement, mediaSource, sourceBuffer, mediaData) + { + test.expectEvent(sourceBuffer, 'updateend', 'updateend after appending data'); + test.expectEvent(mediaElement, 'loadedmetadata', 'media element loadedmetata'); + test.waitForExpectedEvents(() => + { + assert_greater_than(mediaElement.readyState, HTMLMediaElement.HAVE_NOTHING, + 'media element readyState is greater than "HAVE_NOTHING"'); + assert_false(sourceBuffer.updating, 'updating attribute is false'); + assert_equals(mediaSource.readyState, 'open'); + mediaElement.load(); + }); + + sourceBuffer.appendBuffer(mediaData); + }, 'Test media.load() after appending data will trigger MediaSource detaching from a media element.'); +</script> |