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

--HG--
extra : rebase_source : 02b18756f2c70f02ea4bb3c204b58cc6ede71a20
extra : source : dddcd63380f0f5c0cac5fe22e0af0ffcdef07a09
This commit is contained in:
Kaku Kuo 2016-09-09 02:00:41 +08:00
parent 8d9b83ffee
commit 58664d3167
2 changed files with 44 additions and 0 deletions

View File

@ -798,6 +798,8 @@ tags=msg
[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"

View File

@ -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>