file_bug704320_preload_common.js (1145B)
1 // Common code for the iframes used by bug704320_preload. 2 3 var loadCount = 0; 4 5 // Called by the various onload handlers to indicate that a resource has 6 // been fully loaded. We require three loads to complete (img, script, 7 // link) for this test. 8 function incrementLoad(tag) { 9 loadCount++; 10 if (loadCount == 3) { 11 window.parent.postMessage("childLoadComplete", window.location.origin); 12 } else if (loadCount > 3) { 13 document.write("<h1>Too Many Load Events!</h1>"); 14 window.parent.postMessage("childOverload", window.location.origin); 15 } 16 } 17 18 // This is same as incrementLoad, but the caller passes in the loadCount. 19 function incrementLoad2(tag, expectedLoadCount) { 20 loadCount++; 21 if (loadCount == expectedLoadCount) { 22 window.parent.postMessage("childLoadComplete", window.location.origin); 23 } else if (loadCount > expectedLoadCount) { 24 document.write("<h1>Too Many Load Events!</h1>"); 25 window.parent.postMessage("childOverload", window.location.origin); 26 } 27 } 28 29 // in case something fails to load, cause the test to fail. 30 function postfail(msg) { 31 window.parent.postMessage("fail-" + msg, window.location.origin); 32 }