Bug 1301426 part 19 - test case 18; r=jwwang
authorKaku Kuo <kaku@mozilla.com>
Thu, 24 Nov 2016 16:38:52 +0800
changeset 325524 a7ffc4485fa543b73bf8d6cbcf2fa5f3642d4555
parent 325523 e6a5e973ffefb2a88c453324b06eb81249fb89bf
child 325525 9db5834b7c36c53e3af2307b4c8551979e415ead
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjwwang
bugs1301426
milestone53.0a1
Bug 1301426 part 19 - test case 18; r=jwwang MozReview-Commit-ID: JWDEG7gTPwP
dom/media/test/mochitest.ini
dom/media/test/test_play_promise_18.html
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -827,16 +827,18 @@ tags=promise-play
 [test_play_promise_14.html]
 tags=promise-play
 [test_play_promise_15.html]
 tags=promise-play
 [test_play_promise_16.html]
 tags=promise-play
 [test_play_promise_17.html]
 tags=promise-play
+[test_play_promise_18.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_18.html
@@ -0,0 +1,46 @@
+<!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: 'playing' event should come before promise resolving
+// Case: invoke play() on an element which has valis source
+// Expected result: receive a 'playing' event before the promise is resolved
+
+let manager = new MediaTestManager;
+
+function initTest(test, token) {
+  manager.started(token);
+
+  let element = document.createElement(getMajorMimeType(test.type));
+  element.src = test.name;
+  element.receivedPlayingEvent = false;
+
+  element.addEventListener("playing", () => {
+    element.receivedPlayingEvent = true;
+  });
+
+  element.play().then(
+    (result) => {
+      if (result == undefined && element.receivedPlayingEvent) {
+        ok(true, `${token} is resolved with ${result}.`);
+      } else {
+        ok(false, `${token} is resolved with ${result} and receivedPlayingEvent = ${element.receivedPlayingEvent}`);
+      }
+    },
+    (error) => {
+      ok(false, `${token} is rejected with ${error.name}.`);
+    }
+  ).then( () => { manager.finished(token); } );
+}
+
+manager.runTests(gSmallTests, initTest);
+
+</script>
\ No newline at end of file