test_background_loading_iframes.html (2100B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Test for background loading iframes</title> 5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 7 </head> 8 <body> 9 <p id="display"></p> 10 <pre id="test"> 11 12 <script class="testbody" type="text/javascript"> 13 SimpleTest.waitForExplicitFinish(); 14 15 var myLoadTime; 16 var receivedPostMessage = []; 17 18 window.addEventListener('message', function(event) { 19 receivedPostMessage.push(parseInt(event.data)); 20 if (receivedPostMessage.length == 3) { 21 if (!myLoadTime){ 22 ok(false, "Child iframes are loaded earlier than the parent document"); 23 } else { 24 receivedPostMessage.forEach(function(iframeLoadTime, index) { 25 ok(iframeLoadTime, "Iframe load time should not be null"); 26 ok(iframeLoadTime >= myLoadTime, "Parent document should be loaded earlier than child iframes"); 27 }) 28 } 29 SimpleTest.finish(); 30 } 31 }) 32 33 window.onload = function() { 34 myLoadTime = performance.now(); 35 } 36 37 SpecialPowers.pushPrefEnv({"set":[["dom.background_loading_iframe", true]]}).then(async function () { 38 await SpecialPowers.promiseTimeout(0); 39 40 var iframe1 = document.createElement("iframe"); 41 var iframe2 = document.createElement("iframe"); 42 var iframe3 = document.createElement("iframe"); 43 44 iframe1.src = "http://example.org:80/tests/dom/tests/mochitest/dom-level0/file_test_background_loading_iframes.html"; 45 iframe2.src = "http://example.org:80/tests/dom/tests/mochitest/dom-level0/file_test_background_loading_iframes.html"; 46 iframe3.src = "http://example.org:80/tests/dom/tests/mochitest/dom-level0/file_test_background_loading_iframes.html"; 47 48 iframe1.onload = function() { 49 iframe1.contentWindow.postMessage("test", "*"); 50 } 51 52 iframe2.onload = function() { 53 iframe2.contentWindow.postMessage("test", "*"); 54 } 55 56 iframe3.onload = function() { 57 iframe3.contentWindow.postMessage("test", "*"); 58 } 59 60 document.body.append(iframe1); 61 document.body.append(iframe2); 62 document.body.append(iframe3); 63 64 }); 65 66 </script> 67 </pre> 68 </body> 69 </html>