diff options
Diffstat (limited to 'testing/web-platform/tests/html/semantics/forms/attributes-common-to-form-controls/formaction.html')
-rw-r--r-- | testing/web-platform/tests/html/semantics/forms/attributes-common-to-form-controls/formaction.html | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/forms/attributes-common-to-form-controls/formaction.html b/testing/web-platform/tests/html/semantics/forms/attributes-common-to-form-controls/formaction.html new file mode 100644 index 0000000000..82798eaa84 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/forms/attributes-common-to-form-controls/formaction.html @@ -0,0 +1,42 @@ +<!DOCTYPE html> +<html><head> + <title>formaction on button element</title> + <meta content="text/html; charset=UTF-8" http-equiv="content-type"> + <meta content="formaction on button element" name="description"> + <link href="https://html.spec.whatwg.org/multipage/#dom-fs-formaction" rel="help"> +</head> + <body> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + + <div id="log"></div> + <button formaction="http://www.example.com/" style="display: none" type="submit">Submit</button> + <input formaction="http://www.example.com/" style="display: none" type="submit" value="submit"> + <input style="display: none" type="submit" value="submit"> + <input formaction="" style="display: none" type="submit" value="submit"> + + <script type="text/javascript"> + function relativeToAbsolute(relativeURL) { + var a = document.createElement('a'); + a.href = relativeURL; + return a.href; + } + test(function() {assert_equals(document.getElementsByTagName("button")[0].formAction, "http://www.example.com/")}, "formAction on button support"); + test(function() {assert_equals(document.getElementsByTagName("input")[0].formAction, "http://www.example.com/")}, "formAction on input support"); + + var testElem = document.getElementsByTagName("input")[0]; + testElem.formAction = "http://www.example.com/page2.html"; + + test(function() {assert_equals(document.getElementsByTagName("input")[0].formAction, "http://www.example.com/page2.html")}, "formaction absolute URL value on input reflects correct value after being updated by the DOM"); + test(function() {assert_equals(document.getElementsByTagName("input")[0].getAttribute("formaction"), "http://www.example.com/page2.html")}, "formAction absolute URL value is correct using getAttribute"); + + var testElem = document.getElementsByTagName("input")[0]; + testElem.formAction = "../page3.html"; + + test(function() {assert_equals(document.getElementsByTagName("input")[0].formAction, relativeToAbsolute('../page3.html'))}, "formAction relative URL value on input reflects correct value after being updated by the DOM"); + test(function() {assert_equals(document.getElementsByTagName("input")[0].getAttribute("formaction"), "../page3.html")}, "formAction relative URL value is correct using getAttribute"); + + test(function() {assert_equals(document.getElementsByTagName("input")[1].formAction, document.URL)}, "On getting, when formaction is missing, the document's address must be returned"); + test(function() {assert_equals(document.getElementsByTagName("input")[2].formAction, document.URL)}, "On getting, when formaction value is the empty string, the document's address must be returned"); + </script> +</body></html> |