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
--- 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