Attempt to fix bug 681138 by making the test loading not race against snapshotting and focusing the iframe

This commit is contained in:
Ehsan Akhgari 2013-03-05 09:32:51 -05:00
parent baf4a980ad
commit db9b3860a7

View File

@ -47,15 +47,19 @@ function doSnapShot(iframe) {
callbackTestCanvas(iframe);
};
function remotePageLoaded() {
function remotePageLoaded(callback) {
var iframe = this;
setTimeout(function(){doSnapShot(iframe);}, 0)
setTimeout(function(){
doSnapShot(iframe);
callback();
}, 0);
};
const MAX_ITERATIONS = 1000;
function createIframe(url,next) {
var iframe = document.createElement("iframe");
iframe.focus();
iframe.src = url;
iframe.remotePageLoaded = remotePageLoaded;
var me = this;
@ -71,8 +75,11 @@ function createIframe(url,next) {
}
return;
}
iframe.remotePageLoaded();
if (next) setTimeout(function(){createIframe(next,null);}, 0)
iframe.remotePageLoaded(function() {
if (next) {
setTimeout(function(){createIframe(next,null);}, 0)
}
});
}
iframe.addEventListener("load", iframeLoadCompleted, false);
window.document.body.appendChild(iframe);