Permalink
Browse files

Tests: move readywait to an iframe test

Close gh-3576
Fixes gh-3573
  • Loading branch information...
stevemao authored and timmywil committed Sep 25, 2016
1 parent d33bb9c commit fcc9a9ec9685e25864ca793698e4ac5e60226272
Showing with 37 additions and 44 deletions.
  1. +7 −7 src/deprecated.js
  2. +17 −11 test/{ → data}/readywait.html
  3. +0 −1 test/data/readywaitasset.js
  4. +0 −25 test/data/readywaitloader.js
  5. +13 −0 test/unit/ready.js
View
@@ -23,16 +23,16 @@ jQuery.fn.extend( {
return arguments.length === 1 ?
this.off( selector, "**" ) :
this.off( types, selector || "**", fn );
},
holdReady: function( hold ) {
if ( hold ) {
jQuery.readyWait++;
} else {
jQuery.ready( true );
}
}
} );
jQuery.holdReady = function( hold ) {
if ( hold ) {
jQuery.readyWait++;
} else {
jQuery.ready( true );
}
};
jQuery.isArray = Array.isArray;
jQuery.parseJSON = JSON.parse;
jQuery.nodeName = nodeName;
@@ -14,22 +14,28 @@
#output { background-color: green }
#expectedOutput { background-color: green }
</style>
<script src="jquery.js"></script>
<script src="../jquery.js"></script>
<script src="./iframeTest.js"></script>
<!-- Load the script loader that uses
jQuery.readyWait -->
<script src="data/readywaitloader.js"></script>
<script type="text/javascript">
jQuery(function() {
// The delayedMessage is defined by
// the readywaitasset.js file, so the
// next line will only work if this DOM
// ready callback is called after readyWait
// has been decremented by readywaitloader.js
// If an error occurs.
jQuery("#output").append(delayedMessage);
});
(function() {
var released = false;
// Hold on jQuery!
jQuery.holdReady( true );
setTimeout( function() {
released = true;
jQuery.holdReady( false );
}, 300 );
jQuery(function() {
jQuery( "#output" ).text( "Ready called, holdReady released: " + released );
startIframeTest( released );
});
})();
</script>
</head>
<body>

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
View
@@ -4,6 +4,7 @@ QUnit.module( "ready" );
var notYetReady, noEarlyExecution,
whenified = jQuery.when( jQuery.ready ),
promisified = Promise.resolve( jQuery.ready ),
start = new Date(),
order = [],
args = {};
@@ -147,4 +148,16 @@ QUnit.module( "ready" );
done();
} );
} );
testIframe(
"holdReady test needs to be a standalone test since it deals with DOM ready",
"readywait.html",
function( assert, jQuery, window, document, releaseCalled ) {
assert.expect( 2 );
var now = new Date();
assert.ok( now - start >= 300, "Needs to have waited at least half a second" );
assert.ok( releaseCalled, "The release function was called, which resulted in ready" );
}
);
} )();

0 comments on commit fcc9a9e

Please sign in to comment.