r98576 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98575‎ | r98576 | r98577 >
Date:22:16, 30 September 2011
Author:brion
Status:ok
Tags:
Comment:
QUnit test case to confirm consistent browser behavior with initial newlines inside <textarea> HTML source. (for bug 12130)
Modified paths:
  • /trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.jscompat.test.js (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.jscompat.test.js
@@ -33,3 +33,30 @@
3434 deepEqual( foo.\u0069\u0066, orig, 'foo.\\u0069\\u0066' );
3535 });
3636 */
 37+
 38+test( 'Stripping of single initial newline from textarea\'s literal contents (bug 12130)', function() {
 39+ var maxn = 4;
 40+ expect(maxn * 2);
 41+
 42+ var repeat = function(str, n) {
 43+ if (n <= 0) {
 44+ return '';
 45+ } else {
 46+ var out = Array(n);
 47+ for (var i = 0; i < n; i++) {
 48+ out[i] = str;
 49+ }
 50+ return out.join('');
 51+ }
 52+ };
 53+
 54+ for (var n = 0; n < maxn; n++) {
 55+ var expected = repeat('\n', n) + 'some text';
 56+
 57+ var $textarea = $('<textarea>\n' + expected + '</textarea>');
 58+ equal($textarea.val(), expected, 'Expecting ' + n + ' newlines (HTML contained ' + (n + 1) + ')');
 59+
 60+ var $textarea2 = $('<textarea>').val(expected);
 61+ equal($textarea2.val(), expected, 'Expecting ' + n + ' newlines (from DOM set with ' + n + ')');
 62+ }
 63+});

Follow-up revisions

RevisionCommit summaryAuthorDate
r98578* (bug 12130) Initial newlines are now preserved correctly during editing...brion22:50, 30 September 2011
r98583* (bug 26028) Preserve initial newlines in ProofreadPage customized edit inte...brion23:34, 30 September 2011
r98584MFT r98578 (bug 12130), r98583 (bug 26028): fixes for disappearing newlines a...brion23:37, 30 September 2011

Status & tagging log