LibWeb: Implement HTMLImageElement.fetchPriority

This commit is contained in:
Jamie Mansfield 2024-05-27 09:46:36 +01:00 committed by Tim Ledbetter
parent 2b5c3886d9
commit 5ae9b49099
4 changed files with 26 additions and 2 deletions

View file

@ -0,0 +1,5 @@
fetchPriority = auto
fetchPriority = high
fetchPriority = auto

View file

@ -0,0 +1,18 @@
<img id="testImg">
<script src="../include.js"></script>
<script>
test(() => {
const img = document.getElementById('testImg');
println(`fetchPriority = ${img.fetchPriority}`);
println('');
img.fetchPriority = 'high';
println(`fetchPriority = ${img.fetchPriority}`);
println('');
img.fetchPriority = 'invalid-value';
println(`fetchPriority = ${img.fetchPriority}`);
});
</script>

View file

@ -563,7 +563,8 @@ after_step_7:
// 21. Set request's referrer policy to the current state of the element's referrerpolicy attribute.
request->set_referrer_policy(ReferrerPolicy::from_string(get_attribute_value(HTML::AttributeNames::referrerpolicy)).value_or(ReferrerPolicy::ReferrerPolicy::EmptyString));
// FIXME: 22. Set request's priority to the current state of the element's fetchpriority attribute.
// 22. Set request's priority to the current state of the element's fetchpriority attribute.
request->set_priority(Fetch::Infrastructure::request_priority_from_string(get_attribute_value(HTML::AttributeNames::fetchpriority)).value_or(Fetch::Infrastructure::Request::Priority::Auto));
// 24. If the will lazy load element steps given the img return true, then:
if (will_lazy_load_element()) {

View file

@ -23,7 +23,7 @@ interface HTMLImageElement : HTMLElement {
[FIXME, CEReactions] attribute DOMString referrerPolicy;
[FIXME, CEReactions] attribute DOMString decoding;
[CEReactions, Enumerated=LazyLoadingAttribute, Reflect] attribute DOMString loading;
[FIXME, CEReactions] attribute DOMString fetchPriority;
[CEReactions, Enumerated=FetchPriorityAttribute, Reflect=fetchpriority] attribute DOMString fetchPriority;
[FIXME] Promise<undefined> decode();