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..48b3df81290d7d902917e053abd5491fd64e7323 100644 |
| --- a/third_party/WebKit/LayoutTests/media/event-attributes.html |
| +++ b/third_party/WebKit/LayoutTests/media/event-attributes.html |
| @@ -1,113 +1,80 @@ |
| <!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; |
| +<title>Test event attributes for media element.</title> |
| +<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; |
| - function eventHandler() |
| - { |
| - // Don't log progress event since the number and order are platform |
|
fs
2016/05/30 09:11:39
Perhaps keep this comment.
|
| - // 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(); |
| - } |
| + var video = document.querySelector("video"); |
| - </script> |
| - </head> |
| + var actual_events = []; |
| + var expected_events = ["loadstart", "durationchange", "loadedmetadata", |
| + "loadeddata", "canplay", "canplaythrough", "play", "playing", "ratechange", |
| + "volumechange", "pause", "seeking", "seeked", "canplay", "canplaythrough", |
| + "play", "playing", "pause", "ended", "abort", "emptied", "ratechange", |
| + "loadstart", "error"]; |
| + var event_array = ["abort", "canplay", "canplaythrough", "durationchange", |
| + "emptied", "ended", "error", "loadeddata", "loadedmetadata", "loadstart", |
| + "pause", "play", "playing", "progress", "ratechange", "seeked", |
| + "seeking", "volumechange"]; |
| + event_array.forEach(function(type) { |
| + video.addEventListener(type, t.step_func(function() { |
|
fs
2016/05/30 09:11:39
Hmm, the .on<event> will map to the attribute, whi
Srirama
2016/05/31 07:04:23
Done.
|
| + if (type != "progress") |
| + actual_events.push(type); |
| - <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> |
| + switch (event.type) { |
| + case "canplaythrough": |
| + if (playingCount > 0) |
| + return; |
| + video.oncanplaythrough = null; |
| + assert_greater_than_equal(progressEventCount, 1); |
| + video.play(); |
| + break; |
| + case "canplay": |
| + video.oncanplay = null; |
| + break; |
| + case "playing": |
| + if (++playingCount == 1) |
| + video.playbackRate = 2; |
| + break; |
| + case "ratechange": |
| + if (++ratechangeCount == 1) |
| + video.volume = 0.5; |
| + break; |
| + case "volumechange": |
| + video.pause(); |
| + break; |
| + case "pause": |
| + if(++pauseEventCount == 1) |
| + video.currentTime = 5.6; |
| + break; |
| + case "seeked": |
| + video.play(); |
| + break; |
| + case "ended": |
| + video.src = findMediaFile("video", "content/garbage"); |
| + progressEventCount = 0; |
| + break; |
| + case "progress": |
| + ++progressEventCount; |
| + break; |
| + case "error": |
| + assert_equals(progressEventCount, 0); |
| + assert_array_equals(actual_events, expected_events); |
| + t.done(); |
| + break; |
| + default: |
| + break; |
| + } |
| + })); |
| + }); |
| - </body> |
| -</html> |
| + video.src = findMediaFile("video", "content/test"); |
| +}); |
| +</script> |