chromium/third_party/blink/web_tests/http/tests/priority-hints/script-module-initial-load.html

<script src=resources/common.js></script>
<script src=../resources/testharness.js></script>
<script src=../resources/testharnessreport.js></script>

<script>
const priority_tests = [
  {
    promise: internals.getInitialResourcePriority(new URL('../resources/dummy.js', location), document),
    expected_priority: kHigh,
    description: 'high fetchpriority on module <script> has no effect'
  },
  {
    promise: internals.getInitialResourcePriority(new URL('../resources/dummy.js?1', location), document),
    expected_priority: kLow,
    description: 'low fetchpriority on module <script> lowers the priority to kLow'
  },
  {
    promise: internals.getInitialResourcePriority(new URL('../resources/dummy.js?2', location), document),
    expected_priority: kHigh,
    description: 'auto fetchpriority on module <script> has no effect'
  },
  {
    promise: internals.getInitialResourcePriority(new URL('../resources/dummy.js?3', location), document),
    expected_priority: kHigh,
    description: 'invalid fetchpriority on module <script> has no effect'
  },
  {
    promise: internals.getInitialResourcePriority(new URL('../resources/dummy.js?4', location), document),
    expected_priority: kHigh,
    description: 'missing fetchpriority on module <script> has no effect'
  },
  {
    promise: internals.getInitialResourcePriority(new URL('../resources/dummy.js?5', location), document),
    expected_priority: kHigh,
    description: 'blocking=render on module <script> raises the priority to kHigh'
  },
];

</script>

<script id=script1 type=module fetchpriority=high src=../resources/dummy.js></script>
<script id=script2 type=module fetchpriority=low src=../resources/dummy.js?1></script>
<script id=script3 type=module fetchpriority=auto src=../resources/dummy.js?2></script>
<script id=script4 type=module fetchpriority=xyz src=../resources/dummy.js?3></script>
<script id=script5 type=module src=../resources/dummy.js?4></script>
<script id=script6 type=module fetchpriority=low blocking=render src=../resources/dummy.js?5></script>

<script>
  promise_test(async (t) => {
    await new Promise(resolve => {
      addEventListener('DOMContentLoaded', resolve);
    });

    const base_msg = ' was fetched by the preload scanner';
    assert_true(internals.isPreloaded(script1.src), script1.src + base_msg);
    assert_true(internals.isPreloaded(script2.src), script2.src + base_msg);
    assert_true(internals.isPreloaded(script3.src), script3.src + base_msg);
    assert_true(internals.isPreloaded(script4.src), script4.src + base_msg);
    assert_true(internals.isPreloaded(script5.src), script5.src + base_msg);
    assert_true(internals.isPreloaded(script6.src), script6.src + base_msg);
  }, 'all scripts were fetched by the preload scanner');

  // Setup the tests described by |priority_tests|.
  for (const test of priority_tests) {
    promise_test(async () => {
      const load_priority = await test.promise;
      assert_equals(load_priority, test.expected_priority);
    }, test.description);
  }
</script>