Revision 0324a6e8a143f16b689c354982e2a975748e7c56 authored by James Graham on 16 April 2018, 17:58:17 UTC, committed by moz-wptsync-bot on 16 April 2018, 23:59:07 UTC
These were previously timing out regularly on OSX debug builds. bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1454362 gecko-commit: e2f68d3b03c2fe2c8f489ba179e7dc871acda245 gecko-integration-branch: mozilla-inbound gecko-reviewers: testonly
1 parent 25b6727
mediasource-closed.html
<!DOCTYPE html>
<!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). -->
<html>
<head>
<title>MediaSource.readyState equals "closed" test cases.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="mediasource-util.js"></script>
</head>
<body>
<div id="log"></div>
<script>
test(function ()
{
var mediaSource = new MediaSource();
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(isNaN(mediaSource.duration), "duration is NaN");
}, "Test attribute values on a closed MediaSource object.");
test(function ()
{
var mediaSource = new MediaSource();
assert_throws("InvalidStateError",
function() { mediaSource.addSourceBuffer(MediaSourceUtil.VIDEO_ONLY_TYPE); },
"addSourceBuffer() throws an exception when closed.");
}, "Test addSourceBuffer() while closed.");
mediasource_test(function(test, mediaElement, mediaSource)
{
var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_ONLY_TYPE);
// Setup a handler to run when the MediaSource closes.
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_throws("NotFoundError",
function() { mediaSource.removeSourceBuffer(sourceBuffer); },
"removeSourceBuffer() throws an exception when closed.");
test.done();
}));
// Trigger the MediaSource to close.
mediaElement.src = "";
}, "Test removeSourceBuffer() while closed.");
test(function ()
{
var mediaSource = new MediaSource();
assert_throws("InvalidStateError",
function() { mediaSource.endOfStream(); },
"endOfStream() throws an exception when closed.");
}, "Test endOfStream() while closed.");
test(function ()
{
var mediaSource = new MediaSource();
assert_throws("InvalidStateError",
function() { mediaSource.endOfStream("decode"); },
"endOfStream(decode) throws an exception when closed.");
}, "Test endOfStream(decode) while closed.");
test(function ()
{
var mediaSource = new MediaSource();
assert_throws("InvalidStateError",
function() { mediaSource.endOfStream("network"); },
"endOfStream(network) throws an exception when closed.");
}, "Test endOfStream(network) while closed.");
test(function ()
{
var mediaSource = new MediaSource();
assert_throws("InvalidStateError",
function() { mediaSource.duration = 10; },
"Setting duration throws an exception when closed.");
}, "Test setting duration while closed.");
mediasource_test(function(test, mediaElement, mediaSource)
{
var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_ONLY_TYPE);
assert_equals(mediaSource.readyState, "open", "readyState is 'open'");
// Setup a handler to run when the MediaSource closes.
mediaSource.addEventListener("sourceclose", test.step_func(function (event)
{
assert_equals(mediaSource.readyState, "closed", "readyState is 'closed'");
assert_throws("InvalidStateError",
function() { mediaSource.duration = 10; },
"Setting duration when closed throws an exception");
test.done();
}));
// Trigger the MediaSource to close.
mediaElement.src = "";
}, "Test setting duration while open->closed.");
mediasource_test(function(test, mediaElement, mediaSource)
{
var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_ONLY_TYPE);
assert_equals(mediaSource.readyState, "open", "readyState is 'open'");
// Setup a handler to run when the MediaSource closes.
mediaSource.addEventListener("sourceclose", test.step_func(function (event)
{
assert_equals(mediaSource.readyState, "closed", "readyState is 'closed'");
assert_true(isNaN(mediaSource.duration), "duration is NaN");
test.done();
}));
// Trigger the MediaSource to close.
mediaElement.src = "";
}, "Test getting duration while open->closed.");
mediasource_test(function(test, mediaElement, mediaSource)
{
var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_ONLY_TYPE);
assert_equals(mediaSource.readyState, "open", "readyState is open");
// Setup a handler to run when the MediaSource closes.
mediaSource.addEventListener("sourceclose", test.step_func(function (event)
{
assert_equals(mediaSource.readyState, "closed", "readyState is closed");
assert_throws("InvalidStateError",
function() { sourceBuffer.abort(); },
"sourceBuffer.abort() throws INVALID_STATE_ERROR");
test.done();
}));
// Trigger the MediaSource to close.
mediaElement.src = "";
}, "Test sourcebuffer.abort when closed.");
</script>
</body>
</html>
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...