r100656 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100655‎ | r100656 | r100657 >
Date:22:28, 24 October 2011
Author:brion
Status:ok (Comments)
Tags:
Comment:
Followup r100391: fix caret position test case on Opera, Firefox 3.5/3.6/4.0/5.0

Opera (through 11.52 at least) & Firefox prior to 6.0 set the caret initially to the end of the textarea, which gave a mismatch. All we really need is to know we got a sane value, so checking for both (start == 0; end == text.length) gets the job done.
Under ideal circumstances, we'd check after a user clicks in the textarea on the first line, but no good way to trigger that. :)
Modified paths:
  • /trunk/phase3/tests/qunit/suites/resources/jquery/jquery.textSelection.test.js (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/qunit/suites/resources/jquery/jquery.textSelection.test.js
@@ -241,9 +241,17 @@
242242 });
243243 }
244244
 245+ var among = function(actual, expected, message) {
 246+ if ($.isArray(expected)) {
 247+ ok($.inArray(actual, expected) !== -1 , message + ' (got ' + actual + '; expected one of ' + expected.join(', ') + ')');
 248+ } else {
 249+ equal(actual, expected, message);
 250+ }
 251+ };
 252+
245253 var pos = $textarea.textSelection('getCaretPosition', {startAndEnd: true});
246 - equal(pos[0], options.start, 'Caret start should be where we set it.');
247 - equal(pos[1], options.end, 'Caret end should be where we set it.');
 254+ among(pos[0], options.start, 'Caret start should be where we set it.');
 255+ among(pos[1], options.end, 'Caret end should be where we set it.');
248256 });
249257 }
250258
@@ -252,8 +260,8 @@
253261 caretTest({
254262 description: 'getCaretPosition with original/empty selection - bug 31847 with IE 6/7/8',
255263 text: caretSample,
256 - start: 0,
257 - end: 0,
 264+ start: [0, caretSample.length], // Opera and Firefox (prior to FF 6.0) default caret to the end of the box (caretSample.length)
 265+ end: [0, caretSample.length], // Other browsers default it to the beginning (0), so check both.
258266 mode: 'get'
259267 });
260268

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r100391QUnit test cases for bug 31847: will trigger a fail on IE 6/7/8...brion22:50, 20 October 2011

Comments

#Comment by Catrope (talk | contribs)   11:50, 28 October 2011

Untagging 1.18wmf1, test file doesn't exist there.

#Comment by Reedy (talk | contribs)   21:16, 28 October 2011

Same for 1.18

Status & tagging log