@@ -3014,53 +3014,6 @@ protected function parse_markup_fragment( $markup ) {
30143014 return $ dom ;
30153015 }
30163016
3017- /**
3018- * Assert markup is equal after normalizing script tags.
3019- *
3020- * @param string $expected Expected markup.
3021- * @param string $actual Actual markup.
3022- * @param string $message Message.
3023- */
3024- protected function assertEqualMarkup ( $ expected , $ actual , $ message = '' ) {
3025- $ expected_dom = $ this ->parse_markup_fragment ( $ expected );
3026- $ actual_dom = $ this ->parse_markup_fragment ( $ actual );
3027- foreach ( array ( $ expected_dom , $ actual_dom ) as $ dom ) {
3028- $ xpath = new DOMXPath ( $ dom );
3029- /** @var DOMElement $script */
3030-
3031- // Normalize type attribute. When missing, it defaults to text/javascript.
3032- foreach ( $ xpath ->query ( '//script[ not( @type ) ] ' ) as $ script ) {
3033- $ script ->setAttribute ( 'type ' , 'text/javascript ' );
3034- }
3035-
3036- // Normalize script contents to remove CDATA wrapper.
3037- foreach ( $ xpath ->query ( '//script[ contains( text(), "<![CDATA[" ) ] ' ) as $ script ) {
3038- $ script ->textContent = str_replace (
3039- array (
3040- "/* <![CDATA[ */ \n" ,
3041- "\n/* ]]> */ " ,
3042- ),
3043- '' ,
3044- $ script ->textContent
3045- );
3046- }
3047-
3048- // Normalize XHTML-compatible boolean attributes to HTML5 ones.
3049- foreach ( array ( 'async ' , 'defer ' ) as $ attribute ) {
3050- foreach ( iterator_to_array ( $ xpath ->query ( "//script[ @ {$ attribute } = ' {$ attribute }' ] " ) ) as $ script ) {
3051- $ script ->removeAttribute ( $ attribute );
3052- $ script ->setAttributeNode ( $ dom ->createAttribute ( $ attribute ) );
3053- }
3054- }
3055- }
3056-
3057- $ this ->assertEquals (
3058- $ expected_dom ->getElementsByTagName ( 'body ' )->item ( 0 ),
3059- $ actual_dom ->getElementsByTagName ( 'body ' )->item ( 0 ),
3060- $ message
3061- );
3062- }
3063-
30643017 /**
30653018 * Adds html5 script theme support.
30663019 */
0 commit comments