File tree Expand file tree Collapse file tree
tests/phpunit/tests/html-api Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -147,4 +147,99 @@ public function test_fails_to_reconstruct_formatting_elements() {
147147 $ this ->assertTrue ( $ p ->next_tag ( 'EM ' ), 'Could not find first EM. ' );
148148 $ this ->assertFalse ( $ p ->next_tag ( 'EM ' ), 'Should have aborted before finding second EM as it required reconstructing the first EM. ' );
149149 }
150+
151+ /**
152+ * Ensures that special handling of unsupported tags is cleaned up
153+ * as handling is implemented. Otherwise there's risk of leaving special
154+ * handling (that is never reached) when tag handling is implemented.
155+ *
156+ * @dataProvider data_unsupported_special_in_body_tags
157+ *
158+ * @param string $tag_name Name of the tag to test.
159+ *
160+ * @covers WP_HTML_Processor::step_in_body
161+ */
162+ public function test_step_in_body_fails_on_unsupported_tags ( $ tag_name ) {
163+ $ fragment = WP_HTML_Processor::create_fragment ( '< ' . $ tag_name . '> ' );
164+ $ this ->assertFalse ( $ fragment ->next_tag (), 'Should fail to find tag: ' . $ tag_name . '. ' );
165+ $ this ->assertEquals ( $ fragment ->get_last_error (), WP_HTML_Processor::ERROR_UNSUPPORTED , 'Should have unsupported last error. ' );
166+ }
167+
168+ /**
169+ * Data provider.
170+ *
171+ * @return array[]
172+ */
173+ public function data_unsupported_special_in_body_tags () {
174+ return array (
175+ array ( 'APPLET ' ),
176+ array ( 'AREA ' ),
177+ array ( 'BASE ' ),
178+ array ( 'BASEFONT ' ),
179+ array ( 'BGSOUND ' ),
180+ array ( 'BODY ' ),
181+ array ( 'BR ' ),
182+ array ( 'CAPTION ' ),
183+ array ( 'COL ' ),
184+ array ( 'COLGROUP ' ),
185+ array ( 'DD ' ),
186+ array ( 'DT ' ),
187+ array ( 'EMBED ' ),
188+ array ( 'FORM ' ),
189+ array ( 'FRAME ' ),
190+ array ( 'FRAMESET ' ),
191+ array ( 'H1 ' ),
192+ array ( 'H2 ' ),
193+ array ( 'H3 ' ),
194+ array ( 'H4 ' ),
195+ array ( 'H5 ' ),
196+ array ( 'H6 ' ),
197+ array ( 'HEAD ' ),
198+ array ( 'HR ' ),
199+ array ( 'HTML ' ),
200+ array ( 'IFRAME ' ),
201+ array ( 'INPUT ' ),
202+ array ( 'KEYGEN ' ),
203+ array ( 'LI ' ),
204+ array ( 'LINK ' ),
205+ array ( 'LISTING ' ),
206+ array ( 'MARQUEE ' ),
207+ array ( 'MATH ' ),
208+ array ( 'META ' ),
209+ array ( 'NOBR ' ),
210+ array ( 'NOEMBED ' ),
211+ array ( 'NOFRAMES ' ),
212+ array ( 'NOSCRIPT ' ),
213+ array ( 'OBJECT ' ),
214+ array ( 'OL ' ),
215+ array ( 'OPTGROUP ' ),
216+ array ( 'OPTION ' ),
217+ array ( 'PARAM ' ),
218+ array ( 'PLAINTEXT ' ),
219+ array ( 'PRE ' ),
220+ array ( 'RB ' ),
221+ array ( 'RP ' ),
222+ array ( 'RT ' ),
223+ array ( 'RTC ' ),
224+ array ( 'SCRIPT ' ),
225+ array ( 'SELECT ' ),
226+ array ( 'SOURCE ' ),
227+ array ( 'STYLE ' ),
228+ array ( 'SVG ' ),
229+ array ( 'TABLE ' ),
230+ array ( 'TBODY ' ),
231+ array ( 'TD ' ),
232+ array ( 'TEMPLATE ' ),
233+ array ( 'TEXTAREA ' ),
234+ array ( 'TFOOT ' ),
235+ array ( 'TH ' ),
236+ array ( 'THEAD ' ),
237+ array ( 'TITLE ' ),
238+ array ( 'TR ' ),
239+ array ( 'TRACK ' ),
240+ array ( 'UL ' ),
241+ array ( 'WBR ' ),
242+ array ( 'XMP ' ),
243+ );
244+ }
150245}
You can’t perform that action at this time.
0 commit comments