mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-05-18 19:41:06 +00:00
corrections in suite timeout code with a clearTimer addition
This commit is contained in:
parent
32f5b226d7
commit
b016b028f6
2 changed files with 23 additions and 10 deletions
|
|
@ -10,7 +10,9 @@
|
|||
<ol id="qunit-tests">
|
||||
</ol>
|
||||
</div>
|
||||
<iframe data-src="../../tests/unit/{{testdir}}" name="testFrame" id="testFrame" width="800px" height="100%" style="float: left; border: 0px;" scrolling="no">
|
||||
<!-- under normal circumstances inline styles would be a poor choice, but in this case
|
||||
I think an entire link and stylesheet is a waste -->
|
||||
<iframe data-src="../../tests/unit/{{testdir}}" name="testFrame" id="testFrame" width="800px" height="100%" style="float: left; border: 0px; height: 100%;" scrolling="no">
|
||||
</iframe>
|
||||
<link rel="stylesheet" href="../../external/qunit.css"></link>
|
||||
<script src="../../js/jquery.js"></script>
|
||||
|
|
|
|||
|
|
@ -7,22 +7,30 @@
|
|||
|
||||
$.each(testDirectories, function(i, dir){
|
||||
asyncTest( dir, function(){
|
||||
// give each test a maximum of two minutes to finish
|
||||
var nextCheck = null;
|
||||
|
||||
// establish a timeout for a given suite in case of async tests hanging
|
||||
var testTimeout = setTimeout( function(){
|
||||
// prevent any schedule checks for completion
|
||||
clearTimeout(nextCheck);
|
||||
start();
|
||||
}, 2 * 60 * 1000 );
|
||||
}, 2 * 60 * 1000 ),
|
||||
|
||||
expect( 1 );
|
||||
updateFrame( dir );
|
||||
// setup the next state check and record the timer id for removal
|
||||
scheduleCheck = function(){
|
||||
nextCheck = setTimeout( check, 2000 );
|
||||
},
|
||||
|
||||
// check the iframe for success or failure and respond accordingly
|
||||
check = function(){
|
||||
|
||||
function check(){
|
||||
// check for the frames jquery object each time
|
||||
var framejQuery = window.frames["testFrame"].jQuery;
|
||||
|
||||
// if the iframe hasn't loaded (ie loaded jQuery) check back again shortly
|
||||
if( !framejQuery ){
|
||||
scheduleCheck();
|
||||
return;
|
||||
setTimeout( arguments.callee, 2000 );
|
||||
}
|
||||
|
||||
// grab the result of the iframe test suite
|
||||
|
|
@ -34,11 +42,14 @@
|
|||
clearTimeout(testTimeout);
|
||||
start();
|
||||
} else {
|
||||
setTimeout( arguments.callee, 2000 );
|
||||
scheduleCheck();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
setTimeout( check, 2000 );
|
||||
|
||||
expect( 1 );
|
||||
updateFrame( dir );
|
||||
scheduleCheck();
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
|
|
|||
Loading…
Reference in a new issue