mediasource-attach-stops-delaying-load-event.html (2375B)
1 <!DOCTYPE html> 2 <!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). --> 3 <title>Tests that MediaSource attachment stops delaying the load event.</title> 4 <link rel="author" title="Matthew Wolenetz" href="mailto:wolenetz@chromium.org"/> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script> 8 async_test(function(test) 9 { 10 var receivedLoadEvent = false; 11 var receivedSourceOpenEvent = false; 12 13 window.addEventListener("load", test.step_func(function() { 14 assert_false(receivedLoadEvent, "window should not receive multiple load events"); 15 receivedLoadEvent = true; 16 assert_equals(document.readyState, "complete", "document should be complete"); 17 if (receivedLoadEvent && receivedSourceOpenEvent) { 18 test.done(); 19 } 20 })); 21 22 assert_equals(document.readyState, "loading", "document should not be complete yet"); 23 var video = document.createElement("video"); 24 var mediaSource = new MediaSource(); 25 26 // |video| should stop delaying the load event long and complete the MediaSource attachment 27 // before either a "progress", "stalled" or "suspend" event are enqueued. 28 video.addEventListener("suspend", test.unreached_func("unexpected 'suspend' event")); 29 video.addEventListener("stalled", test.unreached_func("unexpected 'stalled' event")); 30 video.addEventListener("progress", test.unreached_func("unexpected 'progress' event")); 31 32 // No error is expected. 33 video.addEventListener("error", test.unreached_func("unexpected 'error' event")); 34 35 mediaSource.addEventListener("sourceopen", test.step_func(function() { 36 assert_false(receivedSourceOpenEvent, "only one sourceopen event should occur in this test"); 37 receivedSourceOpenEvent = true; 38 assert_equals(video.networkState, video.NETWORK_LOADING); 39 assert_equals(video.readyState, video.HAVE_NOTHING); 40 if (receivedLoadEvent && receivedSourceOpenEvent) { 41 test.done(); 42 } 43 })); 44 45 var mediaSourceURL = URL.createObjectURL(mediaSource); 46 video.src = mediaSourceURL; 47 test.add_cleanup(function() { URL.revokeObjectURL(mediaSourceURL); }); 48 }, "MediaSource attachment should immediately stop delaying the load event"); 49 </script>