Assert play promise rejected caused by pause()

This commit is contained in:
CYBAI 2018-10-14 15:03:06 +08:00
parent 445c1d0706
commit 0284afc51a
4 changed files with 29 additions and 25 deletions

View file

@ -612764,7 +612764,7 @@
"testharness"
],
"html/semantics/embedded-content/media-elements/event_pause_noautoplay.html": [
"55482348387de77def1c1be10d3dbe174fa3cb58",
"8b985a65fe372346370075e3e9e992548e9b8abb",
"testharness"
],
"html/semantics/embedded-content/media-elements/event_play.html": [
@ -612772,7 +612772,7 @@
"testharness"
],
"html/semantics/embedded-content/media-elements/event_play_noautoplay.html": [
"67285a95abdca01fd7bc6dc95f4ad8c94b7f8536",
"94fcb837d04c0f82da1660d95465b53bc8a052a6",
"testharness"
],
"html/semantics/embedded-content/media-elements/event_playing.html": [
@ -613172,7 +613172,7 @@
"testharness"
],
"html/semantics/embedded-content/media-elements/paused_true_during_pause.html": [
"6c4eb7c0c09fd2f048c96eff66d58b05ab3e4952",
"2a9335bd4e6026ff1c029fb140c3b146474e3523",
"testharness"
],
"html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-move-to-other-document.html": [

View file

@ -14,26 +14,28 @@
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("calling play() then pause() on non-autoplay audio should trigger pause event", {timeout:5000});
promise_test(function(t) {
var async_t = async_test("calling play() then pause() on non-autoplay audio should trigger pause event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("pause", function() {
t.done();
async_t.done();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
a.play();
var play_promise = a.play();
a.pause();
return promise_rejects(t, "AbortError", play_promise, "pause() should reject all pending play Promises");
}, "audio events - pause");
test(function() {
var t = async_test("calling play() then pause() on non-autoplay video should trigger pause event", {timeout:5000});
promise_test(function(t) {
var async_t = async_test("calling play() then pause() on non-autoplay video should trigger pause event", {timeout:5000});
var v = document.getElementById("v");
v.addEventListener("pause", function() {
t.done();
async_t.done();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
v.play();
var play_promise = v.play()
v.pause();
return promise_rejects(t, "AbortError", play_promise, "pause() should reject all pending play Promises");
}, "video events - pause");
</script>
</body>

View file

@ -14,26 +14,26 @@
</video>
<div id="log"></div>
<script>
test(function() {
var t = async_test("calling play() on audio should trigger play event", {timeout:5000});
promise_test(function(t) {
var async_t = async_test("calling play() on audio should trigger play event", {timeout:5000});
var a = document.getElementById("a");
a.addEventListener("play", function() {
t.done();
a.addEventListener("play", async_t.step_func(function() {
a.pause();
}, false);
async_t.done();
}), false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
a.play();
return promise_rejects(t, "AbortError", a.play(), "pause() should reject all pending play Promises");
}, "audio events - play");
test(function() {
var t = async_test("calling play() on video should trigger play event", {timeout:5000});
promise_test(function(t) {
var async_t = async_test("calling play() on video should trigger play event", {timeout:5000});
var v = document.getElementById("v");
v.addEventListener("play", function() {
t.done();
v.addEventListener("play", async_t.step_func(function() {
v.pause();
}, false);
async_t.done();
}), false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
v.play();
return promise_rejects(t, "AbortError", v.play(), "pause() should reject all pending play Promises");
}, "video events - play");
</script>
</body>

View file

@ -21,10 +21,11 @@ test(function() {
t.step(function() {
assert_true(a.paused);
});
t.done();
}, false);
a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
a.play();
a.play().catch(() => {});
a.pause();
}, "audio events - paused property");
@ -35,10 +36,11 @@ test(function() {
t.step(function() {
assert_true(v.paused);
});
t.done();
}, false);
v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
v.play();
v.play().catch(() => {});
v.pause();
}, "video events - paused property");
</script>