Bug 1093980 - Rewrite test_FrameSelection to avoid assuming that resizes will always be processed before firing 'seeked'. r=mattwoodrow, a=test-only
☠☠ backed out by 73a7e99cfd2a ☠ ☠
authorBobby Holley <bobbyholley@gmail.com>
Thu, 05 Mar 2015 12:33:05 -0800
changeset 250298 7ffee9383f87
parent 250297 88d82b8d1dcf
child 250299 7fc259f73c1d
push id4540
push userryanvm@gmail.com
push date2015-03-09 18:33 +0000
treeherdermozilla-beta@7ffee9383f87 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow, test-only
bugs1093980
milestone37.0
Bug 1093980 - Rewrite test_FrameSelection to avoid assuming that resizes will always be processed before firing 'seeked'. r=mattwoodrow, a=test-only Nothing in the spec says this should hold, and it holds less often when we move invalidation to happen at the end of seeking.
dom/media/mediasource/test/test_FrameSelection.html
--- a/dom/media/mediasource/test/test_FrameSelection.html
+++ b/dom/media/mediasource/test/test_FrameSelection.html
@@ -9,65 +9,70 @@
 <body>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 var updateCount = 0;
 
-runWithMSE(function (ms, v) {
-  ms.addEventListener("sourceopen", function () {
-    var sb = ms.addSourceBuffer("video/webm");
-
-    fetchWithXHR("seek.webm", function (arrayBuffer) {
-      // Append entire file covering range [0, 4].
-      sb.appendBuffer(new Uint8Array(arrayBuffer));
-    });
-
     var targets = [{ currentTime: 3, videoWidth: 160, videoHeight: 120 },
                    { currentTime: 2, videoWidth: 160, videoHeight: 120 },
                    { currentTime: 0, videoWidth: 320, videoHeight: 240 }];
     var target;
 
-    v.addEventListener("loadedmetadata", function () {
+var lowResBuffer;
+runWithMSE(function (ms, v) {
+  ms.addEventListener("sourceopen", function () {
+    var sb = ms.addSourceBuffer("video/webm");
+
+    fetchWithXHR("seek.webm")
+    .then(function (arrayBuffer) {
+      var p = once(v, 'loadedmetadata');
+      // Append entire file covering range [0, 4].
+      sb.appendBuffer(new Uint8Array(arrayBuffer));
+      return p;
+    }).then(function() {
       is(v.currentTime, 0, "currentTime has correct initial value");
       is(v.videoWidth, 320, "videoWidth has correct initial value");
       is(v.videoHeight, 240, "videoHeight has correct initial value");
+      return fetchWithXHR("seek_lowres.webm");
+    }).then(function (arrayBuffer) {
+      // Append initialization segment.
+      var p = once(sb, 'updateend');
+      info("Appending low-res init segment");
+      sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 438));
+      lowResBuffer = arrayBuffer;
+      return p;
+    }).then(function() {
+      var p = once(sb, 'updateend');
+      info("Appending low-res range [2,4]");
+      // Append media segment covering range [2, 4].
+      sb.appendBuffer(new Uint8Array(lowResBuffer, 51003));
+      return p;
+    }).then(function() {
+      ms.endOfStream();
+      var p = Promise.all([once(v, 'seeked'), once(v, 'resize')]);
+      info("Seeking to t=3");
+      v.currentTime = 3;
+      return p;
+    }).then(function() {
+      is(v.currentTime, 3, "Video currentTime at target");
+      is(v.videoWidth, 160, "videoWidth has correct low-res value");
+      is(v.videoHeight, 120, "videoHeight has correct low-res value");
 
-      fetchWithXHR("seek_lowres.webm", function (arrayBuffer) {
-        // Append initialization segment.
-        sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 438));
-        sb.addEventListener("updateend", function () {
-          updateCount++;
-          if (updateCount == 1) {
-            // Append media segment covering range [2, 4].
-            sb.appendBuffer(new Uint8Array(arrayBuffer, 51003));
-          }
-          else if (updateCount == 2) {
-            ms.endOfStream();
-            target = targets.shift();
-            v.currentTime = target.currentTime;
-          }
-        });
-      });
-    });
-
-    v.addEventListener("seeked", function () {
-      is(v.currentTime, target.currentTime, "Video currentTime at target");
-
-      is(v.videoWidth, target.videoWidth, "videoWidth has correct final value");
-      is(v.videoHeight, target.videoHeight, "videoHeight has correct final value");
-
-      target = targets.shift();
-      if (target) {
-        v.currentTime = target.currentTime;
-      } else {
-        SimpleTest.finish();
-      }
+      var p = Promise.all([once(v, 'seeked'), once(v, 'resize')]);
+      info("Seeking to t=1");
+      v.currentTime = 1;
+      return p;
+    }).then(function() {
+      is(v.currentTime, 1, "Video currentTime at target");
+      is(v.videoWidth, 320, "videoWidth has correct high-res value");
+      is(v.videoHeight, 240, "videoHeight has correct high-res value");
+      SimpleTest.finish();
     });
   });
 });
 
 </script>
 </pre>
 </body>
 </html>