qunit-harness
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -461,5 +461,8 @@ // This file was generated by modules-webmake (modules for web) project. | ||
return new Promise(function (resolve, reject) { | ||
var timeoutId = null; | ||
var intervalId = null; | ||
var timeoutId = null; | ||
var isIframeLoaded = false; | ||
if (!iframe || !iframe.tagName || iframe.tagName.toLowerCase() !== 'iframe') | ||
throw 'Incorrect waitForIframe argument'; | ||
timeoutId = window.setTimeout(function () { | ||
@@ -471,12 +474,21 @@ window.clearTimeout(timeoutId); | ||
intervalId = window.setInterval(function () { | ||
if (iframe && iframe.contentWindow) { | ||
window.clearInterval(intervalId); | ||
try { | ||
isIframeLoaded = iframe.contentWindow && iframe.contentWindow.document && | ||
iframe.contentWindow.document.readyState === 'complete'; | ||
} | ||
catch (e) { | ||
//NOTE: if cross-domain iframe raises an error we take it as loaded | ||
isIframeLoaded = true | ||
} | ||
iframe.contentWindow.addEventListener('load', function () { | ||
window.clearTimeout(timeoutId); | ||
resolve(); | ||
}); | ||
} | ||
}, CHECK_PREDICATE_INTERVAL); | ||
if (isIframeLoaded) { | ||
window.clearTimeout(timeoutId); | ||
resolve(); | ||
return; | ||
} | ||
iframe.addEventListener('load', function () { | ||
window.clearTimeout(timeoutId); | ||
resolve(); | ||
}); | ||
}); | ||
@@ -483,0 +495,0 @@ } |
{ | ||
"name": "qunit-harness", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "A library for running qunit tests on a local machine and in the SauceLabs environment.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/AlexanderMoskovkin/qunit-harness", |
463817
24
13044