Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/data/event/focusElem.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<body>
<a href="#" id="frame-link"></a>
<script>
jQuery("#frame-link").focus();
jQuery( "#frame-link" ).trigger( "focus" );
window.parent.iframeCallback( true );
</script>
</body>
Expand Down
85 changes: 41 additions & 44 deletions test/unit/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -900,49 +900,6 @@ QUnit.test( "mouseenter, mouseleave don't catch exceptions", function( assert )
}
} );

if ( jQuery.fn.click ) {

QUnit.test( "trigger() shortcuts", function( assert ) {
assert.expect( 5 );

var counter, clickCounter,
elem = jQuery( "<li><a href='#'>Change location</a></li>" ).prependTo( "#firstUL" );
elem.find( "a" ).on( "click", function() {
var close = jQuery( "spanx", this ); // same with jQuery(this).find("span");
assert.equal( close.length, 0, "Context element does not exist, length must be zero" );
assert.ok( !close[ 0 ], "Context element does not exist, direct access to element must return undefined" );
return false;
} ).click();

// manually clean up detached elements
elem.remove();

jQuery( "#check1" ).click( function() {
assert.ok( true, "click event handler for checkbox gets fired twice, see #815" );
} ).click();

counter = 0;
jQuery( "#firstp" )[ 0 ].onclick = function() {
counter++;
};
jQuery( "#firstp" ).click();
assert.equal( counter, 1, "Check that click, triggers onclick event handler also" );

clickCounter = 0;
jQuery( "#simon1" )[ 0 ].onclick = function() {
clickCounter++;
};
jQuery( "#simon1" ).click();
assert.equal( clickCounter, 1, "Check that click, triggers onclick event handler on an a tag also" );

// test that special handlers do not blow up with VML elements (#7071)
jQuery( "<xml:namespace ns='urn:schemas-microsoft-com:vml' prefix='v' />" ).appendTo( "head" );
jQuery( "<v:oval id='oval' style='width:100pt;height:75pt;' fillcolor='red'> </v:oval>" ).appendTo( "#form" );
jQuery( "#oval" ).click().keydown();
} );

}

QUnit.test( "trigger() bubbling", function( assert ) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just moved this down and made it a QUnit.skip test.

assert.expect( 18 );

Expand Down Expand Up @@ -2778,7 +2735,7 @@ QUnit.test( "preventDefault() on focusin does not throw exception", function( as
"Preventing default on focusin throws no exception" );

done();
} ).focus();
} ).trigger( "focus" );
} );

QUnit.test( "Donor event interference", function( assert ) {
Expand Down Expand Up @@ -2843,6 +2800,46 @@ QUnit.test( "originalEvent property for Chrome, Safari, Fx & Edge of simulated e
jQuery( "#donor-input" ).trigger( "focus" );
} );


QUnit[ jQuery.fn.click ? "test" : "skip" ]( "trigger() shortcuts", function( assert ) {
assert.expect( 5 );

var counter, clickCounter,
elem = jQuery( "<li><a href='#'>Change location</a></li>" ).prependTo( "#firstUL" );
elem.find( "a" ).on( "click", function() {
var close = jQuery( "spanx", this ); // same with jQuery(this).find("span");
assert.equal( close.length, 0, "Context element does not exist, length must be zero" );
assert.ok( !close[ 0 ], "Context element does not exist, direct access to element must return undefined" );
return false;
} ).click();

// manually clean up detached elements
elem.remove();

jQuery( "#check1" ).click( function() {
assert.ok( true, "click event handler for checkbox gets fired twice, see #815" );
} ).click();

counter = 0;
jQuery( "#firstp" )[ 0 ].onclick = function() {
counter++;
};
jQuery( "#firstp" ).click();
assert.equal( counter, 1, "Check that click, triggers onclick event handler also" );

clickCounter = 0;
jQuery( "#simon1" )[ 0 ].onclick = function() {
clickCounter++;
};
jQuery( "#simon1" ).click();
assert.equal( clickCounter, 1, "Check that click, triggers onclick event handler on an a tag also" );

// test that special handlers do not blow up with VML elements (#7071)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look like it belongs on an event alias unit test. It also is appending to head and not removing the markup. Do we need this test at all now? @timmywil do you remember anything about 69866fd ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't recall the specifics, but it looks like we had that xml in the index.html to start. That said, I think it's safe to remove at the end of the test. Regardless, I agree that it should be moved to non-alias tests.

jQuery( "<xml:namespace ns='urn:schemas-microsoft-com:vml' prefix='v' />" ).appendTo( "head" );
jQuery( "<v:oval id='oval' style='width:100pt;height:75pt;' fillcolor='red'> </v:oval>" ).appendTo( "#form" );
jQuery( "#oval" ).click().keydown();
} );

QUnit[ jQuery.fn.click ? "test" : "skip" ]( "Event aliases", function( assert ) {

// Explicitly skipping focus/blur events due to their flakiness
Expand Down