]> source.dussan.org Git - jquery.git/commitdiff
Core: Add test for jQuery.ready.promise fallback load
authorMichał Gołębiowski <m.goleb@gmail.com>
Thu, 13 Mar 2014 01:18:29 +0000 (02:18 +0100)
committerMichał Gołębiowski <m.goleb@gmail.com>
Thu, 13 Mar 2014 01:18:29 +0000 (02:18 +0100)
Fix #13655
Close gh-1209
Ref 32b066d3805a48f8c8312562ed52a1b5910b1d85

test/data/core/dont_return.php [new file with mode: 0644]
test/data/core/dynamic_ready.html [new file with mode: 0644]
test/unit/core.js

diff --git a/test/data/core/dont_return.php b/test/data/core/dont_return.php
new file mode 100644 (file)
index 0000000..3ac56e1
--- /dev/null
@@ -0,0 +1,3 @@
+<?php
+sleep(10000);
+?>
diff --git a/test/data/core/dynamic_ready.html b/test/data/core/dynamic_ready.html
new file mode 100644 (file)
index 0000000..799145b
--- /dev/null
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+       <meta charset="utf-8">
+       <script src="../../jquery.js"></script>
+       <script>var $j = jQuery.noConflict();</script>
+</head>
+<body>
+<iframe id="dont_return" src="dont_return.php"></iframe>
+<script>
+       var timeoutId, $,
+               timeoutFired = false;
+
+       setTimeout(function () {
+               // Load another jQuery copy using the first one.
+               $j.getScript( "../../../dist/jquery.js", function () {
+                       $j( "#dont_return" ).attr( "src", "about:blank" );
+
+                       // document ready handled by the just-loaded jQuery copy.
+                       $(function () {
+                               clearTimeout( timeoutId );
+                               if ( !timeoutFired ) {
+                                       window.parent.iframeCallback( true );
+                               }
+                       });
+               });
+
+               timeoutId = setTimeout(function () {
+                       timeoutFired = true;
+                       window.parent.iframeCallback( false );
+               }, 3000);
+       });
+</script>
+</body>
+</html>
index c59acb84cd554945e62a5d8028d78810f7b00516..d95767586257e0c555f549c4a37e2e56e90701ac 100644 (file)
@@ -1486,6 +1486,11 @@ testIframeWithCallback( "Conditional compilation compatibility (#13274)", "core/
        ok( $(), "jQuery executes" );
 });
 
+testIframeWithCallback( "document ready when jQuery loaded asynchronously (#13655)", "core/dynamic_ready.html", function( ready ) {
+       expect( 1 );
+       equal( true, ready, "document ready correctly fired when jQuery is loaded after DOMContentLoaded" );
+});
+
 testIframeWithCallback( "Tolerating alias-masked DOM properties (#14074)", "core/aliased.html",
        function( errors ) {
                        expect( 1 );