Bug 761708 - Wrong |played| value when seeking back in the media. r=chris.double
authorPaul Adenot <paul@paul.cx>
Thu, 07 Jun 2012 11:43:13 +1200
changeset 96013 849da42323132c4ce65b16ad1cd39f0fda54b275
parent 96012 66e43a0eb505217e31006d7307da8cc435d5acc7
child 96014 45dbfd1debfdb55f62d4991dd369b570eee2c6fd
push id10348
push usercdouble@mozilla.com
push dateWed, 06 Jun 2012 23:44:03 +0000
treeherdermozilla-inbound@5d04d59d85d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschris.double
bugs761708
milestone16.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 761708 - Wrong |played| value when seeking back in the media. r=chris.double
content/html/content/src/nsTimeRanges.cpp
content/media/test/test_played.html
--- a/content/html/content/src/nsTimeRanges.cpp
+++ b/content/html/content/src/nsTimeRanges.cpp
@@ -70,16 +70,20 @@ nsTimeRanges::Normalize()
   if (mRanges.Length() >= 2) {
     nsAutoTArray<TimeRange,4> normalized;
 
     mRanges.Sort(CompareTimeRanges());
 
     // This merges the intervals.
     TimeRange current(mRanges[0]);
     for (PRUint32 i = 1; i < mRanges.Length(); i++) {
+      if (current.mStart <= mRanges[i].mStart &&
+          current.mEnd >= mRanges[i].mEnd) {
+        continue;
+      }
       if (current.mEnd >= mRanges[i].mStart) {
         current.mEnd = mRanges[i].mEnd;
       } else {
         normalized.AppendElement(current);
         current = mRanges[i];
       }
     }
 
--- a/content/media/test/test_played.html
+++ b/content/media/test/test_played.html
@@ -69,17 +69,22 @@ var tests = [
 
 // Play the first half of the file, seek back, while
 // continuing to play. We shall have only one range.
 {
   setup : function (element) {
     let onTimeUpdate = function() {
       if (element.currentTime > element.duration/2) {
         element.removeEventListener("timeupdate", onTimeUpdate, false);
+        element.pause();
+        var oldEndRange = element.played.end(0);
         element.currentTime = element.duration / 4;
+        is(element.played.end(0), oldEndRange,
+            "When seeking back, |played| should not be changed");
+        element.play();
       }
     }
     element.addEventListener("timeupdate", onTimeUpdate, false);
     check_full_file_played(element);
     element.play();
   }
 },