Bug 1513146 [wpt PR 14449] - MSE: Update one of the wpt mediasource-errors sub-tests, a=testonly
authorMatt Wolenetz <wolenetz@chromium.org>
Wed, 19 Dec 2018 11:04:55 +0000
changeset 514989 8fb8f380553e8a17991b4d9653ab98c07a0087cc
parent 514988 e9762abb04f16ad2477db7c535d45a0844b58631
child 514990 e4e338e20c469af25e2b1a7801be823e406b086a
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1513146, 14449, 1371166, 615709
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1513146 [wpt PR 14449] - MSE: Update one of the wpt mediasource-errors sub-tests, a=testonly Automatic update from web-platform-tests MSE: Update one of the wpt mediasource-errors sub-tests Updates one of the subtests to be less tightly bound to one implementation's scheduling of append error algorithm versus readyState transitions to HAVE_METADATA when one appendBuffer could potentially cause both. Change-Id: I50f98c2815014aacd67cb27bfc3d71ba50a16ab4 Reviewed-on: https://chromium-review.googlesource.com/c/1371166 Reviewed-by: Dan Sanders <sandersd@chromium.org> Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org> Cr-Commit-Position: refs/heads/master@{#615709} -- wpt-commits: 48d5d5033d2f634125d0ae2dd494d68f8d01de79 wpt-pr: 14449
testing/web-platform/tests/media-source/mediasource-errors.html
--- a/testing/web-platform/tests/media-source/mediasource-errors.html
+++ b/testing/web-platform/tests/media-source/mediasource-errors.html
@@ -202,33 +202,72 @@
             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);
 
+        // Depending on implementation, mediaElement transition to
+        // HAVE_METADATA and dispatching 'loadedmetadata' may occur, since the
+        // initialization segment is uncorrupted and forms the initial part of
+        // the appended bytes. The segment parser loop continues and
+        // eventually should observe decode error. Other implementations may
+        // delay such transition until some larger portion of the append's
+        // parsing is completed or until the media element is configured to
+        // handle the playback of media with the associated metadata (which may
+        // not occur in this case before the MSE append error algorithm executes.)
+        // So we cannot reliably expect the lack or presence of
+        // 'loadedmetadata' before the MSE append error algortihm executes in
+        // this case; similarly, mediaElement's resulting readyState may be
+        // either HAVE_NOTHING or HAVE_METADATA after the append error
+        // algorithm executes, and the resulting MediaError code would
+        // respectively be MEDIA_ERR_SRC_NOT_SUPPORTED or MEDIA_ERR_DECODE.
+        let loaded = false;
+        mediaElement.addEventListener("loadedmetadata", test.step_func(() => { loaded = true; }));
+        let errored = false;
+        mediaElement.addEventListener("error", test.step_func(() => { errored = true; }));
+
         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);
 
+        let verifyFinalState = test.step_func(function() {
+            if (loaded) {
+                assert_greater_than(mediaElement.readyState, HTMLMediaElement.HAVE_NOTHING);
+                assert_true(mediaElement.error != null);
+                assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_DECODE);
+                test.done();
+            } else {
+                assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_NOTHING);
+                assert_true(mediaElement.error != null);
+                assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED);
+                test.done();
+            }
+        });
+
+        let awaitMediaElementError = test.step_func(function() {
+            if (!errored) {
+                test.step_timeout(awaitMediaElementError, 100);
+            } else {
+                verifyFinalState();
+            }
+        });
+
         test.waitForExpectedEvents(function()
         {
-            assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_NOTHING);
-            assert_true(mediaElement.error != null);
-            assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED);
-            test.done();
+            // Not all implementations will reliably fire a "loadedmetadata"
+            // event, so we use custom logic to verify mediaElement state based
+            // on whether or not "loadedmetadata" was ever fired. But first
+            // we must ensure "error" was fired on the mediaElement.
+            awaitMediaElementError();
         });
-    }, "Signaling 'decode' error via segment parser loop algorithm.");
+
+    }, "Signaling 'decode' error via segment parser loop algorithm of append containing init plus corrupted media segment.");
 </script>