Make WordPress Core

Changeset 60690


Ignore:
Timestamp:
08/29/2025 05:16:50 PM (12 months ago)
Author:
jonsurrell
Message:

Script Loader: Revert sourceURL addition.

It was discovered that these changes cause some issues in the customizer when SCRIPT_DEBUG is false.

Reverts [60685] and [60686].

Developed in https://github.com/WordPress/wordpress-develop/pull/9671

Props jonsurrell, wildworks, tyxla.
See #63887.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-scripts.php

    r60686 r60690  
    222222                        return;
    223223                }
    224 
    225                 $output .= sprintf(
    226                         "\n//# sourceURL=%s",
    227                         rawurlencode( "{$handle}-js-extra" )
    228                 );
    229224
    230225                if ( ! $display ) {
     
    526521                        return '';
    527522                }
    528 
    529                 $data[] = sprintf(
    530                         '//# sourceURL=%s',
    531                         rawurlencode( "{$handle}-js-{$position}" )
    532                 );
    533523
    534524                return trim( implode( "\n", $data ), "\n" );
  • trunk/src/wp-includes/class-wp-styles.php

    r60686 r60690  
    337337                        return false;
    338338                }
    339 
    340                 $output[] = sprintf(
    341                         '/*# sourceURL=%s */',
    342                         rawurlencode( "{$handle}-inline-css" )
    343                 );
    344339
    345340                $output = implode( "\n", $output );
  • trunk/tests/phpunit/tests/blocks/editor.php

    r60686 r60690  
    763763<script id="wp-api-fetch-js-after">
    764764wp.apiFetch.use( wp.apiFetch.createPreloadingMiddleware( {"/test/v0/test-62797":{"body":["Unclosed comment and a script open tag \\u003C!--\\u003Cscript\\u003E"],"headers":{"Allow":"GET"}}} ) );
    765 //# sourceURL=wp-api-fetch-js-after
    766765</script>
    767766
  • trunk/tests/phpunit/tests/dependencies/scripts.php

    r60686 r60690  
    117117        public function test_after_inline_script_with_delayed_main_script( $strategy ) {
    118118                wp_enqueue_script( 'ms-isa-1', 'http://example.org/ms-isa-1.js', array(), null, compact( 'strategy' ) );
    119                 wp_add_inline_script( 'ms-isa-1', 'console.log(\'after one\');', 'after' );
     119                wp_add_inline_script( 'ms-isa-1', 'console.log("after one");', 'after' );
    120120                $output    = get_echo( 'wp_print_scripts' );
    121121                $expected  = "<script type='text/javascript' src='http://example.org/ms-isa-1.js' id='ms-isa-1-js' data-wp-strategy='{$strategy}'></script>\n";
    122122                $expected .= wp_get_inline_script_tag(
    123                         "console.log('after one');\n//# sourceURL=ms-isa-1-js-after",
     123                        'console.log("after one");',
    124124                        array(
    125125                                'id' => 'ms-isa-1-js-after',
     
    144144        public function test_after_inline_script_with_blocking_main_script() {
    145145                wp_enqueue_script( 'ms-insa-3', 'http://example.org/ms-insa-3.js', array(), null );
    146                 wp_add_inline_script( 'ms-insa-3', 'console.log(\'after one\');', 'after' );
     146                wp_add_inline_script( 'ms-insa-3', 'console.log("after one");', 'after' );
    147147                $output = get_echo( 'wp_print_scripts' );
    148148
    149149                $expected  = "<script type='text/javascript' src='http://example.org/ms-insa-3.js' id='ms-insa-3-js'></script>\n";
    150150                $expected .= wp_get_inline_script_tag(
    151                         "console.log('after one');\n//# sourceURL=ms-insa-3-js-after",
     151                        'console.log("after one");',
    152152                        array(
    153153                                'id' => 'ms-insa-3-js-after',
     
    175175        public function test_before_inline_scripts_with_delayed_main_script( $strategy ) {
    176176                wp_enqueue_script( 'ds-i1-1', 'http://example.org/ds-i1-1.js', array(), null, compact( 'strategy' ) );
    177                 wp_add_inline_script( 'ds-i1-1', 'console.log(\'before first\');', 'before' );
     177                wp_add_inline_script( 'ds-i1-1', 'console.log("before first");', 'before' );
    178178                wp_enqueue_script( 'ds-i1-2', 'http://example.org/ds-i1-2.js', array(), null, compact( 'strategy' ) );
    179179                wp_enqueue_script( 'ds-i1-3', 'http://example.org/ds-i1-3.js', array(), null, compact( 'strategy' ) );
    180180                wp_enqueue_script( 'ms-i1-1', 'http://example.org/ms-i1-1.js', array( 'ds-i1-1', 'ds-i1-2', 'ds-i1-3' ), null, compact( 'strategy' ) );
    181                 wp_add_inline_script( 'ms-i1-1', 'console.log(\'before last\');', 'before' );
     181                wp_add_inline_script( 'ms-i1-1', 'console.log("before last");', 'before' );
    182182                $output = get_echo( 'wp_print_scripts' );
    183183
    184184                $expected  = wp_get_inline_script_tag(
    185                         "console.log('before first');\n//# sourceURL=ds-i1-1-js-before",
     185                        'console.log("before first");',
    186186                        array(
    187187                                'id' => 'ds-i1-1-js-before',
     
    192192                $expected .= "<script type='text/javascript' src='http://example.org/ds-i1-3.js' id='ds-i1-3-js' {$strategy}='{$strategy}' data-wp-strategy='{$strategy}'></script>\n";
    193193                $expected .= wp_get_inline_script_tag(
    194                         "console.log('before last');\n//# sourceURL=ms-i1-1-js-before",
     194                        'console.log("before last");',
    195195                        array(
    196196                                'id'   => 'ms-i1-1-js-before',
     
    514514/* <![CDATA[ */
    515515scriptEventLog.push( "blocking-not-async-without-dependency: before inline" )
    516 //# sourceURL=blocking-not-async-without-dependency-js-before
    517516/* ]]> */
    518517</script>
     
    521520/* <![CDATA[ */
    522521scriptEventLog.push( "blocking-not-async-without-dependency: after inline" )
    523 //# sourceURL=blocking-not-async-without-dependency-js-after
    524522/* ]]> */
    525523</script>
     
    527525/* <![CDATA[ */
    528526scriptEventLog.push( "async-with-blocking-dependency: before inline" )
    529 //# sourceURL=async-with-blocking-dependency-js-before
    530527/* ]]> */
    531528</script>
     
    534531/* <![CDATA[ */
    535532scriptEventLog.push( "async-with-blocking-dependency: after inline" )
    536 //# sourceURL=async-with-blocking-dependency-js-after
    537533/* ]]> */
    538534</script>
     
    563559/* <![CDATA[ */
    564560scriptEventLog.push( "async-no-dependency: before inline" )
    565 //# sourceURL=async-no-dependency-js-before
    566561/* ]]> */
    567562</script>
     
    570565/* <![CDATA[ */
    571566scriptEventLog.push( "async-no-dependency: after inline" )
    572 //# sourceURL=async-no-dependency-js-after
    573567/* ]]> */
    574568</script>
     
    576570/* <![CDATA[ */
    577571scriptEventLog.push( "async-one-async-dependency: before inline" )
    578 //# sourceURL=async-one-async-dependency-js-before
    579572/* ]]> */
    580573</script>
     
    583576/* <![CDATA[ */
    584577scriptEventLog.push( "async-one-async-dependency: after inline" )
    585 //# sourceURL=async-one-async-dependency-js-after
    586578/* ]]> */
    587579</script>
     
    589581/* <![CDATA[ */
    590582scriptEventLog.push( "async-two-async-dependencies: before inline" )
    591 //# sourceURL=async-two-async-dependencies-js-before
    592583/* ]]> */
    593584</script>
     
    596587/* <![CDATA[ */
    597588scriptEventLog.push( "async-two-async-dependencies: after inline" )
    598 //# sourceURL=async-two-async-dependencies-js-after
    599589/* ]]> */
    600590</script>
     
    617607/* <![CDATA[ */
    618608scriptEventLog.push( "async-with-blocking-dependent: before inline" )
    619 //# sourceURL=async-with-blocking-dependent-js-before
    620609/* ]]> */
    621610</script>
     
    624613/* <![CDATA[ */
    625614scriptEventLog.push( "async-with-blocking-dependent: after inline" )
    626 //# sourceURL=async-with-blocking-dependent-js-after
    627615/* ]]> */
    628616</script>
     
    630618/* <![CDATA[ */
    631619scriptEventLog.push( "blocking-dependent-of-async: before inline" )
    632 //# sourceURL=blocking-dependent-of-async-js-before
    633620/* ]]> */
    634621</script>
     
    637624/* <![CDATA[ */
    638625scriptEventLog.push( "blocking-dependent-of-async: after inline" )
    639 //# sourceURL=blocking-dependent-of-async-js-after
    640626/* ]]> */
    641627</script>
     
    658644/* <![CDATA[ */
    659645scriptEventLog.push( "async-with-defer-dependent: before inline" )
    660 //# sourceURL=async-with-defer-dependent-js-before
    661646/* ]]> */
    662647</script>
     
    665650/* <![CDATA[ */
    666651scriptEventLog.push( "async-with-defer-dependent: after inline" )
    667 //# sourceURL=async-with-defer-dependent-js-after
    668652/* ]]> */
    669653</script>
     
    671655/* <![CDATA[ */
    672656scriptEventLog.push( "defer-dependent-of-async: before inline" )
    673 //# sourceURL=defer-dependent-of-async-js-before
    674657/* ]]> */
    675658</script>
     
    678661/* <![CDATA[ */
    679662scriptEventLog.push( "defer-dependent-of-async: after inline" )
    680 //# sourceURL=defer-dependent-of-async-js-after
    681663/* ]]> */
    682664</script>
     
    702684/* <![CDATA[ */
    703685scriptEventLog.push( "blocking-bundle-of-none: before inline" )
    704 //# sourceURL=blocking-bundle-of-none-js-before
    705686/* ]]> */
    706687</script>
     
    708689/* <![CDATA[ */
    709690scriptEventLog.push( "blocking-bundle-of-none: after inline" )
    710 //# sourceURL=blocking-bundle-of-none-js-after
    711691/* ]]> */
    712692</script>
     
    714694/* <![CDATA[ */
    715695scriptEventLog.push( "defer-dependent-of-blocking-bundle-of-none: before inline" )
    716 //# sourceURL=defer-dependent-of-blocking-bundle-of-none-js-before
    717696/* ]]> */
    718697</script>
     
    721700/* <![CDATA[ */
    722701scriptEventLog.push( "defer-dependent-of-blocking-bundle-of-none: after inline" )
    723 //# sourceURL=defer-dependent-of-blocking-bundle-of-none-js-after
    724702/* ]]> */
    725703</script>
     
    748726/* <![CDATA[ */
    749727scriptEventLog.push( "blocking-bundle-member-one: before inline" )
    750 //# sourceURL=blocking-bundle-member-one-js-before
    751728/* ]]> */
    752729</script>
     
    755732/* <![CDATA[ */
    756733scriptEventLog.push( "blocking-bundle-member-one: after inline" )
    757 //# sourceURL=blocking-bundle-member-one-js-after
    758734/* ]]> */
    759735</script>
     
    761737/* <![CDATA[ */
    762738scriptEventLog.push( "blocking-bundle-member-two: before inline" )
    763 //# sourceURL=blocking-bundle-member-two-js-before
    764739/* ]]> */
    765740</script>
     
    768743/* <![CDATA[ */
    769744scriptEventLog.push( "blocking-bundle-member-two: after inline" )
    770 //# sourceURL=blocking-bundle-member-two-js-after
    771745/* ]]> */
    772746</script>
     
    774748/* <![CDATA[ */
    775749scriptEventLog.push( "defer-dependent-of-blocking-bundle-of-two: before inline" )
    776 //# sourceURL=defer-dependent-of-blocking-bundle-of-two-js-before
    777750/* ]]> */
    778751</script>
     
    781754/* <![CDATA[ */
    782755scriptEventLog.push( "defer-dependent-of-blocking-bundle-of-two: after inline" )
    783 //# sourceURL=defer-dependent-of-blocking-bundle-of-two-js-after
    784756/* ]]> */
    785757</script>
     
    807779/* <![CDATA[ */
    808780scriptEventLog.push( "defer-bundle-of-none: before inline" )
    809 //# sourceURL=defer-bundle-of-none-js-before
    810781/* ]]> */
    811782</script>
     
    813784/* <![CDATA[ */
    814785scriptEventLog.push( "defer-bundle-of-none: after inline" )
    815 //# sourceURL=defer-bundle-of-none-js-after
    816786/* ]]> */
    817787</script>
     
    819789/* <![CDATA[ */
    820790scriptEventLog.push( "defer-dependent-of-defer-bundle-of-none: before inline" )
    821 //# sourceURL=defer-dependent-of-defer-bundle-of-none-js-before
    822791/* ]]> */
    823792</script>
     
    826795/* <![CDATA[ */
    827796scriptEventLog.push( "defer-dependent-of-defer-bundle-of-none: after inline" )
    828 //# sourceURL=defer-dependent-of-defer-bundle-of-none-js-after
    829797/* ]]> */
    830798</script>
     
    850818/* <![CDATA[ */
    851819scriptEventLog.push( "blocking-dependency-with-defer-following-dependency: before inline" )
    852 //# sourceURL=blocking-dependency-with-defer-following-dependency-js-before
    853820/* ]]> */
    854821</script>
     
    857824/* <![CDATA[ */
    858825scriptEventLog.push( "blocking-dependency-with-defer-following-dependency: after inline" )
    859 //# sourceURL=blocking-dependency-with-defer-following-dependency-js-after
    860826/* ]]> */
    861827</script>
     
    863829/* <![CDATA[ */
    864830scriptEventLog.push( "defer-dependency-with-blocking-preceding-dependency: before inline" )
    865 //# sourceURL=defer-dependency-with-blocking-preceding-dependency-js-before
    866831/* ]]> */
    867832</script>
     
    870835/* <![CDATA[ */
    871836scriptEventLog.push( "defer-dependency-with-blocking-preceding-dependency: after inline" )
    872 //# sourceURL=defer-dependency-with-blocking-preceding-dependency-js-after
    873837/* ]]> */
    874838</script>
     
    876840/* <![CDATA[ */
    877841scriptEventLog.push( "defer-dependent-of-blocking-and-defer-dependencies: before inline" )
    878 //# sourceURL=defer-dependent-of-blocking-and-defer-dependencies-js-before
    879842/* ]]> */
    880843</script>
     
    883846/* <![CDATA[ */
    884847scriptEventLog.push( "defer-dependent-of-blocking-and-defer-dependencies: after inline" )
    885 //# sourceURL=defer-dependent-of-blocking-and-defer-dependencies-js-after
    886848/* ]]> */
    887849</script>
     
    907869/* <![CDATA[ */
    908870scriptEventLog.push( "defer-dependency-with-blocking-following-dependency: before inline" )
    909 //# sourceURL=defer-dependency-with-blocking-following-dependency-js-before
    910871/* ]]> */
    911872</script>
     
    914875/* <![CDATA[ */
    915876scriptEventLog.push( "defer-dependency-with-blocking-following-dependency: after inline" )
    916 //# sourceURL=defer-dependency-with-blocking-following-dependency-js-after
    917877/* ]]> */
    918878</script>
     
    920880/* <![CDATA[ */
    921881scriptEventLog.push( "blocking-dependency-with-defer-preceding-dependency: before inline" )
    922 //# sourceURL=blocking-dependency-with-defer-preceding-dependency-js-before
    923882/* ]]> */
    924883</script>
     
    927886/* <![CDATA[ */
    928887scriptEventLog.push( "blocking-dependency-with-defer-preceding-dependency: after inline" )
    929 //# sourceURL=blocking-dependency-with-defer-preceding-dependency-js-after
    930888/* ]]> */
    931889</script>
     
    933891/* <![CDATA[ */
    934892scriptEventLog.push( "defer-dependent-of-defer-and-blocking-dependencies: before inline" )
    935 //# sourceURL=defer-dependent-of-defer-and-blocking-dependencies-js-before
    936893/* ]]> */
    937894</script>
     
    940897/* <![CDATA[ */
    941898scriptEventLog.push( "defer-dependent-of-defer-and-blocking-dependencies: after inline" )
    942 //# sourceURL=defer-dependent-of-defer-and-blocking-dependencies-js-after
    943899/* ]]> */
    944900</script>
     
    961917/* <![CDATA[ */
    962918scriptEventLog.push( "defer-with-async-dependent: before inline" )
    963 //# sourceURL=defer-with-async-dependent-js-before
    964919/* ]]> */
    965920</script>
     
    968923/* <![CDATA[ */
    969924scriptEventLog.push( "defer-with-async-dependent: after inline" )
    970 //# sourceURL=defer-with-async-dependent-js-after
    971925/* ]]> */
    972926</script>
     
    974928/* <![CDATA[ */
    975929scriptEventLog.push( "async-dependent-of-defer: before inline" )
    976 //# sourceURL=async-dependent-of-defer-js-before
    977930/* ]]> */
    978931</script>
     
    981934/* <![CDATA[ */
    982935scriptEventLog.push( "async-dependent-of-defer: after inline" )
    983 //# sourceURL=async-dependent-of-defer-js-after
    984936/* ]]> */
    985937</script>
     
    998950/* <![CDATA[ */
    999951scriptEventLog.push( "defer-with-before-inline: before inline" )
    1000 //# sourceURL=defer-with-before-inline-js-before
    1001952/* ]]> */
    1002953</script>
     
    1017968/* <![CDATA[ */
    1018969scriptEventLog.push( "defer-with-after-inline: after inline" )
    1019 //# sourceURL=defer-with-after-inline-js-after
    1020970/* ]]> */
    1021971</script>
     
    10651015/* <![CDATA[ */
    10661016scriptEventLog.push( "defer-dependent-of-nested-aliases: before inline" )
    1067 //# sourceURL=defer-dependent-of-nested-aliases-js-before
    10681017/* ]]> */
    10691018</script>
     
    10721021/* <![CDATA[ */
    10731022scriptEventLog.push( "defer-dependent-of-nested-aliases: after inline" )
    1074 //# sourceURL=defer-dependent-of-nested-aliases-js-after
    10751023/* ]]> */
    10761024</script>
     
    16711619                wp_enqueue_script( 'test-only-data', 'example.com', array(), null );
    16721620                wp_script_add_data( 'test-only-data', 'data', 'testing' );
    1673                 $expected  = "<script type='text/javascript' id='test-only-data-js-extra'>\n/* <![CDATA[ */\ntesting\n//# sourceURL=test-only-data-js-extra\n/* ]]> */\n</script>\n";
     1621                $expected  = "<script type='text/javascript' id='test-only-data-js-extra'>\n/* <![CDATA[ */\ntesting\n/* ]]> */\n</script>\n";
    16741622                $expected .= "<script type='text/javascript' src='http://example.com' id='test-only-data-js'></script>\n";
    16751623
     
    17091657                wp_script_add_data( 'test-conditional-with-data', 'data', 'testing' );
    17101658                wp_script_add_data( 'test-conditional-with-data', 'conditional', 'lt IE 9' );
    1711                 $expected  = "<!--[if lt IE 9]>\n<script type='text/javascript' id='test-conditional-with-data-js-extra'>\n/* <![CDATA[ */\ntesting\n//# sourceURL=test-conditional-with-data-js-extra\n/* ]]> */\n</script>\n<![endif]-->\n";
     1659                $expected  = "<!--[if lt IE 9]>\n<script type='text/javascript' id='test-conditional-with-data-js-extra'>\n/* <![CDATA[ */\ntesting\n/* ]]> */\n</script>\n<![endif]-->\n";
    17121660                $expected .= "<!--[if lt IE 9]>\n<script type='text/javascript' src='http://example.com' id='test-conditional-with-data-js'></script>\n<![endif]-->\n";
    17131661                $expected  = str_replace( "'", '"', $expected );
     
    19331881/* <![CDATA[ */
    19341882console.log("before");
    1935 //# sourceURL=test-example-js-before
    19361883/* ]]> */
    19371884</script>
     
    19541901/* <![CDATA[ */
    19551902console.log("after");
    1956 //# sourceURL=test-example-js-after
    19571903/* ]]> */
    19581904</script>
     
    19701916                wp_add_inline_script( 'test-example', 'console.log("after");' );
    19711917
    1972                 $expected  = "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n//# sourceURL=test-example-js-before\n/* ]]> */\n</script>\n";
     1918                $expected  = "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n/* ]]> */\n</script>\n";
    19731919                $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
    1974                 $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n//# sourceURL=test-example-js-after\n/* ]]> */\n</script>\n";
     1920                $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n/* ]]> */\n</script>\n";
    19751921
    19761922                $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) );
     
    19851931                wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
    19861932
    1987                 $expected = "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n//# sourceURL=test-example-js-before\n/* ]]> */\n</script>\n";
     1933                $expected = "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n/* ]]> */\n</script>\n";
    19881934
    19891935                $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) );
     
    19981944                wp_add_inline_script( 'test-example', 'console.log("after");' );
    19991945
    2000                 $expected = "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n//# sourceURL=test-example-js-after\n/* ]]> */\n</script>\n";
     1946                $expected = "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n/* ]]> */\n</script>\n";
    20011947
    20021948                $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) );
     
    20121958                wp_add_inline_script( 'test-example', 'console.log("after");' );
    20131959
    2014                 $expected  = "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n//# sourceURL=test-example-js-before\n/* ]]> */\n</script>\n";
    2015                 $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n//# sourceURL=test-example-js-after\n/* ]]> */\n</script>\n";
     1960                $expected  = "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n/* ]]> */\n</script>\n";
     1961                $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n/* ]]> */\n</script>\n";
    20161962
    20171963                $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) );
     
    20281974                wp_add_inline_script( 'test-example', 'console.log("after");' );
    20291975
    2030                 $expected  = "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\nconsole.log(\"before\");\n//# sourceURL=test-example-js-before\n/* ]]> */\n</script>\n";
     1976                $expected  = "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\nconsole.log(\"before\");\n/* ]]> */\n</script>\n";
    20311977                $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
    2032                 $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\nconsole.log(\"after\");\n//# sourceURL=test-example-js-after\n/* ]]> */\n</script>\n";
     1978                $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\nconsole.log(\"after\");\n/* ]]> */\n</script>\n";
    20331979
    20341980                $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) );
     
    20441990                wp_add_inline_script( 'test-example', 'console.log("after");' );
    20451991
    2046                 $expected  = "<script type='text/javascript' id='test-example-js-extra'>\n/* <![CDATA[ */\nvar testExample = {\"foo\":\"bar\"};\n//# sourceURL=test-example-js-extra\n/* ]]> */\n</script>\n";
    2047                 $expected .= "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n//# sourceURL=test-example-js-before\n/* ]]> */\n</script>\n";
     1992                $expected  = "<script type='text/javascript' id='test-example-js-extra'>\n/* <![CDATA[ */\nvar testExample = {\"foo\":\"bar\"};\n/* ]]> */\n</script>\n";
     1993                $expected .= "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n/* ]]> */\n</script>\n";
    20481994                $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
    2049                 $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n//# sourceURL=test-example-js-after\n/* ]]> */\n</script>\n";
     1995                $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n/* ]]> */\n</script>\n";
    20501996
    20511997                $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) );
     
    20682014                wp_add_inline_script( 'two', 'console.log("before two");', 'before' );
    20692015
    2070                 $expected  = "<script type='text/javascript' id='one-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before one\");\n//# sourceURL=one-js-before\n/* ]]> */\n</script>\n";
     2016                $expected  = "<script type='text/javascript' id='one-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before one\");\n/* ]]> */\n</script>\n";
    20712017                $expected .= "<script type='text/javascript' src='{$this->default_scripts_dir}one.js?ver={$wp_version}' id='one-js'></script>\n";
    2072                 $expected .= "<script type='text/javascript' id='two-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before two\");\n//# sourceURL=two-js-before\n/* ]]> */\n</script>\n";
     2018                $expected .= "<script type='text/javascript' id='two-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before two\");\n/* ]]> */\n</script>\n";
    20732019                $expected .= "<script type='text/javascript' src='{$this->default_scripts_dir}two.js?ver={$wp_version}' id='two-js'></script>\n";
    20742020                $expected .= "<script type='text/javascript' src='{$this->default_scripts_dir}three.js?ver={$wp_version}' id='three-js'></script>\n";
     
    20922038                wp_add_inline_script( 'one', 'console.log("before one");', 'before' );
    20932039
    2094                 $expected  = "<script type='text/javascript' id='one-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before one\");\n//# sourceURL=one-js-before\n/* ]]> */\n</script>\n";
     2040                $expected  = "<script type='text/javascript' id='one-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before one\");\n/* ]]> */\n</script>\n";
    20952041                $expected .= "<script type='text/javascript' src='{$this->default_scripts_dir}one.js?ver={$wp_version}' id='one-js'></script>\n";
    20962042                $expected .= "<script type='text/javascript' src='{$this->default_scripts_dir}two.js?ver={$wp_version}' id='two-js'></script>\n";
     
    21192065                $expected  = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&amp;load%5Bchunk_0%5D=one&amp;ver={$wp_version}'></script>\n";
    21202066                $expected .= "<script type='text/javascript' src='{$this->default_scripts_dir}two.js?ver={$wp_version}' id='two-js'></script>\n";
    2121                 $expected .= "<script type='text/javascript' id='two-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after two\");\n//# sourceURL=two-js-after\n/* ]]> */\n</script>\n";
     2067                $expected .= "<script type='text/javascript' id='two-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after two\");\n/* ]]> */\n</script>\n";
    21222068                $expected .= "<script type='text/javascript' src='{$this->default_scripts_dir}three.js?ver={$wp_version}' id='three-js'></script>\n";
    2123                 $expected .= "<script type='text/javascript' id='three-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after three\");\n//# sourceURL=three-js-after\n/* ]]> */\n</script>\n";
     2069                $expected .= "<script type='text/javascript' id='three-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after three\");\n/* ]]> */\n</script>\n";
    21242070                $expected .= "<script type='text/javascript' src='{$this->default_scripts_dir}four.js?ver={$wp_version}' id='four-js'></script>\n";
    21252071
     
    21372083
    21382084                $expected_localized  = "<!--[if gte IE 9]>\n";
    2139                 $expected_localized .= "<script type='text/javascript' id='test-example-js-extra'>\n/* <![CDATA[ */\nvar testExample = {\"foo\":\"bar\"};\n//# sourceURL=test-example-js-extra\n/* ]]> */\n</script>\n";
     2085                $expected_localized .= "<script type='text/javascript' id='test-example-js-extra'>\n/* <![CDATA[ */\nvar testExample = {\"foo\":\"bar\"};\n/* ]]> */\n</script>\n";
    21402086                $expected_localized .= "<![endif]-->\n";
    21412087                $expected_localized  = str_replace( "'", '"', $expected_localized );
    21422088
    21432089                $expected  = "<!--[if gte IE 9]>\n";
    2144                 $expected .= "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n//# sourceURL=test-example-js-before\n/* ]]> */\n</script>\n";
     2090                $expected .= "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n/* ]]> */\n</script>\n";
    21452091                $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
    2146                 $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n//# sourceURL=test-example-js-after\n/* ]]> */\n</script>\n";
     2092                $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n/* ]]> */\n</script>\n";
    21472093                $expected .= "<![endif]-->\n";
    21482094                $expected  = str_replace( "'", '"', $expected );
     
    21722118                $expected  = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&amp;load%5Bchunk_0%5D=jquery-core,jquery-migrate&amp;ver={$wp_version}'></script>\n";
    21732119                $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
    2174                 $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n//# sourceURL=test-example-js-after\n/* ]]> */\n</script>\n";
     2120                $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n/* ]]> */\n</script>\n";
    21752121
    21762122                wp_enqueue_script( 'test-example', 'http://example.com', array( 'jquery' ), null );
     
    21972143                $expected .= "<!--[if gte IE 9]>\n";
    21982144                $expected .= "<script type=\"text/javascript\" src=\"http://example.com\" id=\"test-example-js\"></script>\n";
    2199                 $expected .= "<script type=\"text/javascript\" id=\"test-example-js-after\">\n/* <![CDATA[ */\nconsole.log(\"after\");\n//# sourceURL=test-example-js-after\n/* ]]> */\n</script>\n";
     2145                $expected .= "<script type=\"text/javascript\" id=\"test-example-js-after\">\n/* <![CDATA[ */\nconsole.log(\"after\");\n/* ]]> */\n</script>\n";
    22002146                $expected .= "<![endif]-->\n";
    22012147
     
    22232169
    22242170                $expected  = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&amp;load%5Bchunk_0%5D=jquery-core,jquery-migrate&amp;ver={$wp_version}'></script>\n";
    2225                 $expected .= "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n//# sourceURL=test-example-js-before\n/* ]]> */\n</script>\n";
     2171                $expected .= "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n/* ]]> */\n</script>\n";
    22262172                $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
    22272173
     
    22482194
    22492195                $expected  = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&amp;load%5Bchunk_0%5D=jquery-core,jquery-migrate,wp-dom-ready,wp-hooks&amp;ver={$wp_version}'></script>\n";
    2250                 $expected .= "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n//# sourceURL=test-example-js-before\n/* ]]> */\n</script>\n";
     2196                $expected .= "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n/* ]]> */\n</script>\n";
    22512197                $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
    22522198                $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/i18n.min.js' id='wp-i18n-js'></script>\n";
     
    22542200                $expected .= "/* <![CDATA[ */\n";
    22552201                $expected .= "wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ 'ltr' ] } );\n";
    2256                 $expected .= "//# sourceURL=wp-i18n-js-after\n";
    22572202                $expected .= "/* ]]> */\n";
    22582203                $expected .= "</script>\n";
    22592204                $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/a11y.min.js' id='wp-a11y-js'></script>\n";
    22602205                $expected .= "<script type='text/javascript' src='http://example2.com' id='test-example2-js'></script>\n";
    2261                 $expected .= "<script type='text/javascript' id='test-example2-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n//# sourceURL=test-example2-js-after\n/* ]]> */\n</script>\n";
     2206                $expected .= "<script type='text/javascript' id='test-example2-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n/* ]]> */\n</script>\n";
     2207
    22622208                wp_enqueue_script( 'test-example', 'http://example.com', array( 'jquery' ), null );
    22632209                wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
     
    23032249                $expected_tail .= "/* <![CDATA[ */\n";
    23042250                $expected_tail .= "tryCustomizeDependency()\n";
    2305                 $expected_tail .= "//# sourceURL=customize-dependency-js-after\n";
    23062251                $expected_tail .= "/* ]]> */\n";
    23072252                $expected_tail .= "</script>\n";
     
    23392284
    23402285                $expected  = "<script type='text/javascript' src='/wp-includes/js/script.js?ver={$wp_version}' id='one-js'></script>\n";
    2341                 $expected .= "<script type='text/javascript' id='one-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after one\");\n//# sourceURL=one-js-after\n/* ]]> */\n</script>\n";
     2286                $expected .= "<script type='text/javascript' id='one-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after one\");\n/* ]]> */\n</script>\n";
    23422287                $expected .= "<script type='text/javascript' src='/wp-includes/js/script2.js?ver={$wp_version}' id='two-js'></script>\n";
    23432288                $expected .= "<script type='text/javascript' src='/wp-includes/js/script3.js?ver={$wp_version}' id='three-js'></script>\n";
     
    23632308
    23642309                $expected  = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&amp;load%5Bchunk_0%5D=one,two&amp;ver={$wp_version}'></script>\n";
    2365                 $expected .= "<script type='text/javascript' id='three-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before three\");\n//# sourceURL=three-js-before\n/* ]]> */\n</script>\n";
     2310                $expected .= "<script type='text/javascript' id='three-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before three\");\n/* ]]> */\n</script>\n";
    23662311                $expected .= "<script type='text/javascript' src='/wp-includes/js/script3.js?ver={$wp_version}' id='three-js'></script>\n";
    23672312                $expected .= "<script type='text/javascript' src='/wp-includes/js/script4.js?ver={$wp_version}' id='four-js'></script>\n";
     
    23832328                                ),
    23842329                                'delayed'        => false,
    2385                                 'expected_data'  => "/*before foo 1*/\n//# sourceURL=foo-js-before",
    2386                                 'expected_tag'   => "<script id='foo-js-before' type='text/javascript'>\n/* <![CDATA[ */\n/*before foo 1*/\n//# sourceURL=foo-js-before\n/* ]]> */\n</script>\n",
     2330                                'expected_data'  => '/*before foo 1*/',
     2331                                'expected_tag'   => "<script id='foo-js-before' type='text/javascript'>\n/* <![CDATA[ */\n/*before foo 1*/\n/* ]]> */\n</script>\n",
    23872332                        ),
    23882333                        'after-blocking'  => array(
     
    23932338                                ),
    23942339                                'delayed'        => false,
    2395                                 'expected_data'  => "/*after foo 1*/\n/*after foo 2*/\n//# sourceURL=foo-js-after",
    2396                                 'expected_tag'   => "<script id='foo-js-after' type='text/javascript'>\n/* <![CDATA[ */\n/*after foo 1*/\n/*after foo 2*/\n//# sourceURL=foo-js-after\n/* ]]> */\n</script>\n",
     2340                                'expected_data'  => "/*after foo 1*/\n/*after foo 2*/",
     2341                                'expected_tag'   => "<script id='foo-js-after' type='text/javascript'>\n/* <![CDATA[ */\n/*after foo 1*/\n/*after foo 2*/\n/* ]]> */\n</script>\n",
    23972342                        ),
    23982343                        'before-delayed'  => array(
     
    24022347                                ),
    24032348                                'delayed'        => true,
    2404                                 'expected_data'  => "/*before foo 1*/\n//# sourceURL=foo-js-before",
    2405                                 'expected_tag'   => "<script id='foo-js-before' type='text/javascript'>\n/* <![CDATA[ */\n/*before foo 1*/\n//# sourceURL=foo-js-before\n/* ]]> */\n</script>\n",
     2349                                'expected_data'  => '/*before foo 1*/',
     2350                                'expected_tag'   => "<script id='foo-js-before' type='text/javascript'>\n/* <![CDATA[ */\n/*before foo 1*/\n/* ]]> */\n</script>\n",
    24062351                        ),
    24072352                        'after-delayed'   => array(
     
    24122357                                ),
    24132358                                'delayed'        => true,
    2414                                 'expected_data'  => "/*after foo 1*/\n/*after foo 2*/\n//# sourceURL=foo-js-after",
    2415                                 'expected_tag'   => "<script id='foo-js-after' type='text/javascript'>\n/* <![CDATA[ */\n/*after foo 1*/\n/*after foo 2*/\n//# sourceURL=foo-js-after\n/* ]]> */\n</script>\n",
     2359                                'expected_data'  => "/*after foo 1*/\n/*after foo 2*/",
     2360                                'expected_tag'   => "<script id='foo-js-after' type='text/javascript'>\n/* <![CDATA[ */\n/*after foo 1*/\n/*after foo 2*/\n/* ]]> */\n</script>\n",
    24162361                        ),
    24172362                );
     
    30553000                wp_localize_script( 'test-example', 'testExample', $l10n_data );
    30563001
    3057                 $expected  = "<script type='text/javascript' id='test-example-js-extra'>\n/* <![CDATA[ */\nvar testExample = {$expected};\n//# sourceURL=test-example-js-extra\n/* ]]> */\n</script>\n";
     3002                $expected  = "<script type='text/javascript' id='test-example-js-extra'>\n/* <![CDATA[ */\nvar testExample = {$expected};\n/* ]]> */\n</script>\n";
    30583003                $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
    30593004
     
    36243569                return $data['dependencies'];
    36253570        }
    3626 
    3627         /**
    3628          * @ticket 63887
    3629          */
    3630         public function test_source_url_encoding() {
    3631                 $this->add_html5_script_theme_support();
    3632 
    3633                 $handle = '# test/</script> #';
    3634                 wp_enqueue_script( $handle, '/example.js', array(), '0.0' );
    3635                 wp_add_inline_script( $handle, '"ok";' );
    3636 
    3637                 $expected = <<<HTML
    3638 <script src="/example.js?ver=0.0" id="# test/</script> #-js"></script>
    3639 <script id="# test/</script> #-js-after">
    3640 "ok";
    3641 //# sourceURL=%23%20test%2F%3C%2Fscript%3E%20%23-js-after
    3642 </script>
    3643 
    3644 HTML;
    3645 
    3646                 $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) );
    3647         }
    36483571}
  • trunk/tests/phpunit/tests/dependencies/styles.php

    r60686 r60690  
    151151                $expected .= "<style id='handle-inline-css' type='text/css'>\n";
    152152                $expected .= "$style\n";
    153                 $expected .= "/*# sourceURL=handle-inline-css */\n";
    154153                $expected .= "</style>\n";
    155154
     
    181180                $expected .= "<style id='handle-inline-css' type='text/css'>\n";
    182181                $expected .= "$style\n";
    183                 $expected .= "/*# sourceURL=handle-inline-css */\n";
    184182                $expected .= "</style>\n";
    185183
     
    277275                $expected .= "$style1\n";
    278276                $expected .= "$style2\n";
    279                 $expected .= "/*# sourceURL=handle-inline-css */\n";
    280277                $expected .= "</style>\n";
    281278
     
    296293        public function test_plugin_doing_inline_styles_wrong() {
    297294
    298                 $style  = ".thing {\n";
     295                $style  = "<style id='handle-inline-css' type='text/css'>\n";
     296                $style .= ".thing {\n";
    299297                $style .= "\tbackground: red;\n";
    300                 $style .= '}';
     298                $style .= "}\n";
     299                $style .= '</style>';
    301300
    302301                $expected  = "<link rel='stylesheet' id='handle-css' href='http://example.com?ver=1' type='text/css' media='all' />\n";
    303                 $expected .= "<style id='handle-inline-css' type='text/css'>\n";
    304302                $expected .= "$style\n";
    305                 $expected .= "/*# sourceURL=handle-inline-css */\n";
    306                 $expected .= "</style>\n";
    307303
    308304                wp_enqueue_style( 'handle', 'http://example.com', array(), 1 );
    309305
    310                 wp_add_inline_style( 'handle', "<style>{$style}</style>" );
     306                wp_add_inline_style( 'handle', $style );
    311307
    312308                $this->assertSame( $expected, get_echo( 'wp_print_styles' ) );
     
    337333<style id='handle-inline-css' type='text/css'>
    338334a { color: blue; }
    339 /*# sourceURL=handle-inline-css */
    340335</style>
    341336<![endif]-->
     
    369364                $expected .= "<style id='handle-three-inline-css' type='text/css'>\n";
    370365                $expected .= "$style\n";
    371                 $expected .= "/*# sourceURL=handle-three-inline-css */\n";
    372366                $expected .= "</style>\n";
    373367
     
    639633                $this->assertSame( $GLOBALS['wp_styles']->registered['test-handle']->src, $url );
    640634        }
    641 
    642         /**
    643          * @ticket 63887
    644          */
    645         public function test_source_url_encoding() {
    646                 $handle = '# test/</style> #';
    647                 wp_enqueue_style( $handle, '/example.css', array(), '0.0' );
    648                 wp_add_inline_style( $handle, 'custom-el { content: "ok"; }' );
    649 
    650                 $expected = <<<HTML
    651 <link rel='stylesheet' href="/example.css?ver=0.0" id="# test/</style> #-css" media="all" type="text/css">
    652 <style id="# test/</style> #-inline-css" type="text/css">
    653 custom-el { content: "ok"; }
    654 /*# sourceURL=%23%20test%2F%3C%2Fstyle%3E%20%23-inline-css */
    655 </style>
    656 
    657 HTML;
    658 
    659                 $this->assertEqualHTML( $expected, get_echo( 'wp_print_styles' ) );
    660         }
    661635}
  • trunk/tests/phpunit/tests/dependencies/wpLocalizeScript.php

    r60686 r60690  
    5757                $output = get_echo( 'wp_print_scripts' );
    5858
    59                 $expected  = "<script id=\"test-script-js-extra\">\nvar testData = {\"\\u003C!--\":\"\\u003Cscript\\u003E\"};\n//# sourceURL=test-script-js-extra\n</script>\n";
     59                $expected  = "<script id=\"test-script-js-extra\">\nvar testData = {\"\\u003C!--\":\"\\u003Cscript\\u003E\"};\n</script>\n";
    6060                $expected .= "<script src=\"{$base_url}\" id=\"test-script-js\"></script>\n";
    6161
Note: See TracChangeset for help on using the changeset viewer.