Skip to content
Browse files
Add readyWait tests. Fixes #8145.
Adds tests for the fix to #6781.
  • Loading branch information
jrburke authored and jitter committed Feb 12, 2011
1 parent 2862f58 commit d99268a
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
@@ -0,0 +1 @@
var delayedMessage = "It worked!";
@@ -0,0 +1,25 @@
// Simple script loader that uses jQuery.readyWait

//Hold on jQuery!

var readyRegExp = /^(complete|loaded)$/;

function assetLoaded( evt ){
var node = evt.currentTarget || evt.srcElement;
if ( evt.type === "load" || readyRegExp.test(node.readyState) ) {

setTimeout( function() {
var script = document.createElement("script");
script.type = "text/javascript";
if ( script.addEventListener ) {
script.addEventListener( "load", assetLoaded, false );
} else {
script.attachEvent( "onreadystatechange", assetLoaded );
script.src = "data/readywaitasset.js";
}, 2000 );
@@ -0,0 +1,85 @@
<!DOCTYPE html>
Test for jQuery.readyWait. Needs to be a
standalone test since it deals with DOM
jQuery.readyWait Test
div { margin-top: 10px; }
#output { background-color: green }
#expectedOutput { background-color: green }
<script src="../src/core.js"></script>
<script src="../src/support.js"></script>
<script src="../src/data.js"></script>
<script src="../src/queue.js"></script>
<script src="../src/attributes.js"></script>
<script src="../src/event.js"></script>
<script src="../src/sizzle/sizzle.js"></script>
<script src="../src/sizzle-jquery.js"></script>
<script src="../src/traversing.js"></script>
<script src="../src/manipulation.js"></script>
<script src="../src/css.js"></script>
<script src="../src/ajax.js"></script>
<script src="../src/ajax/jsonp.js"></script>
<script src="../src/ajax/script.js"></script>
<script src="../src/ajax/xhr.js"></script>
<script src="../src/effects.js"></script>
<script src="../src/offset.js"></script>
<script src="../src/dimensions.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.readyWait Test
This is a test page for jQuery.readyWait, that was
added due to this ticket
<a href="">#6781</a>.
Test for jQuery.readyWait, which can be used
by plugins and other scripts to indicate something
important to the page is still loading and needs
to block the DOM ready callbacks that are registered
with jQuery.
Script loaders are the most likely kind of script
to use jQuery.readyWait, but it could be used by
other things like a script that loads a CSS file
and wants to pause the DOM ready callbacks.
<strong>Expected Result</strong>: The text
<span id="expectedOutput">It Worked!</span>
appears below after about <strong>2 seconds.</strong>
If there is an error in the console,
or the text does not show up, then the test failed.
<div id="output"></div>

0 comments on commit d99268a

Please sign in to comment.