<script src=../priorities/resources/common.js></script>
<script src=../resources/testharness.js></script>
<script src=../resources/testharnessreport.js></script>
<script>
const tests = [
{description: 'high fetchpriority on <img>s not fetched by the preload scanner must translate to kHigh resource load priority', fetchPriority: 'high', expected_priority: kHigh},
{description: 'low fetchpriority on <img>s not fetched by the preload scanner must translate to kLow resource load priority', fetchPriority: 'low', expected_priority: kLow},
{description: 'auto fetchpriority on <img>s not fetched by the preload scanner must have no effect on resource load priority', fetchPriority: 'auto', expected_priority: kLow},
{description: 'invalid fetchpriority on <img>s not fetched by the preload scanner must have no effect on resource load priority', fetchPriority: 'xyz', expected_priority: kLow},
{description: 'missing fetchpriority on <img>s not fetched by the preload scanner must have no effect on resource load priority', expected_priority: kLow}
];
let iteration = 0;
for (const test of tests) {
promise_test(async () => {
const img = document.createElement('img');
img.alt = 'img';
if (test.fetchPriority) img.fetchPriority = test.fetchPriority;
const url = new URL(`../resources/square.png?${iteration++}`, location);
const priorityPromise = internals.getInitialResourcePriority(url, document);
img.src = url;
const priority = await priorityPromise;
assert_equals(priority, test.expected_priority, test.description);
});
}
</script>