<script src=resources/common.js></script>
<script src=../resources/testharness.js></script>
<script src=../resources/testharnessreport.js></script>
<script>
test(t => {
t.add_cleanup(clearUseCounter);
assert_false(internals.isUseCounted(document, kPriorityHints),
'Priority Hints is not use-counted before the ' +
'fetchPriority IDL attribute is set');
const image = new Image();
image.fetchPriority = 'high';
assert_true(internals.isUseCounted(document, kPriorityHints),
'Priority Hints is use-counted once the fetchPriority IDL ' +
'attribute is set');
}, 'Priority Hints use-counter works properly with the <img> ' +
'fetchPriority IDL attribute');
test(t => {
t.add_cleanup(clearUseCounter);
assert_false(internals.isUseCounted(document, kPriorityHints),
'Priority Hints is not use-counted before the ' +
'fetchpriority content attribute is set');
const image = new Image();
image.setAttribute('fetchpriority', 'high');
assert_true(internals.isUseCounted(document, kPriorityHints),
'Priority Hints is use-counted once the fetchpriority ' +
'content attribute is set');
}, 'Priority Hints use-counter works properly with the <img> ' +
'fetchpriority content attribute');
const t = async_test('Priority Hints is use-counted when the ' +
'fetchpriority content attribute is parsed on the ' +
'<img> element');
t.add_cleanup(clearUseCounter);
t.step_func(() => {
assert_false(internals.isUseCounted(document, kPriorityHints),
'Priority Hints is not use-counted before the ' +
'fetchpriority content attribute is parsed');
});
window.addEventListener('DOMContentLoaded', t.step_func_done(() => {
document.body.innerHTML += '<img fetchpriority=high ' +
'src../resources/square.png>';
assert_true(internals.isUseCounted(document, kPriorityHints),
'Priority Hints is use-counted once the fetchpriority ' +
'content attribute is parsed');
}));
</script>