зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1314533: Do not expect init segment to be parsed when appending corrupted data. r=gerald
From the Segment Parser Loop definition: https://w3c.github.io/media-source/index.html#sourcebuffer-segment-parser-loop "2. If the input buffer contains bytes that violate the SourceBuffer byte stream format specification, then run the append error algorithm and abort this algorithm." The test appends data with a valid init segment followed by corrupted content. The corrupted content satisfies the condition that the input buffer contains bytes that violate byte stream format specification. As such, the append error algorithm is to be run prior parsing the init segment. Add a new test verifying the defined behavior. --HG-- extra : rebase_source : b20c653129c9f38bb5930c309f919131cd2fcc51
This commit is contained in:
Родитель
ad3b3a4b82
Коммит
9f6cc56c92
|
@ -174,13 +174,49 @@
|
|||
{
|
||||
assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_NOTHING);
|
||||
|
||||
var initSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init);
|
||||
test.expectEvent(sourceBuffer, "updateend", "mediaSegment append ended.");
|
||||
test.expectEvent(mediaElement, "loadedmetadata", "mediaElement metadata.");
|
||||
sourceBuffer.appendBuffer(initSegment);
|
||||
|
||||
test.waitForExpectedEvents(function()
|
||||
{
|
||||
assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_METADATA);
|
||||
var mediaSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.media[0]);
|
||||
var index = segmentInfo.init.size + (mediaSegment.length - 1) / 2;
|
||||
// Corrupt the media data from index of mediaData, so it can signal 'decode' error.
|
||||
// Here use mediaSegment to replace the original mediaData[index, index + mediaSegment.length]
|
||||
mediaData.set(mediaSegment, index);
|
||||
|
||||
test.expectEvent(sourceBuffer, "error", "sourceBuffer error.");
|
||||
test.expectEvent(sourceBuffer, "updateend", "mediaSegment append ended.");
|
||||
test.expectEvent(mediaElement, "error", "mediaElement error.");
|
||||
test.expectEvent(mediaSource, "sourceended", "mediaSource ended.");
|
||||
sourceBuffer.appendBuffer(mediaData);
|
||||
});
|
||||
|
||||
test.waitForExpectedEvents(function()
|
||||
{
|
||||
assert_true(mediaElement.error != null);
|
||||
assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_DECODE);
|
||||
test.done();
|
||||
});
|
||||
}, "Signaling 'decode' error via segment parser loop algorithm after initialization segment has been appended.");
|
||||
|
||||
ErrorTest(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
|
||||
{
|
||||
assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_NOTHING);
|
||||
|
||||
// Fail if the append error algorithm occurs, since the network
|
||||
// error will be provided by us directly via endOfStream().
|
||||
mediaElement.addEventListener("loadedmetadata", test.unreached_func("'loadedmetadata' should not be fired on mediaElement"));
|
||||
|
||||
var mediaSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.media[0]);
|
||||
var index = segmentInfo.init.size + (mediaSegment.length - 1) / 2;
|
||||
// Corrupt the media data from index of mediaData, so it can signal 'decode' error.
|
||||
// Here use mediaSegment to replace the original mediaData[index, index + mediaSegment.length]
|
||||
mediaData.set(mediaSegment, index);
|
||||
|
||||
test.expectEvent(mediaElement, "loadedmetadata", "mediaElement metadata.");
|
||||
test.expectEvent(sourceBuffer, "error", "sourceBuffer error.");
|
||||
test.expectEvent(sourceBuffer, "updateend", "mediaSegment append ended.");
|
||||
test.expectEvent(mediaElement, "error", "mediaElement error.");
|
||||
|
@ -189,9 +225,10 @@
|
|||
|
||||
test.waitForExpectedEvents(function()
|
||||
{
|
||||
assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_NOTHING);
|
||||
assert_true(mediaElement.error != null);
|
||||
assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_DECODE);
|
||||
assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED);
|
||||
test.done();
|
||||
});
|
||||
}, "Signaling 'decode' error via segment parser loop algorithm after initialization segment and partial media segment has been appended.");
|
||||
}, "Signaling 'decode' error via segment parser loop algorithm.");
|
||||
</script>
|
||||
|
|
Загрузка…
Ссылка в новой задаче