Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!doctype html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <title>Tests that moving a "video" in and out of an "iframe" does not trigger a crash.</title> |
| 3 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 3 <script src="../resources/testharness.js"></script> |
| 4 (Please avoid writing new tests using video-test.js) --> | 4 <script src="../resources/testharnessreport.js"></script> |
| 5 <script src="../../media-resources/video-test.js"></script> | 5 <body> |
| 6 <script> | 6 <div></div> |
| 7 function getNextURL() | 7 <video></video> |
| 8 { | 8 <script> |
| 9 var url = location.href; | 9 async_test(function(t) { |
| 10 var queryIndex = url.indexOf("?"); | 10 var iframe = document.createElement("iframe"); |
| 11 var loadCount = 1; | 11 iframe.src = "../../media-resources/resources/frame_size_change.webm"; |
| 12 if (queryIndex >= 0) { | 12 document.querySelector("div").appendChild(iframe); |
| 13 loadCount = parseInt(url.substring(queryIndex + 1)); | |
| 14 | 13 |
| 15 // Enforce an arbitrary reload limit that is high enough to trigge r previosly observed crashes. | 14 setTimeout(t.step_func(function() { |
|
Srirama
2016/07/26 13:29:30
Thought of using iframe.onload but then looking at
| |
| 16 if (loadCount >= 10) | 15 var iframeContentDocument = iframe.contentDocument; |
| 17 return ""; | 16 var iframeDocumentElement = iframeContentDocument.documentElement; |
| 18 | 17 |
| 19 url = url.substring(0, queryIndex); | 18 iframeContentDocument.onreadystatechange = function() { |
| 19 // Attempts to move the document body back into the iframe document. | |
| 20 iframeContentDocument.appendChild(iframeDocumentElement); | |
| 21 }; | |
| 22 | |
| 23 // Moves the iframe body into the current document. | |
| 24 document.body.appendChild(iframeContentDocument.firstChild); | |
| 25 // Reload page. | |
| 26 var url = location.href; | |
| 27 var loadCount = 1; | |
| 28 var queryIndex = url.indexOf("?"); | |
| 29 if (queryIndex >= 0) { | |
| 30 loadCount = parseInt(url.substring(queryIndex + 1)); | |
| 31 // Enforce an arbitrary reload limit that is high enough to trigger previosly observed crashes. | |
| 32 if (loadCount >= 10) { | |
| 33 t.done(); | |
| 34 return; | |
| 20 } | 35 } |
| 21 | 36 |
| 22 return url + "?" + (loadCount + 1); | 37 url = url.substring(0, queryIndex); |
| 23 } | 38 } |
| 24 | 39 |
| 25 function reloadPage() | 40 location.href = url + "?" + (loadCount + 1); |
| 26 { | 41 }), 20); |
| 27 var url = getNextURL(); | 42 }); |
| 28 if (url.length == 0) { | 43 </script> |
| 29 endTest(); | |
| 30 return; | |
| 31 } | |
| 32 location.href = url; | |
| 33 } | |
| 34 | |
| 35 function start() | |
| 36 { | |
| 37 iframe = document.createElement("iframe"); | |
| 38 iframe.src = "../../media-resources/resources/frame_size_change.webm "; | |
| 39 document.getElementById("store_div").appendChild(iframe); | |
| 40 window.setTimeout(moveIframeBodyIntoDocumentBody, 20); | |
| 41 } | |
| 42 | |
| 43 function moveIframeBodyIntoDocumentBody() | |
| 44 { | |
| 45 var iframeContentDocument = iframe.contentDocument; | |
| 46 var iframeDocumentElement = iframeContentDocument.documentElement; | |
| 47 | |
| 48 iframeContentDocument.onreadystatechange = function(e) | |
| 49 { | |
| 50 // Attempts to move the document body back into the iframe docum ent. | |
| 51 iframeContentDocument.appendChild(iframeDocumentElement); | |
| 52 } | |
| 53 | |
| 54 // Moves the iframe body into the current document. | |
| 55 document.body.appendChild(iframeContentDocument.firstChild); | |
| 56 reloadPage(); | |
| 57 } | |
| 58 | |
| 59 </script> | |
| 60 <body onload="start()"> | |
| 61 <p>Tests that moving a <video> in and out of an iframe does not tr igger a crash.</p> | |
| 62 <div id="store_div"></div> | |
| 63 </body> | |
| 64 </html> | |
| OLD | NEW |