mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
Focus on the body before running focus test
(cherry picked from commit b2f27632eb
)
Conflicts:
test/unit/event.js
This commit is contained in:
parent
f519539d3b
commit
0a62e22579
@ -2567,35 +2567,34 @@ test( "make sure events cloned correctly", 18, function() {
|
|||||||
clone.find("#check1").trigger("change"); // 0 events should fire
|
clone.find("#check1").trigger("change"); // 0 events should fire
|
||||||
});
|
});
|
||||||
|
|
||||||
// This test fails in some browsers if document does not have focus
|
test( "Check order of focusin/focusout events", 2, function() {
|
||||||
if ( !document.hasFocus || document.hasFocus && document.hasFocus() ) {
|
var focus, blur,
|
||||||
test( "Check order of focusin/focusout events", 2, function() {
|
input = jQuery( "#name" );
|
||||||
var focus, blur,
|
|
||||||
input = jQuery( "#name" );
|
|
||||||
|
|
||||||
input.on( "focus", function() {
|
document.body.focus();
|
||||||
focus = true;
|
|
||||||
|
|
||||||
}).on( "focusin", function() {
|
input.on( "focus", function() {
|
||||||
ok( !focus, "Focusin event should fire before focus does" );
|
focus = true;
|
||||||
|
|
||||||
}).on( "blur", function() {
|
}).on( "focusin", function() {
|
||||||
blur = true;
|
ok( !focus, "Focusin event should fire before focus does" );
|
||||||
|
|
||||||
}).on( "focusout", function() {
|
}).on( "blur", function() {
|
||||||
ok( !blur, "Focusout event should fire before blur does" );
|
blur = true;
|
||||||
});
|
|
||||||
|
|
||||||
// gain focus
|
}).on( "focusout", function() {
|
||||||
input.trigger( "focus" );
|
ok( !blur, "Focusout event should fire before blur does" );
|
||||||
|
|
||||||
// then lose it
|
|
||||||
jQuery( "#search" ).trigger( "focus" );
|
|
||||||
|
|
||||||
// cleanup
|
|
||||||
input.off();
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
// gain focus
|
||||||
|
input.trigger( "focus" );
|
||||||
|
|
||||||
|
// then lose it
|
||||||
|
jQuery( "#search" ).trigger( "focus" );
|
||||||
|
|
||||||
|
// cleanup
|
||||||
|
input.off();
|
||||||
|
});
|
||||||
|
|
||||||
test( "String.prototype.namespace does not cause trigger() to throw (#13360)", function() {
|
test( "String.prototype.namespace does not cause trigger() to throw (#13360)", function() {
|
||||||
expect( 1 );
|
expect( 1 );
|
||||||
|
Loading…
Reference in New Issue
Block a user