| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Verify that moving a video element to a new document, still loads it norm
ally</title> | 2 <title>Verify that moving a video element to a new document, still loads it norm
ally</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></video> | 6 <div id=container> |
| 7 <iframe></iframe> | 7 <iframe></iframe> |
| 8 </div> |
| 8 <script> | 9 <script> |
| 9 async_test(function(t) { | 10 function whenIframeLoaded(iframe, callback) { |
| 10 var video = document.querySelector('video'); | 11 if (iframe.contentDocument.readyState != 'uninitialized') |
| 11 video.src = findMediaFile("video", "content/test"); | 12 return callback(); |
| 12 video.onloadeddata = this.step_func(function() { | 13 iframe.onload = callback; |
| 13 video.onloadeddata = null; | 14 } |
| 14 assert_true(video.networkState == video.NETWORK_IDLE || video.networ
kState == video.NETWORK_LOADING); | 15 |
| 15 assert_greater_than(video.readyState, video.HAVE_METADATA); | 16 async_test(function(t) { |
| 16 // Move the video element to iframe document from | 17 var iframe = document.querySelector('iframe'); |
| 17 // main document and verify that it loads properly | 18 whenIframeLoaded(iframe, this.step_func(function() { |
| 18 document.querySelector('iframe').contentDocument.body.appendChild(vi
deo); | 19 var video = iframe.contentDocument.createElement('video'); |
| 19 assert_equals(video.networkState, video.NETWORK_NO_SOURCE); | 20 iframe.contentDocument.body.appendChild(video); |
| 20 assert_equals(video.readyState, video.HAVE_NOTHING); | 21 video.src = findMediaFile('video', 'content/test');//'https://storage.goog
leapis.com/dalecurtis-shared/buck2.mp4'; |
| 21 var actual_events = []; | 22 video.preload = 'auto'; |
| 22 var expected_events = ['emptied', 'loadstart', 'loadeddata']; | 23 |
| 23 expected_events.forEach(function(type) { | 24 video.onloadeddata = this.step_func_done(function() { |
| 24 video.addEventListener(type, t.step_func(function() { | 25 video.onloadeddata = null; |
| 25 actual_events.push(type); | 26 assert_true(video.networkState == video.NETWORK_IDLE || video.networkS
tate == video.NETWORK_LOADING); |
| 26 if (type == 'loadeddata') { | 27 assert_greater_than(video.readyState, video.HAVE_METADATA); |
| 27 assert_array_equals(actual_events, expected_events); | 28 |
| 28 t.done(); | 29 // Move the video element parent document. The state shouldn't change. |
| 29 } | 30 document.body.appendChild(video); |
| 30 })); | 31 document.body.querySelector('#container').innerHTML = ''; |
| 31 }); | 32 |
| 32 }); | 33 assert_true(video.networkState == video.NETWORK_IDLE || video.networkS
tate == video.NETWORK_LOADING); |
| 33 }); | 34 assert_greater_than(video.readyState, video.HAVE_METADATA); |
| 35 }); |
| 36 })); |
| 37 }); |
| 34 </script> | 38 </script> |
| OLD | NEW |