Bug 1550633 - part11.1 - modify 'track-element-src-change-error.html'. r=jya
☠☠ backed out by 6acae89335b0 ☠ ☠
authoralwu <alwu@mozilla.com>
Thu, 23 May 2019 09:03:29 +0000
changeset 475261 2aaaa42c409b7b56b3660326c4c7ffbdb2215635
parent 475260 d85485f76233138488e76d8434be46d954547ea3
child 475262 4265dd65cec3cc256ead96f0b9054c0756f13252
push id36058
push useraciure@mozilla.com
push dateFri, 24 May 2019 03:53:25 +0000
treeherdermozilla-central@c87317c41902 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1550633
milestone69.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 1550633 - part11.1 - modify 'track-element-src-change-error.html'. r=jya According to spec [1], if the track URL changes so that it is no longer equal to URL while fetching is ongoing, we need to change the text track readiness state to`failed to load` and dispatch `error`. So we now only fire `error` if `src` is removed during loading, but if the track element has finished loading before removing `src`, we won't dispatch `error` for it. [1] https://html.spec.whatwg.org/multipage/media.html#sourcing-out-of-band-text-tracks:text-track-failed-to-load-3 Differential Revision: https://phabricator.services.mozilla.com/D31915
testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/track-element-src-change-error.html
--- a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/track-element-src-change-error.html
+++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/track-element-src-change-error.html
@@ -16,67 +16,63 @@
                     cues = testTrack.track.cues;
                     assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after first loading of the track");
                     assert_equals(cues.length, 4, "Number of cues after first loading of the track");
                     ++stage;
                     testTrack.src = "resources/non-existing-file.vtt"; // this should fail
                     break;
                 case 1:
                 case 3:
-                case 5:
+                case 4:
                     assert_unreached("'error' event did not fire, stage = " + stage);
                     break;
                 case 2:
                     assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after loading of the second track");
                     assert_equals(cues.length, 4, "Number of cues after loading of the second track");
                     assert_equals(cues[cues.length-1].text, 'I said Bear is coming now!!!! Tab separators.', "Last cue content check");
                     ++stage;
                     testTrack.src = ""; // this should fail
                     assert_equals(cues.length, 0, "cues list is reset immediately after 'src' mutation with the new URL");
                     // This should raise onError event. If no, we'll know about this after some time.
                     timer = t.step_timeout(t.unreached_func("'error' event is not fired when an empty URL is set"), 100);
                     break;
-                case 4:
-                    assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after loading of the second track");
-                    assert_equals(cues.length, 4, "Number of cues after loading of the second track");
-                    assert_equals(cues[cues.length-1].text, 'I said Bear is coming now!!!! Tab separators.', "Last cue content check");
-                    ++stage;
-                    testTrack.removeAttribute('src');
-                    // This should raise onError event, so we'll wait for it for some time
-                    timer = t.step_timeout(t.unreached_func("'error' event is not fired when an empty URL is set"), 100);
-                    break;
                 default:
                     assert_unreached("unexpected stage number = " + stage);
                     break;
             }
         }
 
         function step_onError() {
             switch (stage) {
                 case 0:
                 case 2:
-                case 4:
                     assert_unreached("'error' event fired, stage = " + stage);
                     break;
                 case 1:
                     assert_equals(cues, testTrack.track.cues, ".cues object are the same after 'src' attr mutation");
                     assert_equals(cues.length, 0, "Number of cues after trying to load non-existing url");
                     assert_equals(testTrack.readyState, HTMLTrackElement.ERROR, "readyState after trying to load non-existing url");
                     ++stage;
                     testTrack.src = "resources/settings.vtt";
                     break;
                 case 3:
                     clearTimeout(timer);
                     assert_equals(testTrack.readyState, HTMLTrackElement.ERROR, "readyState after setting an empty URL");
                     assert_equals(cues, testTrack.track.cues, ".cues object are the same after 'src' attr mutation");
                     assert_equals(cues.length, 0, "Number of cues with an empty URL set");
                     ++stage;
                     testTrack.src = "resources/settings.vtt";
+                    // error should happen when we remove `src` during loading, so we have to wait a task because loading starts asynchronously.
+                    t.step_timeout(() => {
+                        testTrack.removeAttribute('src');
+                        // This should raise onError event, so we'll wait for it for some time
+                        timer = t.step_timeout(t.unreached_func("'error' event is not fired when an empty URL is set"), 100);
+                    }, 0);
                     break;
-                case 5:
+                case 4:
                     clearTimeout(timer);
                     assert_equals(testTrack.readyState, HTMLTrackElement.ERROR, "readyState after removing 'src' attr");
                     assert_equals(cues.length, 0, "Number of cues after removing 'src' attr");
                     t.done();
                     break;
                 default:
                     assert_unreached("unexpected stage number = " + stage);
                     break;