Bug 1301426 part 2 - test case 1; r=jwwang
authorKaku Kuo <kaku@mozilla.com>
Fri, 09 Sep 2016 02:00:41 +0800
changeset 325507 fe6a6213ad78892649705a31dcc51fd81efb501f
parent 325506 3022d045808ddbeafe280fd583804acfd2eb3a33
child 325508 8c29980a4c222186c820b8908a1e133f123f3133
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjwwang
bugs1301426
milestone53.0a1
Bug 1301426 part 2 - test case 1; r=jwwang Case: invoke play() on an element that doesn't have enough data Expected result: resolve the promise MozReview-Commit-ID: 7bUs8cy5Fkv
dom/media/test/mochitest.ini
dom/media/test/test_play_promise_1.html
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -793,16 +793,18 @@ tags=msg
 [test_multiple_mediastreamtracks.html]
 [test_networkState.html]
 [test_new_audio.html]
 [test_no_load_event.html]
 [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_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_1.html
@@ -0,0 +1,42 @@
+<!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: playBeforeCanPlay
+// Case: invoke play() on an element that doesn't have enough data
+// Expected result: resolve the promise
+
+let manager = new MediaTestManager;
+
+function initTest(test, token) {
+  manager.started(token);
+
+  let element = document.createElement(getMajorMimeType(test.type));
+  element.src = test.name;
+  ok(element.readyState == HTMLMediaElement.HAVE_NOTHING);
+
+  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