]> source.dussan.org Git - jquery.git/commitdiff
Tests: Don't test synchronous XHR on unload in Chrome
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>
Mon, 28 Oct 2019 19:27:49 +0000 (20:27 +0100)
committerMichał Gołębiowski-Owczarek <m.goleb@gmail.com>
Mon, 28 Oct 2019 19:43:16 +0000 (20:43 +0100)
Chrome 78 dropped support for synchronous XHR requests inside of
beforeunload, unload, pagehide, and visibilitychange event handlers.
See https://bugs.chromium.org/p/chromium/issues/detail?id=952452

Closes gh-4536

(cherry picked from commit c5b48c8caa58e7b73164ac033bf726a072903708)

test/unit/ajax.js

index 23fb0b47359856b7d4b439be461384a326e2e215..a2cc34e3277bc8de309021dd96d6cfc74e70b95c 100644 (file)
@@ -2085,14 +2085,19 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
                };
        } );
 
-       testIframe(
-               "#14379 - jQuery.ajax() on unload",
-               "ajax/onunload.html",
-               function( assert, jQuery, window, document, status ) {
-                       assert.expect( 1 );
-                       assert.strictEqual( status, "success", "Request completed" );
-               }
-       );
+       // Chrome 78 dropped support for synchronous XHR requests inside of
+       // beforeunload, unload, pagehide, and visibilitychange event handlers.
+       // See https://bugs.chromium.org/p/chromium/issues/detail?id=952452
+       if ( !/chrome/i.test( navigator.userAgent ) ) {
+               testIframe(
+                       "#14379 - jQuery.ajax() on unload",
+                       "ajax/onunload.html",
+                       function( assert, jQuery, window, document, status ) {
+                               assert.expect( 1 );
+                               assert.strictEqual( status, "success", "Request completed" );
+                       }
+               );
+       }
 
        ajaxTest( "#14683 - jQuery.ajax() - Exceptions thrown synchronously by xhr.send should be caught", 4, function( assert ) {
                return [ {