mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-11-24 08:13:38 +00:00
Fix failing focus tests
jQuery 1.9 changes how $.focus() calls are handled: instead of directly calling the handlers, it just invokes the DOM element's focus(), and leaves it to the browser's event handling to trigger them. This can fail for several reasons (e.g. element is not attached to document, element is already focused, browser bugs such as http://bugs.jquery.com/ticket/13363 ), so we are using triggerHandler('focus') instead, which calls the handlers directly without simulating actual browser events. Since these are unit tests verifying event handler attach/unattach behavior, not acceptance tests verifying actual event handling behavior, that should be okay. Change-Id: I65ecda28ace4f380ad33d6212e12069e18001232
This commit is contained in:
parent
4329d453ec
commit
d74b4dce4f
|
@ -295,8 +295,9 @@
|
|||
};
|
||||
|
||||
// Triggering action events before attaching should do nothing
|
||||
embed.embedTextHtml.$element.focus();
|
||||
embed.embedTextWikitext.$element.focus();
|
||||
// use of focus() would run into jQuery bug #14740 and similar issues
|
||||
embed.embedTextHtml.$element.triggerHandler( 'focus' );
|
||||
embed.embedTextWikitext.$element.triggerHandler( 'focus' );
|
||||
embed.embedSwitch.emit( 'select' );
|
||||
embed.embedSizeSwitchHtml.getMenu().emit(
|
||||
'choose', embed.embedSizeSwitchHtml.getMenu().getSelectedItem() );
|
||||
|
@ -316,8 +317,8 @@
|
|||
embed.attach();
|
||||
|
||||
// Action events should be handled now
|
||||
embed.embedTextHtml.$element.focus();
|
||||
embed.embedTextWikitext.$element.focus();
|
||||
embed.embedTextHtml.$element.triggerHandler( 'focus' );
|
||||
embed.embedTextWikitext.$element.triggerHandler( 'focus' );
|
||||
embed.embedSwitch.emit( 'select' );
|
||||
embed.embedSizeSwitchHtml.getMenu().emit(
|
||||
'choose', embed.embedSizeSwitchHtml.getMenu().getSelectedItem() );
|
||||
|
@ -338,8 +339,8 @@
|
|||
embed.unattach();
|
||||
|
||||
// Triggering action events now that we are unattached should do nothing
|
||||
embed.embedTextHtml.$element.focus();
|
||||
embed.embedTextWikitext.$element.focus();
|
||||
embed.embedTextHtml.$element.triggerHandler( 'focus' );
|
||||
embed.embedTextWikitext.$element.triggerHandler( 'focus' );
|
||||
embed.embedSwitch.emit( 'select' );
|
||||
embed.embedSizeSwitchHtml.getMenu().emit(
|
||||
'choose', embed.embedSizeSwitchHtml.getMenu().getSelectedItem() );
|
||||
|
|
|
@ -69,7 +69,8 @@
|
|||
};
|
||||
|
||||
// Triggering action events before attaching should do nothing
|
||||
share.pageInput.$element.focus();
|
||||
// use of focus() would run into jQuery bug #14740 and similar issues
|
||||
share.pageInput.$element.triggerHandler( 'focus' );
|
||||
|
||||
share.selectAllOnEvent = function () {
|
||||
assert.ok( true, 'selectAllOnEvent was called.' );
|
||||
|
@ -78,7 +79,7 @@
|
|||
share.attach();
|
||||
|
||||
// Action events should be handled now
|
||||
share.pageInput.$element.focus();
|
||||
share.pageInput.$element.triggerHandler( 'focus' );
|
||||
|
||||
// Test the unattach part
|
||||
share.selectAllOnEvent = function() {
|
||||
|
@ -88,7 +89,7 @@
|
|||
share.unattach();
|
||||
|
||||
// Triggering action events now that we are unattached should do nothing
|
||||
share.pageInput.$element.focus();
|
||||
share.pageInput.$element.triggerHandler( 'focus' );
|
||||
} );
|
||||
|
||||
}( mediaWiki, jQuery ) );
|
||||
|
|
Loading…
Reference in a new issue