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

Case: invlke play() and the pause() on an element that deoen't have enough data to play.
Expected result: reject the promise.

MozReview-Commit-ID: 8x5dFhhbTVJ

--HG--
extra : rebase_source : 281b16f0cfd208ee6caf06cbc5f6e8dceaa4303b
extra : source : 34b7647611521957a069735b839822c13ec81296
This commit is contained in:
Kaku Kuo 2016-10-11 15:25:59 +08:00
Родитель 586ebec477
Коммит b8f70247ab
2 изменённых файлов: 46 добавлений и 0 удалений

Просмотреть файл

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

Просмотреть файл

@ -0,0 +1,44 @@
<!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: playAndPauseBeforeCanPlay
// Case: invlke play() and then pause() on an element that deoen't have enough data to play.
// Expected result: reject the promise with AbortError DOM exception.
// Note: the pause() cancels the play() because the promise is still pending.
let manager = new MediaTestManager;
function initTest(test, token) {
manager.started(token);
let element = document.createElement(getMajorMimeType(test.type));
ok(element.readyState == HTMLMediaElement.HAVE_NOTHING);
element.play().then(
(result) => {
ok(false, `${token} is resolved with ${result}.`);
},
(error) => {
if (error.name == "AbortError") {
ok(true, `${token} is rejected with ${error.name}.`);
} else {
ok(false, `${token} is rejected with ${error.name}.`);
}
}
).then( () => { manager.finished(token); } );
ok(!element.paused, `playAndPauseBeforeCanPlay(${token}) element should not be paused.`);
element.pause();
ok(element.paused, `playAndPauseBeforeCanPlay(${token}) element should be paused.`);
}
manager.runTests(gSmallTests, initTest);
</script>