aboutsummaryrefslogtreecommitdiffstats
path: root/test/data
diff options
context:
space:
mode:
authorSteve Mao <maochenyan@gmail.com>2016-09-25 14:12:20 +1000
committerTimmy Willison <4timmywil@gmail.com>2017-03-20 11:37:15 -0400
commitfcc9a9ec9685e25864ca793698e4ac5e60226272 (patch)
tree99ea209438834538b9da56894356dd1e2a4bc314 /test/data
parentd33bb9c33ac84a1d1aa1aa8805b667efca2e51d6 (diff)
downloadjquery-fcc9a9ec9685e25864ca793698e4ac5e60226272.tar.gz
jquery-fcc9a9ec9685e25864ca793698e4ac5e60226272.zip
Tests: move readywait to an iframe test
Close gh-3576 Fixes gh-3573
Diffstat (limited to 'test/data')
-rw-r--r--test/data/readywait.html76
-rw-r--r--test/data/readywaitasset.js1
-rw-r--r--test/data/readywaitloader.js25
3 files changed, 76 insertions, 26 deletions
diff --git a/test/data/readywait.html b/test/data/readywait.html
new file mode 100644
index 000000000..d7de0b082
--- /dev/null
+++ b/test/data/readywait.html
@@ -0,0 +1,76 @@
+<!DOCTYPE html>
+<html>
+<!--
+ Test for jQuery.holdReady. Needs to be a
+ standalone test since it deals with DOM
+ ready.
+-->
+<head>
+ <title>
+ jQuery.holdReady Test
+ </title>
+ <style>
+ div { margin-top: 10px; }
+ #output { background-color: green }
+ #expectedOutput { background-color: green }
+ </style>
+ <script src="../jquery.js"></script>
+ <script src="./iframeTest.js"></script>
+
+ <!-- Load the script loader that uses
+ jQuery.readyWait -->
+
+ <script type="text/javascript">
+ (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>
+ <h1>
+ jQuery.holdReady Test
+ </h1>
+ <p>
+ This is a test page for jQuery.readyWait and jQuery.holdReady,
+ see
+ <a href="https://bugs.jquery.com/ticket/6781">#6781</a>
+ and
+ <a href="https://bugs.jquery.com/ticket/8803">#8803</a>.
+ </p>
+ <p>
+ Test for jQuery.holdReady, 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.
+ </p>
+ <p>
+ Script loaders are the most likely kind of script
+ to use jQuery.holdReady, but it could be used by
+ other things like a script that loads a CSS file
+ and wants to pause the DOM ready callbacks.
+ </p>
+ <p>
+ <strong>Expected Result</strong>: The text
+ <span id="expectedOutput">It Worked!</span>
+ appears below after about <strong>2 seconds.</strong>
+ </p>
+ <p>
+ If there is an error in the console,
+ or the text does not show up, then the test failed.
+ </p>
+ <div id="output"></div>
+</body>
+</html>
diff --git a/test/data/readywaitasset.js b/test/data/readywaitasset.js
deleted file mode 100644
index 2308965ce..000000000
--- a/test/data/readywaitasset.js
+++ /dev/null
@@ -1 +0,0 @@
-var delayedMessage = "It worked!";
diff --git a/test/data/readywaitloader.js b/test/data/readywaitloader.js
deleted file mode 100644
index 8f4a3452e..000000000
--- a/test/data/readywaitloader.js
+++ /dev/null
@@ -1,25 +0,0 @@
-// Simple script loader that uses jQuery.readyWait via jQuery.holdReady()
-
-//Hold on jQuery!
-jQuery.holdReady( true );
-
-var readyRegExp = /^(complete|loaded)$/;
-
-function assetLoaded( evt ) {
- var node = evt.currentTarget || evt.srcElement;
- if ( evt.type === "load" || readyRegExp.test( node.readyState ) ) {
- jQuery.holdReady( false );
- }
-}
-
-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 );