chromium/third_party/blink/web_tests/http/tests/priority-hints/link-stylesheet-initial-load.html

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

<!-- Setup getInitialResourcePriority promises.  -->
<script>
const priority_tests = [
  {
    promise: internals.getInitialResourcePriority(new URL('../resources/dummy.css', location), document),
    expected_priority: kHigh,
    description: 'low fetchpriority on <link rel=stylesheet> must load with kHigh priority'
  },
  {
    promise: internals.getInitialResourcePriority(new URL('../resources/dummy.css?1', location), document),
    expected_priority: kVeryHigh,
    description: 'high fetchpriority on <link rel=stylesheet> must have no effect on resource load priority'
  },
  {
    promise: internals.getInitialResourcePriority(new URL('../resources/dummy.css?2', location), document),
    expected_priority: kVeryHigh,
    description: 'auto fetchpriority on <link rel=stylesheet> must have no effect on resource load priority'
  },
  {
    promise: internals.getInitialResourcePriority(new URL('../resources/dummy.css?3', location), document),
    expected_priority: kVeryHigh,
    description: 'invalid fetchpriority on <link rel=stylesheet> must have no effect on resource load priority'
  },
  {
    promise: internals.getInitialResourcePriority(new URL('../resources/dummy.css?4', location), document),
    expected_priority: kVeryHigh,
    description: 'missing fetchpriority on <link rel=stylesheet> must have no effect on resource load priority'
  }
];
</script>

<link id=link1 fetchpriority=low rel=stylesheet href=../resources/dummy.css>
<link id=link2 fetchpriority=high rel=stylesheet href=../resources/dummy.css?1>
<link id=link3 fetchpriority=auto rel=stylesheet href=../resources/dummy.css?2>
<link id=link4 fetchpriority=xyz rel=stylesheet href=../resources/dummy.css?3>
<link id=link5 rel=stylesheet href=../resources/dummy.css?4>

<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(link1.href), link1.href + base_msg);
    assert_true(internals.isPreloaded(link2.href), link2.href + base_msg);
    assert_true(internals.isPreloaded(link3.href), link3.href + base_msg);
    assert_true(internals.isPreloaded(link4.href), link4.href + base_msg);
    assert_true(internals.isPreloaded(link5.href), link5.href + base_msg);
  }, 'all stylesheets must be 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>