Bug 1301426 part 9 - test case 8; r=jwwang

Case: invlke play() and the pause() on an element that already has enough data to play.
Expected result: resolve the promise.

MozReview-Commit-ID: BdbYHf7moyH

--HG--
extra : rebase_source : c0fa86c888c936f9a19622c74e135e5aafdbc754
extra : source : de021cfd2633cb7c0bc307ce67fe80b54010bd93
This commit is contained in:
Kaku Kuo 2016-10-11 15:25:41 +08:00
parent ae6593c7e6
commit 586ebec477
2 changed files with 49 additions and 0 deletions

View File

@ -812,6 +812,8 @@ tags=promise-play
tags=promise-play
[test_play_promise_7.html]
tags=promise-play
[test_play_promise_8.html]
tags=promise-play
[test_play_twice.html]
# Seamonkey: Bug 598252
skip-if = appname == "seamonkey"

View File

@ -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>
</head>
<body>
<pre id="test">
<script>
// Name: playAndPauseWhenCanplay
// Case: invlke play() and then pause() on an element that already has enough data to play
// Expected result: resolve the promise
// Note: the pause() doesn't cancel the play() because it was alredy been queued to be resolved.
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); } );
ok(!element.paused, `playAndPauseWhenCanplay(${token}) element should not be paused.`);
element.pause();
ok(element.paused, `playAndPauseWhenCanplay(${token}) element should be paused.`);
});
}
manager.runTests(gSmallTests, initTest);
</script>