1
1
<?php
2
2
/**
3
3
* Unit tests covering WP_HTML_Processor compliance with HTML5 semantic parsing rules
4
- * for the LI list item element .
4
+ * for the list elements, including DD, DL, DT, LI, OL, and UL .
5
5
*
6
6
* @package WordPress
7
7
* @subpackage HTML-API
@@ -16,6 +16,12 @@ class Tests_HtmlApi_WpHtmlProcessorSemanticRulesListElements extends WP_UnitTest
16
16
/*******************************************************************
17
17
* RULES FOR "IN BODY" MODE
18
18
*******************************************************************/
19
+
20
+ /**
21
+ * Ensures that an opening LI element implicitly closes an open LI element.
22
+ *
23
+ * @ticket 60215
24
+ */
19
25
public function test_in_body_li_closes_open_li () {
20
26
$ processor = WP_HTML_Processor::create_fragment ( '<li><li><li target> ' );
21
27
@@ -38,6 +44,11 @@ public function test_in_body_li_closes_open_li() {
38
44
);
39
45
}
40
46
47
+ /**
48
+ * Ensures that an opening LI element implicitly closes other open elements with optional closing tags.
49
+ *
50
+ * @ticket 60215
51
+ */
41
52
public function test_in_body_li_generates_implied_end_tags_inside_open_li () {
42
53
$ processor = WP_HTML_Processor::create_fragment ( '<li><li><div><li target> ' );
43
54
@@ -60,6 +71,11 @@ public function test_in_body_li_generates_implied_end_tags_inside_open_li() {
60
71
);
61
72
}
62
73
74
+ /**
75
+ * Ensures that when closing tags with optional tag closers, an opening LI tag doesn't close beyond a special boundary.
76
+ *
77
+ * @ticket 60215
78
+ */
63
79
public function test_in_body_li_generates_implied_end_tags_inside_open_li_but_stopping_at_special_tags () {
64
80
$ processor = WP_HTML_Processor::create_fragment ( '<li><li><blockquote><li target> ' );
65
81
@@ -82,6 +98,11 @@ public function test_in_body_li_generates_implied_end_tags_inside_open_li_but_st
82
98
);
83
99
}
84
100
101
+ /**
102
+ * Ensures that an opening LI closes an open P in button scope.
103
+ *
104
+ * @ticket 60215
105
+ */
85
106
public function test_in_body_li_in_li_closes_p_in_button_scope () {
86
107
$ processor = WP_HTML_Processor::create_fragment ( '<li><li><p><button><p><li target> ' );
87
108
@@ -104,6 +125,13 @@ public function test_in_body_li_in_li_closes_p_in_button_scope() {
104
125
);
105
126
}
106
127
128
+ /**
129
+ * Ensures that an opening DD closes an open DD element.
130
+ *
131
+ * Note that a DD closes an open DD and also an open DT.
132
+ *
133
+ * @ticket 60215
134
+ */
107
135
public function test_in_body_dd_closes_open_dd () {
108
136
$ processor = WP_HTML_Processor::create_fragment ( '<dd><dd><dd target> ' );
109
137
@@ -126,6 +154,13 @@ public function test_in_body_dd_closes_open_dd() {
126
154
);
127
155
}
128
156
157
+ /**
158
+ * Ensures that an opening DD closes an open DT element.
159
+ *
160
+ * Note that a DD closes an open DD and also an open DT.
161
+ *
162
+ * @ticket 60215
163
+ */
129
164
public function test_in_body_dd_closes_open_dt () {
130
165
$ processor = WP_HTML_Processor::create_fragment ( '<dt><dt><dd target> ' );
131
166
@@ -148,7 +183,12 @@ public function test_in_body_dd_closes_open_dt() {
148
183
);
149
184
}
150
185
151
- public function test_in_body_dd_generates_impdded_end_tags_inside_open_dd () {
186
+ /**
187
+ * Ensures that an opening DD implicitly closes open elements with optional closing tags.
188
+ *
189
+ * @ticket 60215
190
+ */
191
+ public function test_in_body_dd_generates_implied_end_tags_inside_open_dd () {
152
192
$ processor = WP_HTML_Processor::create_fragment ( '<dd><dd><div><dd target> ' );
153
193
154
194
while (
@@ -170,7 +210,13 @@ public function test_in_body_dd_generates_impdded_end_tags_inside_open_dd() {
170
210
);
171
211
}
172
212
173
- public function test_in_body_dd_generates_impdded_end_tags_inside_open_dd_but_stopping_at_special_tags () {
213
+ /**
214
+ * Ensures that an opening DD implicitly closes open elements with optional closing tags,
215
+ * but doesn't close beyond a special boundary.
216
+ *
217
+ * @ticket 60215
218
+ */
219
+ public function test_in_body_dd_generates_implied_end_tags_inside_open_dd_but_stopping_at_special_tags () {
174
220
$ processor = WP_HTML_Processor::create_fragment ( '<dd><dd><blockquote><dd target> ' );
175
221
176
222
while (
@@ -192,6 +238,11 @@ public function test_in_body_dd_generates_impdded_end_tags_inside_open_dd_but_st
192
238
);
193
239
}
194
240
241
+ /**
242
+ * Ensures that an opening DD inside a DD closes a P in button scope.
243
+ *
244
+ * @ticket 60215
245
+ */
195
246
public function test_in_body_dd_in_dd_closes_p_in_button_scope () {
196
247
$ processor = WP_HTML_Processor::create_fragment ( '<dd><dd><p><button><p><dd target> ' );
197
248
@@ -214,6 +265,11 @@ public function test_in_body_dd_in_dd_closes_p_in_button_scope() {
214
265
);
215
266
}
216
267
268
+ /**
269
+ * Ensures that an opening DT closes an open DT element.
270
+ *
271
+ * @ticket 60215
272
+ */
217
273
public function test_in_body_dt_closes_open_dt () {
218
274
$ processor = WP_HTML_Processor::create_fragment ( '<dt><dt><dt target> ' );
219
275
@@ -236,6 +292,11 @@ public function test_in_body_dt_closes_open_dt() {
236
292
);
237
293
}
238
294
295
+ /**
296
+ * Ensures that an opening DT closes an open DD.
297
+ *
298
+ * @ticket 60215
299
+ */
239
300
public function test_in_body_dt_closes_open_dd () {
240
301
$ processor = WP_HTML_Processor::create_fragment ( '<dd><dd><dt target> ' );
241
302
@@ -258,7 +319,12 @@ public function test_in_body_dt_closes_open_dd() {
258
319
);
259
320
}
260
321
261
- public function test_in_body_dt_generates_impdted_end_tags_inside_open_dt () {
322
+ /**
323
+ * Ensures that an opening DT implicitly closes open elements with optional closing tags.
324
+ *
325
+ * @ticket 60215
326
+ */
327
+ public function test_in_body_dt_generates_implied_end_tags_inside_open_dt () {
262
328
$ processor = WP_HTML_Processor::create_fragment ( '<dt><dt><div><dt target> ' );
263
329
264
330
while (
@@ -280,7 +346,13 @@ public function test_in_body_dt_generates_impdted_end_tags_inside_open_dt() {
280
346
);
281
347
}
282
348
283
- public function test_in_body_dt_generates_impdted_end_tags_inside_open_dt_but_stopping_at_special_tags () {
349
+ /**
350
+ * Ensures that an opening DT implicitly closes open elements with optional closing tags,
351
+ * but doesn't close beyond a special boundary.
352
+ *
353
+ * @ticket 60215
354
+ */
355
+ public function test_in_body_dt_generates_implied_end_tags_inside_open_dt_but_stopping_at_special_tags () {
284
356
$ processor = WP_HTML_Processor::create_fragment ( '<dt><dt><blockquote><dt target> ' );
285
357
286
358
while (
@@ -302,6 +374,11 @@ public function test_in_body_dt_generates_impdted_end_tags_inside_open_dt_but_st
302
374
);
303
375
}
304
376
377
+ /**
378
+ * Ensures that an opening DT inside a DT closes a P in button scope.
379
+ *
380
+ * @ticket 60215
381
+ */
305
382
public function test_in_body_dt_in_dt_closes_p_in_button_scope () {
306
383
$ processor = WP_HTML_Processor::create_fragment ( '<dt><dt><p><button><p><dt target> ' );
307
384
@@ -324,6 +401,12 @@ public function test_in_body_dt_in_dt_closes_p_in_button_scope() {
324
401
);
325
402
}
326
403
404
+ /**
405
+ * Ensures that an unexpected LI doesn't close more elements than it should, that it doesn't
406
+ * close open LI elements that are beyond a special element (in this case, the UL).
407
+ *
408
+ * @ticket 60215
409
+ */
327
410
public function test_unexpected_li_close_tag_is_properly_contained () {
328
411
$ processor = WP_HTML_Processor::create_fragment ( '<ul><li><ul></li><li target>a</li></ul></li></ul> ' );
329
412
0 commit comments