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

Side by Side Diff: third_party/WebKit/LayoutTests/media/event-attributes.html

Issue 2024533002: Convert csp-*, event-* and invalid-* 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>Test event attributes for media element.</title>
foolip 2016/05/31 10:50:18 This is testing way too many things at once IMHO.
Srirama 2016/05/31 13:23:28 Acknowledged. I will check it later.
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 <video controls></video>
7 <script src=video-test.js></script> 7 <script>
8 <script> 8 async_test(function(t) {
9 var ratechangeCount = 0; 9 var ratechangeCount = 0;
10 var playingCount = 0; 10 var playingCount = 0;
11 var progressEventCount = 0; 11 var progressEventCount = 0;
12 var pauseEventCount = 0; 12 var pauseEventCount = 0;
13 13
14 function eventHandler() 14 var video = document.querySelector("video");
15 {
16 // Don't log progress event since the number and order are platf orm
17 // specific.
18 if (event.type != "progress")
19 consoleWrite("EVENT(" + event.type + ")");
20 switch (event.type)
21 {
22 case "canplaythrough":
23 if (playingCount > 0)
24 return;
25 video.oncanplaythrough = null;
26 testExpected('progressEventCount', 1, '>=');
27 consoleWrite("<br>*** starting playback");
28 run("video.play()");
29 break;
30 case "canplay":
31 video.oncanplay = null;
32 break;
33 case "playing":
34 if (++playingCount == 1) {
35 consoleWrite("<br>*** changing playback rate");
36 run("video.playbackRate = 2");
37 }
38 break;
39 case "ratechange":
40 if (++ratechangeCount == 1) {
41 consoleWrite("<br>*** setting volume");
42 run("video.volume = 0.5");
43 }
44 break;
45 case "volumechange":
46 consoleWrite("<br>*** pausing playback");
47 run("video.pause()");
48 break;
49 case "pause":
50 if(++pauseEventCount == 1) {
51 consoleWrite("<br>*** seeking");
52 run("video.currentTime = 5.6");
53 }
54 break;
55 case "seeked":
56 consoleWrite("<br>*** beginning playback");
57 run("video.play()");
58 break;
59 case "ended":
60 var mediaFile = findMediaFile("video", "content/garbage" );
61 consoleWrite("<br>*** played to end, setting 'src' to an invalid movie");
62 run("progressEventCount = 0");
63 video.src = mediaFile;
64 break;
65 case "progress":
66 ++progressEventCount;
67 break;
68 case "error":
69 testExpected('progressEventCount', 0);
70 endTest();
71 break;
72 default:
73 break;
74 }
75 }
76 15
77 function start() 16 var actual_events = [];
78 { 17 var expected_events = ["loadstart", "durationchange", "loadedmetadata",
79 setSrcByTagName("video", findMediaFile("video", "content/test")) ; 18 "loadeddata", "canplay", "canplaythrough", "play", "playing", "ratechan ge",
80 findMediaElement(); 19 "volumechange", "pause", "seeking", "seeked", "play", "playing", "pause ",
81 } 20 "ended", "abort", "emptied", "ratechange", "loadstart", "error"];
82 21
83 </script> 22 video.oncanplaythrough = t.step_func(function() {
84 </head> 23 actual_events.push(event.type);
foolip 2016/05/31 10:50:18 This and the other event handlers is relying on th
Srirama 2016/05/31 13:23:28 Done.
24 if (playingCount > 0)
25 return;
foolip 2016/05/31 10:50:18 This seems kind of pointless given that oncanplayt
Srirama 2016/05/31 13:23:28 Done.
26 video.oncanplaythrough = null;
27 assert_greater_than_equal(progressEventCount, 1);
28 video.play();
29 });
85 30
86 <body onload="start()"> 31 video.oncanplay = t.step_func(function() {
32 actual_events.push(event.type);
33 video.oncanplay = null;
34 });
87 35
88 <video controls 36 video.onplaying = t.step_func(function() {
89 onabort="eventHandler()" 37 actual_events.push(event.type);
90 oncanplay="eventHandler()" 38 if (++playingCount == 1)
91 oncanplaythrough="eventHandler()" 39 video.playbackRate = 2;
92 ondurationchange="eventHandler()" 40 });
93 onemptied="eventHandler()"
94 onended="eventHandler()"
95 onerror="eventHandler()"
96 onloadeddata="eventHandler()"
97 onloadedmetadata="eventHandler()"
98 onloadstart="eventHandler()"
99 onpause="eventHandler()"
100 onplay="eventHandler()"
101 onplaying="eventHandler()"
102 onprogress="eventHandler()"
103 onratechange="eventHandler()"
104 onseeked="eventHandler()"
105 onseeking="eventHandler()"
106 onstalled="eventHandler()"
107 onvolumechange="eventHandler()"
108 onwaiting="eventHandler()"
109 >
110 </video>
111 41
112 </body> 42 video.onratechange = t.step_func(function() {
113 </html> 43 actual_events.push(event.type);
44 if (++ratechangeCount == 1)
45 video.volume = 0.5;
46 });
47
48 video.onvolumechange = t.step_func(function() {
49 actual_events.push(event.type);
50 video.pause();
51 });
52
53 video.onpause = t.step_func(function() {
54 actual_events.push(event.type);
55 if(++pauseEventCount == 1)
56 video.currentTime = 5.6;
57 });
58
59 video.onseeked = t.step_func(function() {
60 actual_events.push(event.type);
61 video.play();
62 });
63
64 video.onended = t.step_func(function() {
65 actual_events.push(event.type);
66 video.src = findMediaFile("video", "content/garbage");
67 progressEventCount = 0;
68 });
69
70 video.onprogress = t.step_func(function() {
71 // Don't log progress event since the number and order are platform spec ific.
foolip 2016/05/31 10:50:18 I've seen (maybe written) other tests like this th
Srirama 2016/05/31 13:23:28 Acknowledged.
72 ++progressEventCount;
73 });
74
75 video.onerror = t.step_func_done(function() {
76 actual_events.push(event.type);
77 assert_equals(progressEventCount, 0);
78 assert_array_equals(actual_events, expected_events);
79 });
80
81 video.onabort = t.step_func(function() {
fs 2016/05/31 08:53:06 Arguably, these that don't "do" anything, could pe
Srirama 2016/05/31 13:23:28 Done.
82 actual_events.push(event.type);
83 });
84
85 video.ondurationchange = t.step_func(function() {
86 actual_events.push(event.type);
87 });
88
89 video.onemptied = t.step_func(function() {
90 actual_events.push(event.type);
91 });
92
93 video.onloadeddata = t.step_func(function() {
94 actual_events.push(event.type);
95 });
96
97 video.onloadedmetadata = t.step_func(function() {
98 actual_events.push(event.type);
99 });
100
101 video.onloadstart = t.step_func(function() {
102 actual_events.push(event.type);
103 });
104
105 video.onplay = t.step_func(function() {
106 actual_events.push(event.type);
107 });
108
109 video.onseeking = t.step_func(function() {
110 actual_events.push(event.type);
111 });
112
113 video.src = findMediaFile("video", "content/test");
114 });
115 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698