mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-18 21:02:52 +00:00
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:
parent
ae6593c7e6
commit
586ebec477
@ -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"
|
||||
|
47
dom/media/test/test_play_promise_8.html
Normal file
47
dom/media/test/test_play_promise_8.html
Normal 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>
|
Loading…
Reference in New Issue
Block a user