mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-22 17:31:58 -05:00
LibWeb: Implement HTMLAreaElement.referrerPolicy
This commit is contained in:
parent
07cd441e95
commit
91c7920b34
9 changed files with 26 additions and 4 deletions
|
@ -12,6 +12,13 @@ a referrerPolicy value after setting to null: ''
|
|||
a referrerPolicy value after setting to "NO-REFERRER": 'no-referrer'
|
||||
a referrerPolicy value after setting to "": ''
|
||||
a referrerPolicy value after calling removeAttribute: ''
|
||||
area referrerPolicy initial value: ''
|
||||
area referrerPolicy value after setting to "invalid": ''
|
||||
area referrerPolicy value after setting to "no-referrer": 'no-referrer'
|
||||
area referrerPolicy value after setting to null: ''
|
||||
area referrerPolicy value after setting to "NO-REFERRER": 'no-referrer'
|
||||
area referrerPolicy value after setting to "": ''
|
||||
area referrerPolicy value after calling removeAttribute: ''
|
||||
img referrerPolicy initial value: ''
|
||||
img referrerPolicy value after setting to "invalid": ''
|
||||
img referrerPolicy value after setting to "no-referrer": 'no-referrer'
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
for (const elementName of ["link", "a", "img", "iframe", "script"]) {
|
||||
for (const elementName of ["link", "a", "area", "img", "iframe", "script"]) {
|
||||
const element = document.createElement(elementName);
|
||||
println(`${elementName} referrerPolicy initial value: '${element.referrerPolicy}'`);
|
||||
element.referrerPolicy = "invalid";
|
||||
|
|
|
@ -61,6 +61,11 @@ WebIDL::ExceptionOr<void> HTMLAnchorElement::set_hyperlink_element_utils_href(St
|
|||
return set_attribute(HTML::AttributeNames::href, move(href));
|
||||
}
|
||||
|
||||
Optional<String> HTMLAnchorElement::hyperlink_element_utils_referrerpolicy() const
|
||||
{
|
||||
return attribute(HTML::AttributeNames::referrerpolicy);
|
||||
}
|
||||
|
||||
bool HTMLAnchorElement::has_activation_behavior() const
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -52,6 +52,7 @@ private:
|
|||
virtual DOM::Document& hyperlink_element_utils_document() override { return document(); }
|
||||
virtual Optional<String> hyperlink_element_utils_href() const override;
|
||||
virtual WebIDL::ExceptionOr<void> set_hyperlink_element_utils_href(String) override;
|
||||
virtual Optional<String> hyperlink_element_utils_referrerpolicy() const override;
|
||||
virtual bool hyperlink_element_utils_is_html_anchor_element() const final { return true; }
|
||||
virtual bool hyperlink_element_utils_is_connected() const final { return is_connected(); }
|
||||
virtual void hyperlink_element_utils_queue_an_element_task(HTML::Task::Source source, Function<void()> steps) override
|
||||
|
|
|
@ -63,6 +63,11 @@ WebIDL::ExceptionOr<void> HTMLAreaElement::set_hyperlink_element_utils_href(Stri
|
|||
return set_attribute(HTML::AttributeNames::href, move(href));
|
||||
}
|
||||
|
||||
Optional<String> HTMLAreaElement::hyperlink_element_utils_referrerpolicy() const
|
||||
{
|
||||
return attribute(HTML::AttributeNames::referrerpolicy);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
|
||||
i32 HTMLAreaElement::default_tab_index_value() const
|
||||
{
|
||||
|
|
|
@ -36,6 +36,7 @@ private:
|
|||
virtual DOM::Document& hyperlink_element_utils_document() override { return document(); }
|
||||
virtual Optional<String> hyperlink_element_utils_href() const override;
|
||||
virtual WebIDL::ExceptionOr<void> set_hyperlink_element_utils_href(String) override;
|
||||
virtual Optional<String> hyperlink_element_utils_referrerpolicy() const override;
|
||||
virtual bool hyperlink_element_utils_is_html_anchor_element() const override { return false; }
|
||||
virtual bool hyperlink_element_utils_is_connected() const override { return is_connected(); }
|
||||
virtual void hyperlink_element_utils_queue_an_element_task(HTML::Task::Source source, Function<void()> steps) override
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#import <Fetch/Request.idl>
|
||||
#import <HTML/HTMLElement.idl>
|
||||
#import <HTML/HTMLHyperlinkElementUtils.idl>
|
||||
|
||||
|
@ -15,7 +16,7 @@ interface HTMLAreaElement : HTMLElement {
|
|||
[CEReactions, Reflect] attribute USVString ping;
|
||||
[CEReactions, Reflect] attribute DOMString rel;
|
||||
[SameObject, PutForwards=value] readonly attribute DOMTokenList relList;
|
||||
[FIXME, CEReactions] attribute DOMString referrerPolicy;
|
||||
[CEReactions, Reflect=referrerpolicy, Enumerated=ReferrerPolicy] attribute DOMString referrerPolicy;
|
||||
|
||||
// Obsolete
|
||||
[Reflect=nohref] attribute boolean noHref;
|
||||
|
|
|
@ -515,9 +515,10 @@ void HTMLHyperlinkElementUtils::follow_the_hyperlink(Optional<String> hyperlink_
|
|||
url_string = MUST(url_builder.to_string());
|
||||
}
|
||||
|
||||
// FIXME: 11. Let referrerPolicy be the current state of subject's referrerpolicy content attribute.
|
||||
// 11. Let referrerPolicy be the current state of subject's referrerpolicy content attribute.
|
||||
auto referrer_policy = ReferrerPolicy::from_string(hyperlink_element_utils_referrerpolicy().value_or({})).value_or(ReferrerPolicy::ReferrerPolicy::EmptyString);
|
||||
|
||||
// FIXME: 12. If subject's link types includes the noreferrer keyword, then set referrerPolicy to "no-referrer".
|
||||
auto const referrer_policy = ReferrerPolicy::ReferrerPolicy::EmptyString;
|
||||
|
||||
// 13. Navigate targetNavigable to urlString using subject's node document, with referrerPolicy set to referrerPolicy and userInvolvement set to userInvolvement.
|
||||
MUST(target_navigable->navigate({ .url = url_string, .source_document = hyperlink_element_utils_document(), .referrer_policy = referrer_policy, .user_involvement = user_involvement }));
|
||||
|
|
|
@ -54,6 +54,7 @@ protected:
|
|||
virtual DOM::Document& hyperlink_element_utils_document() = 0;
|
||||
virtual Optional<String> hyperlink_element_utils_href() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_hyperlink_element_utils_href(String) = 0;
|
||||
virtual Optional<String> hyperlink_element_utils_referrerpolicy() const = 0;
|
||||
virtual bool hyperlink_element_utils_is_html_anchor_element() const = 0;
|
||||
virtual bool hyperlink_element_utils_is_connected() const = 0;
|
||||
virtual String hyperlink_element_utils_get_an_elements_target() const = 0;
|
||||
|
|
Loading…
Reference in a new issue