blob: 722d3202bcd4a33867e79f35c23af1d2d3ea228d [file]
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="http://127.0.0.1:8000/resources/slow-script.pl?delay=100"></script>
<script src="http://127.0.0.1:8000/resources/checkResourcePriority.js"></script>
<script>
const priority_tests = [
{
url: new URL('../resources/square100.png', location),
expected_priority: "ResourceLoadPriorityMedium",
description: 'high fetchpriority on <img> must translate to medium resource load priority'
},
{
url: new URL('../resources/square100.png?1', location),
expected_priority: "ResourceLoadPriorityVeryLow",
description: 'low fetchpriority on <img> must translate to very low resource load priority'
},
{
url: new URL('../resources/square100.png?2', location),
expected_priority: "ResourceLoadPriorityLow",
description: 'auto fetchpriority on <img> must translate to low resource load priority'
},
{
url: new URL('../resources/square100.png?3', location),
expected_priority: "ResourceLoadPriorityLow",
description: 'invalid fetchpriority on <img> must translate to low resource load priority'
},
{
url: new URL('../resources/square100.png?4', location),
expected_priority: "ResourceLoadPriorityLow",
description: 'missing fetchpriority on <img> must translate to low resource load priority'
}
];
</script>
<img id=img1 fetchpriority=high src=../resources/square100.png alt=img>
<img id=img2 fetchpriority=low src=../resources/square100.png?1 alt=img>
<img id=img3 fetchpriority=auto src=../resources/square100.png?2 alt=img>
<img id=img4 fetchpriority=xyz src=../resources/square100.png?3 alt=img>
<img id=img5 src=../resources/square100.png?4 alt=img>
<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(img1.src), img1.src + base_msg);
assert_true(internals.isPreloaded(img2.src), img2.src + base_msg);
assert_true(internals.isPreloaded(img3.src), img3.src + base_msg);
assert_true(internals.isPreloaded(img4.src), img4.src + base_msg);
assert_true(internals.isPreloaded(img5.src), img5.src + base_msg);
}, 'all images must be fetched by the preload scanner');
// Setup the tests described by |priority_tests|.
for (const test of priority_tests) {
async_test(t => {
checkResourcePriority(test.url, test.expected_priority, test.description);
t.done();
});
}
</script>