- Timestamp:
- 12/22/2025 08:18:36 PM (11 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/script-modules/wpScriptModules.php
r61391 r61401 1554 1554 public function data_provider_to_test_fetchpriority_bumping(): array { 1555 1555 return array( 1556 'enqueue_bajo' => array(1556 'enqueue_bajo' => array( 1557 1557 'enqueues' => array( 'bajo' ), 1558 1558 'expected' => array( … … 1560 1560 'script_tags' => array( 1561 1561 'bajo' => array( 1562 'url' => '/bajo.js', 1563 'fetchpriority' => 'low', // Priority of 'low' not 'high' because the 'auto' dependent was not enqueued. 1564 'in_footer' => false, 1565 ), 1566 ), 1567 'import_map' => array( 1568 'dyno' => '/dyno.js', 1569 ), 1570 ), 1571 ), 1572 'enqueue_bajo_and_auto' => array( 1573 'enqueues' => array( 'bajo', 'auto' ), 1574 'expected' => array( 1575 'preload_links' => array(), 1576 'script_tags' => array( 1577 'bajo' => array( 1562 1578 'url' => '/bajo.js', 1563 'fetchpriority' => ' high',1579 'fetchpriority' => 'auto', 1564 1580 'in_footer' => false, 1565 1581 'data-wp-fetchpriority' => 'low', 1566 1582 ), 1583 'auto' => array( 1584 'url' => '/auto.js', 1585 'fetchpriority' => 'auto', 1586 'in_footer' => false, 1587 ), 1567 1588 ), 1568 1589 'import_map' => array( 1569 1590 'dyno' => '/dyno.js', 1591 'bajo' => '/bajo.js', 1570 1592 ), 1571 1593 ), 1572 1594 ), 1573 'enqueue_auto' => array(1595 'enqueue_auto' => array( 1574 1596 'enqueues' => array( 'auto' ), 1575 1597 'expected' => array( … … 1583 1605 'script_tags' => array( 1584 1606 'auto' => array( 1585 'url' => '/auto.js', 1586 'fetchpriority' => 'high', 1587 'in_footer' => false, 1588 'data-wp-fetchpriority' => 'auto', 1607 'url' => '/auto.js', 1608 'fetchpriority' => 'auto', // Priority of 'auto' not 'high' because the 'alto' dependent was not enqueued. 1609 'in_footer' => false, 1589 1610 ), 1590 1611 ), … … 1595 1616 ), 1596 1617 ), 1597 'enqueue_alto' => array(1618 'enqueue_alto' => array( 1598 1619 'enqueues' => array( 'alto' ), 1599 1620 'expected' => array( … … 1827 1848 '<body>', 1828 1849 "Snapshot:\n$actual_footer_script_modules" 1850 ); 1851 } 1852 1853 /** 1854 * Tests expected priority is used when a dependent is registered but not enqueued. 1855 * 1856 * @ticket 64429 1857 * 1858 * @covers ::wp_default_script_modules 1859 * @covers WP_Script_Modules::print_enqueued_script_modules 1860 * @covers WP_Script_Modules::get_highest_fetchpriority 1861 */ 1862 public function test_priority_of_dependency_for_non_enqueued_dependent() { 1863 wp_default_script_modules(); 1864 wp_register_script_module( 'not-enqueued', 'https://example.com/not-enqueued.js', array( '@wordpress/a11y' ), null, array( 'priority' => 'high' ) ); 1865 wp_enqueue_script_module( '@wordpress/a11y' ); 1866 1867 $actual = $this->normalize_markup_for_snapshot( get_echo( array( wp_script_modules(), 'print_enqueued_script_modules' ) ) ); 1868 $this->assertEqualHTML( 1869 '<script type="module" src="/wp-includes/js/dist/script-modules/a11y/index.min.js" id="@wordpress/a11y-js-module" fetchpriority="low"></script>', 1870 $actual, 1871 '<body>', 1872 "Snapshot:\n$actual" 1829 1873 ); 1830 1874 }
Note:
See TracChangeset
for help on using the changeset viewer.