summaryrefslogtreecommitdiffstats
path: root/editor/libeditor/tests/browserscope/lib/richtext2/richtext2/tests/apply.py
blob: 3eb465c84c4b369e0611b9c1902e1406fb311f0d (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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
APPLY_TESTS = {
  'id':            'A',
  'caption':       'Apply Formatting Tests',
  'checkAttrs':    True,
  'checkStyle':    True,
  'styleWithCSS':  False,

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

    { 'desc':       '[HTML5] bold',
      'command':    'bold',
      'tests':      [
        { 'id':         'B_TEXT-1_SI',
          'rte1-id':    'a-bold-0',
          'desc':       'Bold selection',
          'pad':        'foo[bar]baz',
          'expected':   [ 'foo<b>[bar]</b>baz',
                          'foo<strong>[bar]</strong>baz' ] },

        { 'id':         'B_TEXT-1_SIR',
          'desc':       'Bold reversed selection',
          'pad':        'foo]bar[baz',
          'expected':   [ 'foo<b>[bar]</b>baz',
                          'foo<strong>[bar]</strong>baz' ] },

        { 'id':         'B_I-1_SL',
          'desc':       'Bold selection, partially including italic',
          'pad':        'foo[bar<i>baz]qoz</i>quz',
          'expected':   [ 'foo<b>[bar</b><i><b>baz]</b>qoz</i>quz',
                          'foo<b>[bar<i>baz]</i></b><i>qoz</i>quz',
                          'foo<strong>[bar</strong><i><strong>baz]</strong>qoz</i>quz',
                          'foo<strong>[bar<i>baz]</i></strong><i>qoz</i>quz' ] }
      ]
    },

    { 'desc':       '[HTML5] italic',
      'command':    'italic',
      'tests':      [
        { 'id':         'I_TEXT-1_SI',
          'rte1-id':    'a-italic-0',
          'desc':       'Italicize selection',
          'pad':        'foo[bar]baz',
          'expected':   [ 'foo<i>[bar]</i>baz',
                          'foo<em>[bar]</em>baz' ] }
      ]
    },

    { 'desc':       '[HTML5] underline',
      'command':    'underline',
      'tests':      [
        { 'id':         'U_TEXT-1_SI',
          'rte1-id':    'a-underline-0',
          'desc':       'Underline selection',
          'pad':        'foo[bar]baz',
          'expected':   'foo<u>[bar]</u>baz' }          
      ]
    },

    { 'desc':       '[HTML5] strikethrough',
      'command':    'strikethrough',
      'tests':      [
        { 'id':         'S_TEXT-1_SI',
          'rte1-id':    'a-strikethrough-0',
          'desc':       'Strike-through selection',
          'pad':        'foo[bar]baz',
          'expected':   [ 'foo<s>[bar]</s>baz',
                          'foo<strike>[bar]</strike>baz',
                          'foo<del>[bar]</del>baz' ] }          
      ]
    },

    { 'desc':       '[HTML5] subscript',
      'command':    'subscript',
      'tests':      [
        { 'id':         'SUB_TEXT-1_SI',
          'rte1-id':    'a-subscript-0',
          'desc':       'Change selection to subscript',
          'pad':        'foo[bar]baz',
          'expected':   'foo<sub>[bar]</sub>baz' }
      ]
    },

    { 'desc':       '[HTML5] superscript',
      'command':    'superscript',
      'tests':      [
        { 'id':         'SUP_TEXT-1_SI',
          'rte1-id':    'a-superscript-0',
          'desc':       'Change selection to superscript',
          'pad':        'foo[bar]baz',
          'expected':   'foo<sup>[bar]</sup>baz' }
      ]
    },

    { 'desc':       '[HTML5] createlink',
      'command':    'createlink',
      'tests':      [
        { 'id':         'CL:url_TEXT-1_SI',
          'rte1-id':    'a-createlink-0',
          'desc':       'create a link around the selection',
          'value':      '#foo',
          'pad':        'foo[bar]baz',
          'expected':   'foo<a href="#foo">[bar]</a>baz' }
      ]
    },

    { 'desc':       '[HTML5] formatBlock',
      'command':    'formatblock',
      'tests':      [
        { 'id':         'FB:H1_TEXT-1_SI',
          'rte1-id':    'a-formatblock-0',
          'desc':       'format the selection into a block: use <h1>',
          'value':      'h1',
          'pad':        'foo[bar]baz',
          'expected':   '<h1>foo[bar]baz</h1>' },

        { 'id':         'FB:P_TEXT-1_SI',
          'desc':       'format the selection into a block: use <p>',
          'value':      'p',
          'pad':        'foo[bar]baz',
          'expected':   '<p>foo[bar]baz</p>' },

        { 'id':         'FB:PRE_TEXT-1_SI',
          'desc':       'format the selection into a block: use <pre>',
          'value':      'pre',
          'pad':        'foo[bar]baz',
          'expected':   '<pre>foo[bar]baz</pre>' },

        { 'id':         'FB:ADDRESS_TEXT-1_SI',
          'desc':       'format the selection into a block: use <address>',
          'value':      'address',
          'pad':        'foo[bar]baz',
          'expected':   '<address>foo[bar]baz</address>' },

        { 'id':         'FB:BQ_TEXT-1_SI',
          'desc':       'format the selection into a block: use <blockquote>',
          'value':      'blockquote',
          'pad':        'foo[bar]baz',
          'expected':   '<blockquote>foo[bar]baz</blockquote>' },

        { 'id':         'FB:BQ_BR.BR-1_SM',
          'desc':       'format a multi-line selection into a block: use <blockquote>',
          'command':    'formatblock',
          'value':      'blockquote',
          'pad':        'fo[o<br>bar<br>b]az',
          'expected':   '<blockquote>fo[o<br>bar<br>b]az</blockquote>' }
      ]
    },


    { 'desc':       '[MIDAS] backcolor',
      'command':    'backcolor',
      'tests':      [
        { 'id':         'BC:blue_TEXT-1_SI',
          'rte1-id':    'a-backcolor-0',
          'desc':       'Change background color (note: no non-CSS variant available)',
          'value':      'blue',
          'pad':        'foo[bar]baz',
          'expected':   [ 'foo<span style="background-color: blue">[bar]</span>baz',
                          'foo<font style="background-color: blue">[bar]</font>baz' ] }
      ]
    },

    { 'desc':       '[MIDAS] forecolor',
      'command':    'forecolor',
      'tests':      [
        { 'id':         'FC:blue_TEXT-1_SI',
          'rte1-id':    'a-forecolor-0',
          'desc':       'Change the text color',
          'value':      'blue',
          'pad':        'foo[bar]baz',
          'expected':   'foo<font color="blue">[bar]</font>baz' }
      ]
    },

    { 'desc':       '[MIDAS] hilitecolor',
      'command':    'hilitecolor',
      'tests':      [
        { 'id':         'HC:blue_TEXT-1_SI',
          'rte1-id':    'a-hilitecolor-0',
          'desc':       'Change the hilite color',
          'value':      'blue',
          'pad':        'foo[bar]baz',
          'expected':   [ 'foo<span style="background-color: blue">[bar]</span>baz',
                          'foo<font style="background-color: blue">[bar]</font>baz' ] }
      ]
    },

    { 'desc':       '[MIDAS] fontname',
      'command':    'fontname',
      'tests':      [
        { 'id':         'FN:a_TEXT-1_SI',
          'rte1-id':    'a-fontname-0',
          'desc':       'Change the font name',
          'value':      'arial',
          'pad':        'foo[bar]baz',
          'expected':   'foo<font face="arial">[bar]</font>baz' }
      ]
    },

    { 'desc':       '[MIDAS] fontsize',
      'command':    'fontsize',
      'tests':      [
        { 'id':         'FS:2_TEXT-1_SI',
          'rte1-id':    'a-fontsize-0',
          'desc':       'Change the font size to "2"',
          'value':      '2',
          'pad':        'foo[bar]baz',
          'expected':   'foo<font size="2">[bar]</font>baz' },

        { 'id':         'FS:18px_TEXT-1_SI',
          'desc':       'Change the font size to "18px"',
          'value':      '18px',
          'pad':        'foo[bar]baz',
          'expected':   'foo<font size="18px">[bar]</font>baz' },

        { 'id':         'FS:large_TEXT-1_SI',
          'desc':       'Change the font size to "large"',
          'value':      'large',
          'pad':        'foo[bar]baz',
          'expected':   'foo<font size="large">[bar]</font>baz' }
      ]
    },

    { 'desc':       '[MIDAS] increasefontsize',
      'command':    'increasefontsize',
      'tests':      [
        { 'id':         'INCFS:2_TEXT-1_SI',
          'desc':       'Decrease the font size (to small)',
          'pad':        'foo[bar]baz',
          'expected':   [ 'foo<font size="4">[bar]</font>baz',
                          'foo<font size="+1">[bar]</font>baz',
                          'foo<big>[bar]</big>baz' ] }
      ]
    },

    { 'desc':       '[MIDAS] decreasefontsize',
      'command':    'decreasefontsize',
      'tests':      [
        { 'id':         'DECFS:2_TEXT-1_SI',
          'rte1-id':    'a-decreasefontsize-0',
          'desc':       'Decrease the font size (to small)',
          'pad':        'foo[bar]baz',
          'expected':   [ 'foo<font size="2">[bar]</font>baz',
                          'foo<font size="-1">[bar]</font>baz',
                          'foo<small>[bar]</small>baz' ] }
      ]
    },

    { 'desc':       '[MIDAS] indent (note: accept the de-facto standard indent of 40px)',
      'command':    'indent',
      'tests':      [
        { 'id':         'IND_TEXT-1_SI',
          'rte1-id':    'a-indent-0',
          'desc':       'Indent the text (accept the de-facto standard of 40px indent)',
          'pad':        'foo[bar]baz',
          'checkAttrs': False,
          'expected':   [ '<blockquote>foo[bar]baz</blockquote>',
                          '<div style="margin-left: 40px">foo[bar]baz</div>' ],
          'div': {
            'accOuter': '<div contenteditable="true" style="margin-left: 40px">foo[bar]baz</div>' } }
      ]
    },

    { 'desc':       '[MIDAS] outdent (-> unapply tests)',
      'command':    'outdent',
      'tests':      [
      ]
    },

    { 'desc':       '[MIDAS] justifycenter',
      'command':    'justifycenter',
      'tests':      [
        { 'id':         'JC_TEXT-1_SC',
          'rte1-id':    'a-justifycenter-0',
          'desc':       'justify the text centrally',
          'pad':        'foo^bar',
          'expected':   [ '<center>foo^bar</center>',
                          '<p align="center">foo^bar</p>',
                          '<p align="middle">foo^bar</p>',
                          '<div align="center">foo^bar</div>',
                          '<div align="middle">foo^bar</div>' ],
          'div': {
            'accOuter': [ '<div align="center" contenteditable="true">foo^bar</div>',
                          '<div align="middle" contenteditable="true">foo^bar</div>' ] } }
      ]
    },

    { 'desc':       '[MIDAS] justifyfull',
      'command':    'justifyfull',
      'tests':      [
        { 'id':         'JF_TEXT-1_SC',
          'rte1-id':    'a-justifyfull-0',
          'desc':       'justify the text fully',
          'pad':        'foo^bar',
          'expected':   [ '<p align="justify">foo^bar</p>',
                          '<div align="justify">foo^bar</div>' ],
          'div': {
            'accOuter': '<div align="justify" contenteditable="true">foo^bar</div>' } }
      ]
    },

    { 'desc':       '[MIDAS] justifyleft',
      'command':    'justifyleft',
      'tests':      [
        { 'id':         'JL_TEXT-1_SC',
          'rte1-id':    'a-justifyleft-0',
          'desc':       'justify the text left',
          'pad':        'foo^bar',
          'expected':   [ '<p align="left">foo^bar</p>',
                          '<div align="left">foo^bar</div>' ],
          'div': {
            'accOuter': '<div align="left" contenteditable="true">foo^bar</div>' } }
      ]
    },

    { 'desc':       '[MIDAS] justifyright',
      'command':    'justifyright',
      'tests':      [
        { 'id':         'JR_TEXT-1_SC',
          'rte1-id':    'a-justifyright-0',
          'desc':       'justify the text right',
          'pad':        'foo^bar',
          'expected':   [ '<p align="right">foo^bar</p>',
                          '<div align="right">foo^bar</div>' ],
          'div': {
            'accOuter': '<div align="right" contenteditable="true">foo^bar</div>' } }
      ]
    },

    { 'desc':       '[MIDAS] heading',
      'command':    'heading',
      'tests':      [
        { 'id':         'H:H1_TEXT-1_SC',
          'desc':       'create a heading from the paragraph that contains the selection',
          'value':      'h1',
          'pad':        'foo[bar]baz',
          'expected':   '<h1>foo[bar]baz</h1>' }
      ]
    },


    { 'desc':       '[Other] createbookmark',
      'command':    'createbookmark',
      'tests':      [
        { 'id':         'CB:name_TEXT-1_SI',
          'rte1-id':    'a-createbookmark-0',
          'desc':       'create a bookmark (named link) around selection',
          'value':      'created',
          'pad':        'foo[bar]baz',
          'expected':   'foo<a name="created">[bar]</a>baz' }
      ]
    }
  ]
}