Bug 1301426 part 13 - test case 12; r=jwwang
authorKaku Kuo <kaku@mozilla.com>
Tue, 11 Oct 2016 15:27:30 +0800
changeset 325518 876048fb7c8fc3af0f4fceaf9040f0763fc29dfc
parent 325517 7c73bc8bc144e149ec2c40a5a278bf64b22f87d1
child 325519 cb5d7ef529bdfdecd1bbf02417fd2d0d2a78b728
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjwwang
bugs1301426
milestone53.0a1
Bug 1301426 part 13 - test case 12; r=jwwang Case:: invoke pause() and then play() on an element that is already playing. Expected result: resolve the promise. MozReview-Commit-ID: DaYzxTgEWwL
dom/media/test/mochitest.ini
dom/media/test/test_play_promise_12.html
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -815,16 +815,18 @@ tags=promise-play
 [test_play_promise_8.html]
 tags=promise-play
 [test_play_promise_9.html]
 tags=promise-play
 [test_play_promise_10.html]
 tags=promise-play
 [test_play_promise_11.html]
 tags=promise-play
+[test_play_promise_12.html]
+tags=promise-play
 [test_play_twice.html]
 # Seamonkey: Bug 598252
 skip-if = appname == "seamonkey"
 [test_playback.html]
 [test_playback_errors.html]
 [test_playback_rate.html]
 [test_playback_rate_playpause.html]
 [test_playback_reactivate.html]
new file mode 100644
--- /dev/null
+++ b/dom/media/test/test_play_promise_12.html
@@ -0,0 +1,45 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Media test: promise-based play() method</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>
+<pre id="test">
+
+<script>
+// Name: pausePlayAfterPlaybackStarted
+// Case: invoke pause() and then play() on an element that is already playing.
+// Expected result: resolve the promise with undefined.
+
+let manager = new MediaTestManager;
+
+function initTest(test, token) {
+  manager.started(token);
+
+  let element = document.createElement(getMajorMimeType(test.type));
+  element.preload = "auto";
+  element.src = test.name;
+  element.play();
+  once(element, "playing").then(() => {
+    element.pause();
+    element.play().then(
+      (result) => {
+        if (result == undefined) {
+          ok(true, `${token} is resolved with ${result}.`);
+        } else {
+          ok(false, `${token} is resolved with ${result}.`);
+        }
+      },
+      (error) => {
+        ok(false, `${token} is rejected with ${error.name}.`);
+      }
+    ).then( () => { manager.finished(token); } );
+  });
+}
+
+manager.runTests(gSmallTests, initTest);
+
+</script>
\ No newline at end of file