diff options
author | Richard Gibson <richard.gibson@gmail.com> | 2013-10-28 17:40:13 -0400 |
---|---|---|
committer | Richard Gibson <richard.gibson@gmail.com> | 2013-11-04 09:41:19 -0500 |
commit | 26705c6c5b52d527177de9cbbbc62d93bf7dbafb (patch) | |
tree | c4f5796223f3762836b196cc6c4e2d3dab0dde17 /test | |
parent | d8576139c14fb777c24867d7f72d70d7334aabd1 (diff) | |
download | jquery-26705c6c5b52d527177de9cbbbc62d93bf7dbafb.tar.gz jquery-26705c6c5b52d527177de9cbbbc62d93bf7dbafb.zip |
Fix #14379: AJAX requests on unload
(cherry picked from commit f9d41ac641dcb5a93ba8a9027476b160d8f41111)
Conflicts:
src/ajax/xhr.js
Diffstat (limited to 'test')
-rw-r--r-- | test/data/ajax/onunload.html | 30 | ||||
-rw-r--r-- | test/unit/ajax.js | 5 |
2 files changed, 35 insertions, 0 deletions
diff --git a/test/data/ajax/onunload.html b/test/data/ajax/onunload.html new file mode 100644 index 000000000..2c629f67d --- /dev/null +++ b/test/data/ajax/onunload.html @@ -0,0 +1,30 @@ +<!doctype html> +<html> +<head> + <meta http-equiv="Content-type" content="text/html; charset=utf-8"/> + <title>onunload ajax requests (#14379)</title> + <script src="../../jquery.js"></script> +</head> +<body> + <form id="navigate" action="about:blank"></form> + <script> + jQuery( window ).on( "unload", function() { + var ajaxStatus; + jQuery.ajax({ + url: "../name.html", + async: false, + complete: function( xhr, status ) { + ajaxStatus = status; + } + }); + parent.iframeCallback( ajaxStatus ); + }); + + jQuery(function() { + setTimeout(function() { + document.getElementById( "navigate" ).submit(); + }, 0 ); + }); + </script> +</body> +</html> diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 22fed363c..fee2d8a04 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -1565,6 +1565,11 @@ module( "ajax", { } } ); + testIframeWithCallback( "#14379 - jQuery.ajax() on unload", "ajax/onunload.html", function( status ) { + expect( 1 ); + strictEqual( status, "success", "Request completed" ); + }); + //----------- jQuery.ajaxPrefilter() ajaxTest( "jQuery.ajaxPrefilter() - abort", 1, { |