- Timestamp:
- 08/08/2024 07:23:53 AM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/html-api/wpHtmlTagProcessor-token-scanning.php
r58779 r58867 514 514 515 515 /** 516 * Ensures that basic CDATA sections inside foreign content are detected. 517 * 518 * @ticket 61576 519 */ 520 public function test_basic_cdata_in_foreign_content() { 521 $processor = new WP_HTML_Tag_Processor( '<svg><![CDATA[this is >> real CDATA]]></svg>' ); 522 $processor->next_token(); 523 524 // Artificially change namespace; this should be done in the HTML Processor. 525 $processor->change_parsing_namespace( 'svg' ); 526 $processor->next_token(); 527 528 $this->assertSame( 529 '#cdata-section', 530 $processor->get_token_name(), 531 "Should have found a CDATA section but found {$processor->get_token_name()} instead." 532 ); 533 534 $this->assertNull( 535 $processor->get_tag(), 536 'Should not have been able to query tag name on non-element token.' 537 ); 538 539 $this->assertNull( 540 $processor->get_attribute( 'type' ), 541 'Should not have been able to query attributes on non-element token.' 542 ); 543 544 $this->assertSame( 545 'this is >> real CDATA', 546 $processor->get_modifiable_text(), 547 'Found incorrect modifiable text.' 548 ); 549 } 550 551 /** 552 * Ensures that empty CDATA sections inside foreign content are detected. 553 * 554 * @ticket 61576 555 */ 556 public function test_empty_cdata_in_foreign_content() { 557 $processor = new WP_HTML_Tag_Processor( '<svg><![CDATA[]]></svg>' ); 558 $processor->next_token(); 559 560 // Artificially change namespace; this should be done in the HTML Processor. 561 $processor->change_parsing_namespace( 'svg' ); 562 $processor->next_token(); 563 564 $this->assertSame( 565 '#cdata-section', 566 $processor->get_token_name(), 567 "Should have found a CDATA section but found {$processor->get_token_name()} instead." 568 ); 569 570 $this->assertEmpty( 571 $processor->get_modifiable_text(), 572 'Found non-empty modifiable text.' 573 ); 574 } 575 576 /** 516 577 * Ensures that normative Processing Instruction nodes are properly parsed. 517 578 *
Note: See TracChangeset
for help on using the changeset viewer.