diff --git a/Tests/LibWeb/Text/expected/HTML/HTMLFormElement-action.txt b/Tests/LibWeb/Text/expected/HTML/HTMLFormElement-action.txt new file mode 100644 index 00000000000..87afb8e7e02 --- /dev/null +++ b/Tests/LibWeb/Text/expected/HTML/HTMLFormElement-action.txt @@ -0,0 +1,3 @@ + form.action initial value: http://www.example.com/ +Final segment of form.action after setting to the empty string: HTMLFormElement-action.html +Final segment of form.action after setting to "../test.html": test.html diff --git a/Tests/LibWeb/Text/input/HTML/HTMLFormElement-action.html b/Tests/LibWeb/Text/input/HTML/HTMLFormElement-action.html new file mode 100644 index 00000000000..da585416486 --- /dev/null +++ b/Tests/LibWeb/Text/input/HTML/HTMLFormElement-action.html @@ -0,0 +1,14 @@ + + +
+ diff --git a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp index e1f92cd17bf..5adcb87fc52 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLFormElement.cpp @@ -604,12 +604,12 @@ String HTMLFormElement::action() const // The action IDL attribute must reflect the content attribute of the same name, except that on getting, when the // content attribute is missing or its value is the empty string, the element's node document's URL must be returned // instead. - if (auto maybe_action = attribute(AttributeNames::action); - maybe_action.has_value() && !maybe_action.value().is_empty()) { - return maybe_action.value(); + auto form_action_attribute = attribute(AttributeNames::action); + if (!form_action_attribute.has_value() || form_action_attribute.value().is_empty()) { + return document().url_string(); } - return MUST(document().url().to_string()); + return MUST(document().base_url().complete_url(form_action_attribute.value()).to_string()); } // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-fs-action