Bug 213205

Summary: [WPT] form.action does not return document.url when unset (part of https://wpt.live/html/dom/reflection-forms.html)
Product: WebKit Reporter: Sam Weinig <sam>
Component: DOMAssignee: Sam Weinig <sam>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, changseok, ddkilzer, esprehn+autocc, ews-watchlist, gyuyoung.kim, kondapallykalyan, mifenton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Test case
none
WIP
none
WIP
none
Patch
none
Patch none

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>