Backed out 3 changesets (bug 1551385) for breaking reftests at vtt_overlapping_time.html on a CLOSED TREE
authorAndreea Pavel <apavel@mozilla.com>
Fri, 24 May 2019 00:23:19 +0300
changeset 475281 ca67f4681a4a6674f3ae2e1bed1bc2cfbdea3749
parent 475280 ab9d5eeaa90e155f484ae3457aac82fd4d61f8d9
child 475282 cd5d8525541fc8a324498043cc250a87632dc72a
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)
bugs1551385
milestone69.0a1
backs out4268e661e741a5ad122880f818bbcabc9135cb7d
fb20dcf3c07280de6c2b4d8b9a1edcdeec9d4d29
883151b42d88925215fb1212af70e6e425cd0f23
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
Backed out 3 changesets (bug 1551385) for breaking reftests at vtt_overlapping_time.html on a CLOSED TREE Backed out changeset 4268e661e741 (bug 1551385) Backed out changeset fb20dcf3c072 (bug 1551385) Backed out changeset 883151b42d88 (bug 1551385)
dom/html/TextTrackManager.cpp
dom/media/test/mochitest.ini
dom/media/test/reftest/cues_time_overlapping.webvtt
dom/media/test/reftest/reftest.list
dom/media/test/reftest/vtt_overlapping_time-ref.html
dom/media/test/reftest/vtt_overlapping_time.html
dom/media/test/test_webvtt_overlapping_time.html
dom/media/webvtt/vtt.jsm
--- a/dom/html/TextTrackManager.cpp
+++ b/dom/html/TextTrackManager.cpp
@@ -235,49 +235,50 @@ void TextTrackManager::DidSeek() {
   mHasSeeked = true;
 }
 
 void TextTrackManager::UpdateCueDisplay() {
   WEBVTT_LOG("UpdateCueDisplay");
   mUpdateCueDisplayDispatched = false;
 
   if (!mMediaElement || !mTextTracks || IsShutdown()) {
-    WEBVTT_LOG("Abort UpdateCueDisplay.");
     return;
   }
 
   nsIFrame* frame = mMediaElement->GetPrimaryFrame();
   nsVideoFrame* videoFrame = do_QueryFrame(frame);
   if (!videoFrame) {
-    WEBVTT_LOG("Abort UpdateCueDisplay, because of no video frame.");
     return;
   }
 
   nsCOMPtr<nsIContent> overlay = videoFrame->GetCaptionOverlay();
+  nsCOMPtr<nsIContent> controls = videoFrame->GetVideoControls();
   if (!overlay) {
-    WEBVTT_LOG("Abort UpdateCueDisplay, because of no overlay.");
     return;
   }
 
-  nsPIDOMWindowInner* window = mMediaElement->OwnerDoc()->GetInnerWindow();
-  if (!window) {
-    WEBVTT_LOG("Abort UpdateCueDisplay, because of no window.");
-  }
-
   nsTArray<RefPtr<TextTrackCue>> showingCues;
   mTextTracks->GetShowingCues(showingCues);
 
-  WEBVTT_LOG("UpdateCueDisplay, processCues, showingCuesNum=%zu",
-             showingCues.Length());
-  RefPtr<nsVariantCC> jsCues = new nsVariantCC();
-  jsCues->SetAsArray(nsIDataType::VTYPE_INTERFACE, &NS_GET_IID(EventTarget),
-                     showingCues.Length(),
-                     static_cast<void*>(showingCues.Elements()));
-  nsCOMPtr<nsIContent> controls = videoFrame->GetVideoControls();
-  sParserWrapper->ProcessCues(window, jsCues, overlay, controls);
+  if (showingCues.Length() > 0) {
+    WEBVTT_LOG("UpdateCueDisplay, processCues, showingCuesNum=%zu",
+               showingCues.Length());
+    RefPtr<nsVariantCC> jsCues = new nsVariantCC();
+
+    jsCues->SetAsArray(nsIDataType::VTYPE_INTERFACE, &NS_GET_IID(EventTarget),
+                       showingCues.Length(),
+                       static_cast<void*>(showingCues.Elements()));
+    nsPIDOMWindowInner* window = mMediaElement->OwnerDoc()->GetInnerWindow();
+    if (window) {
+      sParserWrapper->ProcessCues(window, jsCues, overlay, controls);
+    }
+  } else if (overlay->Length() > 0) {
+    WEBVTT_LOG("UpdateCueDisplay EmptyString");
+    nsContentUtils::SetNodeTextContent(overlay, EmptyString(), true);
+  }
 }
 
 void TextTrackManager::NotifyCueAdded(TextTrackCue& aCue) {
   WEBVTT_LOG("NotifyCueAdded, cue=%p", &aCue);
   if (mNewCues) {
     mNewCues->AddCue(aCue);
   }
   MaybeRunTimeMarchesOn();
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -1264,18 +1264,16 @@ skip-if = toolkit == 'android' # android
 skip-if = android_version == '22' # android(bug 1368010)
 tags = webvtt
 [test_webvtt_empty_displaystate.html]
 skip-if = android_version == '17' || android_version == '22' # android(bug 1368010, bug 1372457)
 tags = webvtt
 [test_webvtt_update_display_after_adding_or_removing_cue.html]
 skip-if = android_version == '22' # android(bug 1368010)
 tags = webvtt
-[test_webvtt_overlapping_time.html]
-tags = webvtt
 [test_webvtt_positionalign.html]
 skip-if = android_version == '22' # android(bug 1368010)
 tags = webvtt
 [test_webvtt_seeking.html]
 skip-if = toolkit == 'android' # bug 1368010, bug 1548446
 tags = webvtt
 # The tests below contain backend-specific tests. Write backend independent
 # tests rather than adding to this list.
deleted file mode 100644
--- a/dom/media/test/reftest/cues_time_overlapping.webvtt
+++ /dev/null
@@ -1,7 +0,0 @@
-WEBVTT FILE
-
-00:00:00.000 --> 00:00:01.000
-First cue
-
-00:00:00.000 --> 00:00:04.000
-Second cue
--- a/dom/media/test/reftest/reftest.list
+++ b/dom/media/test/reftest/reftest.list
@@ -1,6 +1,5 @@
 skip-if(Android) fuzzy-if(OSX,0-62,0-76799) fuzzy-if(winWidget,0-62,0-76799) fuzzy-if(gtkWidget&&layersGPUAccelerated,0-70,0-600) HTTP(..) == short.mp4.firstframe.html short.mp4.firstframe-ref.html
 skip-if(Android) fuzzy-if(OSX,0-60,0-76797) fuzzy-if(winWidget,0-60,0-76797) fuzzy-if(gtkWidget&&layersGPUAccelerated,0-60,0-1800) HTTP(..) == short.mp4.lastframe.html short.mp4.lastframe-ref.html
 skip-if(Android) skip-if(winWidget) fuzzy-if(gtkWidget&&layersGPUAccelerated,0-55,0-4281) fuzzy-if(OSX,55-55,4173-4173) HTTP(..) == bipbop_300_215kbps.mp4.lastframe.html bipbop_300_215kbps.mp4.lastframe-ref.html
 skip-if(Android) fuzzy-if(OSX,0-25,0-175921) fuzzy-if(winWidget,0-71,0-179198) fuzzy-if((/^Windows\x20NT\x2010\.0/.test(http.oscpu))&&(/^aarch64-msvc/.test(xulRuntime.XPCOMABI)),0-255,0-179500) HTTP(..) == gizmo.mp4.seek.html gizmo.mp4.55thframe-ref.html
 skip-if(Android) fuzzy-if((/^Windows\x20NT\x2010\.0/.test(http.oscpu))&&(/^aarch64-msvc/.test(xulRuntime.XPCOMABI)),0-136,0-427680) == vtt_update_display_after_removed_cue.html vtt_update_display_after_removed_cue_ref.html
-skip-if(Android) == vtt_overlapping_time.html vtt_overlapping_time-ref.html
deleted file mode 100644
--- a/dom/media/test/reftest/vtt_overlapping_time-ref.html
+++ /dev/null
@@ -1,29 +0,0 @@
-<!DOCTYPE HTML>
-<html class="reftest-wait">
-<head>
-</head>
-<body>
-<video id="v1" src="../black.mp4" width="320" height="180">
-  <track label="English" src="cues_time_overlapping.webvtt" default>
-</video>
-<script type="text/javascript">
-/**
- * This test is to ensure that when cues with overlapping times, the one with
- * earlier end timestamp should disappear when the media time reaches its
- * end time. This vtt file contains two cues, the first cue is [0,1], the second
- * cue is [0,4], so if we seek video to 2s, only cue2 should be displayed.
- */
-async function testTimeOverlappingCues() {
-  const video = document.getElementById("v1");
-  video.currentTime = 2;
-  video.onseeked = () => {
-    video.onseeked = null;
-    document.documentElement.removeAttribute('class');
-  }
-};
-
-window.addEventListener("MozReftestInvalidate",
-                        testTimeOverlappingCues);
-</script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/media/test/reftest/vtt_overlapping_time.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE HTML>
-<html class="reftest-wait">
-<head>
-</head>
-<body>
-<video id="v1" src="../black.mp4" autoplay width="320" height="180">
-  <track label="English" src="cues_time_overlapping.webvtt" default>
-</video>
-<script type="text/javascript">
-/**
- * This test is to ensure that when cues with overlapping times, the one with
- * earlier end timestamp should disappear when the media time reaches its
- * end time. This vtt file contains two cues, the first cue is [0,1], the second
- * cue is [0,4], so after video is playing over 1s, only cue2 should be displayed.
- */
-async function testTimeOverlappingCues() {
-  const video = document.getElementById("v1");
-  video.ontimeupdate = () => {
-    if (video.currentTime > 1.0) {
-      document.documentElement.removeAttribute('class');
-      video.ontimeupdate = null;
-    }
-  }
-};
-
-window.addEventListener("MozReftestInvalidate",
-                        testTimeOverlappingCues);
-</script>
-</body>
-</html>
deleted file mode 100644
--- a/dom/media/test/test_webvtt_overlapping_time.html
+++ /dev/null
@@ -1,104 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>WebVTT : cues with overlapping time should be displayed correctly </title>
-  <script src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script src="manifest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-<script class="testbody" type="text/javascript">
-/**
- * This test is used to ensure that when cues with overlapping times, the one
- * with earlier end timestamp should disappear when the media time reaches its
- * end time. In this test, we have two cues with overlapping time, when the video
- * starts, both cues should be displayed. When the time passes 1 seconds, the
- * first cue should disappear and the second cues should be still displayed.
- */
-var CUES_INFO = [
-  { id: 0, startTime: 0, endTime: 1, text: "This is cue 0."},
-  { id: 1, startTime: 0, endTime: 6, text: "This is cue 1."},
-];
-
-async function startTest() {
-  const video = createVideo();
-  const cues = createCues(video);
-  await startVideo(video);
-
-  await waitUntilCueIsShowing(cues[0]);
-  await waitUntilCueIsShowing(cues[1]);
-
-  await waitUntilCueIsHiding(cues[0]);
-  await waitUntilCueIsShowing(cues[1]);
-  IsVideoStillPlaying(video);
-
-  endTestAndClearVideo(video);
-}
-
-SimpleTest.waitForExplicitFinish();
-onload = startTest;
-
-/**
- * The following are test helper functions.
- */
-function createVideo() {
-  let video = document.createElement("video");
-  video.src = "gizmo.mp4";
-  video.controls = true;
-  document.body.appendChild(video);
-  return video;
-}
-
-function createCues(video) {
-  let track = video.addTextTrack("subtitles");
-  track.mode = "showing";
-  let cue0 = new VTTCue(CUES_INFO[0].startTime, CUES_INFO[0].endTime,
-                        CUES_INFO[0].text);
-  cue0.id = CUES_INFO[0].id;
-  let cue1 = new VTTCue(CUES_INFO[1].startTime, CUES_INFO[1].endTime,
-                        CUES_INFO[1].text);
-  cue1.id = CUES_INFO[1].id;
-  track.addCue(cue0);
-  track.addCue(cue1);
-  // Convert them to chrome objects in order to use chrome privilege APIs.
-  cue0 = SpecialPowers.wrap(cue0);
-  cue1 = SpecialPowers.wrap(cue1);
-  return [cue0, cue1];
-}
-
-async function startVideo(video) {
-  info(`start play video`);
-  const played = video && await video.play().then(() => true, () => false);
-  ok(played, "video has started playing");
-}
-
-async function waitUntilCueIsShowing(cue) {
-  info(`wait until cue ${cue.id} is showing`);
-  // cue has not been showing yet.
-  if (!cue.getActive) {
-    await once(cue, "enter");
-  }
-  ok(cue.getActive, `cue ${cue.id} is showing`);
-}
-
-async function waitUntilCueIsHiding(cue) {
-  info(`wait until cue ${cue.id} is hiding`);
-  // cue has not been hidden yet.
-  if (cue.getActive) {
-    await once(cue, "exit");
-  }
-  ok(!cue.getActive, `cue ${cue.id} is hidding`);
-}
-
-function IsVideoStillPlaying(video) {
-  ok(!video.paused, `video is still playing`);
-}
-
-function endTestAndClearVideo(video) {
-  removeNodeAndSource(video);
-  SimpleTest.finish();
-}
-
-</script>
-</body>
-</html>
--- a/dom/media/webvtt/vtt.jsm
+++ b/dom/media/webvtt/vtt.jsm
@@ -1079,80 +1079,63 @@ XPCOMUtils.defineLazyPreferenceGetter(th
 
   WebVTT.convertCueToDOMTree = function(window, cuetext) {
     if (!window) {
       return null;
     }
     return parseContent(window, cuetext, PARSE_CONTENT_MODE.DOCUMENT_FRAGMENT);
   };
 
-  function clearAllCuesDiv(overlay) {
-    while (overlay.firstChild) {
-      overlay.firstChild.remove();
-    }
-  }
-
-  // It's used to record how many cues we process in the last `processCues` run.
-  var lastDisplayedCueNums = 0;
-
   // Runs the processing model over the cues and regions passed to it.
-  // Spec https://www.w3.org/TR/webvtt1/#processing-model
-  // @parem window : JS window
-  // @param cues : the VTT cues are going to be displayed.
-  // @param overlay : A block level element (usually a div) that the computed cues
+  // @param overlay A block level element (usually a div) that the computed cues
   //                and regions will be placed into.
-  // @param controls : A Control bar element. Cues' position will be
+  // @param controls  A Control bar element. Cues' position will be
   //                 affected and repositioned according to it.
   WebVTT.processCues = function(window, cues, overlay, controls) {
-    if (!cues) {
-      LOG(`Abort processing because no cue.`);
-      clearAllCuesDiv(overlay);
-      lastDisplayedCueNums = 0;
-      return;
+    if (!window || !cues || !overlay) {
+      return null;
     }
 
     let controlBar, controlBarShown;
     if (controls) {
       // controls is a <div> that is the children of the UA Widget Shadow Root.
       controlBar = controls.parentNode.getElementById("controlBar");
       controlBarShown = controlBar ? !!controlBar.clientHeight : false;
     } else {
       // There is no controls element. This only happen to UA Widget because
       // it is created lazily.
       controlBarShown = false;
     }
 
     // Determine if we need to compute the display states of the cues. This could
     // be the case if a cue's state has been changed since the last computation or
-    // if it has not been computed yet, or the displayed cues number changes.
+    // if it has not been computed yet.
     function shouldCompute(cues) {
-      if (lastDisplayedCueNums != cues.length) {
-        return true;
-      }
-
       if (overlay.lastControlBarShownStatus != controlBarShown) {
         return true;
       }
 
       for (let i = 0; i < cues.length; i++) {
         if (cues[i].hasBeenReset || !cues[i].displayState) {
           return true;
         }
       }
       return false;
     }
 
     // We don't need to recompute the cues' display states. Just reuse them.
     if (!shouldCompute(cues)) {
-      LOG(`Abort processing because no need to compute cues' display state.`);
       return;
     }
     overlay.lastControlBarShownStatus = controlBarShown;
 
-    clearAllCuesDiv(overlay);
+    // Remove all previous children.
+    while (overlay.firstChild) {
+      overlay.firstChild.remove();
+    }
     let rootOfCues = window.document.createElement("div");
     rootOfCues.style.position = "absolute";
     rootOfCues.style.left = "0";
     rootOfCues.style.right = "0";
     rootOfCues.style.top = "0";
     rootOfCues.style.bottom = "0";
     overlay.appendChild(rootOfCues);
 
@@ -1166,19 +1149,18 @@ XPCOMUtils.defineLazyPreferenceGetter(th
       boxPositions.push(controlBarBox);
     }
 
     // https://w3c.github.io/webvtt/#processing-model 6.1.12.1
     // Create regionNode
     let regionNodeBoxes = {};
     let regionNodeBox;
 
-    LOG(`=== processCues, ` +
-        `lastDisplayedCueNums=${lastDisplayedCueNums}, currentCueNums=${cues.length} ===`);
-    lastDisplayedCueNums = cues.length;
+    LOG(`=== processCues ===`);
+
     for (let i = 0; i < cues.length; i++) {
       cue = cues[i];
       if (cue.region != null) {
        // 6.1.14.1
         styleBox = new RegionCueStyleBox(window, cue);
 
         if (!regionNodeBoxes[cue.region.id]) {
           // create regionNode