diff options
Diffstat (limited to 'testing/web-platform/tests/html/semantics/forms/the-input-element/input-type-change-value.html')
-rw-r--r-- | testing/web-platform/tests/html/semantics/forms/the-input-element/input-type-change-value.html | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/forms/the-input-element/input-type-change-value.html b/testing/web-platform/tests/html/semantics/forms/the-input-element/input-type-change-value.html new file mode 100644 index 0000000000..74aeef7cd5 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/forms/the-input-element/input-type-change-value.html @@ -0,0 +1,33 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Input type switch from / to color</title> +<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez"> +<link rel="author" href="https://mozilla.org" title="Mozilla"> +<link rel="help" href="https://html.spec.whatwg.org/#input-type-change"> +<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1833477"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<body> +<script> +function runTest(focus) { + let input = document.createElement("input"); + input.type = "color"; + document.body.appendChild(input); + if (focus) { + input.focus(); + } + assert_equals(input.value, "#000000", "Invalid color should return a non-empty sanitized value"); + input.type = "text"; + assert_equals(input.value, "", "Value dirty flag should remain false"); + input.type = "color"; + input.value = "#ffffff"; + assert_equals(input.value, "#ffffff", "Valid color is returned"); + input.type = "text"; + assert_equals(input.value, "#ffffff", "Value dirty flag should remain true"); + if (focus) { + assert_equals(document.activeElement, input, "Focus is preserved"); + } +} +test(() => runTest(false), "Without focus"); +test(() => runTest(true), "With focus"); +</script> |