Bug 1548731 - part3 : modify wpt 'track-mode.html'. r=smaug
authoralwu <alwu@mozilla.com>
Tue, 07 May 2019 18:01:44 +0000
changeset 531943 304294b29dae2db6e398ed5693d5a65821812c0d
parent 531942 cea220a6b7dd6c86a71c09d805e0eaa719b34317
child 531944 175f567cd163eb70fd015e585bb0ae74f60c2cfe
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1548731
milestone68.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 1548731 - part3 : modify wpt 'track-mode.html'. r=smaug This patch does two changes in order to test the correct behavior. (1) Not to use time out function Waiting for 0.4s by using timeout function doesn't mean the code will exactly be executed after 0.4s. If we would like to specify the time when we would like to change track's mode, we should listen for video's `timeupdate` to get the correct result. (2) Modify ending condition As this test is going to turn the track's mode to `showing/hidden` after video plays after 0.4s, the second and the third cue would be showed correctly. The second cue is from 0.3 to 0.7, so when we changed track mode in 0.4s, the second cue would be regard as an active cue, and we would dispatched `enter` event on it. When the cue is going to become inactive, the event `exit` would be dispatched. Therefore, there would be total 4 times of the accumulation of `enter` and `exit` events, which means `oncuechange` would also be dispatched 4 times. Differential Revision: https://phabricator.services.mozilla.com/D30141
testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/track-mode.html
--- a/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/track-mode.html
+++ b/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/track-mode.html
@@ -29,23 +29,31 @@
             assert_equals(textTrack.mode, "showing");
             assert_equals(video.textTracks[0].mode, "showing");
 
             // Set to known values.
             setModeAndCheck("disabled");
 
             video.src = getVideoURI("/media/test");
             video.play();
+
             // Wait for end of first cue (no events should fire while track is disabled).
-            t.step_timeout(testHiddenAndShowing, 400);
+            video.ontimeupdate = () => {
+                if (video.currentTime > 0.4) {
+                    testHiddenAndShowing();
+                    video.ontimeupdate = null;
+                }
+            }
         }
 
         track.oncuechange = t.step_func(function(event) {
             cueCount++;
-            if (cueCount == textTrack.cues.length)
+            // As the 'enter' and the 'exit' event would be fired for the second
+            // and the third cue, so there would be 4 times 'oncuechange' event.
+            if (cueCount == 4)
                 t.done();
         });
 
         function setModeAndCheck(value) {
             textTrack.mode =  value;
             assert_equals(textTrack.mode, value);
             assert_equals(video.textTracks[0].mode, value);
             if (value == "disabled")