Skip to content

Commit

Permalink
Make form.action return the actual form submission URL
Browse files Browse the repository at this point in the history
Changes the behavior of the form.action attribute to resolve the form's
action against the current page's URL.  If the action attribute is empty
or missing, the form's action attribute returns the current document URL
(as per the HTML spec).

This change also removes several FAIL cases in the WebKit layout tests
(and the containing *-expected.html files), since those imported tests
now pass.

Bug: 724596
Change-Id: Ieab1615180a2c78d73c0731d9ff1f5beb346f10e
Reviewed-on: https://chromium-review.googlesource.com/888664
Reviewed-by: Kent Tamura <tkent@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#535262}
  • Loading branch information
pes10k authored and Commit Bot committed Feb 8, 2018
1 parent 258943a commit e7d9eab
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 27 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ Peter Brophy <pbrophy@adobe.com>
Peter Collingbourne <peter@pcc.me.uk>
Peter Gal <pgal.u-szeged@partner.samsung.com>
Peter Molnar <pmolnar.u-szeged@partner.samsung.com>
Peter Snyder <snyderp@gmail.com>
Philip Hanson <philip.hanson@intel.com>
Philipp Hancke <fippo@andyet.net>
Philipp Hancke <philipp.hancke@googlemail.com>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This is a testharness.js-based test.
Found 6725 tests; 6709 PASS, 16 FAIL, 0 TIMEOUT, 0 NOTRUN.
Found 6725 tests; 6710 PASS, 15 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS form.title: 32 tests
PASS form.lang: 32 tests
PASS form.dir: 62 tests
Expand All @@ -8,9 +8,7 @@ PASS form.hidden: 33 tests
PASS form.accessKey: 32 tests
PASS form.tabIndex: 24 tests
PASS form.acceptCharset (<form accept-charset>): 32 tests
NOTRUN test
NOTRUN test
PASS form.action: 36 tests
PASS form.action: 38 tests
PASS form.autocomplete: 52 tests
PASS form.enctype: 62 tests
PASS form.encoding (<form enctype>): 62 tests
Expand Down

This file was deleted.

This file was deleted.

3 changes: 2 additions & 1 deletion third_party/WebKit/Source/core/exported/WebFormElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ bool WebFormElement::AutoComplete() const {
}

WebString WebFormElement::Action() const {
return ConstUnwrap<HTMLFormElement>()->Action();
return ConstUnwrap<HTMLFormElement>()->FastGetAttribute(
HTMLNames::actionAttr);
}

WebString WebFormElement::GetName() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,7 @@ WebSearchableFormData::WebSearchableFormData(
if (!is_valid_search_string)
return;

String action(form_element->Action());
KURL url(
form_element->GetDocument().CompleteURL(action.IsNull() ? "" : action));
KURL url(form_element->action());
scoped_refptr<EncodedFormData> form_data =
EncodedFormData::Create(encoded_string);
url.SetQuery(form_data->FlattenToString());
Expand Down
16 changes: 10 additions & 6 deletions third_party/WebKit/Source/core/html/forms/HTMLFormElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,12 +653,16 @@ bool HTMLFormElement::NoValidate() const {
return FastHasAttribute(novalidateAttr);
}

// FIXME: This function should be removed because it does not do the same thing
// as the JavaScript binding for action, which treats action as a URL attribute.
// Last time I (Darin Adler) removed this, someone added it back, so I am
// leaving it in for now.
const AtomicString& HTMLFormElement::Action() const {
return getAttribute(actionAttr);
String HTMLFormElement::action() const {
Document& document = GetDocument();
KURL action_url = document.CompleteURL(attributes_.Action().IsEmpty()
? document.Url().GetString()
: attributes_.Action());
return action_url.GetString();
}

void HTMLFormElement::setAction(const AtomicString& value) {
setAttribute(actionAttr, value);
}

void HTMLFormElement::setEnctype(const AtomicString& value) {
Expand Down
3 changes: 3 additions & 0 deletions third_party/WebKit/Source/core/html/forms/HTMLFormElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class CORE_EXPORT HTMLFormElement final : public HTMLElement {
unsigned length() const;
HTMLElement* item(unsigned index);

String action() const;
void setAction(const AtomicString&);

String enctype() const { return attributes_.EncodingType(); }
void setEnctype(const AtomicString&);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
OverrideBuiltins
] interface HTMLFormElement : HTMLElement {
[CEReactions, Reflect=accept_charset] attribute DOMString acceptCharset;
[CEReactions, Reflect, URL] attribute DOMString action;
[CEReactions, URL] attribute DOMString action;
[CEReactions, Reflect, ReflectOnly=("on","off"), ReflectMissing="on", ReflectInvalid="on"] attribute DOMString autocomplete;
[CEReactions, CustomElementCallbacks] attribute DOMString enctype;
[CEReactions, CustomElementCallbacks] attribute DOMString encoding;
Expand Down

0 comments on commit e7d9eab

Please sign in to comment.