diff options
author | jrburke <jrburke@gmail.com> | 2011-02-12 03:42:35 +0100 |
---|---|---|
committer | Anton M <obhvsbypqghgc@gmail.com> | 2011-02-12 13:53:05 +0100 |
commit | d99268a4b728e47d02b9b893e08796c8060a68e9 (patch) | |
tree | d8ba4759a1a31ec3b78ba3b929512807fa4e5ba7 /test/data | |
parent | 2862f589db08b92c7b1f78fa961aff7354027c0b (diff) | |
download | jquery-d99268a4b728e47d02b9b893e08796c8060a68e9.tar.gz jquery-d99268a4b728e47d02b9b893e08796c8060a68e9.zip |
Add readyWait tests. Fixes #8145.
Adds tests for the fix to #6781.
Diffstat (limited to 'test/data')
-rw-r--r-- | test/data/readywaitasset.js | 1 | ||||
-rw-r--r-- | test/data/readywaitloader.js | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/test/data/readywaitasset.js b/test/data/readywaitasset.js new file mode 100644 index 000000000..2308965ce --- /dev/null +++ b/test/data/readywaitasset.js @@ -0,0 +1 @@ +var delayedMessage = "It worked!"; diff --git a/test/data/readywaitloader.js b/test/data/readywaitloader.js new file mode 100644 index 000000000..483e07c4d --- /dev/null +++ b/test/data/readywaitloader.js @@ -0,0 +1,25 @@ +// Simple script loader that uses jQuery.readyWait + +//Hold on jQuery! +jQuery.readyWait++; + +var readyRegExp = /^(complete|loaded)$/; + +function assetLoaded( evt ){ + var node = evt.currentTarget || evt.srcElement; + if ( evt.type === "load" || readyRegExp.test(node.readyState) ) { + jQuery.ready(true); + } +} + +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"; + document.getElementsByTagName("head")[0].appendChild(script); +}, 2000 ); |