summaryrefslogtreecommitdiffstats
path: root/editor/libeditor/tests/browserscope/lib/richtext2/richtext2/tests/forwarddelete.py
blob: 813b22914a39e8bc87159eec214865c94544847d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
FORWARDDELETE_TESTS = {
  'id':          'FD',
  'caption':     'Forward-Delete Tests',
  'command':     'forwardDelete',
  'checkAttrs':  True,
  'checkStyle':  False,

  'Proposed': [
    { 'desc':       '',
      'tests':      [
      ]
    },

    { 'desc':       'forward-delete single characters',
      'tests':      [
        { 'id':          'CHAR-1_SC',
          'desc':        'Delete 1 character',
          'pad':         'foo^barbaz',
          'expected':    'foo^arbaz' },

        { 'id':          'CHAR-2_SC',
          'desc':        'Delete 1 pre-composed character o with diaeresis',
          'pad':         'fo^öbarbaz',
          'expected':    'fo^barbaz' },

        { 'id':          'CHAR-3_SC',
          'desc':        'Delete 1 character with combining diaeresis above',
          'pad':         'fo^öbarbaz',
          'expected':    'fo^barbaz' },

        { 'id':          'CHAR-4_SC',
          'desc':        'Delete 1 character with combining diaeresis below',
          'pad':         'fo^o̤barbaz',
          'expected':    'fo^barbaz' },

        { 'id':          'CHAR-5_SC',
          'desc':        'Delete 1 character with combining diaeresis above and below',
          'pad':         'fo^ö̤barbaz',
          'expected':    'fo^barbaz' },

        { 'id':          'CHAR-6_SC',
          'desc':        'Delete 1 character with enclosing square',
          'pad':         'fo^o⃞barbaz',
          'expected':    'fo^barbaz' },

        { 'id':          'CHAR-7_SC',
          'desc':        'Delete 1 character with combining long solidus overlay',
          'pad':         'fo^o̸barbaz',
          'expected':    'fo^barbaz' }
      ]
    },

    { 'desc':       'forward-delete text selections',
      'tests':      [
        { 'id':          'TEXT-1_SI',
          'desc':        'Delete text selection',
          'pad':         'foo[bar]baz',
          'expected':    'foo^baz' },
          
        { 'id':          'B-1_SE',
          'desc':        'Forward-delete at end of span',
          'pad':         'foo<b>bar^</b>baz',
          'expected':    'foo<b>bar^</b>az' },

        { 'id':          'B-1_SB',
          'desc':        'Forward-delete from position before span',
          'pad':         'foo^<b>bar</b>baz',
          'expected':    'foo^<b>ar</b>baz' },

        { 'id':          'B-1_SW',
          'desc':        'Delete selection that wraps the whole span content',
          'pad':         'foo<b>[bar]</b>baz',
          'expected':    'foo^baz' },

        { 'id':          'B-1_SO',
          'desc':        'Delete selection that wraps the whole span',
          'pad':         'foo[<b>bar</b>]baz',
          'expected':    'foo^baz' },

        { 'id':          'B-1_SL',
          'desc':        'Delete oblique selection that starts before span',
          'pad':         'foo[bar<b>baz]quoz</b>quuz',
          'expected':    'foo^<b>quoz</b>quuz' },

        { 'id':          'B-1_SR',
          'desc':        'Delete oblique selection that ends after span',
          'pad':         'foo<b>bar[baz</b>quoz]quuz',
          'expected':    'foo<b>bar^</b>quuz' },

        { 'id':          'B.I-1_SM',
          'desc':        'Delete oblique selection that starts and ends in different spans',
          'pad':         'foo<b>bar[baz</b><i>qoz]quuz</i>quuuz',
          'expected':    'foo<b>bar^</b><i>quuz</i>quuuz' },

        { 'id':          'GEN-1_SE',
          'desc':        'Delete at end of span with generated content',
          'pad':         'foo<gen>bar^</gen>baz',
          'expected':    'foo<gen>bar^</gen>az' },

        { 'id':          'GEN-1_SB',
          'desc':        'Delete from position before span with generated content',
          'pad':         'foo^<gen>bar</gen>baz',
          'expected':    'foo^<gen>ar</gen>baz' }
      ]
    },

    { 'desc':       'forward-delete paragraphs',
      'tests':      [
        { 'id':          'P2-1_SE1',
          'desc':        'Delete from collapsed selection at end of paragraph - should merge with next',
          'pad':         '<p>foobar^</p><p>bazqoz</p>',
          'expected':    '<p>foobar^bazqoz</p>' },

        { 'id':          'P2-1_SI1',
          'desc':        'Delete non-collapsed selection at end of paragraph - should not merge with next',
          'pad':         '<p>foo[bar]</p><p>bazqoz</p>',
          'expected':    '<p>foo^</p><p>bazqoz</p>' },

        { 'id':          'P2-1_SM',
          'desc':        'Delete non-collapsed selection spanning 2 paragraphs - should merge them',
          'pad':         '<p>foo[bar</p><p>baz]qoz</p>',
          'expected':    '<p>foo^qoz</p>' }
      ]
    },

    { 'desc':       'forward-delete lists and list items',
      'tests':      [
        { 'id':          'OL-LI2-1_SO1',
          'desc':        'Delete fully wrapped list item',
          'pad':         'foo<ol>{<li>bar</li>}<li>baz</li></ol>qoz', 
          'expected':    ['foo<ol>|<li>baz</li></ol>qoz',
                          'foo<ol><li>^baz</li></ol>qoz'] },

        { 'id':          'OL-LI2-1_SM',
          'desc':        'Delete oblique range between list items within same list',
          'pad':         'foo<ol><li>ba[r</li><li>b]az</li></ol>qoz',
          'expected':    'foo<ol><li>ba^az</li></ol>qoz' },

        { 'id':          'OL-LI-1_SW',
          'desc':        'Delete contents of last list item (list should remain)',
          'pad':         'foo<ol><li>[foo]</li></ol>qoz',
          'expected':    ['foo<ol><li>|</li></ol>qoz',
                          'foo<ol><li>^</li></ol>qoz'] },

        { 'id':          'OL-LI-1_SO',
          'desc':        'Delete last list item of list (should remove entire list)',
          'pad':         'foo<ol>{<li>foo</li>}</ol>qoz',
          'expected':    'foo^qoz' }
      ]
    },

    { 'desc':       'forward-delete with strange selections',
      'tests':      [
        { 'id':          'HR.BR-1_SM',
          'desc':        'Delete selection that starts and ends within nodes that don\'t have children',
          'pad':         'foo<hr {>bar<br }>baz',
          'expected':    'foo<hr>|<br>baz' }
      ]
    },

    { 'desc':       'forward-delete from immediately before a table',
      'tests':      [
        { 'id':          'TABLE-1_SB',
          'desc':        'Delete from position immediately before table (should have no effect)',
          'pad':         'foo^<table><tbody><tr><td>bar</td></tr></tbody></table>baz',
          'expected':    'foo^<table><tbody><tr><td>bar</td></tr></tbody></table>baz' }
      ]
    },

    { 'desc':       'forward-delete within table cells',
      'tests':      [
        { 'id':          'TD-1_SE',
          'desc':        'Delete from end of last cell (should have no effect)',
          'pad':         'foo<table><tbody><tr><td>bar^</td></tr></tbody></table>baz',
          'expected':    'foo<table><tbody><tr><td>bar^</td></tr></tbody></table>baz' },

        { 'id':          'TD2-1_SE1',
          'desc':        'Delete from end of inner cell (should have no effect)',
          'pad':         'foo<table><tbody><tr><td>bar^</td><td>baz</td></tr></tbody></table>quoz',
          'expected':    'foo<table><tbody><tr><td>bar^</td><td>baz</td></tr></tbody></table>quoz' },

        { 'id':          'TD2-1_SM',
          'desc':        'Delete with selection spanning 2 cells',
          'pad':         'foo<table><tbody><tr><td>ba[r</td><td>b]az</td></tr></tbody></table>quoz',
          'expected':    'foo<table><tbody><tr><td>ba^</td><td>az</td></tr></tbody></table>quoz' }
      ]
    },

    { 'desc':       'forward-delete table rows',
      'tests':      [
        { 'id':          'TR3-1_SO1',
          'desc':        'Delete first table row',
          'pad':         '<table><tbody>{<tr><td>A</td></tr>}<tr><td>B</td></tr><tr><td>C</td></tr></tbody></table>',
          'expected':    ['<table><tbody>|<tr><td>B</td></tr><tr><td>C</td></tr></tbody></table>',
                          '<table><tbody><tr><td>^B</td></tr><tr><td>C</td></tr></tbody></table>'] },

        { 'id':          'TR3-1_SO2',
          'desc':        'Delete middle table row',
          'pad':         '<table><tbody><tr><td>A</td></tr>{<tr><td>B</td></tr>}<tr><td>C</td></tr></tbody></table>',
          'expected':    ['<table><tbody><tr><td>A</td></tr>|<tr><td>C</td></tr></tbody></table>',
                          '<table><tbody><tr><td>A</td></tr><tr><td>^C</td></tr></tbody></table>'] },

        { 'id':          'TR3-1_SO3',
          'desc':        'Delete last table row',
          'pad':         '<table><tbody><tr><td>A</td></tr><tr><td>B</td></tr>{<tr><td>C</td></tr>}</tbody></table>',
          'expected':    ['<table><tbody><tr><td>A</td></tr><tr><td>B</td></tr>|</tbody></table>',
                          '<table><tbody><tr><td>A</td></tr><tr><td>B^</td></tr></tbody></table>'] },

        { 'id':          'TR2rs:2-1_SO1',
          'desc':        'Delete first table row where a cell has rowspan 2',
          'pad':         '<table><tbody>{<tr><td>A</td><td rowspan=2>R</td></tr>}<tr><td>B</td></tr></tbody></table>',
          'expected':    ['<table><tbody>|<tr><td>B</td><td>R</td></tr></tbody></table>',
                          '<table><tbody><tr><td>^B</td><td>R</td></tr></tbody></table>'] },

        { 'id':          'TR2rs:2-1_SO2',
          'desc':        'Delete second table row where a cell has rowspan 2',
          'pad':         '<table><tbody><tr><td>A</td><td rowspan=2>R</td></tr>{<tr><td>B</td></tr>}</tbody></table>',
          'expected':    ['<table><tbody><tr><td>A</td><td>R</td></tr>|</tbody></table>',
                          '<table><tbody><tr><td>A</td><td>R^</td></tr></tbody></table>'] },

        { 'id':          'TR3rs:3-1_SO1',
          'desc':        'Delete first table row where a cell has rowspan 3',
          'pad':         '<table><tbody>{<tr><td>A</td><td rowspan=3>R</td></tr>}<tr><td>B</td></tr><tr><td>C</td></tr></tbody></table>',
          'expected':    ['<table><tbody>|<tr><td>A</td><td rowspan="2">R</td></tr><tr><td>C</td></tr></tbody></table>',
                          '<table><tbody><tr><td>^A</td><td rowspan="2">R</td></tr><tr><td>C</td></tr></tbody></table>'] },

        { 'id':          'TR3rs:3-1_SO2',
          'desc':        'Delete middle table row where a cell has rowspan 3',
          'pad':         '<table><tbody><tr><td>A</td><td rowspan=3>R</td></tr>{<tr><td>B</td></tr>}<tr><td>C</td></tr></tbody></table>',
          'expected':    ['<table><tbody><tr><td>B</td><td rowspan="2">R</td></tr>|<tr><td>C</td></tr></tbody></table>',
                          '<table><tbody><tr><td>B</td><td rowspan="2">R</td></tr><tr><td>^C</td></tr></tbody></table>'] },

        { 'id':          'TR3rs:3-1_SO3',
          'desc':        'Delete last table row where a cell has rowspan 3',
          'pad':         '<table><tbody><tr><td>A</td><td rowspan=3>R</td></tr><tr><td>B</td></tr>{<tr><td>C</td></tr>}</tbody></table>',
          'expected':    ['<table><tbody><tr><td>A</td><td rowspan="2">R</td></tr><tr><td>B</td></tr>|</tbody></table>',
                          '<table><tbody><tr><td>A</td><td rowspan="2">R</td></tr><tr><td>B^</td></tr></tbody></table>'] }
      ]
    },

    { 'desc':       'delete with non-editable nested content',
      'tests':      [
        { 'id':         'DIV:ce:false-1_SO',
          'desc':       'Delete nested non-editable <div>',
          'pad':        'foo[bar<div contenteditable="false">NESTED</div>baz]qoz',
          'expected':   'foo^qoz' },

        { 'id':         'DIV:ce:false-1_SB',
          'desc':       'Delete from immediately before a nested non-editable <div>',
          'pad':        'foobar^<div contenteditable="false">NESTED</div>bazqoz',
          'expected':   'foobar^bazqoz' },

        { 'id':         'DIV:ce:false-1_SL',
          'desc':       'Delete nested non-editable <div> with oblique selection',
          'pad':        'foo[bar<div contenteditable="false">NES]TED</div>bazqoz',
          'expected':   [ 'foo^<div contenteditable="false">NESTED</div>bazqoz',
                          'foo<div contenteditable="false">[NES]TED</div>bazqoz' ] },

        { 'id':         'DIV:ce:false-1_SR',
          'desc':       'Delete nested non-editable <div> with oblique selection',
          'pad':        'foobar<div contenteditable="false">NES[TED</div>baz]qoz',
          'expected':   [ 'foobar<div contenteditable="false">NESTED</div>^qoz',
                          'foobar<div contenteditable="false">NES[TED]</div>qoz' ] },

        { 'id':         'DIV:ce:false-1_SI',
          'desc':       'Delete inside nested non-editable <div> (should be no-op)',
          'pad':        'foobar<div contenteditable="false">NE[ST]ED</div>bazqoz',
          'expected':   'foobar<div contenteditable="false">NE[ST]ED</div>bazqoz' }
      ]
    },

    { 'desc':       'Delete with display:inline-block',
      'checkStyle':  True,
      'tests':      [
        { 'id':         'SPAN:d:ib-1_SC',
          'desc':       'Delete inside an inline-block <span>',
          'pad':        'foo<span style="display: inline-block">bar^baz</span>qoz',
          'expected':   'foo<span style="display: inline-block">bar^az</span>qoz' },

        { 'id':         'SPAN:d:ib-1_SA',
          'desc':       'Delete from immediately before an inline-block <span>',
          'pad':        'foo^<span style="display: inline-block">barbaz</span>qoz',
          'expected':   'foo^<span style="display: inline-block">arbaz</span>qoz' },

        { 'id':         'SPAN:d:ib-2_SL',
          'desc':       'Delete with nested inline-block <span>, oblique selection',
          'pad':        'foo[DEL<span style="display: inline-block">ETE]bar</span>baz',
          'expected':   'foo^<span style="display: inline-block">bar</span>baz' },

        { 'id':         'SPAN:d:ib-3_SR',
          'desc':       'Delete with nested inline-block <span>, oblique selection',
          'pad':        'foo<span style="display: inline-block">bar[DEL</span>ETE]baz',
          'expected':   'foo<span style="display: inline-block">bar^</span>baz' },

        { 'id':         'SPAN:d:ib-4i_SI',
          'desc':       'Delete with nested inline-block <span>, oblique selection',
          'pad':        'foo<span style="display: inline-block">bar[DELETE]baz</span>qoz',
          'expected':   'foo<span style="display: inline-block">bar^baz</span>qoz' },

        { 'id':         'SPAN:d:ib-4l_SI',
          'desc':       'Delete with nested inline-block <span>, oblique selection',
          'pad':        'foo<span style="display: inline-block">[DELETE]barbaz</span>qoz',
          'expected':   'foo<span style="display: inline-block">^barbaz</span>qoz' },

        { 'id':         'SPAN:d:ib-4r_SI',
          'desc':       'Delete with nested inline-block <span>, oblique selection',
          'pad':        'foo<span style="display: inline-block">barbaz[DELETE]</span>qoz',
          'expected':   'foo<span style="display: inline-block">barbaz^</span>qoz' }
      ]
    }
  ]
}