Adrian Lang has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/105945


Change subject: Make focus-related test cases succeed in Firefox
......................................................................

Make focus-related test cases succeed in Firefox

Firefox throws an exception if an element to be focused is not visible or not
in DOM at all. This patch fixes three test cases: two by accepting the
exception as valid, one by making sure the element is visible.

Change-Id: I6e8ea796b7afaaa799f5d70dfdc84b1bdd59703d
---
M ValueView/tests/qunit/jquery.valueview/valueview.tests.testExpert.js
M ValueView/tests/qunit/jquery/jquery.fn.focusAt.tests.js
2 files changed, 27 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DataValues 
refs/changes/45/105945/1

diff --git 
a/ValueView/tests/qunit/jquery.valueview/valueview.tests.testExpert.js 
b/ValueView/tests/qunit/jquery.valueview/valueview.tests.testExpert.js
index 22774a8..0043e96 100644
--- a/ValueView/tests/qunit/jquery.valueview/valueview.tests.testExpert.js
+++ b/ValueView/tests/qunit/jquery.valueview/valueview.tests.testExpert.js
@@ -279,7 +279,22 @@
                        'Viewport node is not empty after draw()'
                );
        } );
-       expertCasesMemberCallTest( 'focus' );
+
+       expertCasesTestAndCleanup( 'focus', function( args, assert ) {
+               try {
+                       args.expert.focus();
+               } catch (e) {
+                        // Firefox does not support focusing elements that are 
not visible.
+                        assert.equal(e.name, 'NS_ERROR_FAILURE');
+                        assert.equal(e.result, 0x80004005);
+                        return;
+               }
+               assert.ok(
+                       true,
+                       'focus() has been called'
+               );
+       } );
+
        expertCasesMemberCallTest( 'blur' );
 
        // Separate test for change notification:
diff --git a/ValueView/tests/qunit/jquery/jquery.fn.focusAt.tests.js 
b/ValueView/tests/qunit/jquery/jquery.fn.focusAt.tests.js
index 1c6e52e..8471e80 100644
--- a/ValueView/tests/qunit/jquery/jquery.fn.focusAt.tests.js
+++ b/ValueView/tests/qunit/jquery/jquery.fn.focusAt.tests.js
@@ -67,10 +67,13 @@
                var positions = [ 0, 1, 4, 9, 9999, 'start', 'end', -1, -3, 
-9999 ];
 
                $.each( positions, function( i, pos ) {
+                       // Put element in DOM, since Firefox expects this
+                       $('body').append(params.elem);
                        assert.ok(
                                params.elem.focusAt( pos ),
                                'focusAt takes "' + pos + '" as a valid 
position for the element'
                        );
+                       params.elem.remove();
                } );
        } );
 
@@ -95,10 +98,14 @@
                        throw new Error( 'Can only run this test on a HTML page 
with "body" tag in the browser.' );
                }
 
-               assert.ok(
-                       elem.focusAt( 0 ),
-                       'Can call focusAt on element not in DOM yet'
-               );
+               try {
+                       elem.focusAt( 0 );
+               } catch (e) {
+                       // Firefox does not support focusing elements that are 
not visible.
+                       assert.equal(e.name, 'NS_ERROR_FAILURE');
+                       assert.equal(e.result, 0x80004005);
+                       return;
+               }
 
                $( ':focus' ).blur();
                elem.appendTo( $dom );

-- 
To view, visit https://gerrit.wikimedia.org/r/105945
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6e8ea796b7afaaa799f5d70dfdc84b1bdd59703d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DataValues
Gerrit-Branch: master
Gerrit-Owner: Adrian Lang <adrian.l...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to