Bug 1301426 part 18 - test case 17; r=jwwang
authorKaku Kuo <kaku@mozilla.com>
Tue, 11 Oct 2016 15:28:14 +0800
changeset 325523 e6a5e973ffefb2a88c453324b06eb81249fb89bf
parent 325522 f3d6fedbddab7ba6afda648921eb6e79a916db37
child 325524 a7ffc4485fa543b73bf8d6cbcf2fa5f3642d4555
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjwwang
bugs1301426
milestone53.0a1
Bug 1301426 part 18 - test case 17; r=jwwang Case: invoke load() on an element should reject pending promises in order. Expected result: the pending promises are rejected in order. MozReview-Commit-ID: AJMX7uLTEN0
dom/media/test/mochitest.ini
dom/media/test/test_play_promise_17.html
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -825,16 +825,18 @@ tags=promise-play
 [test_play_promise_13.html]
 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_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_17.html
@@ -0,0 +1,43 @@
+<!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: loadAlgorithmRejectOrdering
+// Case: invoke load() on an element should reject pending promises in order.
+// Expected result: the pending promises are rejected in order.
+
+let manager = new MediaTestManager;
+
+function initTest(test, token) {
+  manager.started(token);
+
+  let element = document.createElement(getMajorMimeType(test.type));
+  let firstPromiseRejected = false;
+
+  // play
+  element.play().then(
+    () => { ok(false,  `loadAlgorithmRejectOrdering(${token}) should not be resolved.`); },
+    () => { firstPromiseRejected = true; }
+  );
+
+  // play again
+  element.play().then(
+    () => { ok(false,  `loadAlgorithmRejectOrdering(${token}) should not be resolved.`); },
+    () => { ok(firstPromiseRejected, `loadAlgorithmRejectOrdering(${token}), the first play should already be rejected.`); }
+  ).then( () => { manager.finished(token); } );
+
+  // triger load
+  element.src = test.name;
+}
+
+manager.runTests(gSmallTests, initTest);
+
+</script>
\ No newline at end of file