Changeset 60690 for trunk/tests/phpunit/tests/dependencies/scripts.php
- Timestamp:
- 08/29/2025 05:16:50 PM (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/dependencies/scripts.php
r60686 r60690 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');\n//# sourceURL=ms-isa-1-js-after",123 'console.log("after one");', 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');\n//# sourceURL=ms-insa-3-js-after",151 'console.log("after one");', 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');\n//# sourceURL=ds-i1-1-js-before",185 'console.log("before first");', 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');\n//# sourceURL=ms-i1-1-js-before",194 'console.log("before last");', 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=blocking-not-async-without-dependency-js-before517 516 /* ]]> */ 518 517 </script> … … 521 520 /* <![CDATA[ */ 522 521 scriptEventLog.push( "blocking-not-async-without-dependency: after inline" ) 523 //# sourceURL=blocking-not-async-without-dependency-js-after524 522 /* ]]> */ 525 523 </script> … … 527 525 /* <![CDATA[ */ 528 526 scriptEventLog.push( "async-with-blocking-dependency: before inline" ) 529 //# sourceURL=async-with-blocking-dependency-js-before530 527 /* ]]> */ 531 528 </script> … … 534 531 /* <![CDATA[ */ 535 532 scriptEventLog.push( "async-with-blocking-dependency: after inline" ) 536 //# sourceURL=async-with-blocking-dependency-js-after537 533 /* ]]> */ 538 534 </script> … … 563 559 /* <![CDATA[ */ 564 560 scriptEventLog.push( "async-no-dependency: before inline" ) 565 //# sourceURL=async-no-dependency-js-before566 561 /* ]]> */ 567 562 </script> … … 570 565 /* <![CDATA[ */ 571 566 scriptEventLog.push( "async-no-dependency: after inline" ) 572 //# sourceURL=async-no-dependency-js-after573 567 /* ]]> */ 574 568 </script> … … 576 570 /* <![CDATA[ */ 577 571 scriptEventLog.push( "async-one-async-dependency: before inline" ) 578 //# sourceURL=async-one-async-dependency-js-before579 572 /* ]]> */ 580 573 </script> … … 583 576 /* <![CDATA[ */ 584 577 scriptEventLog.push( "async-one-async-dependency: after inline" ) 585 //# sourceURL=async-one-async-dependency-js-after586 578 /* ]]> */ 587 579 </script> … … 589 581 /* <![CDATA[ */ 590 582 scriptEventLog.push( "async-two-async-dependencies: before inline" ) 591 //# sourceURL=async-two-async-dependencies-js-before592 583 /* ]]> */ 593 584 </script> … … 596 587 /* <![CDATA[ */ 597 588 scriptEventLog.push( "async-two-async-dependencies: after inline" ) 598 //# sourceURL=async-two-async-dependencies-js-after599 589 /* ]]> */ 600 590 </script> … … 617 607 /* <![CDATA[ */ 618 608 scriptEventLog.push( "async-with-blocking-dependent: before inline" ) 619 //# sourceURL=async-with-blocking-dependent-js-before620 609 /* ]]> */ 621 610 </script> … … 624 613 /* <![CDATA[ */ 625 614 scriptEventLog.push( "async-with-blocking-dependent: after inline" ) 626 //# sourceURL=async-with-blocking-dependent-js-after627 615 /* ]]> */ 628 616 </script> … … 630 618 /* <![CDATA[ */ 631 619 scriptEventLog.push( "blocking-dependent-of-async: before inline" ) 632 //# sourceURL=blocking-dependent-of-async-js-before633 620 /* ]]> */ 634 621 </script> … … 637 624 /* <![CDATA[ */ 638 625 scriptEventLog.push( "blocking-dependent-of-async: after inline" ) 639 //# sourceURL=blocking-dependent-of-async-js-after640 626 /* ]]> */ 641 627 </script> … … 658 644 /* <![CDATA[ */ 659 645 scriptEventLog.push( "async-with-defer-dependent: before inline" ) 660 //# sourceURL=async-with-defer-dependent-js-before661 646 /* ]]> */ 662 647 </script> … … 665 650 /* <![CDATA[ */ 666 651 scriptEventLog.push( "async-with-defer-dependent: after inline" ) 667 //# sourceURL=async-with-defer-dependent-js-after668 652 /* ]]> */ 669 653 </script> … … 671 655 /* <![CDATA[ */ 672 656 scriptEventLog.push( "defer-dependent-of-async: before inline" ) 673 //# sourceURL=defer-dependent-of-async-js-before674 657 /* ]]> */ 675 658 </script> … … 678 661 /* <![CDATA[ */ 679 662 scriptEventLog.push( "defer-dependent-of-async: after inline" ) 680 //# sourceURL=defer-dependent-of-async-js-after681 663 /* ]]> */ 682 664 </script> … … 702 684 /* <![CDATA[ */ 703 685 scriptEventLog.push( "blocking-bundle-of-none: before inline" ) 704 //# sourceURL=blocking-bundle-of-none-js-before705 686 /* ]]> */ 706 687 </script> … … 708 689 /* <![CDATA[ */ 709 690 scriptEventLog.push( "blocking-bundle-of-none: after inline" ) 710 //# sourceURL=blocking-bundle-of-none-js-after711 691 /* ]]> */ 712 692 </script> … … 714 694 /* <![CDATA[ */ 715 695 scriptEventLog.push( "defer-dependent-of-blocking-bundle-of-none: before inline" ) 716 //# sourceURL=defer-dependent-of-blocking-bundle-of-none-js-before717 696 /* ]]> */ 718 697 </script> … … 721 700 /* <![CDATA[ */ 722 701 scriptEventLog.push( "defer-dependent-of-blocking-bundle-of-none: after inline" ) 723 //# sourceURL=defer-dependent-of-blocking-bundle-of-none-js-after724 702 /* ]]> */ 725 703 </script> … … 748 726 /* <![CDATA[ */ 749 727 scriptEventLog.push( "blocking-bundle-member-one: before inline" ) 750 //# sourceURL=blocking-bundle-member-one-js-before751 728 /* ]]> */ 752 729 </script> … … 755 732 /* <![CDATA[ */ 756 733 scriptEventLog.push( "blocking-bundle-member-one: after inline" ) 757 //# sourceURL=blocking-bundle-member-one-js-after758 734 /* ]]> */ 759 735 </script> … … 761 737 /* <![CDATA[ */ 762 738 scriptEventLog.push( "blocking-bundle-member-two: before inline" ) 763 //# sourceURL=blocking-bundle-member-two-js-before764 739 /* ]]> */ 765 740 </script> … … 768 743 /* <![CDATA[ */ 769 744 scriptEventLog.push( "blocking-bundle-member-two: after inline" ) 770 //# sourceURL=blocking-bundle-member-two-js-after771 745 /* ]]> */ 772 746 </script> … … 774 748 /* <![CDATA[ */ 775 749 scriptEventLog.push( "defer-dependent-of-blocking-bundle-of-two: before inline" ) 776 //# sourceURL=defer-dependent-of-blocking-bundle-of-two-js-before777 750 /* ]]> */ 778 751 </script> … … 781 754 /* <![CDATA[ */ 782 755 scriptEventLog.push( "defer-dependent-of-blocking-bundle-of-two: after inline" ) 783 //# sourceURL=defer-dependent-of-blocking-bundle-of-two-js-after784 756 /* ]]> */ 785 757 </script> … … 807 779 /* <![CDATA[ */ 808 780 scriptEventLog.push( "defer-bundle-of-none: before inline" ) 809 //# sourceURL=defer-bundle-of-none-js-before810 781 /* ]]> */ 811 782 </script> … … 813 784 /* <![CDATA[ */ 814 785 scriptEventLog.push( "defer-bundle-of-none: after inline" ) 815 //# sourceURL=defer-bundle-of-none-js-after816 786 /* ]]> */ 817 787 </script> … … 819 789 /* <![CDATA[ */ 820 790 scriptEventLog.push( "defer-dependent-of-defer-bundle-of-none: before inline" ) 821 //# sourceURL=defer-dependent-of-defer-bundle-of-none-js-before822 791 /* ]]> */ 823 792 </script> … … 826 795 /* <![CDATA[ */ 827 796 scriptEventLog.push( "defer-dependent-of-defer-bundle-of-none: after inline" ) 828 //# sourceURL=defer-dependent-of-defer-bundle-of-none-js-after829 797 /* ]]> */ 830 798 </script> … … 850 818 /* <![CDATA[ */ 851 819 scriptEventLog.push( "blocking-dependency-with-defer-following-dependency: before inline" ) 852 //# sourceURL=blocking-dependency-with-defer-following-dependency-js-before853 820 /* ]]> */ 854 821 </script> … … 857 824 /* <![CDATA[ */ 858 825 scriptEventLog.push( "blocking-dependency-with-defer-following-dependency: after inline" ) 859 //# sourceURL=blocking-dependency-with-defer-following-dependency-js-after860 826 /* ]]> */ 861 827 </script> … … 863 829 /* <![CDATA[ */ 864 830 scriptEventLog.push( "defer-dependency-with-blocking-preceding-dependency: before inline" ) 865 //# sourceURL=defer-dependency-with-blocking-preceding-dependency-js-before866 831 /* ]]> */ 867 832 </script> … … 870 835 /* <![CDATA[ */ 871 836 scriptEventLog.push( "defer-dependency-with-blocking-preceding-dependency: after inline" ) 872 //# sourceURL=defer-dependency-with-blocking-preceding-dependency-js-after873 837 /* ]]> */ 874 838 </script> … … 876 840 /* <![CDATA[ */ 877 841 scriptEventLog.push( "defer-dependent-of-blocking-and-defer-dependencies: before inline" ) 878 //# sourceURL=defer-dependent-of-blocking-and-defer-dependencies-js-before879 842 /* ]]> */ 880 843 </script> … … 883 846 /* <![CDATA[ */ 884 847 scriptEventLog.push( "defer-dependent-of-blocking-and-defer-dependencies: after inline" ) 885 //# sourceURL=defer-dependent-of-blocking-and-defer-dependencies-js-after886 848 /* ]]> */ 887 849 </script> … … 907 869 /* <![CDATA[ */ 908 870 scriptEventLog.push( "defer-dependency-with-blocking-following-dependency: before inline" ) 909 //# sourceURL=defer-dependency-with-blocking-following-dependency-js-before910 871 /* ]]> */ 911 872 </script> … … 914 875 /* <![CDATA[ */ 915 876 scriptEventLog.push( "defer-dependency-with-blocking-following-dependency: after inline" ) 916 //# sourceURL=defer-dependency-with-blocking-following-dependency-js-after917 877 /* ]]> */ 918 878 </script> … … 920 880 /* <![CDATA[ */ 921 881 scriptEventLog.push( "blocking-dependency-with-defer-preceding-dependency: before inline" ) 922 //# sourceURL=blocking-dependency-with-defer-preceding-dependency-js-before923 882 /* ]]> */ 924 883 </script> … … 927 886 /* <![CDATA[ */ 928 887 scriptEventLog.push( "blocking-dependency-with-defer-preceding-dependency: after inline" ) 929 //# sourceURL=blocking-dependency-with-defer-preceding-dependency-js-after930 888 /* ]]> */ 931 889 </script> … … 933 891 /* <![CDATA[ */ 934 892 scriptEventLog.push( "defer-dependent-of-defer-and-blocking-dependencies: before inline" ) 935 //# sourceURL=defer-dependent-of-defer-and-blocking-dependencies-js-before936 893 /* ]]> */ 937 894 </script> … … 940 897 /* <![CDATA[ */ 941 898 scriptEventLog.push( "defer-dependent-of-defer-and-blocking-dependencies: after inline" ) 942 //# sourceURL=defer-dependent-of-defer-and-blocking-dependencies-js-after943 899 /* ]]> */ 944 900 </script> … … 961 917 /* <![CDATA[ */ 962 918 scriptEventLog.push( "defer-with-async-dependent: before inline" ) 963 //# sourceURL=defer-with-async-dependent-js-before964 919 /* ]]> */ 965 920 </script> … … 968 923 /* <![CDATA[ */ 969 924 scriptEventLog.push( "defer-with-async-dependent: after inline" ) 970 //# sourceURL=defer-with-async-dependent-js-after971 925 /* ]]> */ 972 926 </script> … … 974 928 /* <![CDATA[ */ 975 929 scriptEventLog.push( "async-dependent-of-defer: before inline" ) 976 //# sourceURL=async-dependent-of-defer-js-before977 930 /* ]]> */ 978 931 </script> … … 981 934 /* <![CDATA[ */ 982 935 scriptEventLog.push( "async-dependent-of-defer: after inline" ) 983 //# sourceURL=async-dependent-of-defer-js-after984 936 /* ]]> */ 985 937 </script> … … 998 950 /* <![CDATA[ */ 999 951 scriptEventLog.push( "defer-with-before-inline: before inline" ) 1000 //# sourceURL=defer-with-before-inline-js-before1001 952 /* ]]> */ 1002 953 </script> … … 1017 968 /* <![CDATA[ */ 1018 969 scriptEventLog.push( "defer-with-after-inline: after inline" ) 1019 //# sourceURL=defer-with-after-inline-js-after1020 970 /* ]]> */ 1021 971 </script> … … 1065 1015 /* <![CDATA[ */ 1066 1016 scriptEventLog.push( "defer-dependent-of-nested-aliases: before inline" ) 1067 //# sourceURL=defer-dependent-of-nested-aliases-js-before1068 1017 /* ]]> */ 1069 1018 </script> … … 1072 1021 /* <![CDATA[ */ 1073 1022 scriptEventLog.push( "defer-dependent-of-nested-aliases: after inline" ) 1074 //# sourceURL=defer-dependent-of-nested-aliases-js-after1075 1023 /* ]]> */ 1076 1024 </script> … … 1671 1619 wp_enqueue_script( 'test-only-data', 'example.com', array(), null ); 1672 1620 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"; 1674 1622 $expected .= "<script type='text/javascript' src='http://example.com' id='test-only-data-js'></script>\n"; 1675 1623 … … 1709 1657 wp_script_add_data( 'test-conditional-with-data', 'data', 'testing' ); 1710 1658 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"; 1712 1660 $expected .= "<!--[if lt IE 9]>\n<script type='text/javascript' src='http://example.com' id='test-conditional-with-data-js'></script>\n<![endif]-->\n"; 1713 1661 $expected = str_replace( "'", '"', $expected ); … … 1933 1881 /* <![CDATA[ */ 1934 1882 console.log("before"); 1935 //# sourceURL=test-example-js-before1936 1883 /* ]]> */ 1937 1884 </script> … … 1954 1901 /* <![CDATA[ */ 1955 1902 console.log("after"); 1956 //# sourceURL=test-example-js-after1957 1903 /* ]]> */ 1958 1904 </script> … … 1970 1916 wp_add_inline_script( 'test-example', 'console.log("after");' ); 1971 1917 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"; 1973 1919 $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"; 1975 1921 1976 1922 $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); … … 1985 1931 wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ); 1986 1932 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"; 1988 1934 1989 1935 $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); … … 1998 1944 wp_add_inline_script( 'test-example', 'console.log("after");' ); 1999 1945 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"; 2001 1947 2002 1948 $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); … … 2012 1958 wp_add_inline_script( 'test-example', 'console.log("after");' ); 2013 1959 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"; 2016 1962 2017 1963 $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); … … 2028 1974 wp_add_inline_script( 'test-example', 'console.log("after");' ); 2029 1975 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"; 2031 1977 $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"; 2033 1979 2034 1980 $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); … … 2044 1990 wp_add_inline_script( 'test-example', 'console.log("after");' ); 2045 1991 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"; 2048 1994 $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"; 2050 1996 2051 1997 $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); … … 2068 2014 wp_add_inline_script( 'two', 'console.log("before two");', 'before' ); 2069 2015 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"; 2071 2017 $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"; 2073 2019 $expected .= "<script type='text/javascript' src='{$this->default_scripts_dir}two.js?ver={$wp_version}' id='two-js'></script>\n"; 2074 2020 $expected .= "<script type='text/javascript' src='{$this->default_scripts_dir}three.js?ver={$wp_version}' id='three-js'></script>\n"; … … 2092 2038 wp_add_inline_script( 'one', 'console.log("before one");', 'before' ); 2093 2039 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"; 2095 2041 $expected .= "<script type='text/javascript' src='{$this->default_scripts_dir}one.js?ver={$wp_version}' id='one-js'></script>\n"; 2096 2042 $expected .= "<script type='text/javascript' src='{$this->default_scripts_dir}two.js?ver={$wp_version}' id='two-js'></script>\n"; … … 2119 2065 $expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=one&ver={$wp_version}'></script>\n"; 2120 2066 $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"; 2122 2068 $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"; 2124 2070 $expected .= "<script type='text/javascript' src='{$this->default_scripts_dir}four.js?ver={$wp_version}' id='four-js'></script>\n"; 2125 2071 … … 2137 2083 2138 2084 $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"; 2140 2086 $expected_localized .= "<![endif]-->\n"; 2141 2087 $expected_localized = str_replace( "'", '"', $expected_localized ); 2142 2088 2143 2089 $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"; 2145 2091 $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"; 2147 2093 $expected .= "<![endif]-->\n"; 2148 2094 $expected = str_replace( "'", '"', $expected ); … … 2172 2118 $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"; 2173 2119 $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"; 2175 2121 2176 2122 wp_enqueue_script( 'test-example', 'http://example.com', array( 'jquery' ), null ); … … 2197 2143 $expected .= "<!--[if gte IE 9]>\n"; 2198 2144 $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"; 2200 2146 $expected .= "<![endif]-->\n"; 2201 2147 … … 2223 2169 2224 2170 $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"; 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"; 2226 2172 $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n"; 2227 2173 … … 2248 2194 2249 2195 $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"; 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"; 2251 2197 $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n"; 2252 2198 $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/i18n.min.js' id='wp-i18n-js'></script>\n"; … … 2254 2200 $expected .= "/* <![CDATA[ */\n"; 2255 2201 $expected .= "wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ 'ltr' ] } );\n"; 2256 $expected .= "//# sourceURL=wp-i18n-js-after\n";2257 2202 $expected .= "/* ]]> */\n"; 2258 2203 $expected .= "</script>\n"; 2259 2204 $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/a11y.min.js' id='wp-a11y-js'></script>\n"; 2260 2205 $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 2262 2208 wp_enqueue_script( 'test-example', 'http://example.com', array( 'jquery' ), null ); 2263 2209 wp_add_inline_script( 'test-example', 'console.log("before");', 'before' ); … … 2303 2249 $expected_tail .= "/* <![CDATA[ */\n"; 2304 2250 $expected_tail .= "tryCustomizeDependency()\n"; 2305 $expected_tail .= "//# sourceURL=customize-dependency-js-after\n";2306 2251 $expected_tail .= "/* ]]> */\n"; 2307 2252 $expected_tail .= "</script>\n"; … … 2339 2284 2340 2285 $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"; 2342 2287 $expected .= "<script type='text/javascript' src='/wp-includes/js/script2.js?ver={$wp_version}' id='two-js'></script>\n"; 2343 2288 $expected .= "<script type='text/javascript' src='/wp-includes/js/script3.js?ver={$wp_version}' id='three-js'></script>\n"; … … 2363 2308 2364 2309 $expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=one,two&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"; 2366 2311 $expected .= "<script type='text/javascript' src='/wp-includes/js/script3.js?ver={$wp_version}' id='three-js'></script>\n"; 2367 2312 $expected .= "<script type='text/javascript' src='/wp-includes/js/script4.js?ver={$wp_version}' id='four-js'></script>\n"; … … 2383 2328 ), 2384 2329 '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", 2387 2332 ), 2388 2333 'after-blocking' => array( … … 2393 2338 ), 2394 2339 '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", 2397 2342 ), 2398 2343 'before-delayed' => array( … … 2402 2347 ), 2403 2348 '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", 2406 2351 ), 2407 2352 'after-delayed' => array( … … 2412 2357 ), 2413 2358 '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", 2416 2361 ), 2417 2362 ); … … 3055 3000 wp_localize_script( 'test-example', 'testExample', $l10n_data ); 3056 3001 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"; 3058 3003 $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n"; 3059 3004 … … 3624 3569 return $data['dependencies']; 3625 3570 } 3626 3627 /**3628 * @ticket 638873629 */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 = <<<HTML3638 <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-after3642 </script>3643 3644 HTML;3645 3646 $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) );3647 }3648 3571 }
Note: See TracChangeset
for help on using the changeset viewer.