diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs
index 9622914b5b5..a4cb42711d7 100644
--- a/components/script/dom/htmlformelement.rs
+++ b/components/script/dom/htmlformelement.rs
@@ -98,7 +98,7 @@ impl HTMLFormElementMethods for HTMLFormElement {
make_setter!(SetAcceptCharset, "accept-charset");
// https://html.spec.whatwg.org/multipage/#dom-fs-action
- make_url_or_base_getter!(Action, "action");
+ make_string_or_document_url_getter!(Action, "action");
// https://html.spec.whatwg.org/multipage/#dom-fs-action
make_setter!(SetAction, "action");
@@ -295,7 +295,7 @@ impl HTMLFormElement {
pub fn submit(&self, submit_method_flag: SubmittedFrom, submitter: FormSubmitter) {
// Step 1
let doc = document_from_node(self);
- let base = doc.url();
+ let base = doc.base_url();
// TODO: Handle browsing contexts (Step 2, 3)
// Step 4
if submit_method_flag == SubmittedFrom::NotFromForm &&
diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs
index 2b29ec8014c..e69255b6aed 100644
--- a/components/script/dom/macros.rs
+++ b/components/script/dom/macros.rs
@@ -123,6 +123,26 @@ macro_rules! make_url_or_base_getter(
);
);
+#[macro_export]
+macro_rules! make_string_or_document_url_getter(
+ ( $attr:ident, $htmlname:tt ) => (
+ fn $attr(&self) -> DOMString {
+ use dom::bindings::inheritance::Castable;
+ use dom::element::Element;
+ use dom::node::document_from_node;
+ let element = self.upcast::();
+ let val = element.get_string_attribute(&atom!($htmlname));
+
+ if val.is_empty() {
+ let doc = document_from_node(self);
+ DOMString::from(doc.url().clone().into_string())
+ } else {
+ val
+ }
+ }
+ );
+);
+
#[macro_export]
macro_rules! make_enumerated_getter(
( $attr:ident, $htmlname:tt, $default:expr, $(($choices: pat))|+) => (
diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json
index 7f95b602122..265c4e6ce34 100644
--- a/tests/wpt/metadata/MANIFEST.json
+++ b/tests/wpt/metadata/MANIFEST.json
@@ -37715,6 +37715,12 @@
"deleted_reftests": {},
"items": {
"testharness": {
+ "html/semantics/forms/the-form-element/form-action-url.html": [
+ {
+ "path": "html/semantics/forms/the-form-element/form-action-url.html",
+ "url": "/html/semantics/forms/the-form-element/form-action-url.html"
+ }
+ ],
"html/semantics/forms/the-select-element/common-HTMLOptionsCollection-add.html": [
{
"path": "html/semantics/forms/the-select-element/common-HTMLOptionsCollection-add.html",
diff --git a/tests/wpt/web-platform-tests/html/semantics/forms/the-form-element/form-action-url.html b/tests/wpt/web-platform-tests/html/semantics/forms/the-form-element/form-action-url.html
new file mode 100644
index 00000000000..09f073ab945
--- /dev/null
+++ b/tests/wpt/web-platform-tests/html/semantics/forms/the-form-element/form-action-url.html
@@ -0,0 +1,9 @@
+
+
+
+
+
+