зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1301426 part 6 - test case 5; r=jwwang
Case: invoke play() on an element with MEDIA_ERR_SRC_NOT_SUPPORTED has been set. Expected result: reject the promise. MozReview-Commit-ID: Bp4Ng6gKUa1 --HG-- extra : rebase_source : 8b9dc3480c021beef91922ef3d00f8f5465bb1dc extra : source : b4a7b91df34da2fe8fe9eda5e3860f9dcd103733
This commit is contained in:
Родитель
684c2d69ce
Коммит
30e3a090f9
|
@ -806,6 +806,8 @@ tags=promise-play
|
|||
tags=promise-play
|
||||
[test_play_promise_4.html]
|
||||
tags=promise-play
|
||||
[test_play_promise_5.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>
|
||||
<script type="text/javascript" src="play_promise.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
|
||||
<script>
|
||||
// Name: playWithErrorAlreadySet
|
||||
// Case: invoke play() on an element with MEDIA_ERR_SRC_NOT_SUPPORTED has been set
|
||||
// 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.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>
|
Загрузка…
Ссылка в новой задаче