Bug 1301426 part 11 - test case 10; r=jwwang
authorKaku Kuo <kaku@mozilla.com>
Tue, 11 Oct 2016 15:27:08 +0800
changeset 325516 29d8085fd77d113b5dd2eea59fb5be858a237d42
parent 325515 95b156f55a2d894a9994feab8a780343b1765902
child 325517 7c73bc8bc144e149ec2c40a5a278bf64b22f87d1
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjwwang
bugs1301426
milestone53.0a1
Bug 1301426 part 11 - test case 10; r=jwwang Case: invoke load() on an element with pending promises. Expected result: reject all the pending promises. MozReview-Commit-ID: Kg5FHAmhF4L
dom/media/test/mochitest.ini
dom/media/test/test_play_promise_10.html
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -811,16 +811,18 @@ 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_promise_10.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_10.html
@@ -0,0 +1,40 @@
+<!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: loadRejectsPendingPromises
+// Case: invoke load() on an element with pending promises.
+// Expected result: reject all the pending promises with AbortError DOM exception.
+
+let manager = new MediaTestManager;
+
+function initTest(test, token) {
+  manager.started(token);
+
+  let element = document.createElement(getMajorMimeType(test.type));
+  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); } );
+  element.load();
+}
+
+manager.runTests(gSmallTests, initTest);
+
+</script>
\ No newline at end of file