Bug 1512958 - Add mochitest. r=jya,jib
☠☠ backed out by 66865fdea5af ☠ ☠
authorAndreas Pehrson <apehrson@mozilla.com>
Fri, 21 Dec 2018 16:23:55 +0000
changeset 451705 1d4816ef6e013b44000d5c633245ec8effef810d
parent 451704 b8a2ab65c47930c8c2fa1a80da1be46221aeb27b
child 451706 74101900e7d484cc9ddcba2cd867ca172b961ea0
push id35251
push userccoroiu@mozilla.com
push dateFri, 21 Dec 2018 21:54:30 +0000
treeherdermozilla-central@74101900e7d4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya, jib
bugs1512958
milestone66.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 1512958 - Add mochitest. r=jya,jib Differential Revision: https://phabricator.services.mozilla.com/D14583
dom/media/test/mochitest.ini
dom/media/test/test_bug1512958.html
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -762,16 +762,19 @@ skip-if = (android_version == '23' && de
 skip-if = android_version >= '19' # bug 1198168, android(bug 1232305)
 tags=capturestream
 [test_bug1242338.html]
 skip-if = toolkit == 'android' # bug 1306916, bug 1329566, android(bug 1232305)
 [test_bug1242594.html]
 [test_bug1248229.html]
 skip-if = android_version == '17' # bug 1306917, 1323778, android(bug 1232305)
 tags=capturestream
+[test_bug1512958.html]
+skip-if = toolkit == 'android' # android(bug 1232305)
+tags=msg capturestream
 [test_can_play_type.html]
 skip-if = (android_version == '23' && debug) || (android_version == '25' && debug) # android(bug 1232305)
 [test_can_play_type_mpeg.html]
 skip-if = (android_version == '23' && debug) || (android_version == '25' && debug) # android(bug 1232305)
 [test_can_play_type_no_ogg.html]
 skip-if = (android_version == '23' && debug) || (android_version == '25' && debug) # android(bug 1232305)
 [test_can_play_type_ogg.html]
 skip-if = (android_version == '23' && debug) || (android_version == '25' && debug) # android(bug 1232305)
new file mode 100644
--- /dev/null
+++ b/dom/media/test/test_bug1512958.html
@@ -0,0 +1,74 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Test that pausing and resuming a captured media element with audio doesn't stall</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+  <script type="text/javascript" src="manifest.js"></script>
+</head>
+<body>
+<audio id="a"></audio>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+function dumpEvent({target, type}) {
+  info(`${target.name} GOT EVENT ${type} currentTime=${target.currentTime} ` +
+       `paused=${target.paused} ended=${target.ended} ` +
+       `readyState=${target.readyState}`);
+}
+
+function wait(ms) {
+  return new Promise(resolve => setTimeout(resolve, ms));
+}
+
+const a = document.getElementById('a');
+
+const events = ["timeupdate", "seeking", "seeked", "ended", "playing", "pause"];
+for (let ev of events) {
+  a.addEventListener(ev, dumpEvent);
+}
+
+(async _ => {
+  try {
+    SimpleTest.waitForExplicitFinish();
+    SimpleTest.requestFlakyTimeout("Timeouts for shortcutting test-timeout");
+
+    const test = getPlayableAudio(gTrackTests.filter(t => t.duration > 2));
+    if (!test) {
+      todo(false, "No playable audio");
+      return;
+    }
+
+    // Start playing and capture
+    a.src = test.name;
+    a.name = test.name;
+    const ac = new AudioContext();
+    const src = ac.createMediaElementSource(a);
+    a.play();
+    do {
+      await new Promise(r => a.ontimeupdate = r);
+    } while(a.currentTime == 0)
+
+    // Pause to trigger recreating tracks in DecodedStream
+    a.pause();
+    await new Promise(r => a.onpause = r);
+
+    // Resuming should now work. Bug 1512958 would cause a stall because the
+    // original track wasn't ended and we'd block on it.
+    // See https://bugzilla.mozilla.org/show_bug.cgi?id=1512958#c5
+    a.play();
+    await new Promise(r => a.onplaying = r);
+    a.currentTime = test.duration - 1;
+    await Promise.race([
+      new Promise(res => a.onended = res),
+      wait(30000).then(_ => Promise.reject(new Error("Timeout"))),
+    ]);
+  } catch(e) {
+    ok(false, e);
+  } finally {
+    SimpleTest.finish();
+  }
+})();
+</script>
+</pre>
+</body>
+</html>