From 3c7e6a4be83ce406a21c6b23fd1a89ddaa2a67d2 Mon Sep 17 00:00:00 2001 From: Rebecca Date: Tue, 29 Mar 2016 18:48:07 -0400 Subject: [PATCH 1/2] Fix HtmlLabelElement activation to run on correct element Also removes old code that caused radio button clicks on disabled elements --- components/script/dom/htmlinputelement.rs | 4 ---- components/script/dom/htmllabelelement.rs | 15 +++++++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 03c3bf83d0c..8a0fa78887e 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -861,10 +861,6 @@ impl VirtualMethods for HTMLInputElement { } if event.type_() == atom!("click") && !event.DefaultPrevented() { - if let InputType::InputRadio = self.input_type.get() { - self.update_checked_state(true, true); - } - // TODO: Dispatch events for non activatable inputs // https://html.spec.whatwg.org/multipage/#common-input-element-events diff --git a/components/script/dom/htmllabelelement.rs b/components/script/dom/htmllabelelement.rs index 7042b98f0d7..90d4a16b86e 100644 --- a/components/script/dom/htmllabelelement.rs +++ b/components/script/dom/htmllabelelement.rs @@ -63,12 +63,15 @@ impl Activatable for HTMLLabelElement { // https://html.spec.whatwg.org/multipage/#run-post-click-activation-steps fn activation_behavior(&self, _event: &Event, _target: &EventTarget) { - synthetic_click_activation(self.upcast::(), - false, - false, - false, - false, - ActivationSource::NotFromClick); + if let Some(e) = self.GetControl() { + let elem = e.upcast::(); + synthetic_click_activation(elem, + false, + false, + false, + false, + ActivationSource::NotFromClick); + } } // https://html.spec.whatwg.org/multipage/#implicit-submission From e813f4a85a80edd311c62f546c7692a653a98ccc Mon Sep 17 00:00:00 2001 From: Rebecca Date: Tue, 29 Mar 2016 18:49:56 -0400 Subject: [PATCH 2/2] Add test for HtmlLabelElement clicks --- tests/wpt/mozilla/meta/MANIFEST.json | 6 + .../tests/mozilla/htmllabel-activation.html | 170 ++++++++++++++++++ .../mozilla/htmllabel-form-activation.html | 4 + 3 files changed, 180 insertions(+) create mode 100644 tests/wpt/mozilla/tests/mozilla/htmllabel-activation.html create mode 100644 tests/wpt/mozilla/tests/mozilla/htmllabel-form-activation.html diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 24c84798ed4..79c777f8e90 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -5892,6 +5892,12 @@ "url": "/_mozilla/mozilla/htmlfontelement_size_attribute.html" } ], + "mozilla/htmllabel-activation.html": [ + { + "path": "mozilla/htmllabel-activation.html", + "url": "/_mozilla/mozilla/htmllabel-activation.html" + } + ], "mozilla/htmlspacechars.html": [ { "path": "mozilla/htmlspacechars.html", diff --git a/tests/wpt/mozilla/tests/mozilla/htmllabel-activation.html b/tests/wpt/mozilla/tests/mozilla/htmllabel-activation.html new file mode 100644 index 00000000000..ff77c80a18f --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/htmllabel-activation.html @@ -0,0 +1,170 @@ + + +Click action on label + + + +
+ + diff --git a/tests/wpt/mozilla/tests/mozilla/htmllabel-form-activation.html b/tests/wpt/mozilla/tests/mozilla/htmllabel-form-activation.html new file mode 100644 index 00000000000..68296b3c724 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/htmllabel-form-activation.html @@ -0,0 +1,4 @@ + + +Click action on label with nested form +