Skip to content

Commit 015c43d

Browse files
committed
Tests: Selection normalisation is needed whenever we operate on real selection. Fixes #12990.
1 parent 503667b commit 015c43d

File tree

2 files changed

+32
-22
lines changed

2 files changed

+32
-22
lines changed

tests/core/editable/keystrokes/delbackspacequirks/_helpers/tools.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ var quirksTools = ( function() {
1111
8: 'BACKSPACE'
1212
};
1313

14-
function assertKeystroke( key, keyModifiers, handled, html, expected, normalizeSelection ) {
15-
normalizeSelection = ( normalizeSelection === false ) ? false : true;
16-
14+
function assertKeystroke( key, keyModifiers, handled, html, expected ) {
1715
function decodeBoguses( html ) {
1816
return html.replace( /@/g, CKEDITOR.env.needsBrFiller ? '<br />' : '' );
1917
}
@@ -43,7 +41,7 @@ var quirksTools = ( function() {
4341
assert.isInnerHtmlMatching(
4442
expected,
4543
htmlWithSelection,
46-
{ compareSelection: true, normalizeSelection: normalizeSelection },
44+
{ compareSelection: true, normalizeSelection: true },
4745
message
4846
);
4947

@@ -61,12 +59,22 @@ var quirksTools = ( function() {
6159
return assertKeystroke.apply( this, [ BACKSPACE, 0, 0 ].concat( [].slice.call( arguments ) ) );
6260
}
6361

64-
function bf( html ) {
65-
return assertKeystroke.apply( this, [ BACKSPACE, 0, 1, html, html, false ] );
62+
// We need expected param, because in some cases selection normalization will change the input
63+
// selection markers. Therefore, in some cases we can't compare the result after with the input HTML.
64+
function bf( html, expected ) {
65+
if ( !expected ) {
66+
expected = html;
67+
}
68+
69+
return assertKeystroke.apply( this, [ BACKSPACE, 0, 1, html, expected ] );
6670
}
6771

68-
function df( html ) {
69-
return assertKeystroke.apply( this, [ DEL, 0, 1, html, html, false ] );
72+
function df( html, expected ) {
73+
if ( !expected ) {
74+
expected = html;
75+
}
76+
77+
return assertKeystroke.apply( this, [ DEL, 0, 1, html, expected ] );
7078
}
7179

7280
return {

tests/core/editable/keystrokes/delbackspacequirks/collapsed.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,14 @@
111111
'test backspace, bogus #4': b( '<p><br>@</p><p>[]@</p>', '<p><br />^@!</p>' ),
112112

113113
// False positives. Some of them are buggy, but it's a different case e.g. not merging blocks.
114-
'test backspace, no action #1': bf( '<p>x</p><p>y{}y</p>' ),
115-
'test backspace, no action #2': bf( '<span>x</span><p>{}y</p>' ),
116-
'test backspace, no action #3': bf( '<p>x</p><p><strong>y{}y</strong></p>' ),
117-
'test backspace, no action #4': bf( '<p>x</p><blockquote><p>y{}y</p></blockquote>' ),
118-
'test backspace, no action #5': bf( '<p>x</p><blockquote>z<p>{}y</p></blockquote>' ),
119-
'test backspace, no action #6': bf( 'x<p>{}y</p>' ),
120-
'test backspace, no action #7': bf( '<p>x</p>z<p>{}y</p>' ),
114+
// Note: The second pattern is just the first but after a selection normalization.
115+
'test backspace, no action #1': bf( '<p>x</p><p>y{}y</p>', '<p>x</p><p>y^y</p>' ),
116+
'test backspace, no action #2': bf( '<span>x</span><p>{}y</p>', '<span>x</span><p>^y</p>' ),
117+
'test backspace, no action #3': bf( '<p>x</p><p><strong>y{}y</strong></p>', '<p>x</p><p><strong>y^y</strong></p>' ),
118+
'test backspace, no action #4': bf( '<p>x</p><blockquote><p>y{}y</p></blockquote>', '<p>x</p><blockquote><p>y^y</p></blockquote>' ),
119+
'test backspace, no action #5': bf( '<p>x</p><blockquote>z<p>{}y</p></blockquote>', '<p>x</p><blockquote>z<p>^y</p></blockquote>' ),
120+
'test backspace, no action #6': bf( 'x<p>{}y</p>', 'x<p>^y</p>' ),
121+
'test backspace, no action #7': bf( '<p>x</p>z<p>{}y</p>', '<p>x</p>z<p>^y</p>' ),
121122

122123
// Handled by list or table plugin or editable, but not related to #9998.
123124
// This is just to control whether the fix for #9998 does not break some case which it should not handle at all.
@@ -162,13 +163,14 @@
162163
'test delete, bogus #4': d( '<p>[]@</p><p><br>@</p>', '<p>^<br />@!</p>' ),
163164

164165
// False positives. Some of them are buggy, but it's a different case e.g. not merging blocks.
165-
'test delete, no action #1': df( '<p>x{}x</p><p>y</p>' ),
166-
'test delete, no action #2': df( '<p>x{}</p><span>y</span>' ),
167-
'test delete, no action #3': df( '<p><strong>x{}x</strong></p><p>y</p>' ),
168-
'test delete, no action #4': df( '<blockquote><p>x{}x</p></blockquote><p>y</p>' ),
169-
'test delete, no action #5': df( '<blockquote><p>x{}</p>x</blockquote><p>y</p>' ),
170-
'test delete, no action #6': df( '<p>x{}</p>y' ),
171-
'test delete, no action #7': df( '<p>y{}</p>y<p>z</p>' ),
166+
// Note: The second pattern is just the first but after a selection normalization.
167+
'test delete, no action #1': df( '<p>x{}x</p><p>y</p>', '<p>x^x</p><p>y</p>' ),
168+
'test delete, no action #2': df( '<p>x{}</p><span>y</span>', '<p>x^</p><span>y</span>' ),
169+
'test delete, no action #3': df( '<p><strong>x{}x</strong></p><p>y</p>', '<p><strong>x^x</strong></p><p>y</p>' ),
170+
'test delete, no action #4': df( '<blockquote><p>x{}x</p></blockquote><p>y</p>', '<blockquote><p>x^x</p></blockquote><p>y</p>' ),
171+
'test delete, no action #5': df( '<blockquote><p>x{}</p>x</blockquote><p>y</p>', '<blockquote><p>x^</p>x</blockquote><p>y</p>' ),
172+
'test delete, no action #6': df( '<p>x{}</p>y', '<p>x^</p>y' ),
173+
'test delete, no action #7': df( '<p>y{}</p>y<p>z</p>', '<p>y^</p>y<p>z</p>' ),
172174

173175
// Handled by list or table plugin or editable, but not related to #9998.
174176
// This is just to control whether the fix for #9998 does not break some case which it should not handle at all.

0 commit comments

Comments
 (0)