mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-18 04:44:17 +00:00
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:
parent
58664d3167
commit
ed83d02508
@ -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"
|
||||
|
43
dom/media/test/test_play_promise_2.html
Normal file
43
dom/media/test/test_play_promise_2.html
Normal 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>
|
Loading…
Reference in New Issue
Block a user