Update WPT tests for embedded content
[WebKit-https.git] / LayoutTests / imported / w3c / web-platform-tests / html / semantics / embedded-content / media-elements / event_order_canplay_playing.html
1 <!doctype html>
2 <html>
3  <head>
4   <title>{audio,video} events - canplay, then playing</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("setting src attribute on autoplay audio should trigger canplay then playing event");
19   var a = document.getElementById("a");
20   var found_canplay = false;
21   a.addEventListener("error", t.unreached_func());
22   a.addEventListener("canplay", t.step_func(function() {
23     found_canplay = true;
24   }));
25   a.addEventListener("playing", t.step_func(function() {
26     assert_true(found_canplay);
27     t.done();
28     a.pause();
29   }), false);
30   a.src = getAudioURI("/media/sound_5") + "?" + new Date() + Math.random();
31 }, "audio events - canplay, then playing");
32
33 test(function() {
34   var t = async_test("setting src attribute on autoplay video should trigger canplay then playing event");
35   var v = document.getElementById("v");
36   var found_canplay = false;
37   v.addEventListener("error", t.unreached_func());
38   v.addEventListener("canplay", t.step_func(function() {
39     found_canplay = true;
40   }));
41   v.addEventListener("playing", t.step_func(function() {
42     assert_true(found_canplay);
43     t.done();
44     v.pause();
45   }), false);
46   v.src = getVideoURI("/media/movie_5") + "?" + new Date() + Math.random();
47 }, "video events - canplay, then playing");
48   </script>
49  </body>
50 </html>