Bug 1301426 part 4 - test case 3; r=jwwang
authorKaku Kuo <kaku@mozilla.com>
Tue, 11 Oct 2016 15:24:36 +0800
changeset 325509 d3b6ec3f3c6a33ec587cb1864cd80a8ffc51d6bf
parent 325508 8c29980a4c222186c820b8908a1e133f123f3133
child 325510 8946df884a6fd18fdedcb66d4197c85eb96de562
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjwwang
bugs1301426
milestone53.0a1
Bug 1301426 part 4 - test case 3; r=jwwang Case: invoke play() on an element that is already playing. Expected result: resolve the promise. MozReview-Commit-ID: 83IbJNF7Rzd
dom/media/test/mochitest.ini
dom/media/test/test_play_promise_3.html
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -797,16 +797,18 @@ tags=msg
 [test_paused.html]
 [test_paused_after_ended.html]
 [test_play_events.html]
 [test_play_events_2.html]
 [test_play_promise_1.html]
 tags=promise-play
 [test_play_promise_2.html]
 tags=promise-play
+[test_play_promise_3.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_3.html
@@ -0,0 +1,47 @@
+<!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: playAfterPlaybackStarted
+// Case: invoke play() on an element that is already playing
+// Expected result: resolve the promise
+
+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;
+  once(element, "playing").then(() => {
+    ok(element.readyState >= HTMLMediaElement.HAVE_FUTURE_DATA, `playAfterPlaybackStarted(${token})`);
+    ok(!element.paused, `playAfterPlaybackStarted(${token})`);
+    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); } );
+  });
+
+  element.play();
+}
+
+manager.runTests(gSmallTests, initTest);
+
+</script>
\ No newline at end of file