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

Commit9b73204

Browse files
authored
Tests: Use only one focusin/out handler per matching window & document
Backport tests from a jQuery 3.x fix that's not needed on `master`.Also, fix the "focusin from an iframe" test to actually verify the behaviorfrom commit1cecf64 - the commit thatintroduced the regression - to make sure we don't regress on either front.The main part of the modified test was checking that focusin handling in aniframe works and that's still checked. The test was also checking that itdoesn't propagate to the parent document, though, and, apparently, in IE itdoes. This one test is now blacklisted in IE.(cherry picked from9e15d6b)(cherry picked from1a4f10d)Refgh-4652Refgh-4656Closesgh-4657
1 parent34296ec commit9b73204

File tree

1 file changed

+54
-9
lines changed

1 file changed

+54
-9
lines changed

‎test/unit/event.js

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2560,31 +2560,76 @@ testIframe(
25602560
function(assert,framejQuery,frameWin,frameDoc){
25612561
assert.expect(1);
25622562

2563-
varinput=jQuery(frameDoc).find("#frame-input");
2563+
vardone=assert.async(),
2564+
focus=false,
2565+
input=jQuery(frameDoc).find("#frame-input");
25642566

25652567
// Create a focusin handler on the parent; shouldn't affect the iframe's fate
25662568
jQuery("body").on("focusin.iframeTest",function(){
2567-
assert.ok(false,"fired a focusin event in the parent document");
2569+
2570+
// Support: IE 9 - 11+
2571+
// IE does propagate the event to the parent document. In this test
2572+
// we mainly care about the inner element so we'll just skip this one
2573+
// assertion in IE.
2574+
if(!document.documentMode){
2575+
assert.ok(false,"fired a focusin event in the parent document");
2576+
}
25682577
});
25692578

25702579
input.on("focusin",function(){
2580+
focus=true;
25712581
assert.ok(true,"fired a focusin event in the iframe");
25722582
});
25732583

25742584
// Avoid a native event; Chrome can't force focus to another frame
2575-
input.trigger("focusin");
2576-
2577-
// Must manually remove handler to avoid leaks in our data store
2578-
input.remove();
2579-
2580-
// Be sure it was removed; nothing should happen
2581-
input.trigger("focusin");
2585+
input[0].focus();
25822586

25832587
// Remove body handler manually since it's outside the fixture
25842588
jQuery("body").off("focusin.iframeTest");
2589+
2590+
setTimeout(function(){
2591+
2592+
// DOM focus is unreliable in TestSwarm
2593+
if(QUnit.isSwarm&&!focus){
2594+
assert.ok(true,"GAP: Could not observe focus change");
2595+
}
2596+
2597+
done();
2598+
},50);
25852599
}
25862600
);
25872601

2602+
QUnit.test("focusin on document & window",function(assert){
2603+
assert.expect(1);
2604+
2605+
varcounter=0,
2606+
input=jQuery("<input />");
2607+
2608+
functionincrement(){
2609+
counter++;
2610+
}
2611+
2612+
input.appendTo("#qunit-fixture");
2613+
2614+
input[0].focus();
2615+
2616+
jQuery(window).on("focusout",increment);
2617+
jQuery(document).on("focusout",increment);
2618+
2619+
input[0].blur();
2620+
2621+
// DOM focus is unreliable in TestSwarm
2622+
if(QUnit.isSwarm&&counter===0){
2623+
assert.ok(true,"GAP: Could not observe focus change");
2624+
}
2625+
2626+
assert.strictEqual(counter,2,
2627+
"focusout handlers on document/window fired once only");
2628+
2629+
jQuery(window).off("focusout",increment);
2630+
jQuery(document).off("focusout",increment);
2631+
});
2632+
25882633
testIframe(
25892634
"jQuery.ready promise",
25902635
"event/promiseReady.html",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp