Bug 1301426 part 8 - test case 7; r=jwwang
authorKaku Kuo <kaku@mozilla.com>
Tue, 11 Oct 2016 15:25:30 +0800
changeset 325513 6caab9b2dbeb6438b3c603377c13fb2a75452852
parent 325512 094826abc0e724a2e2ae196a06cc786eb12ec033
child 325514 c444d693373e4ca0d90a316c2f08fd8177749c14
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjwwang
bugs1301426
milestone53.0a1
Bug 1301426 part 8 - test case 7; r=jwwang Case: invoke play() on an element which had its source changed (to a invalid source) after suffering from an error. Expected result: reject the promise. MozReview-Commit-ID: 3EDf0TpTwYb
dom/media/test/mochitest.ini
dom/media/test/test_play_promise_7.html
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -805,16 +805,18 @@ tags=promise-play
 [test_play_promise_3.html]
 tags=promise-play
 [test_play_promise_4.html]
 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_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_7.html
@@ -0,0 +1,47 @@
+<!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>
+  <script type="text/javascript" src="play_promise.js"></script>
+</head>
+<body>
+<pre id="test">
+
+<script>
+// Name: playSwitchToInvalidSrcAfterError
+// Case: invoke play() on an element which had its source changed (to a invalid source) after suffering from an error
+// Expected result: reject the promise with NotSupportedError DOM exception
+
+let manager = new MediaTestManager;
+
+function initTest(test, token) {
+  manager.started(token);
+
+  let element = document.createElement(getMajorMimeType(test.type));
+  element.src = getNotSupportedFile(test.name);
+  once(element, "error").then(() => {
+    ok(element.error.code == MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED);
+    element.src = getNotSupportedFile(test.name);
+    ok(element.error == null);
+    ok(element.readyState == HTMLMediaElement.HAVE_NOTHING);
+    element.play().then(
+      (result) => {
+        ok(false, `${token} is resolved with ${result}.`);
+      },
+      (error) => {
+        if (error.name == "NotSupportedError") {
+          ok(true, `${token} is rejected with ${error.name}.`);
+        } else {
+          ok(false, `${token} is rejected with ${error.name}.`);
+        }
+      }
+    ).then( () => { manager.finished(token); } );
+  });
+}
+
+manager.runTests(gSmallTests, initTest);
+
+</script>
\ No newline at end of file