Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/media/event-attributes.html |
| diff --git a/third_party/WebKit/LayoutTests/media/event-attributes.html b/third_party/WebKit/LayoutTests/media/event-attributes.html |
| index 3f871a489877571be3d71bfc82a0badad47a0a22..0b79f604efd85ff4efef37eafe976d1442708511 100644 |
| --- a/third_party/WebKit/LayoutTests/media/event-attributes.html |
| +++ b/third_party/WebKit/LayoutTests/media/event-attributes.html |
| @@ -1,113 +1,115 @@ |
| <!DOCTYPE html> |
| -<html> |
| - <head> |
| - <script src=media-file.js></script> |
| - <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 |
| - (Please avoid writing new tests using video-test.js) --> |
| - <script src=video-test.js></script> |
| - <script> |
| - var ratechangeCount = 0; |
| - var playingCount = 0; |
| - var progressEventCount = 0; |
| - var pauseEventCount = 0; |
| - |
| - function eventHandler() |
| - { |
| - // Don't log progress event since the number and order are platform |
| - // specific. |
| - if (event.type != "progress") |
| - consoleWrite("EVENT(" + event.type + ")"); |
| - switch (event.type) |
| - { |
| - case "canplaythrough": |
| - if (playingCount > 0) |
| - return; |
| - video.oncanplaythrough = null; |
| - testExpected('progressEventCount', 1, '>='); |
| - consoleWrite("<br>*** starting playback"); |
| - run("video.play()"); |
| - break; |
| - case "canplay": |
| - video.oncanplay = null; |
| - break; |
| - case "playing": |
| - if (++playingCount == 1) { |
| - consoleWrite("<br>*** changing playback rate"); |
| - run("video.playbackRate = 2"); |
| - } |
| - break; |
| - case "ratechange": |
| - if (++ratechangeCount == 1) { |
| - consoleWrite("<br>*** setting volume"); |
| - run("video.volume = 0.5"); |
| - } |
| - break; |
| - case "volumechange": |
| - consoleWrite("<br>*** pausing playback"); |
| - run("video.pause()"); |
| - break; |
| - case "pause": |
| - if(++pauseEventCount == 1) { |
| - consoleWrite("<br>*** seeking"); |
| - run("video.currentTime = 5.6"); |
| - } |
| - break; |
| - case "seeked": |
| - consoleWrite("<br>*** beginning playback"); |
| - run("video.play()"); |
| - break; |
| - case "ended": |
| - var mediaFile = findMediaFile("video", "content/garbage"); |
| - consoleWrite("<br>*** played to end, setting 'src' to an invalid movie"); |
| - run("progressEventCount = 0"); |
| - video.src = mediaFile; |
| - break; |
| - case "progress": |
| - ++progressEventCount; |
| - break; |
| - case "error": |
| - testExpected('progressEventCount', 0); |
| - endTest(); |
| - break; |
| - default: |
| - break; |
| - } |
| - } |
| - |
| - function start() |
| - { |
| - setSrcByTagName("video", findMediaFile("video", "content/test")); |
| - findMediaElement(); |
| - } |
| - |
| - </script> |
| - </head> |
| - |
| - <body onload="start()"> |
| - |
| - <video controls |
| - onabort="eventHandler()" |
| - oncanplay="eventHandler()" |
| - oncanplaythrough="eventHandler()" |
| - ondurationchange="eventHandler()" |
| - onemptied="eventHandler()" |
| - onended="eventHandler()" |
| - onerror="eventHandler()" |
| - onloadeddata="eventHandler()" |
| - onloadedmetadata="eventHandler()" |
| - onloadstart="eventHandler()" |
| - onpause="eventHandler()" |
| - onplay="eventHandler()" |
| - onplaying="eventHandler()" |
| - onprogress="eventHandler()" |
| - onratechange="eventHandler()" |
| - onseeked="eventHandler()" |
| - onseeking="eventHandler()" |
| - onstalled="eventHandler()" |
| - onvolumechange="eventHandler()" |
| - onwaiting="eventHandler()" |
| - > |
| - </video> |
| - |
| - </body> |
| -</html> |
| +<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.
|
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="media-file.js"></script> |
| +<video controls></video> |
| +<script> |
| +async_test(function(t) { |
| + var ratechangeCount = 0; |
| + var playingCount = 0; |
| + var progressEventCount = 0; |
| + var pauseEventCount = 0; |
| + |
| + var video = document.querySelector("video"); |
| + |
| + var actual_events = []; |
| + var expected_events = ["loadstart", "durationchange", "loadedmetadata", |
| + "loadeddata", "canplay", "canplaythrough", "play", "playing", "ratechange", |
| + "volumechange", "pause", "seeking", "seeked", "play", "playing", "pause", |
| + "ended", "abort", "emptied", "ratechange", "loadstart", "error"]; |
| + |
| + video.oncanplaythrough = t.step_func(function() { |
| + 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.
|
| + if (playingCount > 0) |
| + return; |
|
foolip
2016/05/31 10:50:18
This seems kind of pointless given that oncanplayt
Srirama
2016/05/31 13:23:28
Done.
|
| + video.oncanplaythrough = null; |
| + assert_greater_than_equal(progressEventCount, 1); |
| + video.play(); |
| + }); |
| + |
| + video.oncanplay = t.step_func(function() { |
| + actual_events.push(event.type); |
| + video.oncanplay = null; |
| + }); |
| + |
| + video.onplaying = t.step_func(function() { |
| + actual_events.push(event.type); |
| + if (++playingCount == 1) |
| + video.playbackRate = 2; |
| + }); |
| + |
| + video.onratechange = t.step_func(function() { |
| + actual_events.push(event.type); |
| + if (++ratechangeCount == 1) |
| + video.volume = 0.5; |
| + }); |
| + |
| + video.onvolumechange = t.step_func(function() { |
| + actual_events.push(event.type); |
| + video.pause(); |
| + }); |
| + |
| + video.onpause = t.step_func(function() { |
| + actual_events.push(event.type); |
| + if(++pauseEventCount == 1) |
| + video.currentTime = 5.6; |
| + }); |
| + |
| + video.onseeked = t.step_func(function() { |
| + actual_events.push(event.type); |
| + video.play(); |
| + }); |
| + |
| + video.onended = t.step_func(function() { |
| + actual_events.push(event.type); |
| + video.src = findMediaFile("video", "content/garbage"); |
| + progressEventCount = 0; |
| + }); |
| + |
| + video.onprogress = t.step_func(function() { |
| + // Don't log progress event since the number and order are platform specific. |
|
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.
|
| + ++progressEventCount; |
| + }); |
| + |
| + video.onerror = t.step_func_done(function() { |
| + actual_events.push(event.type); |
| + assert_equals(progressEventCount, 0); |
| + assert_array_equals(actual_events, expected_events); |
| + }); |
| + |
| + 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.
|
| + actual_events.push(event.type); |
| + }); |
| + |
| + video.ondurationchange = t.step_func(function() { |
| + actual_events.push(event.type); |
| + }); |
| + |
| + video.onemptied = t.step_func(function() { |
| + actual_events.push(event.type); |
| + }); |
| + |
| + video.onloadeddata = t.step_func(function() { |
| + actual_events.push(event.type); |
| + }); |
| + |
| + video.onloadedmetadata = t.step_func(function() { |
| + actual_events.push(event.type); |
| + }); |
| + |
| + video.onloadstart = t.step_func(function() { |
| + actual_events.push(event.type); |
| + }); |
| + |
| + video.onplay = t.step_func(function() { |
| + actual_events.push(event.type); |
| + }); |
| + |
| + video.onseeking = t.step_func(function() { |
| + actual_events.push(event.type); |
| + }); |
| + |
| + video.src = findMediaFile("video", "content/test"); |
| +}); |
| +</script> |