Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/forms/attributes-common-to-form-controls/formaction.html - WPT Dashboard Interop Dashboard
<!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">
</head>
<body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<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];
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>