Bug 213205 - [WPT] form.action does not return document.url when unset (part of https://wpt.live/html/dom/reflection-forms.html)
Summary: [WPT] form.action does not return document.url when unset (part of https://wp...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Sam Weinig
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-06-15 12:32 PDT by Sam Weinig
Modified: 2020-06-16 14:04 PDT (History)
9 users (show)

See Also:


Attachments
Test case (1.29 KB, text/html)
2020-06-15 12:32 PDT, Sam Weinig
no flags Details
WIP (2.38 KB, patch)
2020-06-15 12:37 PDT, Sam Weinig
no flags Details | Formatted Diff | Diff
WIP (3.19 KB, patch)
2020-06-15 13:25 PDT, Sam Weinig
no flags Details | Formatted Diff | Diff
Patch (15.04 KB, patch)
2020-06-15 18:22 PDT, Sam Weinig
no flags Details | Formatted Diff | Diff
Patch (15.05 KB, patch)
2020-06-15 20:44 PDT, Sam Weinig
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Weinig 2020-06-15 12:32:25 PDT
Created attachment 401922 [details]
Test case

WPT: form.action does not return document.url when unset (part of https://wpt.live/html/dom/reflection-forms.html)

Test: https://wpt.live/html/dom/reflection-forms.html
Spec: https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-fs-action

From the spec: "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".
Comment 1 Sam Weinig 2020-06-15 12:37:27 PDT Comment hidden (obsolete)
Comment 2 Sam Weinig 2020-06-15 13:25:44 PDT Comment hidden (obsolete)
Comment 3 Sam Weinig 2020-06-15 18:22:57 PDT Comment hidden (obsolete)
Comment 4 Sam Weinig 2020-06-15 20:44:07 PDT
Created attachment 401972 [details]
Patch
Comment 5 David Kilzer (:ddkilzer) 2020-06-16 13:32:05 PDT
Comment on attachment 401972 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=401972&action=review

r=me

> Source/WebCore/html/HTMLFormElement.cpp:641
>  String HTMLFormElement::action() const
>  {
> -    return attributeWithoutSynchronization(actionAttr);
> +    auto& value = attributeWithoutSynchronization(actionAttr);
> +    if (value.isEmpty())
> +        return document().url().string();
> +    return document().completeURL(stripLeadingAndTrailingHTMLSpaces(value)).string();
>  }

HTMLFormElement::action() and HTMLFormControlElement::formAction() are now identical, except for the attribute retrieved.

Is there a good place to share the code?  Not necessary to land the patch; just noticed white reviewing.
Comment 6 Sam Weinig 2020-06-16 13:57:28 PDT
(In reply to David Kilzer (:ddkilzer) from comment #5)
> Comment on attachment 401972 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=401972&action=review
> 
> r=me
> 
> > Source/WebCore/html/HTMLFormElement.cpp:641
> >  String HTMLFormElement::action() const
> >  {
> > -    return attributeWithoutSynchronization(actionAttr);
> > +    auto& value = attributeWithoutSynchronization(actionAttr);
> > +    if (value.isEmpty())
> > +        return document().url().string();
> > +    return document().completeURL(stripLeadingAndTrailingHTMLSpaces(value)).string();
> >  }
> 
> HTMLFormElement::action() and HTMLFormControlElement::formAction() are now
> identical, except for the attribute retrieved.
> 
> Is there a good place to share the code?  Not necessary to land the patch;
> just noticed white reviewing.

Not at the minute. Darin and I are discussing how to potentially cover more Reflection cases in https://bugs.webkit.org/show_bug.cgi?id=213227, which, depending on what we do, could cover this as well.
Comment 7 EWS 2020-06-16 14:03:54 PDT
Committed r263113: <https://trac.webkit.org/changeset/263113>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 401972 [details].
Comment 8 Radar WebKit Bug Importer 2020-06-16 14:04:23 PDT
<rdar://problem/64420918>