Bug 1367955 - Remove onended handler during ended handling to avoid video.ended race issues. r?pehrsons draft
authorBryce Van Dyk <bvandyk@mozilla.com>
Fri, 27 Oct 2017 08:32:12 +1300
changeset 688349 e798c9df0b9c48b6e8cdac622ecf3e29886b814d
parent 680599 d418c3e7535042d22ce9a336a9bb50af88bf6599
child 737843 e4417e0f5fd6e3d00c2a26256489aa7d511172c2
push id86723
push userbvandyk@mozilla.com
push dateMon, 30 Oct 2017 01:05:14 +0000
reviewerspehrsons
bugs1367955, 1386489
milestone58.0a1
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
dom/media/test/test_mediarecorder_record_changing_video_resolution.html
--- 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(() => {