mirror of
https://github.com/jquery/jquery.git
synced 2026-02-02 01:25:10 -05:00
Fix #14180. Allow cross-frame use of focusin/out. Close gh-1369.
(cherry picked from commit 6d5dfa0eda2c19e8838930fafff83b596654eca2) Manually edited for conflicts.
This commit is contained in:
18
test/data/event/focusinCrossFrame.html
Normal file
18
test/data/event/focusinCrossFrame.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||
<title>focusin event cross-frame (#14180)</title>
|
||||
|
||||
<script src="../../jquery.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<input type="text" id="frame-input" />
|
||||
<script>
|
||||
// Call parent when this frame is fully loaded, it will mess with #frame-input
|
||||
jQuery( window ).one( "load", function() {
|
||||
window.parent.iframeCallback( document );
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -2507,6 +2507,33 @@ test("fixHooks extensions", function() {
|
||||
jQuery.event.fixHooks.click = saved;
|
||||
});
|
||||
|
||||
testIframeWithCallback( "focusin from an iframe", "event/focusinCrossFrame.html", function( frameDoc ) {
|
||||
expect(1);
|
||||
|
||||
var input = jQuery( frameDoc ).find( "#frame-input" );
|
||||
|
||||
// Create a focusin handler on the parent; shouldn't affect the iframe's fate
|
||||
jQuery ( "body" ).on( "focusin.iframeTest", function() {
|
||||
ok( false, "fired a focusin event in the parent document" );
|
||||
});
|
||||
|
||||
input.on( "focusin", function() {
|
||||
ok( true, "fired a focusin event in the iframe" );
|
||||
});
|
||||
|
||||
// Avoid a native event; Chrome can't force focus to another frame
|
||||
input.trigger( "focusin" );
|
||||
|
||||
// Must manually remove handler to avoid leaks in our data store
|
||||
input.remove();
|
||||
|
||||
// Be sure it was removed; nothing should happen
|
||||
input.trigger( "focusin" );
|
||||
|
||||
// Remove body handler manually since it's outside the fixture
|
||||
jQuery( "body" ).off( "focusin.iframeTest" );
|
||||
});
|
||||
|
||||
testIframeWithCallback( "jQuery.ready promise", "event/promiseReady.html", function( isOk ) {
|
||||
expect(1);
|
||||
ok( isOk, "$.when( $.ready ) works" );
|
||||
|
||||
Reference in New Issue
Block a user