| 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..c7072587941679c6b27bde2db7ff4708584df1fd 100644
|
| --- a/third_party/WebKit/LayoutTests/media/event-attributes.html
|
| +++ b/third_party/WebKit/LayoutTests/media/event-attributes.html
|
| @@ -1,113 +1,94 @@
|
| <!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
|
| - // 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;
|
| - }
|
| - }
|
| + var video = document.querySelector("video");
|
|
|
| - function start()
|
| - {
|
| - setSrcByTagName("video", findMediaFile("video", "content/test"));
|
| - findMediaElement();
|
| - }
|
| + 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"];
|
|
|
| - </script>
|
| - </head>
|
| + video.oncanplaythrough = t.step_func(function(event) {
|
| + actual_events.push(event.type);
|
| + video.oncanplaythrough = null;
|
| + assert_greater_than_equal(progressEventCount, 1);
|
| + video.play();
|
| + });
|
|
|
| - <body onload="start()">
|
| + video.oncanplay = t.step_func(function(event) {
|
| + actual_events.push(event.type);
|
| + video.oncanplay = null;
|
| + });
|
|
|
| - <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>
|
| + video.onplaying = t.step_func(function(event) {
|
| + actual_events.push(event.type);
|
| + if (++playingCount == 1)
|
| + video.playbackRate = 2;
|
| + });
|
|
|
| - </body>
|
| -</html>
|
| + video.onratechange = t.step_func(function(event) {
|
| + actual_events.push(event.type);
|
| + if (++ratechangeCount == 1)
|
| + video.volume = 0.5;
|
| + });
|
| +
|
| + video.onvolumechange = t.step_func(function(event) {
|
| + actual_events.push(event.type);
|
| + video.pause();
|
| + });
|
| +
|
| + video.onpause = t.step_func(function(event) {
|
| + actual_events.push(event.type);
|
| + if(++pauseEventCount == 1)
|
| + video.currentTime = 5.6;
|
| + });
|
| +
|
| + video.onseeked = t.step_func(function(event) {
|
| + actual_events.push(event.type);
|
| + video.play();
|
| + });
|
| +
|
| + video.onended = t.step_func(function(event) {
|
| + 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.
|
| + ++progressEventCount;
|
| + });
|
| +
|
| + video.onerror = t.step_func_done(function(event) {
|
| + actual_events.push(event.type);
|
| + assert_equals(progressEventCount, 0);
|
| + assert_array_equals(actual_events, expected_events);
|
| + });
|
| +
|
| + var defaultEventStepFunction = t.step_func(function() {
|
| + actual_events.push(event.type);
|
| + });
|
| +
|
| + video.onabort = defaultEventStepFunction;
|
| + video.ondurationchange = defaultEventStepFunction;
|
| + video.onemptied = defaultEventStepFunction;
|
| + video.onloadeddata = defaultEventStepFunction;
|
| + video.onloadedmetadata = defaultEventStepFunction;
|
| + video.onloadstart = defaultEventStepFunction;
|
| + video.onplay = defaultEventStepFunction;
|
| + video.onseeking = defaultEventStepFunction;
|
| +
|
| + video.src = findMediaFile("video", "content/test");
|
| +});
|
| +</script>
|
|
|