Bug 1367955 - Remove onended handler during ended handling to avoid video.ended race issues. r?pehrsons
Bug 1386489 means that ended is not reliably set in relation to the test
seeking machinery. This results in the following behaviour being possible:
- seekToNextFrame seeks to last frame
- the seek promise resolves and invokes check to see if video has ended
- ended is not yet set (race), so another seekToNextFrame is setup
- onended handler is invoked at some point (1st time)
- seekToNextFrame seeks again, remains at last frame
- oneended handler is invoked again due to the seek (2nd time)
- finish() has been called twice
This changeset should bandaid the above being possible.
MozReview-Commit-ID: BkskWUnaJQ9
--- a/dom/media/test/test_mediarecorder_record_changing_video_resolution.html
+++ b/dom/media/test/test_mediarecorder_record_changing_video_resolution.html
@@ -91,16 +91,22 @@ function startTest() {
video.onloadedmetadata = function() {
info("loadedmetadata");
seekThroughFrames();
};
video.onended = function() {
is(numResizeRaised, resolution_change.length, "Expected number of resize events");
SimpleTest.finish();
+ // This shouldn't be needed, however video.ended may not be set after
+ // seeking to the final frame. This can result in seekToNextFrame being
+ // called again by seekThroughFrames and onended being invoked again,
+ // resulting in multiple finish() calls.
+ // FIXME: https://bugzilla.mozilla.org/show_bug.cgi?id=1386489
+ video.onended = null;
};
document.getElementById("content").appendChild(video);
function seekThroughFrames() {
info("Seeking to next frame");
video.seekToNextFrame()
.then(() => {