<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 script = document.createElement('script');
script.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 <script> ' +
'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 script = document.createElement('script');
script.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 <script> ' +
'fetchpriority content attribute');
const t = async_test('Priority Hints is use-counted when the ' +
'fetchpriority content attribute is parsed on the ' +
'<script> 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.head.innerHTML += "<script src=../resources/dummy.js " +
"fetchpriority=high><" + "/script>";
assert_true(internals.isUseCounted(document, kPriorityHints),
'Priority Hints is use-counted once the fetchpriority ' +
'content attribute is parsed');
}));
</script>