load-removes-queued-error-event.html (2207B)
1 <!doctype html> 2 <title>load() removes queued error event</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <div id=log></div> 6 <script> 7 // The loadstart and error event firing tasks are queued in the synchronous 8 // section of the resource selection algorithm, so no tasks can come between 9 // them. Calling load() in the loadstart event handler removes the queued error 10 // event task at very latest opportunity, failing any implementation that fires 11 // the events in the same task. 12 13 async_test(function(t) { 14 var v = document.createElement('video'); 15 var events = []; 16 v.onloadstart = v.onerror = t.step_func(function(e) { 17 events.push(e.type); 18 if (events.length == 1) { 19 v.load(); 20 } else if (events.length == 3) { 21 assert_array_equals(events, ['loadstart', 'loadstart', 'error']); 22 t.done(); 23 } 24 }); 25 v.src = ''; 26 }, 'video error event with load()'); 27 28 async_test(function(t) { 29 var v = document.createElement('video'); 30 var events = []; 31 v.onloadstart = v.onerror = v.onsuspend = t.step_func(function(e) { 32 events.push(e.type); 33 if (events.length == 1) { 34 // Wait for a usable resource to check that no 'error' event is pending. 35 v.src = '/media/sound_0.mp3'; 36 } else if (events.length == 3) { 37 // 'suspend' is queued "if the user agent intends to not attempt to 38 // fetch the resource", "when a media element's download has been 39 // suspended", or "once the entire media resource has been fetched". 40 assert_array_equals(events, ['loadstart', 'loadstart', 'suspend']); 41 t.done(); 42 } 43 }); 44 v.src = ''; 45 }, 'video error event with src resource'); 46 47 async_test(function(t) { 48 var v = document.createElement('video'); 49 var s = document.createElement('source'); 50 var events = []; 51 v.onloadstart = s.onerror = t.step_func(function(e) { 52 events.push(e.type); 53 if (events.length == 1) { 54 v.load(); 55 } else if (events.length == 3) { 56 assert_array_equals(events, ['loadstart', 'loadstart', 'error']); 57 t.done(); 58 } 59 }); 60 v.onerror = t.step_func(function() { assert_unreached(); }); 61 v.appendChild(s); 62 }, 'source error event'); 63 </script>