Changeset 60685 for trunk/tests/phpunit/tests/dependencies/scripts.php
- Timestamp:
- 08/28/2025 07:54:21 AM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/dependencies/scripts.php
r60666 r60685 117 117 public function test_after_inline_script_with_delayed_main_script( $strategy ) { 118 118 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' ); 120 120 $output = get_echo( 'wp_print_scripts' ); 121 121 $expected = "<script type='text/javascript' src='http://example.org/ms-isa-1.js' id='ms-isa-1-js' data-wp-strategy='{$strategy}'></script>\n"; 122 122 $expected .= wp_get_inline_script_tag( 123 'console.log("after one");',123 "console.log('after one');\n//# sourceURL=inline:ms-isa-1-js-after", 124 124 array( 125 125 'id' => 'ms-isa-1-js-after', … … 144 144 public function test_after_inline_script_with_blocking_main_script() { 145 145 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' ); 147 147 $output = get_echo( 'wp_print_scripts' ); 148 148 149 149 $expected = "<script type='text/javascript' src='http://example.org/ms-insa-3.js' id='ms-insa-3-js'></script>\n"; 150 150 $expected .= wp_get_inline_script_tag( 151 'console.log("after one");',151 "console.log('after one');\n//# sourceURL=inline:ms-insa-3-js-after", 152 152 array( 153 153 'id' => 'ms-insa-3-js-after', … … 175 175 public function test_before_inline_scripts_with_delayed_main_script( $strategy ) { 176 176 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' ); 178 178 wp_enqueue_script( 'ds-i1-2', 'http://example.org/ds-i1-2.js', array(), null, compact( 'strategy' ) ); 179 179 wp_enqueue_script( 'ds-i1-3', 'http://example.org/ds-i1-3.js', array(), null, compact( 'strategy' ) ); 180 180 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' ); 182 182 $output = get_echo( 'wp_print_scripts' ); 183 183 184 184 $expected = wp_get_inline_script_tag( 185 'console.log("before first");',185 "console.log('before first');\n//# sourceURL=inline:ds-i1-1-js-before", 186 186 array( 187 187 'id' => 'ds-i1-1-js-before', … … 192 192 $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"; 193 193 $expected .= wp_get_inline_script_tag( 194 'console.log("before last");',194 "console.log('before last');\n//# sourceURL=inline:ms-i1-1-js-before", 195 195 array( 196 196 'id' => 'ms-i1-1-js-before', … … 514 514 /* <![CDATA[ */ 515 515 scriptEventLog.push( "blocking-not-async-without-dependency: before inline" ) 516 //# sourceURL=inline:blocking-not-async-without-dependency-js-before 516 517 /* ]]> */ 517 518 </script> … … 520 521 /* <![CDATA[ */ 521 522 scriptEventLog.push( "blocking-not-async-without-dependency: after inline" ) 523 //# sourceURL=inline:blocking-not-async-without-dependency-js-after 522 524 /* ]]> */ 523 525 </script> … … 525 527 /* <![CDATA[ */ 526 528 scriptEventLog.push( "async-with-blocking-dependency: before inline" ) 529 //# sourceURL=inline:async-with-blocking-dependency-js-before 527 530 /* ]]> */ 528 531 </script> … … 531 534 /* <![CDATA[ */ 532 535 scriptEventLog.push( "async-with-blocking-dependency: after inline" ) 536 //# sourceURL=inline:async-with-blocking-dependency-js-after 533 537 /* ]]> */ 534 538 </script> … … 559 563 /* <![CDATA[ */ 560 564 scriptEventLog.push( "async-no-dependency: before inline" ) 565 //# sourceURL=inline:async-no-dependency-js-before 561 566 /* ]]> */ 562 567 </script> … … 565 570 /* <![CDATA[ */ 566 571 scriptEventLog.push( "async-no-dependency: after inline" ) 572 //# sourceURL=inline:async-no-dependency-js-after 567 573 /* ]]> */ 568 574 </script> … … 570 576 /* <![CDATA[ */ 571 577 scriptEventLog.push( "async-one-async-dependency: before inline" ) 578 //# sourceURL=inline:async-one-async-dependency-js-before 572 579 /* ]]> */ 573 580 </script> … … 576 583 /* <![CDATA[ */ 577 584 scriptEventLog.push( "async-one-async-dependency: after inline" ) 585 //# sourceURL=inline:async-one-async-dependency-js-after 578 586 /* ]]> */ 579 587 </script> … … 581 589 /* <![CDATA[ */ 582 590 scriptEventLog.push( "async-two-async-dependencies: before inline" ) 591 //# sourceURL=inline:async-two-async-dependencies-js-before 583 592 /* ]]> */ 584 593 </script> … … 587 596 /* <![CDATA[ */ 588 597 scriptEventLog.push( "async-two-async-dependencies: after inline" ) 598 //# sourceURL=inline:async-two-async-dependencies-js-after 589 599 /* ]]> */ 590 600 </script> … … 607 617 /* <![CDATA[ */ 608 618 scriptEventLog.push( "async-with-blocking-dependent: before inline" ) 619 //# sourceURL=inline:async-with-blocking-dependent-js-before 609 620 /* ]]> */ 610 621 </script> … … 613 624 /* <![CDATA[ */ 614 625 scriptEventLog.push( "async-with-blocking-dependent: after inline" ) 626 //# sourceURL=inline:async-with-blocking-dependent-js-after 615 627 /* ]]> */ 616 628 </script> … … 618 630 /* <![CDATA[ */ 619 631 scriptEventLog.push( "blocking-dependent-of-async: before inline" ) 632 //# sourceURL=inline:blocking-dependent-of-async-js-before 620 633 /* ]]> */ 621 634 </script> … … 624 637 /* <![CDATA[ */ 625 638 scriptEventLog.push( "blocking-dependent-of-async: after inline" ) 639 //# sourceURL=inline:blocking-dependent-of-async-js-after 626 640 /* ]]> */ 627 641 </script> … … 644 658 /* <![CDATA[ */ 645 659 scriptEventLog.push( "async-with-defer-dependent: before inline" ) 660 //# sourceURL=inline:async-with-defer-dependent-js-before 646 661 /* ]]> */ 647 662 </script> … … 650 665 /* <![CDATA[ */ 651 666 scriptEventLog.push( "async-with-defer-dependent: after inline" ) 667 //# sourceURL=inline:async-with-defer-dependent-js-after 652 668 /* ]]> */ 653 669 </script> … … 655 671 /* <![CDATA[ */ 656 672 scriptEventLog.push( "defer-dependent-of-async: before inline" ) 673 //# sourceURL=inline:defer-dependent-of-async-js-before 657 674 /* ]]> */ 658 675 </script> … … 661 678 /* <![CDATA[ */ 662 679 scriptEventLog.push( "defer-dependent-of-async: after inline" ) 680 //# sourceURL=inline:defer-dependent-of-async-js-after 663 681 /* ]]> */ 664 682 </script> … … 684 702 /* <![CDATA[ */ 685 703 scriptEventLog.push( "blocking-bundle-of-none: before inline" ) 704 //# sourceURL=inline:blocking-bundle-of-none-js-before 686 705 /* ]]> */ 687 706 </script> … … 689 708 /* <![CDATA[ */ 690 709 scriptEventLog.push( "blocking-bundle-of-none: after inline" ) 710 //# sourceURL=inline:blocking-bundle-of-none-js-after 691 711 /* ]]> */ 692 712 </script> … … 694 714 /* <![CDATA[ */ 695 715 scriptEventLog.push( "defer-dependent-of-blocking-bundle-of-none: before inline" ) 716 //# sourceURL=inline:defer-dependent-of-blocking-bundle-of-none-js-before 696 717 /* ]]> */ 697 718 </script> … … 700 721 /* <![CDATA[ */ 701 722 scriptEventLog.push( "defer-dependent-of-blocking-bundle-of-none: after inline" ) 723 //# sourceURL=inline:defer-dependent-of-blocking-bundle-of-none-js-after 702 724 /* ]]> */ 703 725 </script> … … 726 748 /* <![CDATA[ */ 727 749 scriptEventLog.push( "blocking-bundle-member-one: before inline" ) 750 //# sourceURL=inline:blocking-bundle-member-one-js-before 728 751 /* ]]> */ 729 752 </script> … … 732 755 /* <![CDATA[ */ 733 756 scriptEventLog.push( "blocking-bundle-member-one: after inline" ) 757 //# sourceURL=inline:blocking-bundle-member-one-js-after 734 758 /* ]]> */ 735 759 </script> … … 737 761 /* <![CDATA[ */ 738 762 scriptEventLog.push( "blocking-bundle-member-two: before inline" ) 763 //# sourceURL=inline:blocking-bundle-member-two-js-before 739 764 /* ]]> */ 740 765 </script> … … 743 768 /* <![CDATA[ */ 744 769 scriptEventLog.push( "blocking-bundle-member-two: after inline" ) 770 //# sourceURL=inline:blocking-bundle-member-two-js-after 745 771 /* ]]> */ 746 772 </script> … … 748 774 /* <![CDATA[ */ 749 775 scriptEventLog.push( "defer-dependent-of-blocking-bundle-of-two: before inline" ) 776 //# sourceURL=inline:defer-dependent-of-blocking-bundle-of-two-js-before 750 777 /* ]]> */ 751 778 </script> … … 754 781 /* <![CDATA[ */ 755 782 scriptEventLog.push( "defer-dependent-of-blocking-bundle-of-two: after inline" ) 783 //# sourceURL=inline:defer-dependent-of-blocking-bundle-of-two-js-after 756 784 /* ]]> */ 757 785 </script> … … 779 807 /* <![CDATA[ */ 780 808 scriptEventLog.push( "defer-bundle-of-none: before inline" ) 809 //# sourceURL=inline:defer-bundle-of-none-js-before 781 810 /* ]]> */ 782 811 </script> … … 784 813 /* <![CDATA[ */ 785 814 scriptEventLog.push( "defer-bundle-of-none: after inline" ) 815 //# sourceURL=inline:defer-bundle-of-none-js-after 786 816 /* ]]> */ 787 817 </script> … … 789 819 /* <![CDATA[ */ 790 820 scriptEventLog.push( "defer-dependent-of-defer-bundle-of-none: before inline" ) 821 //# sourceURL=inline:defer-dependent-of-defer-bundle-of-none-js-before 791 822 /* ]]> */ 792 823 </script> … … 795 826 /* <![CDATA[ */ 796 827 scriptEventLog.push( "defer-dependent-of-defer-bundle-of-none: after inline" ) 828 //# sourceURL=inline:defer-dependent-of-defer-bundle-of-none-js-after 797 829 /* ]]> */ 798 830 </script> … … 818 850 /* <![CDATA[ */ 819 851 scriptEventLog.push( "blocking-dependency-with-defer-following-dependency: before inline" ) 852 //# sourceURL=inline:blocking-dependency-with-defer-following-dependency-js-before 820 853 /* ]]> */ 821 854 </script> … … 824 857 /* <![CDATA[ */ 825 858 scriptEventLog.push( "blocking-dependency-with-defer-following-dependency: after inline" ) 859 //# sourceURL=inline:blocking-dependency-with-defer-following-dependency-js-after 826 860 /* ]]> */ 827 861 </script> … … 829 863 /* <![CDATA[ */ 830 864 scriptEventLog.push( "defer-dependency-with-blocking-preceding-dependency: before inline" ) 865 //# sourceURL=inline:defer-dependency-with-blocking-preceding-dependency-js-before 831 866 /* ]]> */ 832 867 </script> … … 835 870 /* <![CDATA[ */ 836 871 scriptEventLog.push( "defer-dependency-with-blocking-preceding-dependency: after inline" ) 872 //# sourceURL=inline:defer-dependency-with-blocking-preceding-dependency-js-after 837 873 /* ]]> */ 838 874 </script> … … 840 876 /* <![CDATA[ */ 841 877 scriptEventLog.push( "defer-dependent-of-blocking-and-defer-dependencies: before inline" ) 878 //# sourceURL=inline:defer-dependent-of-blocking-and-defer-dependencies-js-before 842 879 /* ]]> */ 843 880 </script> … … 846 883 /* <![CDATA[ */ 847 884 scriptEventLog.push( "defer-dependent-of-blocking-and-defer-dependencies: after inline" ) 885 //# sourceURL=inline:defer-dependent-of-blocking-and-defer-dependencies-js-after 848 886 /* ]]> */ 849 887 </script> … … 869 907 /* <![CDATA[ */ 870 908 scriptEventLog.push( "defer-dependency-with-blocking-following-dependency: before inline" ) 909 //# sourceURL=inline:defer-dependency-with-blocking-following-dependency-js-before 871 910 /* ]]> */ 872 911 </script> … … 875 914 /* <![CDATA[ */ 876 915 scriptEventLog.push( "defer-dependency-with-blocking-following-dependency: after inline" ) 916 //# sourceURL=inline:defer-dependency-with-blocking-following-dependency-js-after 877 917 /* ]]> */ 878 918 </script> … … 880 920 /* <![CDATA[ */ 881 921 scriptEventLog.push( "blocking-dependency-with-defer-preceding-dependency: before inline" ) 922 //# sourceURL=inline:blocking-dependency-with-defer-preceding-dependency-js-before 882 923 /* ]]> */ 883 924 </script> … … 886 927 /* <![CDATA[ */ 887 928 scriptEventLog.push( "blocking-dependency-with-defer-preceding-dependency: after inline" ) 929 //# sourceURL=inline:blocking-dependency-with-defer-preceding-dependency-js-after 888 930 /* ]]> */ 889 931 </script> … … 891 933 /* <![CDATA[ */ 892 934 scriptEventLog.push( "defer-dependent-of-defer-and-blocking-dependencies: before inline" ) 935 //# sourceURL=inline:defer-dependent-of-defer-and-blocking-dependencies-js-before 893 936 /* ]]> */ 894 937 </script> … … 897 940 /* <![CDATA[ */ 898 941 scriptEventLog.push( "defer-dependent-of-defer-and-blocking-dependencies: after inline" ) 942 //# sourceURL=inline:defer-dependent-of-defer-and-blocking-dependencies-js-after 899 943 /* ]]> */ 900 944 </script> … … 917 961 /* <![CDATA[ */ 918 962 scriptEventLog.push( "defer-with-async-dependent: before inline" ) 963 //# sourceURL=inline:defer-with-async-dependent-js-before 919 964 /* ]]> */ 920 965 </script> … … 923 968 /* <![CDATA[ */ 924 969 scriptEventLog.push( "defer-with-async-dependent: after inline" ) 970 //# sourceURL=inline:defer-with-async-dependent-js-after 925 971 /* ]]> */ 926 972 </script> … … 928 974 /* <![CDATA[ */ 929 975 scriptEventLog.push( "async-dependent-of-defer: before inline" ) 976 //# sourceURL=inline:async-dependent-of-defer-js-before 930 977 /* ]]> */ 931 978 </script> … … 934 981 /* <![CDATA[ */ 935 982 scriptEventLog.push( "async-dependent-of-defer: after inline" ) 983 //# sourceURL=inline:async-dependent-of-defer-js-after 936 984 /* ]]> */ 937 985 </script> … … 950 998 /* <![CDATA[ */ 951 999 scriptEventLog.push( "defer-with-before-inline: before inline" ) 1000 //# sourceURL=inline:defer-with-before-inline-js-before 952 1001 /* ]]> */ 953 1002 </script> … … 968 1017 /* <![CDATA[ */ 969 1018 scriptEventLog.push( "defer-with-after-inline: after inline" ) 1019 //# sourceURL=inline:defer-with-after-inline-js-after 970 1020 /* ]]> */ 971 1021 </script> … … 1015 1065 /* <![CDATA[ */ 1016 1066 scriptEventLog.push( "defer-dependent-of-nested-aliases: before inline" ) 1067 //# sourceURL=inline:defer-dependent-of-nested-aliases-js-before 1017 1068 /* ]]> */ 1018 1069 </script> … … 1021 1072 /* <![CDATA[ */ 1022 1073 scriptEventLog.push( "defer-dependent-of-nested-aliases: after inline" ) 1074 //# sourceURL=inline:defer-dependent-of-nested-aliases-js-after 1023 1075 /* ]]> */ 1024 1076 </script> … … 1619 1671 wp_enqueue_script( 'test-only-data', 'example.com', array(), null ); 1620 1672 wp_script_add_data( 'test-only-data', 'data', 'testing' ); 1621 $expected = "<script type='text/javascript' id='test-only-data-js-extra'>\n/* <![CDATA[ */\ntesting\n/ * ]]> */\n</script>\n";1673 $expected = "<script type='text/javascript' id='test-only-data-js-extra'>\n/* <![CDATA[ */\ntesting\n//# sourceURL=inline:test-only-data-js-extra\n/* ]]> */\n</script>\n"; 1622 1674 $expected .= "<script type='text/javascript' src='http://example.com' id='test-only-data-js'></script>\n"; 1623 1675 … … 1657 1709 wp_script_add_data( 'test-conditional-with-data', 'data', 'testing' ); 1658 1710 wp_script_add_data( 'test-conditional-with-data', 'conditional', 'lt IE 9' ); 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";1711 $expected = "<!--[if lt IE 9]>\n<script type='text/javascript' id='test-conditional-with-data-js-extra'>\n/* <![CDATA[ */\ntesting\n//# sourceURL=inline:test-conditional-with-data-js-extra\n/* ]]> */\n</script>\n<![endif]-->\n"; 1660 1712 $expected .= "<!--[if lt IE 9]>\n<script type='text/javascript' src='http://example.com' id='test-conditional-with-data-js'></script>\n<![endif]-->\n"; 1661 1713 $expected = str_replace( "'", '"', $expected ); … … 1881 1933 /* <![CDATA[ */ 1882 1934 console.log("before"); 1935 //# sourceURL=inline:test-example-js-before 1883 1936 /* ]]> */ 1884 1937 </script> … … 1901 1954 /* <![CDATA[ */ 1902 1955 console.log("after"); 1956 //# sourceURL=inline:test-example-js-after 1903 1957 /* ]]> */ 1904 1958 </script> … … 1916 1970 wp_add_inline_script( 'test-example', 'console.log("after");' ); 1917 1971 1918 $expected = "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n/ * ]]> */\n</script>\n";1972 $expected = "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n//# sourceURL=inline:test-example-js-before\n/* ]]> */\n</script>\n"; 1919 1973 $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n"; 1920 $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n/ * ]]> */\n</script>\n";1974 $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n//# sourceURL=inline:test-example-js-after\n/* ]]> */\n</script>\n"; 1921 1975 1922 1976 $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); … … 1931 1985 wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ); 1932 1986 1933 $expected = "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n/ * ]]> */\n</script>\n";1987 $expected = "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n//# sourceURL=inline:test-example-js-before\n/* ]]> */\n</script>\n"; 1934 1988 1935 1989 $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); … … 1944 1998 wp_add_inline_script( 'test-example', 'console.log("after");' ); 1945 1999 1946 $expected = "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n/ * ]]> */\n</script>\n";2000 $expected = "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n//# sourceURL=inline:test-example-js-after\n/* ]]> */\n</script>\n"; 1947 2001 1948 2002 $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); … … 1958 2012 wp_add_inline_script( 'test-example', 'console.log("after");' ); 1959 2013 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";2014 $expected = "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n//# sourceURL=inline: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=inline:test-example-js-after\n/* ]]> */\n</script>\n"; 1962 2016 1963 2017 $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); … … 1974 2028 wp_add_inline_script( 'test-example', 'console.log("after");' ); 1975 2029 1976 $expected = "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\nconsole.log(\"before\");\n/ * ]]> */\n</script>\n";2030 $expected = "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\nconsole.log(\"before\");\n//# sourceURL=inline:test-example-js-before\n/* ]]> */\n</script>\n"; 1977 2031 $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></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";2032 $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\nconsole.log(\"after\");\n//# sourceURL=inline:test-example-js-after\n/* ]]> */\n</script>\n"; 1979 2033 1980 2034 $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); … … 1990 2044 wp_add_inline_script( 'test-example', 'console.log("after");' ); 1991 2045 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";2046 $expected = "<script type='text/javascript' id='test-example-js-extra'>\n/* <![CDATA[ */\nvar testExample = {\"foo\":\"bar\"};\n//# sourceURL=inline: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=inline:test-example-js-before\n/* ]]> */\n</script>\n"; 1994 2048 $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n"; 1995 $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n/ * ]]> */\n</script>\n";2049 $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n//# sourceURL=inline:test-example-js-after\n/* ]]> */\n</script>\n"; 1996 2050 1997 2051 $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); … … 2014 2068 wp_add_inline_script( 'two', 'console.log("before two");', 'before' ); 2015 2069 2016 $expected = "<script type='text/javascript' id='one-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before one\");\n/ * ]]> */\n</script>\n";2070 $expected = "<script type='text/javascript' id='one-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before one\");\n//# sourceURL=inline:one-js-before\n/* ]]> */\n</script>\n"; 2017 2071 $expected .= "<script type='text/javascript' src='{$this->default_scripts_dir}one.js?ver={$wp_version}' id='one-js'></script>\n"; 2018 $expected .= "<script type='text/javascript' id='two-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before two\");\n/ * ]]> */\n</script>\n";2072 $expected .= "<script type='text/javascript' id='two-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before two\");\n//# sourceURL=inline:two-js-before\n/* ]]> */\n</script>\n"; 2019 2073 $expected .= "<script type='text/javascript' src='{$this->default_scripts_dir}two.js?ver={$wp_version}' id='two-js'></script>\n"; 2020 2074 $expected .= "<script type='text/javascript' src='{$this->default_scripts_dir}three.js?ver={$wp_version}' id='three-js'></script>\n"; … … 2038 2092 wp_add_inline_script( 'one', 'console.log("before one");', 'before' ); 2039 2093 2040 $expected = "<script type='text/javascript' id='one-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before one\");\n/ * ]]> */\n</script>\n";2094 $expected = "<script type='text/javascript' id='one-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before one\");\n//# sourceURL=inline:one-js-before\n/* ]]> */\n</script>\n"; 2041 2095 $expected .= "<script type='text/javascript' src='{$this->default_scripts_dir}one.js?ver={$wp_version}' id='one-js'></script>\n"; 2042 2096 $expected .= "<script type='text/javascript' src='{$this->default_scripts_dir}two.js?ver={$wp_version}' id='two-js'></script>\n"; … … 2065 2119 $expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=one&ver={$wp_version}'></script>\n"; 2066 2120 $expected .= "<script type='text/javascript' src='{$this->default_scripts_dir}two.js?ver={$wp_version}' id='two-js'></script>\n"; 2067 $expected .= "<script type='text/javascript' id='two-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after two\");\n/ * ]]> */\n</script>\n";2121 $expected .= "<script type='text/javascript' id='two-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after two\");\n//# sourceURL=inline:two-js-after\n/* ]]> */\n</script>\n"; 2068 2122 $expected .= "<script type='text/javascript' src='{$this->default_scripts_dir}three.js?ver={$wp_version}' id='three-js'></script>\n"; 2069 $expected .= "<script type='text/javascript' id='three-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after three\");\n/ * ]]> */\n</script>\n";2123 $expected .= "<script type='text/javascript' id='three-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after three\");\n//# sourceURL=inline:three-js-after\n/* ]]> */\n</script>\n"; 2070 2124 $expected .= "<script type='text/javascript' src='{$this->default_scripts_dir}four.js?ver={$wp_version}' id='four-js'></script>\n"; 2071 2125 … … 2083 2137 2084 2138 $expected_localized = "<!--[if gte IE 9]>\n"; 2085 $expected_localized .= "<script type='text/javascript' id='test-example-js-extra'>\n/* <![CDATA[ */\nvar testExample = {\"foo\":\"bar\"};\n/ * ]]> */\n</script>\n";2139 $expected_localized .= "<script type='text/javascript' id='test-example-js-extra'>\n/* <![CDATA[ */\nvar testExample = {\"foo\":\"bar\"};\n//# sourceURL=inline:test-example-js-extra\n/* ]]> */\n</script>\n"; 2086 2140 $expected_localized .= "<![endif]-->\n"; 2087 2141 $expected_localized = str_replace( "'", '"', $expected_localized ); 2088 2142 2089 2143 $expected = "<!--[if gte IE 9]>\n"; 2090 $expected .= "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n/ * ]]> */\n</script>\n";2144 $expected .= "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n//# sourceURL=inline:test-example-js-before\n/* ]]> */\n</script>\n"; 2091 2145 $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n"; 2092 $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n/ * ]]> */\n</script>\n";2146 $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n//# sourceURL=inline:test-example-js-after\n/* ]]> */\n</script>\n"; 2093 2147 $expected .= "<![endif]-->\n"; 2094 2148 $expected = str_replace( "'", '"', $expected ); … … 2118 2172 $expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate&ver={$wp_version}'></script>\n"; 2119 2173 $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n"; 2120 $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n/ * ]]> */\n</script>\n";2174 $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n//# sourceURL=inline:test-example-js-after\n/* ]]> */\n</script>\n"; 2121 2175 2122 2176 wp_enqueue_script( 'test-example', 'http://example.com', array( 'jquery' ), null ); … … 2143 2197 $expected .= "<!--[if gte IE 9]>\n"; 2144 2198 $expected .= "<script type=\"text/javascript\" src=\"http://example.com\" id=\"test-example-js\"></script>\n"; 2145 $expected .= "<script type=\"text/javascript\" id=\"test-example-js-after\">\n/* <![CDATA[ */\nconsole.log(\"after\");\n/ * ]]> */\n</script>\n";2199 $expected .= "<script type=\"text/javascript\" id=\"test-example-js-after\">\n/* <![CDATA[ */\nconsole.log(\"after\");\n//# sourceURL=inline:test-example-js-after\n/* ]]> */\n</script>\n"; 2146 2200 $expected .= "<![endif]-->\n"; 2147 2201 … … 2169 2223 2170 2224 $expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate&ver={$wp_version}'></script>\n"; 2171 $expected .= "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n/ * ]]> */\n</script>\n";2225 $expected .= "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n//# sourceURL=inline:test-example-js-before\n/* ]]> */\n</script>\n"; 2172 2226 $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n"; 2173 2227 … … 2194 2248 2195 2249 $expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,wp-dom-ready,wp-hooks&ver={$wp_version}'></script>\n"; 2196 $expected .= "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n/ * ]]> */\n</script>\n";2250 $expected .= "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n//# sourceURL=inline:test-example-js-before\n/* ]]> */\n</script>\n"; 2197 2251 $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n"; 2198 2252 $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/i18n.min.js' id='wp-i18n-js'></script>\n"; … … 2200 2254 $expected .= "/* <![CDATA[ */\n"; 2201 2255 $expected .= "wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ 'ltr' ] } );\n"; 2256 $expected .= "//# sourceURL=inline:wp-i18n-js-after\n"; 2202 2257 $expected .= "/* ]]> */\n"; 2203 2258 $expected .= "</script>\n"; 2204 2259 $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/a11y.min.js' id='wp-a11y-js'></script>\n"; 2205 2260 $expected .= "<script type='text/javascript' src='http://example2.com' id='test-example2-js'></script>\n"; 2206 $expected .= "<script type='text/javascript' id='test-example2-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n/* ]]> */\n</script>\n"; 2207 2261 $expected .= "<script type='text/javascript' id='test-example2-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n//# sourceURL=inline:test-example2-js-after\n/* ]]> */\n</script>\n"; 2208 2262 wp_enqueue_script( 'test-example', 'http://example.com', array( 'jquery' ), null ); 2209 2263 wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ); … … 2249 2303 $expected_tail .= "/* <![CDATA[ */\n"; 2250 2304 $expected_tail .= "tryCustomizeDependency()\n"; 2305 $expected_tail .= "//# sourceURL=inline:customize-dependency-js-after\n"; 2251 2306 $expected_tail .= "/* ]]> */\n"; 2252 2307 $expected_tail .= "</script>\n"; … … 2284 2339 2285 2340 $expected = "<script type='text/javascript' src='/wp-includes/js/script.js?ver={$wp_version}' id='one-js'></script>\n"; 2286 $expected .= "<script type='text/javascript' id='one-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after one\");\n/ * ]]> */\n</script>\n";2341 $expected .= "<script type='text/javascript' id='one-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after one\");\n//# sourceURL=inline:one-js-after\n/* ]]> */\n</script>\n"; 2287 2342 $expected .= "<script type='text/javascript' src='/wp-includes/js/script2.js?ver={$wp_version}' id='two-js'></script>\n"; 2288 2343 $expected .= "<script type='text/javascript' src='/wp-includes/js/script3.js?ver={$wp_version}' id='three-js'></script>\n"; … … 2308 2363 2309 2364 $expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=one,two&ver={$wp_version}'></script>\n"; 2310 $expected .= "<script type='text/javascript' id='three-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before three\");\n/ * ]]> */\n</script>\n";2365 $expected .= "<script type='text/javascript' id='three-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before three\");\n//# sourceURL=inline:three-js-before\n/* ]]> */\n</script>\n"; 2311 2366 $expected .= "<script type='text/javascript' src='/wp-includes/js/script3.js?ver={$wp_version}' id='three-js'></script>\n"; 2312 2367 $expected .= "<script type='text/javascript' src='/wp-includes/js/script4.js?ver={$wp_version}' id='four-js'></script>\n"; … … 2328 2383 ), 2329 2384 'delayed' => false, 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",2385 'expected_data' => "/*before foo 1*/\n//# sourceURL=inline:foo-js-before", 2386 'expected_tag' => "<script id='foo-js-before' type='text/javascript'>\n/* <![CDATA[ */\n/*before foo 1*/\n//# sourceURL=inline:foo-js-before\n/* ]]> */\n</script>\n", 2332 2387 ), 2333 2388 'after-blocking' => array( … … 2338 2393 ), 2339 2394 'delayed' => false, 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",2395 'expected_data' => "/*after foo 1*/\n/*after foo 2*/\n//# sourceURL=inline: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=inline:foo-js-after\n/* ]]> */\n</script>\n", 2342 2397 ), 2343 2398 'before-delayed' => array( … … 2347 2402 ), 2348 2403 'delayed' => true, 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",2404 'expected_data' => "/*before foo 1*/\n//# sourceURL=inline:foo-js-before", 2405 'expected_tag' => "<script id='foo-js-before' type='text/javascript'>\n/* <![CDATA[ */\n/*before foo 1*/\n//# sourceURL=inline:foo-js-before\n/* ]]> */\n</script>\n", 2351 2406 ), 2352 2407 'after-delayed' => array( … … 2357 2412 ), 2358 2413 'delayed' => true, 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",2414 'expected_data' => "/*after foo 1*/\n/*after foo 2*/\n//# sourceURL=inline: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=inline:foo-js-after\n/* ]]> */\n</script>\n", 2361 2416 ), 2362 2417 ); … … 3000 3055 wp_localize_script( 'test-example', 'testExample', $l10n_data ); 3001 3056 3002 $expected = "<script type='text/javascript' id='test-example-js-extra'>\n/* <![CDATA[ */\nvar testExample = {$expected};\n/ * ]]> */\n</script>\n";3057 $expected = "<script type='text/javascript' id='test-example-js-extra'>\n/* <![CDATA[ */\nvar testExample = {$expected};\n//# sourceURL=inline:test-example-js-extra\n/* ]]> */\n</script>\n"; 3003 3058 $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n"; 3004 3059 … … 3569 3624 return $data['dependencies']; 3570 3625 } 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=inline:%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 } 3571 3648 }
Note: See TracChangeset
for help on using the changeset viewer.