diff options
Diffstat (limited to 'testing/web-platform/tests/html/semantics/forms/the-button-element/button-type.html')
-rw-r--r-- | testing/web-platform/tests/html/semantics/forms/the-button-element/button-type.html | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/forms/the-button-element/button-type.html b/testing/web-platform/tests/html/semantics/forms/the-button-element/button-type.html new file mode 100644 index 0000000000..6cfd6687c7 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/forms/the-button-element/button-type.html @@ -0,0 +1,41 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>HTMLButtonElement.prototype.type</title> +<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me"> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-button-type"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<script> +"use strict"; + +test(() => { + + const button = document.createElement("button"); + assert_equals(button.type, "submit"); + +}, "a button's type should be submit by default"); + +test(() => { + + const button = document.createElement("button"); + + for (const type of ["reset", "button", "submit"]) { + button.type = type; + assert_equals(button.type, type); + + button.type = type.toUpperCase(); + assert_equals(button.type, type); + } + + button.type = "reset"; + button.type = "asdfgdsafd"; + assert_equals(button.type, "submit"); + + button.type = "reset"; + button.type = ""; + assert_equals(button.type, "submit"); + +}, "a button's type should stay within the range of valid values"); + +</script> |