Bug 1301426 part 10 - test case 9; r=jwwang
authorKaku Kuo <kaku@mozilla.com>
Tue, 11 Oct 2016 15:25:59 +0800
changeset 325515 95b156f55a2d894a9994feab8a780343b1765902
parent 325514 c444d693373e4ca0d90a316c2f08fd8177749c14
child 325516 29d8085fd77d113b5dd2eea59fb5be858a237d42
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjwwang
bugs1301426
milestone53.0a1
Bug 1301426 part 10 - test case 9; r=jwwang Case: invlke play() and the pause() on an element that deoen't have enough data to play. Expected result: reject the promise. MozReview-Commit-ID: 8x5dFhhbTVJ
dom/media/test/mochitest.ini
dom/media/test/test_play_promise_9.html
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -809,16 +809,18 @@ tags=promise-play
 [test_play_promise_5.html]
 tags=promise-play
 [test_play_promise_6.html]
 tags=promise-play
 [test_play_promise_7.html]
 tags=promise-play
 [test_play_promise_8.html]
 tags=promise-play
+[test_play_promise_9.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_9.html
@@ -0,0 +1,44 @@
+<!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: playAndPauseBeforeCanPlay
+// Case: invlke play() and then pause() on an element that deoen't have enough data to play.
+// Expected result: reject the promise with AbortError DOM exception.
+// Note: the pause() cancels the play() because the promise is still pending.
+
+let manager = new MediaTestManager;
+
+function initTest(test, token) {
+  manager.started(token);
+
+  let element = document.createElement(getMajorMimeType(test.type));
+  ok(element.readyState == HTMLMediaElement.HAVE_NOTHING);
+  element.play().then(
+    (result) => {
+      ok(false, `${token} is resolved with ${result}.`);
+    },
+    (error) => {
+      if (error.name == "AbortError") {
+        ok(true, `${token} is rejected with ${error.name}.`);
+      } else {
+        ok(false, `${token} is rejected with ${error.name}.`);
+      }
+    }
+  ).then( () => { manager.finished(token); } );
+  ok(!element.paused, `playAndPauseBeforeCanPlay(${token}) element should not be paused.`);
+  element.pause();
+  ok(element.paused, `playAndPauseBeforeCanPlay(${token}) element should be paused.`);
+}
+
+manager.runTests(gSmallTests, initTest);
+
+</script>
\ No newline at end of file