diff options
Diffstat (limited to 'testing/web-platform/tests/html/semantics/forms/the-input-element/valueMode.html')
-rw-r--r-- | testing/web-platform/tests/html/semantics/forms/the-input-element/valueMode.html | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/forms/the-input-element/valueMode.html b/testing/web-platform/tests/html/semantics/forms/the-input-element/valueMode.html new file mode 100644 index 000000000..709c176dd --- /dev/null +++ b/testing/web-platform/tests/html/semantics/forms/the-input-element/valueMode.html @@ -0,0 +1,72 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>Input element value mode</title> +<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> + var types = [ + { type: "hidden", mode: "default" }, + { type: "text", mode: "value", sanitizedValue: "foo" }, + { type: "search", mode: "value", sanitizedValue: "foo" }, + { type: "tel", mode: "value", sanitizedValue: "foo" }, + { type: "url", mode: "value", sanitizedValue: "foo" }, + { type: "email", mode: "value", sanitizedValue: "foo" }, + { type: "password", mode: "value", sanitizedValue: "foo" }, + { type: "datetime-local", mode: "value", sanitizedValue: "" }, + { type: "date", mode: "value", sanitizedValue: "" }, + { type: "month", mode: "value", sanitizedValue: "" }, + { type: "week", mode: "value", sanitizedValue: "" }, + { type: "time", mode: "value", sanitizedValue: "" }, + { type: "number", mode: "value", sanitizedValue: "" }, + { type: "range", mode: "value", sanitizedValue: "50" }, + { type: "color", mode: "value", sanitizedValue: "#000000" }, + { type: "checkbox", mode: "default/on" }, + { type: "radio", mode: "default/on" }, + { type: "submit", mode: "default" }, + { type: "image", mode: "default" }, + { type: "reset", mode: "default" }, + { type: "button", mode: "default" } + ]; + for (var i = 0; i < types.length; i++) { + test(function() { + var input = document.createElement("input"), + expected; + input.type = types[i].type; + input.value = "foo"; + switch(types[i].mode) { + case "default": + expected = ""; + break; + case "default/on": + expected = "on"; + break; + case "value": + expected = types[i].sanitizedValue; + break; + } + assert_equals(input.value, expected); + }, "value IDL attribute of input type " + types[i].type + " without value attribute"); + + test(function() { + var input = document.createElement("input"), + expected; + input.type = types[i].type; + input.setAttribute("value", "bar"); + input.value = "foo"; + switch(types[i].mode) { + case "default": + expected = "bar"; + break; + case "default/on": + expected = "bar"; + break; + case "value": + expected = types[i].sanitizedValue; + break; + } + assert_equals(input.value, expected); + }, "value IDL attribute of input type " + types[i].type + " with value attribute"); + } +</script> |