diff --git a/components/script/dom/textcontrol.rs b/components/script/dom/textcontrol.rs index 0b8870b1996..2b47fcd00a4 100644 --- a/components/script/dom/textcontrol.rs +++ b/components/script/dom/textcontrol.rs @@ -21,7 +21,16 @@ pub trait TextControl: DerivedFrom + DerivedFrom { // https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionstart fn set_dom_selection_start(&self, start: u32) { - self.set_selection_range(start, self.dom_selection_end(), self.selection_direction()); + // Step 2 + let mut end = self.dom_selection_end(); + + // Step 3 + if end < start { + end = start; + } + + // Step 4 + self.set_selection_range(start, end, self.selection_direction()); } // https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionend diff --git a/tests/wpt/metadata/html/semantics/forms/textfieldselection/selection-start-end.html.ini b/tests/wpt/metadata/html/semantics/forms/textfieldselection/selection-start-end.html.ini deleted file mode 100644 index 1cd51a8db16..00000000000 --- a/tests/wpt/metadata/html/semantics/forms/textfieldselection/selection-start-end.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[selection-start-end.html] - type: testharness - [Setting selectionStart to a value larger than selectionEnd should increase selectionEnd] - expected: FAIL -