Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6f2fae7

Browse files
committed
Tests: Fix the new focusin/focusout test in IE
In IE, focus & blur events fire asynchronously, the test now accounts for that.Refgh-4362
1 parent8a74137 commit6f2fae7

File tree

1 file changed

+59
-44
lines changed

1 file changed

+59
-44
lines changed

‎test/unit/event.js

Lines changed: 59 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2952,59 +2952,74 @@ QUnit.test( "focusout/focusin support", function( assert ) {
29522952
varfocus,
29532953
parent=jQuery("<div>"),
29542954
input=jQuery("<input>"),
2955-
inputExternal=jQuery("<input>");
2955+
inputExternal=jQuery("<input>"),
2956+
2957+
// Support: IE <=9 - 11+
2958+
// focus and blur events are asynchronous; this is the resulting mess.
2959+
// The browser window must be topmost for this to work properly!!
2960+
done=assert.async();
29562961

29572962
parent.append(input);
29582963
jQuery("#qunit-fixture").append(parent).append(inputExternal);
29592964

2960-
parent
2961-
.on("focus",function(){
2962-
assert.ok(false,"parent: focus not fired");
2963-
})
2964-
.on("focusin",function(){
2965-
assert.ok(true,"parent: focusin fired");
2966-
})
2967-
.on("blur",function(){
2968-
assert.ok(false,"parent: blur not fired");
2969-
})
2970-
.on("focusout",function(){
2971-
assert.ok(true,"parent: focusout fired");
2972-
});
2965+
// initially, lose focus
2966+
inputExternal[0].focus();
29732967

2974-
input
2975-
.on("focus",function(){
2976-
assert.ok(true,"element:focus fired");
2977-
focus=true;
2978-
})
2979-
.on("focusin",function(){
2980-
assert.ok(true,"element: focusin fired");
2981-
})
2982-
.on("blur",function(){
2983-
assert.ok(true,"parent: blur fired");
2984-
})
2985-
.on("focusout",function(){
2986-
assert.ok(true,"element: focusout fired");
2987-
});
2968+
setTimeout(function(){
2969+
parent
2970+
.on("focus",function(){
2971+
assert.ok(false,"parent:focusnot fired");
2972+
})
2973+
.on("focusin",function(){
2974+
assert.ok(true,"parent: focusin fired");
2975+
})
2976+
.on("blur",function(){
2977+
assert.ok(false,"parent: blur not fired");
2978+
})
2979+
.on("focusout",function(){
2980+
assert.ok(true,"parent: focusout fired");
2981+
});
29882982

2989-
// gain focus
2990-
input.trigger("focus");
2983+
input
2984+
.on("focus",function(){
2985+
assert.ok(true,"element: focus fired");
2986+
})
2987+
.on("focusin",function(){
2988+
assert.ok(true,"element: focusin fired");
2989+
focus=true;
2990+
})
2991+
.on("blur",function(){
2992+
assert.ok(true,"parent: blur fired");
2993+
})
2994+
.on("focusout",function(){
2995+
assert.ok(true,"element: focusout fired");
2996+
});
29912997

2992-
//then lose it
2993-
inputExternal.trigger("focus");
2998+
//gain focus
2999+
input[0].focus();
29943000

2995-
// cleanup
2996-
parent.off();
2997-
input.off();
3001+
// then lose it
3002+
inputExternal[0].focus();
29983003

2999-
// DOM focus is unreliable in TestSwarm
3000-
if(QUnit.isSwarm&&!focus){
3001-
assert.ok(true,"GAP: Could not observe focus change");
3002-
assert.ok(true,"GAP: Could not observe focus change");
3003-
assert.ok(true,"GAP: Could not observe focus change");
3004-
assert.ok(true,"GAP: Could not observe focus change");
3005-
assert.ok(true,"GAP: Could not observe focus change");
3006-
assert.ok(true,"GAP: Could not observe focus change");
3007-
}
3004+
setTimeout(function(){
3005+
3006+
// DOM focus is unreliable in TestSwarm
3007+
if(QUnit.isSwarm&&!focus){
3008+
assert.ok(true,"GAP: Could not observe focus change");
3009+
assert.ok(true,"GAP: Could not observe focus change");
3010+
assert.ok(true,"GAP: Could not observe focus change");
3011+
assert.ok(true,"GAP: Could not observe focus change");
3012+
assert.ok(true,"GAP: Could not observe focus change");
3013+
assert.ok(true,"GAP: Could not observe focus change");
3014+
}
3015+
3016+
// cleanup
3017+
parent.off();
3018+
input.off();
3019+
3020+
done();
3021+
},50);
3022+
},50);
30083023
});
30093024

30103025
QUnit.test("focus-blur order (#12868)",function(assert){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp