Bug 1301426 part 3 - test case 2; r=jwwang

Case: invoke play() on an element that has enough data
Expected result: resolve the promise

MozReview-Commit-ID: JAloJxN933Z

--HG--
extra : rebase_source : 26c85effe88faecaf95bef6254db2afeede76c30
extra : source : 0170fac6a144c1878a775366fe3e7cc59f09de61
This commit is contained in:
Kaku Kuo 2016-09-09 02:01:46 +08:00
parent 58664d3167
commit ed83d02508
2 changed files with 45 additions and 0 deletions

View File

@ -800,6 +800,8 @@ tags=msg
[test_play_events_2.html]
[test_play_promise_1.html]
tags=promise-play
[test_play_promise_2.html]
tags=promise-play
[test_play_twice.html]
# Seamonkey: Bug 598252
skip-if = appname == "seamonkey"

View File

@ -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: playWhenCanPlay
// Case: invoke play() on an element that has 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.preload = "auto";
element.src = test.name;
once(element, "canplay").then(() => {
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>