| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Test that the document's load event is delayed until a video's meta data
is available.</title> | 2 <title>Test that the document's load event is delayed until a video's meta data
is available.</title> |
| 3 <script src="../resources/testharness.js"></script> | 3 <script src="../resources/testharness.js"></script> |
| 4 <script src="../resources/testharnessreport.js"></script> | 4 <script src="../resources/testharnessreport.js"></script> |
| 5 <script src="media-file.js"></script> | 5 <script src="media-file.js"></script> |
| 6 <video id="video1"></video> | 6 <video id="video1"></video> |
| 7 <video id="video2"></video> | 7 <video id="video2"></video> |
| 8 <video id="video3"><source></source></video> | 8 <video id="video3"></video> |
| 9 <script> | 9 <script> |
| 10 async_test(function(t) { | 10 async_test(function(t) { |
| 11 assertVideoNoSrcNoLoad(document.getElementById("video1")); | 11 assertVideoNoSrcNoLoad(document.getElementById("video1")); |
| 12 | 12 |
| 13 var video = document.getElementById("video2"); | 13 var video = document.getElementById("video2"); |
| 14 video.src = findMediaFile("video", "content/test"); | 14 video.src = findMediaFile("video", "content/test"); |
| 15 assertVideoSrcNoLoad(video); | 15 assertVideoSrcNoLoad(video); |
| 16 | 16 |
| 17 var source = document.querySelector("source"); | 17 var source = document.createElement("source"); |
| 18 source.src = findMediaFile("video", "content/test"); | 18 source.src = findMediaFile("video", "content/test"); |
| 19 assertVideoSrcNoLoad(document.getElementById("video3")); | 19 var video3 = document.getElementById("video3"); |
| 20 video3.appendChild(source); |
| 21 assertVideoSrcNoLoad(video3); |
| 20 | 22 |
| 21 window.onload = t.step_func_done(function() { | 23 window.onload = t.step_func_done(function() { |
| 22 assertVideoNoSrcNoLoad(document.getElementById("video1")); | 24 assertVideoNoSrcNoLoad(document.getElementById("video1")); |
| 23 assertVideoSrcLoad(document.getElementById("video2")); | 25 assertVideoSrcLoad(document.getElementById("video2")); |
| 24 assertVideoSrcLoad(document.getElementById("video3")); | 26 assertVideoSrcLoad(document.getElementById("video3")); |
| 25 }); | 27 }); |
| 26 | 28 |
| 27 function assertVideoNoSrcNoLoad(video) { | 29 function assertVideoNoSrcNoLoad(video) { |
| 28 // Video should not load as there is no "src". | 30 // Video should not load as there is no "src". |
| 29 assert_equals(video.networkState, HTMLMediaElement.NETWORK_EMPTY); | 31 assert_equals(video.networkState, HTMLMediaElement.NETWORK_EMPTY); |
| 30 assert_equals(video.readyState, HTMLMediaElement.HAVE_NOTHING); | 32 assert_equals(video.readyState, HTMLMediaElement.HAVE_NOTHING); |
| 31 } | 33 } |
| 32 | 34 |
| 33 function assertVideoSrcNoLoad(video) { | 35 function assertVideoSrcNoLoad(video) { |
| 34 // Video loading has just triggered. | 36 // Video loading has just triggered. |
| 35 assert_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SOURCE); | 37 assert_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SOURCE); |
| 36 assert_equals(video.readyState, HTMLMediaElement.HAVE_NOTHING); | 38 assert_equals(video.readyState, HTMLMediaElement.HAVE_NOTHING); |
| 37 } | 39 } |
| 38 | 40 |
| 39 function assertVideoSrcLoad(video) { | 41 function assertVideoSrcLoad(video) { |
| 40 // The Video should have loaded at least to HAVE_CURRENT_DATA | 42 // The Video should have loaded at least to HAVE_CURRENT_DATA |
| 41 assert_not_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SOURCE
); | 43 assert_not_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SOURCE
); |
| 42 assert_greater_than_equal(video.networkState, HTMLMediaElement.NETWORK_I
DLE); | 44 assert_greater_than_equal(video.networkState, HTMLMediaElement.NETWORK_I
DLE); |
| 43 assert_greater_than_equal(video.readyState, HTMLMediaElement.HAVE_CURREN
T_DATA); | 45 assert_greater_than_equal(video.readyState, HTMLMediaElement.HAVE_CURREN
T_DATA); |
| 44 } | 46 } |
| 45 }); | 47 }); |
| 46 </script> | 48 </script> |
| OLD | NEW |