From d99268a4b728e47d02b9b893e08796c8060a68e9 Mon Sep 17 00:00:00 2001 From: jrburke Date: Sat, 12 Feb 2011 03:42:35 +0100 Subject: [PATCH] Add readyWait tests. Fixes #8145. Adds tests for the fix to #6781. --- test/data/readywaitasset.js | 1 + test/data/readywaitloader.js | 25 +++++++++++ test/readywait.html | 85 ++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 test/data/readywaitasset.js create mode 100644 test/data/readywaitloader.js create mode 100644 test/readywait.html 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 ); diff --git a/test/readywait.html b/test/readywait.html new file mode 100644 index 000000000..8e0d3d534 --- /dev/null +++ b/test/readywait.html @@ -0,0 +1,85 @@ + + + + + + jQuery.readyWait Test + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ jQuery.readyWait Test +

+

+ This is a test page for jQuery.readyWait, that was + added due to this ticket + #6781. +

+

+ 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. +

+

+ Expected Result: The text + It Worked! + appears below after about 2 seconds. +

+

+ If there is an error in the console, + or the text does not show up, then the test failed. +

+
+ + -- 2.39.5