Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(847)

Side by Side Diff: third_party/WebKit/LayoutTests/media/media-element-play-after-eos.html

Issue 2031783002: Convert media-cont* and media-element* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <title>This test ensures that media element fires the "playing" event every time it starts playing after eos. It also ensure that "pause" and "ended" events are fired when media playback ends.</title>
3 <head> 3 <script src="../resources/testharness.js"></script>
4 <script src=media-file.js></script> 4 <script src="../resources/testharnessreport.js"></script>
5 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 5 <script src="media-file.js"></script>
6 (Please avoid writing new tests using video-test.js) --> 6 <audio></audio>
7 <script src=video-test.js></script> 7 <script>
8 <script> 8 // TODO(srirama.m): Modify the test to record events and check for order
9 var repeated = false; 9 // at the end of test. See autoplay-with-preload-none.html for help.
10 var mediaElement = new Audio(); 10 async_test(function(t) {
11 var loop = true;
12 var audio = document.querySelector("audio");
13 audio.src = findMediaFile("audio", "content/silence");
11 14
12 function start() 15 audio.onloadedmetadata = t.step_func(function() {
13 { 16 audio.onplaying = t.step_func(mediaPlaying);
14 mediaElement.src = findMediaFile('audio', 'content/silence'); 17
15 waitForEvent("loadedmetadata", mediaLoadedMetadata); 18 audio.onpause = t.step_func(function() {
19 assert_true(audio.paused);
20 });
21
22 audio.onended = t.step_func(function() {
23 assert_true(audio.ended, true);
24
25 if (!loop) {
26 t.done();
27 return;
16 } 28 }
17 29
18 function mediaLoadedMetadata() 30 loop = false;
19 { 31 audio.onplaying = t.step_func(mediaPlaying);
20 waitForEventOnce("playing", mediaPlaying); 32 audio.play();
21 waitForEvent("pause", mediaPause); 33 });
22 waitForEvent("ended", mediaEnded);
23 run("mediaElement.play()");
24 }
25 34
26 function mediaPlaying() 35 audio.play();
27 { 36 });
28 mediaElement.currentTime = mediaElement.duration - 0.2;
29 }
30 37
31 function mediaPause() 38 function mediaPlaying() {
32 { 39 audio.onplaying = null;
33 testExpected("mediaElement.paused", true); 40 audio.currentTime = audio.duration - 0.2;
34 } 41 }
35 42 });
36 function mediaEnded() 43 </script>
37 {
38 testExpected("mediaElement.ended", true);
39
40 if (repeated) {
41 endTest();
42 return;
43 }
44
45 repeated = true;
46 waitForEventOnce("playing", mediaPlaying);
47 run("mediaElement.play()");
48 }
49
50 </script>
51 </head>
52 <body onload="start()">
53 <p>This tests ensure that media element emits the 'playing' event every time it starts playing after eos. It also ensure that 'pause' and 'ended' events are sent when media playback ends.</p>
54 </body>
55 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698