diff options
author | Michał Gołębiowski <m.goleb@gmail.com> | 2013-03-24 04:01:50 +0100 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2013-04-04 13:32:25 -0400 |
commit | 32b066d3805a48f8c8312562ed52a1b5910b1d85 (patch) | |
tree | 292ebd19a647e9b76079bb140613dfba826c5708 | |
parent | 7049877530882c2f8ee09f71f7fc736ca9570736 (diff) | |
download | jquery-32b066d3805a48f8c8312562ed52a1b5910b1d85.tar.gz jquery-32b066d3805a48f8c8312562ed52a1b5910b1d85.zip |
Fix #13655. Add test for jQuery.ready.promise fallback load. Close gh-1209.
-rw-r--r-- | test/data/core/dont_return.php | 3 | ||||
-rw-r--r-- | test/data/core/dynamic_ready.html | 35 | ||||
-rw-r--r-- | test/unit/core.js | 5 |
3 files changed, 43 insertions, 0 deletions
diff --git a/test/data/core/dont_return.php b/test/data/core/dont_return.php new file mode 100644 index 000000000..3ac56e1ef --- /dev/null +++ b/test/data/core/dont_return.php @@ -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 index 000000000..799145b98 --- /dev/null +++ b/test/data/core/dynamic_ready.html @@ -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> diff --git a/test/unit/core.js b/test/unit/core.js index 6cdd3b93d..b54438753 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -24,6 +24,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" ); +}); + test("jQuery()", function() { var elem, i, |