Skip to content

Commit

Permalink
Merge pull request #1395 from karlt/SourceBuffer-abort-
Browse files Browse the repository at this point in the history
remove race conditions from media-source/SourceBuffer-abort-*
  • Loading branch information
foolip committed Nov 19, 2014
2 parents f921001 + f37fb40 commit 8c07290
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 41 deletions.
9 changes: 5 additions & 4 deletions media-source/SourceBuffer-abort-readyState.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<div id="log"></div>

<script>
var video = document.createElement('video');
var contents = {'/media/white.webm': 'video/webm; codecs="vorbis,vp8"',
'/media/white.mp4' : 'video/mp4'};

Expand Down Expand Up @@ -49,13 +48,15 @@
mediaSource.addEventListener('sourceopen', function(e) {
sourceBuffer = mediaSource.addSourceBuffer(mime);
mediaSource.endOfStream();
assert_equals(mediaSource.readyState, 'ended',
'mediaSource.readyState is "ended" after endOfStream()');
});
mediaSource.addEventListener('sourceclose', function(e) {
mediaSource.addEventListener('sourceended', t.step_func_done(function(e) {
assert_throws({name: 'InvalidStateError'}, function() {
sourceBuffer.abort();
});
t.done();
});
}));
var video = document.createElement('video');
video.src = window.URL.createObjectURL(mediaSource);
});
}, 'SourceBuffer#abort() (' + mime + ') : If the readyState attribute ' +
Expand Down
19 changes: 8 additions & 11 deletions media-source/SourceBuffer-abort-removed.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<div id="log"></div>

<script>
var video = document.createElement('video');
var mimes = ['video/webm; codecs="vorbis,vp8"', 'video/mp4'];

//check the browser supports the MIME used in this test
Expand All @@ -30,18 +29,16 @@
return;
}
var mediaSource = new MediaSource();
mediaSource.addEventListener('sourceopen', function(e) {
mediaSource.addEventListener('sourceopen', t.step_func_done(function(e) {
var sourceBuffer = mediaSource.addSourceBuffer(mime);
mediaSource.removeSourceBuffer(sourceBuffer);
t.step(function() {
assert_throws({name: 'InvalidStateError'},
function() {
sourceBuffer.abort();
},
'SourceBuffer#abort() after removing the SourceBuffer object');
});
t.done();
}, false);
assert_throws({name: 'InvalidStateError'},
function() {
sourceBuffer.abort();
},
'SourceBuffer#abort() after removing the SourceBuffer object');
}), false);
var video = document.createElement('video');
video.src = window.URL.createObjectURL(mediaSource);
}, 'SourceBuffer#abort (' + mime + ') : ' +
'if this object has been removed from the sourceBuffers attribute of the parent media source, ' +
Expand Down
45 changes: 19 additions & 26 deletions media-source/SourceBuffer-abort-updating.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<div id="log"></div>

<script>
var video = document.createElement('video');
var contents = {'/media/white.webm': 'video/webm; codecs="vorbis,vp8"',
'/media/white.mp4' : 'video/mp4'};

Expand Down Expand Up @@ -47,46 +46,40 @@
var mediaSource = new MediaSource();
var num_updateend = 0;
var events = [];
mediaSource.addEventListener('sourceopen', function(e) {
mediaSource.addEventListener('sourceopen', t.step_func(function(e) {
var sourceBuffer = mediaSource.addSourceBuffer(mime);
t.step(function() {
assert_equals(sourceBuffer.updating, false);
});
sourceBuffer.addEventListener('updatestart', function(e) {
assert_equals(sourceBuffer.updating, false);
sourceBuffer.addEventListener('updatestart', t.step_func(function(e) {
events.push('updatestart');
//abort when sourceBuffer#updating is true
sourceBuffer.abort();

t.step(function() {
assert_equals(sourceBuffer.updating, false,
'Check updating value after calling abort.');
assert_equals(sourceBuffer.appendWindowStart, 0);
assert_equals(sourceBuffer.appendWindowEnd, Number.POSITIVE_INFINITY);
});
});
sourceBuffer.addEventListener('update', function(e) {
assert_equals(sourceBuffer.updating, false,
'Check updating value after calling abort.');
assert_equals(sourceBuffer.appendWindowStart, 0);
assert_equals(sourceBuffer.appendWindowEnd, Number.POSITIVE_INFINITY);
}));
sourceBuffer.addEventListener('update', t.step_func(function(e) {
assert_unreached("Can't touch this");
});
}));
sourceBuffer.addEventListener('updateend', function(e) {
events.push('updateend');
mediaSource.endOfStream();
});
sourceBuffer.addEventListener('abort', function(e) {
events.push('abort');
});
sourceBuffer.addEventListener('error', function(e) {
sourceBuffer.addEventListener('error', t.step_func(function(e) {
assert_unreached("Can't touch this");
});
}));
sourceBuffer.appendBuffer(data);
});
mediaSource.addEventListener('sourceended', function(e) {
t.step(function() {
assert_array_equals(events,
['updatestart', 'abort', 'updateend'],
'Check the sequence of fired events.');
});
t.done();
});
}));
mediaSource.addEventListener('sourceended', t.step_func_done(function(e) {
assert_array_equals(events,
['updatestart', 'abort', 'updateend'],
'Check the sequence of fired events.');
}));
var video = document.createElement('video');
video.src = window.URL.createObjectURL(mediaSource);
});
}, 'SourceBuffer#abort() (' + mime + ') : Check the algorithm when the updating attribute is true.');
Expand Down

0 comments on commit 8c07290

Please sign in to comment.