chromium/third_party/blink/web_tests/http/tests/priority-hints/script-dynamic-insertion.html

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

<script>
  const tests = [
    // Dynamically-inserted <script> tests.
    {test: async_test('high fetchPriority on dynamically-inserted <script>s translates to kHigh resource load priority'), fetchPriority: 'high', expected_priority: kHigh},
    {test: async_test('low fetchPriority on dynamically-inserted <script>s has no effect on resource load priority'), fetchPriority: 'low', expected_priority: kLow},
    {test: async_test('auto fetchPriority on dynamically-inserted <script>s has no effect on resource load priority'), fetchPriority: 'auto', expected_priority: kLow},
    {test: async_test('invalid fetchPriority on dynamically-inserted <script>s has no effect on resource load priority'), fetchPriority: 'xyz', expected_priority: kLow},
    {test: async_test('missing fetchPriority on dynamically-inserted <script>s has no effect on resource load priority'), expected_priority: kLow},

    // Dynamically-inserted <script type=module> tests.
    {test: async_test('high fetchPriority on dynamically-inserted module <script>s has no effect on resource load priority'),
      fetchPriority: 'high', module: true, expected_priority: kHigh},
     // This test below actually fails because ResourceFetcher currently does
     // not make it easy to down-prioritize ResourceRequests whose priority is
     // pre-set, and module scripts have their priority set to kHigh before they
     // reach ResourceFetcher. This is related to crbug.com/882344.
    {test: async_test('low fetchPriority on dynamically-inserted module <script>s translates to kLow resource load priority'),
      fetchPriority: 'low', module: true, expected_priority: kLow},
    {test: async_test('auto fetchPriority on dynamically-inserted module <script>s has no effect on resource load priority'),
      fetchPriority: 'auto', module: true, expected_priority: kHigh},
    {test: async_test('invalid fetchPriority on dynamically-inserted module <script>s has no effect on resource load priority'),
      fetchPriority: 'xyz', module: true, expected_priority: kHigh},
    {test: async_test('missing fetchPriority on dynamically-inserted module <script>s has no effect on resource load priority'),
     module: true, expected_priority: kHigh}

  ];

  let iteration = 0;
  for (const test of tests) {
    const script = document.createElement('script');
    if (test.fetchPriority) script.fetchPriority = test.fetchPriority;
    if (test.module) script.type = "module";
    script.src = `../resources/dummy.js?${iteration++}`;
    script.onload = assert_priority_onload(script.src, test.expected_priority, test.test);
    document.head.appendChild(script);
  }
</script>