summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/events/Event-dispatch-click.tentative.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/dom/events/Event-dispatch-click.tentative.html
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/dom/events/Event-dispatch-click.tentative.html')
-rw-r--r--testing/web-platform/tests/dom/events/Event-dispatch-click.tentative.html78
1 files changed, 78 insertions, 0 deletions
diff --git a/testing/web-platform/tests/dom/events/Event-dispatch-click.tentative.html b/testing/web-platform/tests/dom/events/Event-dispatch-click.tentative.html
new file mode 100644
index 0000000000..cfdae55ef2
--- /dev/null
+++ b/testing/web-platform/tests/dom/events/Event-dispatch-click.tentative.html
@@ -0,0 +1,78 @@
+<!doctype html>
+<title>Clicks on input element</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=dump style=display:none></div>
+<script>
+var dump = document.getElementById("dump")
+
+test(t => {
+ const input = document.createElement("input");
+ input.type = "checkbox";
+ input.disabled = true;
+ const label = document.createElement("label");
+ label.append(input);
+ dump.append(label);
+ label.click();
+ assert_false(input.checked);
+}, "disabled checkbox should not be checked from label click");
+
+test(t => {
+ const input = document.createElement("input");
+ input.type = "radio";
+ input.disabled = true;
+ const label = document.createElement("label");
+ label.append(input);
+ dump.append(label);
+ label.click();
+ assert_false(input.checked);
+}, "disabled radio should not be checked from label click");
+
+test(t => {
+ const input = document.createElement("input");
+ input.type = "checkbox";
+ input.disabled = true;
+ const label = document.createElement("label");
+ label.append(input);
+ dump.append(label);
+ label.dispatchEvent(new MouseEvent("click"));
+ assert_false(input.checked);
+}, "disabled checkbox should not be checked from label click by dispatchEvent");
+
+test(t => {
+ const input = document.createElement("input");
+ input.type = "radio";
+ input.disabled = true;
+ const label = document.createElement("label");
+ label.append(input);
+ dump.append(label);
+ label.dispatchEvent(new MouseEvent("click"));
+ assert_false(input.checked);
+}, "disabled radio should not be checked from label click by dispatchEvent");
+
+test(t => {
+ const checkbox = dump.appendChild(document.createElement("input"));
+ checkbox.type = "checkbox";
+ checkbox.onclick = ev => {
+ checkbox.type = "date";
+ ev.preventDefault();
+ };
+ checkbox.dispatchEvent(new MouseEvent("click", { cancelable: true }));
+ assert_false(checkbox.checked);
+}, "checkbox morphed into another type should not mutate checked state");
+
+test(t => {
+ const radio1 = dump.appendChild(document.createElement("input"));
+ const radio2 = dump.appendChild(radio1.cloneNode());
+ radio1.type = radio2.type = "radio";
+ radio1.name = radio2.name = "foo";
+ radio2.checked = true;
+ radio1.onclick = ev => {
+ radio1.type = "date";
+ ev.preventDefault();
+ };
+ radio1.dispatchEvent(new MouseEvent("click", { cancelable: true }));
+ assert_false(radio1.checked);
+ assert_true(radio2.checked);
+}, "radio morphed into another type should not steal the existing checked state");
+</script>