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

Side by Side Diff: third_party/WebKit/LayoutTests/media/video-pause-immediately.html

Issue 2099083002: Convert video-pause* and video-plays* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 5 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 <html> 1 <!DOCTYPE html>
2 <head> 2 <title>Test that pausing the media element has an immediate effect on the clock. </title>
3 <title>Test pause() pauses the clock immediately</title> 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 <video></video>
7 <script src=video-test.js></script> 7 <script>
8 <script> 8 async_test(function(t) {
9 var timeAfterPause; 9 var timeAfterPause;
10 var video = document.querySelector("video");
11 video.src = findMediaFile("video", "content/test");
12 video.oncanplay = t.step_func(function() {
13 video.play();
14 });
10 15
11 function test() 16 video.onplaying = t.step_func(function() {
12 { 17 video.ontimeupdate = t.step_func(function() {
13 findMediaElement(); 18 assert_greater_than(video.currentTime, 0);
14 video.src = findMediaFile("video", "content/test"); 19 video.ontimeupdate = null;
15 waitForEvent("canplay", canplay); 20 video.pause();
16 waitForEvent("playing", playing); 21 timeAfterPause = video.currentTime;
17 waitForEvent("pause", pause); 22 });
18 } 23 });
19 24
20 function canplay() 25 video.onpause = t.step_func_done(function() {
21 { 26 assert_equals(video.currentTime, timeAfterPause);
22 video.play(); 27 assert_equals(video.played.end(0), timeAfterPause);
23 } 28 });
24 29 });
25 function playing() 30 </script>
26 {
27 video.addEventListener("timeupdate", timeupdate);
28 }
29
30 function timeupdate()
31 {
32 if (video.currentTime > 0) {
33 video.removeEventListener("timeupdate", timeupdate);
34 video.pause();
35 timeAfterPause = video.currentTime;
36 }
37 }
38
39 function pause()
40 {
41 testExpected("(video.currentTime - timeAfterPause)", 0);
42 testExpected("(video.played.end(0) - timeAfterPause)", 0);
43 endTest();
44 }
45 </script>
46 </head>
47 <body onload="test()">
48 <p>Test that pausing the media element has an immediate effect on the cl ock.</p>
49 <video controls></video>
50 </body>
51 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698