event_pause.html (1411B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>{audio,video} events - pause</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/common/media.js"></script> 8 </head> 9 <body> 10 <p><a href="https://html.spec.whatwg.org/multipage/#mediaevents">spec reference</a></p> 11 <audio id="a" autoplay controls> 12 </audio> 13 <video id="v" autoplay controls> 14 </video> 15 <div id="log"></div> 16 <script> 17 test(function() { 18 var t = async_test("calling pause() on autoplay audio should trigger pause event"); 19 var a = document.getElementById("a"); 20 a.addEventListener("error", t.unreached_func()); 21 a.addEventListener("pause", t.step_func_done(), false); 22 a.addEventListener("play", t.step_func(function() { 23 a.pause(); // pause right after play 24 })); 25 a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random(); 26 }, "audio events - pause"); 27 28 test(function() { 29 var t = async_test("calling pause() on autoplay video should trigger pause event"); 30 var v = document.getElementById("v"); 31 v.addEventListener("error", t.unreached_func()); 32 v.addEventListener("pause", t.step_func_done(), false); 33 v.addEventListener("play", t.step_func(function() { 34 v.pause(); // pause right after play 35 })); 36 v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random(); 37 }, "video events - pause"); 38 </script> 39 </body> 40 </html>