From 82386953b9f0249cee76951c78e269ca2f38f076 Mon Sep 17 00:00:00 2001 From: Vincent Ricard Date: Thu, 24 Sep 2020 18:13:20 +0200 Subject: [PATCH 1/2] Allow mutating --- components/script/dom/htmlinputelement.rs | 17 ++++++++++------- .../dom/events/Event-dispatch-click.html.ini | 13 ------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index a8ca388c1728b..cc402f20bf1b4 100755 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -2728,18 +2728,18 @@ impl Activatable for HTMLInputElement { // https://html.spec.whatwg.org/multipage/#reset-button-state-%28type=reset%29:activation-behaviour-2 // https://html.spec.whatwg.org/multipage/#checkbox-state-%28type=checkbox%29:activation-behaviour-2 // https://html.spec.whatwg.org/multipage/#radio-button-state-%28type=radio%29:activation-behaviour-2 - InputType::Submit | - InputType::Reset | - InputType::File | - InputType::Checkbox | - InputType::Radio => self.is_mutable(), + InputType::Submit | InputType::Reset | InputType::File => self.is_mutable(), + InputType::Checkbox | InputType::Radio => true, _ => false, } } // https://dom.spec.whatwg.org/#eventtarget-legacy-pre-activation-behavior fn legacy_pre_activation_behavior(&self) -> Option { - if !self.is_mutable() { + if !self.is_mutable() && + self.input_type() != InputType::Checkbox && + self.input_type() != InputType::Radio + { return None; } @@ -2777,7 +2777,10 @@ impl Activatable for HTMLInputElement { // https://dom.spec.whatwg.org/#eventtarget-legacy-canceled-activation-behavior fn legacy_canceled_activation_behavior(&self, cache: Option) { // Step 1 - if !self.is_mutable() { + if !self.is_mutable() && + self.input_type() != InputType::Checkbox && + self.input_type() != InputType::Radio + { return; } let ty = self.input_type(); diff --git a/tests/wpt/metadata/dom/events/Event-dispatch-click.html.ini b/tests/wpt/metadata/dom/events/Event-dispatch-click.html.ini index 4b9fdba1acae1..33709ceac1cc2 100644 --- a/tests/wpt/metadata/dom/events/Event-dispatch-click.html.ini +++ b/tests/wpt/metadata/dom/events/Event-dispatch-click.html.ini @@ -2,16 +2,3 @@ type: testharness [event state during post-click handling] expected: FAIL - - [disabled radio should be checked from dispatchEvent(new MouseEvent("click"))] - expected: FAIL - - [disabled checkbox should be checked from dispatchEvent(new MouseEvent("click"))] - expected: FAIL - - [disabled radio should get legacy-canceled-activation behavior] - expected: FAIL - - [disabled checkbox should get legacy-canceled-activation behavior] - expected: FAIL - From 15376d031d2b656acf1e43381cd5303c34392c9c Mon Sep 17 00:00:00 2001 From: Vincent Ricard Date: Thu, 24 Sep 2020 19:52:04 +0200 Subject: [PATCH 2/2] Remove unnecessary checks --- components/script/dom/htmlinputelement.rs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index cc402f20bf1b4..b4056514c1345 100755 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -2736,13 +2736,6 @@ impl Activatable for HTMLInputElement { // https://dom.spec.whatwg.org/#eventtarget-legacy-pre-activation-behavior fn legacy_pre_activation_behavior(&self) -> Option { - if !self.is_mutable() && - self.input_type() != InputType::Checkbox && - self.input_type() != InputType::Radio - { - return None; - } - let ty = self.input_type(); match ty { InputType::Checkbox => { @@ -2777,12 +2770,6 @@ impl Activatable for HTMLInputElement { // https://dom.spec.whatwg.org/#eventtarget-legacy-canceled-activation-behavior fn legacy_canceled_activation_behavior(&self, cache: Option) { // Step 1 - if !self.is_mutable() && - self.input_type() != InputType::Checkbox && - self.input_type() != InputType::Radio - { - return; - } let ty = self.input_type(); let cache = match cache { Some(cache) => {