Make WordPress Core

Changeset 38473


Ignore:
Timestamp:
08/31/2016 05:25:03 PM (8 years ago)
Author:
jeremyfelt
Message:

Script Loader: Close the <link> tag in wp_resource_hints().

Adjusts tests to match markup change.

Merge of [38443] and [38447] to the 4.6 branch.

Props Chaos Engine, SergeyBiryukov, swissspidy.
Fixes #37800.

Location:
branches/4.6
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.6

  • branches/4.6/src/wp-includes/general-template.php

    r38256 r38473  
    28542854
    28552855        foreach ( $urls as $url ) {
    2856             printf( "<link rel='%s' href='%s'>\n", $relation_type, $url );
     2856            printf( "<link rel='%s' href='%s' />\n", $relation_type, $url );
    28572857        }
    28582858    }
  • branches/4.6/tests/phpunit/tests/general/resourceHints.php

    r38256 r38473  
    3232
    3333    function test_should_have_defaults_on_frontend() {
    34         $expected = "<link rel='dns-prefetch' href='//s.w.org'>\n";
     34        $expected = "<link rel='dns-prefetch' href='//s.w.org' />\n";
    3535
    3636        $this->expectOutputString( $expected );
     
    4040
    4141    function test_dns_prefetching() {
    42         $expected = "<link rel='dns-prefetch' href='//s.w.org'>\n" .
    43                     "<link rel='dns-prefetch' href='//wordpress.org'>\n" .
    44                     "<link rel='dns-prefetch' href='//google.com'>\n" .
    45                     "<link rel='dns-prefetch' href='//make.wordpress.org'>\n";
     42        $expected = "<link rel='dns-prefetch' href='//s.w.org' />\n" .
     43                    "<link rel='dns-prefetch' href='//wordpress.org' />\n" .
     44                    "<link rel='dns-prefetch' href='//google.com' />\n" .
     45                    "<link rel='dns-prefetch' href='//make.wordpress.org' />\n";
    4646
    4747        add_filter( 'wp_resource_hints', array( $this, '_add_dns_prefetch_domains' ), 10, 2 );
     
    7171     */
    7272    function test_preconnect() {
    73         $expected = "<link rel='dns-prefetch' href='//s.w.org'>\n" .
    74                     "<link rel='preconnect' href='//wordpress.org'>\n" .
    75                     "<link rel='preconnect' href='https://make.wordpress.org'>\n" .
    76                     "<link rel='preconnect' href='http://google.com'>\n" .
    77                     "<link rel='preconnect' href='http://w.org'>\n";
     73        $expected = "<link rel='dns-prefetch' href='//s.w.org' />\n" .
     74                    "<link rel='preconnect' href='//wordpress.org' />\n" .
     75                    "<link rel='preconnect' href='https://make.wordpress.org' />\n" .
     76                    "<link rel='preconnect' href='http://google.com' />\n" .
     77                    "<link rel='preconnect' href='http://w.org' />\n";
    7878
    7979        add_filter( 'wp_resource_hints', array( $this, '_add_preconnect_domains' ), 10, 2 );
     
    9999
    100100    function test_prerender() {
    101         $expected = "<link rel='dns-prefetch' href='//s.w.org'>\n" .
    102                     "<link rel='prerender' href='https://make.wordpress.org/great-again'>\n" .
    103                     "<link rel='prerender' href='http://jobs.wordpress.net'>\n" .
    104                     "<link rel='prerender' href='//core.trac.wordpress.org'>\n";
     101        $expected = "<link rel='dns-prefetch' href='//s.w.org' />\n" .
     102                    "<link rel='prerender' href='https://make.wordpress.org/great-again' />\n" .
     103                    "<link rel='prerender' href='http://jobs.wordpress.net' />\n" .
     104                    "<link rel='prerender' href='//core.trac.wordpress.org' />\n";
    105105
    106106        add_filter( 'wp_resource_hints', array( $this, '_add_prerender_urls' ), 10, 2 );
     
    125125
    126126    function test_parse_url_dns_prefetch() {
    127         $expected = "<link rel='dns-prefetch' href='//s.w.org'>\n" .
    128                     "<link rel='dns-prefetch' href='//make.wordpress.org'>\n";
     127        $expected = "<link rel='dns-prefetch' href='//s.w.org' />\n" .
     128                    "<link rel='dns-prefetch' href='//make.wordpress.org' />\n";
    129129
    130130        add_filter( 'wp_resource_hints', array( $this, '_add_dns_prefetch_long_urls' ), 10, 2 );
     
    146146
    147147    function test_dns_prefetch_styles() {
    148         $expected = "<link rel='dns-prefetch' href='//fonts.googleapis.com'>\n" .
    149                     "<link rel='dns-prefetch' href='//s.w.org'>\n";
     148        $expected = "<link rel='dns-prefetch' href='//fonts.googleapis.com' />\n" .
     149                    "<link rel='dns-prefetch' href='//s.w.org' />\n";
    150150
    151151        $args = array(
     
    165165
    166166    function test_dns_prefetch_scripts() {
    167         $expected = "<link rel='dns-prefetch' href='//fonts.googleapis.com'>\n" .
    168                     "<link rel='dns-prefetch' href='//s.w.org'>\n";
     167        $expected = "<link rel='dns-prefetch' href='//fonts.googleapis.com' />\n" .
     168                    "<link rel='dns-prefetch' href='//s.w.org' />\n";
    169169
    170170        $args = array(
     
    183183
    184184    function test_dns_prefetch_scripts_does_not_included_registered_only() {
    185         $expected = "<link rel='dns-prefetch' href='//s.w.org'>\n";
    186         $unexpected = "<link rel='dns-prefetch' href='//wordpress.org'>\n";
     185        $expected = "<link rel='dns-prefetch' href='//s.w.org' />\n";
     186        $unexpected = "<link rel='dns-prefetch' href='//wordpress.org' />\n";
    187187
    188188        wp_register_script( 'jquery-elsewhere', 'https://wordpress.org/wp-includes/js/jquery/jquery.js' );
     
    200200     */
    201201    function test_deregistered_scripts_are_ignored() {
    202         $expected = "<link rel='dns-prefetch' href='//s.w.org'>\n";
     202        $expected = "<link rel='dns-prefetch' href='//s.w.org' />\n";
    203203
    204204        wp_enqueue_script( 'test-script', 'http://example.org/script.js' );
     
    213213     */
    214214    function test_malformed_urls() {
    215         $expected = "<link rel='dns-prefetch' href='//s.w.org'>\n";
     215        $expected = "<link rel='dns-prefetch' href='//s.w.org' />\n";
    216216
    217217        // Errant colon.
Note: See TracChangeset for help on using the changeset viewer.