| <!DOCTYPE html> |
| <title>Test event attributes for media element.</title> |
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.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(event) { |
| actual_events.push(event.type); |
| video.oncanplaythrough = null; |
| assert_greater_than_equal(progressEventCount, 1); |
| video.play(); |
| }); |
| |
| video.oncanplay = t.step_func(function(event) { |
| actual_events.push(event.type); |
| video.oncanplay = null; |
| }); |
| |
| video.onplaying = t.step_func(function(event) { |
| actual_events.push(event.type); |
| if (++playingCount == 1) |
| video.playbackRate = 2; |
| }); |
| |
| 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 = "content/garbage.ogv"; |
| 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 = "content/test.ogv"; |
| }); |
| </script> |