File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
tests/phpunit/tests/html-api Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -1098,4 +1098,38 @@ public function test_deep_nesting_fails_process_without_error() {
10981098 }
10991099 $ this ->assertSame ( WP_HTML_Processor::MAX_BOOKMARKS , $ reached_tokens );
11001100 }
1101+
1102+ /**
1103+ * @ticket TBD
1104+ *
1105+ * @expectedIncorrectUsage WP_HTML_Tag_Processor::set_bookmark
1106+ */
1107+ public function test_deep_nesting_fails_processing_virtual_tokens_without_error () {
1108+ $ html = str_repeat ( '<table><td> ' , WP_HTML_Processor::MAX_BOOKMARKS );
1109+ $ processor = WP_HTML_Processor::create_fragment ( $ html );
1110+
1111+ // The fragment parser starts with a few context tokens already bookmarked.
1112+ $ reached_tokens = ( fn () => count ( $ this ->bookmarks ) )->call ( $ processor );
1113+ while ( $ processor ->next_token () ) {
1114+ ++$ reached_tokens ;
1115+ }
1116+
1117+ /*
1118+ * This test has some variability depending on how the virtual tokens align.
1119+ * It will produce 1 real, 2 virtual, 1 real.
1120+ *
1121+ * "<table><td><table><td>…" produces:
1122+ * └─TABLE
1123+ * └─TBODY (virtual)
1124+ * └─TR (virtual)
1125+ * └─TD
1126+ * └─TABLE
1127+ * └─TBODY (virtual)
1128+ * └─TR (virtual)
1129+ * └─TD
1130+ * └─…
1131+ */
1132+ $ this ->assertGreaterThanOrEqual ( WP_HTML_Processor::MAX_BOOKMARKS - 1 , $ reached_tokens );
1133+ $ this ->assertLessThanOrEqual ( WP_HTML_Processor::MAX_BOOKMARKS + 1 , $ reached_tokens );
1134+ }
11011135}
You can’t perform that action at this time.
0 commit comments