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

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

Issue 2285143003: Improve readability of media-element-play-after-eos.html (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE 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> 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 <script src="../resources/testharness.js"></script> 3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script> 4 <script src="../resources/testharnessreport.js"></script>
5 <script src="media-file.js"></script> 5 <script src="media-file.js"></script>
6 <audio></audio> 6 <audio></audio>
7 <script> 7 <script>
8 // TODO(srirama.m): Modify the test to record events and check for order
9 // at the end of test. See autoplay-with-preload-none.html for help.
10 async_test(function(t) { 8 async_test(function(t) {
11 var loop = true; 9 var loop = true;
12 var audio = document.querySelector("audio"); 10 var audio = document.querySelector("audio");
13 audio.src = findMediaFile("audio", "content/silence"); 11 audio.src = findMediaFile("audio", "content/silence");
14 12
15 audio.onloadedmetadata = t.step_func(function() { 13 var watcher = new EventWatcher(t, audio, ["loadedmetadata", "playing", "paus e", "ended"]);
16 audio.onplaying = t.step_func(mediaPlaying); 14 watcher.wait_for("loadedmetadata").then(t.step_func(function() {
17
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;
28 }
29
30 loop = false;
31 audio.onplaying = t.step_func(mediaPlaying);
32 audio.play();
33 });
34
35 audio.play(); 15 audio.play();
36 }); 16 return watcher.wait_for("playing");
37 17 })).then(t.step_func(function() {
38 function mediaPlaying() {
39 audio.onplaying = null;
40 audio.currentTime = audio.duration - 0.2; 18 audio.currentTime = audio.duration - 0.2;
41 } 19 return watcher.wait_for("playing");
20 })).then(t.step_func(function() {
21 return watcher.wait_for("pause");
22 })).then(t.step_func(function() {
23 assert_true(audio.paused);
24 return watcher.wait_for("ended");
25 })).then(t.step_func(function() {
26 assert_true(audio.ended);
27 audio.play();
28 return watcher.wait_for("playing");
29 })).then(t.step_func(function() {
30 audio.currentTime = audio.duration - 0.2;
31 return watcher.wait_for("playing");
32 })).then(t.step_func(function() {
33 return watcher.wait_for("pause");
34 })).then(t.step_func(function() {
35 assert_true(audio.paused);
36 return watcher.wait_for("ended");
37 })).then(t.step_func_done());
42 }); 38 });
43 </script> 39 </script>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698