Tests: Cleanup window & document handlers in a new event test

The "focusin on document & window" test didn't cleanup `focusout` handlers
on `window` & `document`. This has been fixed.

Ref gh-4657
This commit is contained in:
Michał Gołębiowski-Owczarek 2020-04-27 21:37:06 +02:00 committed by Michał Gołębiowski-Owczarek
parent 46ba70c5e8
commit c1c0598d8f

View File

@ -2600,16 +2600,16 @@ QUnit.test( "focusin on document & window", function( assert ) {
var counter = 0, var counter = 0,
input = jQuery( "<input />" ); input = jQuery( "<input />" );
function increment() {
counter++;
}
input.appendTo( "#qunit-fixture" ); input.appendTo( "#qunit-fixture" );
input[ 0 ].focus(); input[ 0 ].focus();
jQuery( window ).on( "focusout", function() { jQuery( window ).on( "focusout", increment );
counter++; jQuery( document ).on( "focusout", increment );
} );
jQuery( document ).on( "focusout", function() {
counter++;
} );
input[ 0 ].blur(); input[ 0 ].blur();
@ -2620,6 +2620,9 @@ QUnit.test( "focusin on document & window", function( assert ) {
assert.strictEqual( counter, 2, assert.strictEqual( counter, 2,
"focusout handlers on document/window fired once only" ); "focusout handlers on document/window fired once only" );
jQuery( window ).off( "focusout", increment );
jQuery( document ).off( "focusout", increment );
} ); } );
testIframe( testIframe(