From 89826bf50f210e6388aebc5f9a88d2625512c6f0 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Wed, 12 Aug 2020 16:22:33 +0200 Subject: [PATCH 1/3] Add tests for disabled input clicks --- dom/events/Event-dispatch-click.html | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/dom/events/Event-dispatch-click.html b/dom/events/Event-dispatch-click.html index 7690f753d9cd0b..4d5d79e94048bd 100644 --- a/dom/events/Event-dispatch-click.html +++ b/dom/events/Event-dispatch-click.html @@ -209,6 +209,48 @@ input.dispatchEvent(new MouseEvent('click')); }, `disconnected radio should be checked from dispatchEvent(new MouseEvent('click'))`); +test(() => { + const input = document.createElement("input"); + input.type = "checkbox"; + input.disabled = true; + input.dispatchEvent(new MouseEvent("click")); + assert_true(input.checked); +}, `disabled checkbox should be checked from dispatchEvent(new MouseEvent("click"))`); + +test(() => { + const input = document.createElement("input"); + input.type = "radio"; + input.disabled = true; + input.dispatchEvent(new MouseEvent("click")); + assert_true(input.checked); +}, `disabled radio should be checked from dispatchEvent(new MouseEvent("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.click(); + assert_false(input.checked); + label.dispatchEvent(new MouseEvent("click")); + assert_false(input.checked); +}, "disabled checkbox 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.click(); + assert_false(input.checked); + label.dispatchEvent(new MouseEvent("click")); + assert_false(input.checked); +}, "disabled radio should not be checked from label click"); + async_test(function(t) { var form = document.createElement("form") var didSubmit = false From ff89bc060b9d68124262f72d1634c1204cb3a8c5 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Wed, 12 Aug 2020 17:55:09 +0200 Subject: [PATCH 2/3] Remove label tests --- dom/events/Event-dispatch-click.html | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/dom/events/Event-dispatch-click.html b/dom/events/Event-dispatch-click.html index 4d5d79e94048bd..e350ef4d44cc49 100644 --- a/dom/events/Event-dispatch-click.html +++ b/dom/events/Event-dispatch-click.html @@ -225,32 +225,6 @@ assert_true(input.checked); }, `disabled radio should be checked from dispatchEvent(new MouseEvent("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.click(); - assert_false(input.checked); - label.dispatchEvent(new MouseEvent("click")); - assert_false(input.checked); -}, "disabled checkbox 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.click(); - assert_false(input.checked); - label.dispatchEvent(new MouseEvent("click")); - assert_false(input.checked); -}, "disabled radio should not be checked from label click"); - async_test(function(t) { var form = document.createElement("form") var didSubmit = false From 9c8a755fb1f651987d5a9fc38577f9d5e8b5dd7b Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Wed, 12 Aug 2020 18:00:41 +0200 Subject: [PATCH 3/3] Require firing onclick --- dom/events/Event-dispatch-click.html | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dom/events/Event-dispatch-click.html b/dom/events/Event-dispatch-click.html index e350ef4d44cc49..4b07103027139b 100644 --- a/dom/events/Event-dispatch-click.html +++ b/dom/events/Event-dispatch-click.html @@ -225,6 +225,22 @@ assert_true(input.checked); }, `disabled radio should be checked from dispatchEvent(new MouseEvent("click"))`); +async_test(t => { + const input = document.createElement("input"); + input.type = "checkbox"; + input.disabled = true; + input.onclick = t.step_func_done(); + input.dispatchEvent(new MouseEvent("click")); +}, `disabled checkbox should fire onclick`); + +async_test(t => { + const input = document.createElement("input"); + input.type = "radio"; + input.disabled = true; + input.onclick = t.step_func_done(); + input.dispatchEvent(new MouseEvent("click")); +}, `disabled radio should fire onclick`); + async_test(function(t) { var form = document.createElement("form") var didSubmit = false