| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <title>Test event attributes for media element.</title> |
| 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(event) { |
| 84 </head> | 23 actual_events.push(event.type); |
| 24 video.oncanplaythrough = null; |
| 25 assert_greater_than_equal(progressEventCount, 1); |
| 26 video.play(); |
| 27 }); |
| 85 | 28 |
| 86 <body onload="start()"> | 29 video.oncanplay = t.step_func(function(event) { |
| 30 actual_events.push(event.type); |
| 31 video.oncanplay = null; |
| 32 }); |
| 87 | 33 |
| 88 <video controls | 34 video.onplaying = t.step_func(function(event) { |
| 89 onabort="eventHandler()" | 35 actual_events.push(event.type); |
| 90 oncanplay="eventHandler()" | 36 if (++playingCount == 1) |
| 91 oncanplaythrough="eventHandler()" | 37 video.playbackRate = 2; |
| 92 ondurationchange="eventHandler()" | 38 }); |
| 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 | 39 |
| 112 </body> | 40 video.onratechange = t.step_func(function(event) { |
| 113 </html> | 41 actual_events.push(event.type); |
| 42 if (++ratechangeCount == 1) |
| 43 video.volume = 0.5; |
| 44 }); |
| 45 |
| 46 video.onvolumechange = t.step_func(function(event) { |
| 47 actual_events.push(event.type); |
| 48 video.pause(); |
| 49 }); |
| 50 |
| 51 video.onpause = t.step_func(function(event) { |
| 52 actual_events.push(event.type); |
| 53 if(++pauseEventCount == 1) |
| 54 video.currentTime = 5.6; |
| 55 }); |
| 56 |
| 57 video.onseeked = t.step_func(function(event) { |
| 58 actual_events.push(event.type); |
| 59 video.play(); |
| 60 }); |
| 61 |
| 62 video.onended = t.step_func(function(event) { |
| 63 actual_events.push(event.type); |
| 64 video.src = findMediaFile("video", "content/garbage"); |
| 65 progressEventCount = 0; |
| 66 }); |
| 67 |
| 68 video.onprogress = t.step_func(function() { |
| 69 // Don't log progress event since the number and order are platform spec
ific. |
| 70 ++progressEventCount; |
| 71 }); |
| 72 |
| 73 video.onerror = t.step_func_done(function(event) { |
| 74 actual_events.push(event.type); |
| 75 assert_equals(progressEventCount, 0); |
| 76 assert_array_equals(actual_events, expected_events); |
| 77 }); |
| 78 |
| 79 var defaultEventStepFunction = t.step_func(function() { |
| 80 actual_events.push(event.type); |
| 81 }); |
| 82 |
| 83 video.onabort = defaultEventStepFunction; |
| 84 video.ondurationchange = defaultEventStepFunction; |
| 85 video.onemptied = defaultEventStepFunction; |
| 86 video.onloadeddata = defaultEventStepFunction; |
| 87 video.onloadedmetadata = defaultEventStepFunction; |
| 88 video.onloadstart = defaultEventStepFunction; |
| 89 video.onplay = defaultEventStepFunction; |
| 90 video.onseeking = defaultEventStepFunction; |
| 91 |
| 92 video.src = findMediaFile("video", "content/test"); |
| 93 }); |
| 94 </script> |
| OLD | NEW |