Bug 1129091 - Wait for the iframes to load before running test functions that use them. r?jgraham
MozReview-Commit-ID: Di6pxnrZxcZ
--- a/testing/web-platform/tests/old-tests/submission/Microsoft/history/history_000.htm
+++ b/testing/web-platform/tests/old-tests/submission/Microsoft/history/history_000.htm
@@ -317,13 +317,30 @@
}
}
function queue(func) {
//50 allows adequate time for .back and .forward navigations to queue first
setTimeout(func, 50);
}
add_result_callback(testFinished);
- //start the first test manually
- queue(testCollection[testIndex]);
+
+ function startTestsWhenIframesLoaded() {
+ if (testframe1.contentWindow.document.readyState != 'complete' ||
+ testframe2.contentWindow.document.readyState != 'complete') {
+ return;
+ }
+ testframe1.removeEventListener('load', startTestsWhenIframesLoaded, false);
+ testframe2.removeEventListener('load', startTestsWhenIframesLoaded, false);
+
+ //start the first test
+ queue(testCollection[testIndex]);
+ }
+
+ // add listeners to trigger the tests once the iframes are loaded,
+ // but also try to start it right away in case the load events have
+ // already fired and we missed them.
+ testframe1.addEventListener('load', startTestsWhenIframesLoaded, false);
+ testframe2.addEventListener('load', startTestsWhenIframesLoaded, false);
+ startTestsWhenIframesLoaded();
</script>
</body>
</html>