diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs
index d748919914e8..998b9b275e12 100755
--- a/components/script/dom/htmlinputelement.rs
+++ b/components/script/dom/htmlinputelement.rs
@@ -408,6 +408,18 @@ impl TextControl for HTMLInputElement {
fn textinput(&self) -> &DomRefCell> {
&self.textinput
}
+
+ // https://html.spec.whatwg.org/multipage/#concept-input-apply
+ fn selection_api_applies(&self) -> bool {
+ match self.input_type() {
+ InputType::Text | InputType::Search | InputType::Url
+ | InputType::Tel | InputType::Password => {
+ true
+ },
+
+ _ => false
+ }
+ }
}
impl HTMLInputElementMethods for HTMLInputElement {
@@ -679,38 +691,38 @@ impl HTMLInputElementMethods for HTMLInputElement {
}
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionstart
- fn SelectionStart(&self) -> u32 {
- self.dom_selection_start()
+ fn GetSelectionStart(&self) -> Option {
+ self.get_dom_selection_start()
}
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionstart
- fn SetSelectionStart(&self, start: u32) {
- self.set_dom_selection_start(start);
+ fn SetSelectionStart(&self, start: Option) -> ErrorResult {
+ self.set_dom_selection_start(start)
}
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionend
- fn SelectionEnd(&self) -> u32 {
- self.dom_selection_end()
+ fn GetSelectionEnd(&self) -> Option {
+ self.get_dom_selection_end()
}
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionend
- fn SetSelectionEnd(&self, end: u32) {
+ fn SetSelectionEnd(&self, end: Option) -> ErrorResult {
self.set_dom_selection_end(end)
}
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectiondirection
- fn SelectionDirection(&self) -> DOMString {
- self.dom_selection_direction()
+ fn GetSelectionDirection(&self) -> Option {
+ self.get_dom_selection_direction()
}
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectiondirection
- fn SetSelectionDirection(&self, direction: DOMString) {
- self.set_dom_selection_direction(direction);
+ fn SetSelectionDirection(&self, direction: Option) -> ErrorResult {
+ self.set_dom_selection_direction(direction)
}
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-setselectionrange
- fn SetSelectionRange(&self, start: u32, end: u32, direction: Option) {
- self.set_dom_selection_range(start, end, direction);
+ fn SetSelectionRange(&self, start: u32, end: u32, direction: Option) -> ErrorResult {
+ self.set_dom_selection_range(start, end, direction)
}
// Select the files based on filepaths passed in,
diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs
index b9a6ad3ff697..7996eecc563b 100755
--- a/components/script/dom/htmltextareaelement.rs
+++ b/components/script/dom/htmltextareaelement.rs
@@ -8,6 +8,7 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding;
use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods;
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
+use dom::bindings::error::ErrorResult;
use dom::bindings::inheritance::Castable;
use dom::bindings::root::{DomRoot, LayoutDom, MutNullableDom};
use dom::bindings::str::DOMString;
@@ -145,6 +146,10 @@ impl TextControl for HTMLTextAreaElement {
fn textinput(&self) -> &DomRefCell> {
&self.textinput
}
+
+ fn selection_api_applies(&self) -> bool {
+ true
+ }
}
impl HTMLTextAreaElementMethods for HTMLTextAreaElement {
@@ -260,38 +265,38 @@ impl HTMLTextAreaElementMethods for HTMLTextAreaElement {
}
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionstart
- fn SelectionStart(&self) -> u32 {
- self.dom_selection_start()
+ fn GetSelectionStart(&self) -> Option {
+ self.get_dom_selection_start()
}
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionstart
- fn SetSelectionStart(&self, start: u32) {
- self.set_dom_selection_start(start);
+ fn SetSelectionStart(&self, start: Option) -> ErrorResult {
+ self.set_dom_selection_start(start)
}
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionend
- fn SelectionEnd(&self) -> u32 {
- self.dom_selection_end()
+ fn GetSelectionEnd(&self) -> Option {
+ self.get_dom_selection_end()
}
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionend
- fn SetSelectionEnd(&self, end: u32) {
- self.set_dom_selection_end(end);
+ fn SetSelectionEnd(&self, end: Option) -> ErrorResult {
+ self.set_dom_selection_end(end)
}
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectiondirection
- fn SelectionDirection(&self) -> DOMString {
- self.dom_selection_direction()
+ fn GetSelectionDirection(&self) -> Option {
+ self.get_dom_selection_direction()
}
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectiondirection
- fn SetSelectionDirection(&self, direction: DOMString) {
- self.set_dom_selection_direction(direction);
+ fn SetSelectionDirection(&self, direction: Option) -> ErrorResult {
+ self.set_dom_selection_direction(direction)
}
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-setselectionrange
- fn SetSelectionRange(&self, start: u32, end: u32, direction: Option) {
- self.set_dom_selection_range(start, end, direction);
+ fn SetSelectionRange(&self, start: u32, end: u32, direction: Option) -> ErrorResult {
+ self.set_dom_selection_range(start, end, direction)
}
}
diff --git a/components/script/dom/textcontrol.rs b/components/script/dom/textcontrol.rs
index 2b47fcd00a44..9143c2bda233 100644
--- a/components/script/dom/textcontrol.rs
+++ b/components/script/dom/textcontrol.rs
@@ -4,6 +4,7 @@
use dom::bindings::cell::DomRefCell;
use dom::bindings::conversions::DerivedFrom;
+use dom::bindings::error::{Error, ErrorResult};
use dom::bindings::str::DOMString;
use dom::event::{EventBubbles, EventCancelable};
use dom::eventtarget::EventTarget;
@@ -13,52 +14,108 @@ use textinput::{SelectionDirection, TextInput};
pub trait TextControl: DerivedFrom + DerivedFrom {
fn textinput(&self) -> &DomRefCell>;
+ fn selection_api_applies(&self) -> bool;
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionstart
- fn dom_selection_start(&self) -> u32 {
- self.textinput().borrow().get_selection_start()
+ fn get_dom_selection_start(&self) -> Option {
+ // Step 1
+ if !self.selection_api_applies() {
+ return None;
+ }
+
+ // Steps 2-3
+ Some(self.selection_start())
}
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionstart
- fn set_dom_selection_start(&self, start: u32) {
+ fn set_dom_selection_start(&self, start: Option) -> ErrorResult {
+ // Step 1
+ if !self.selection_api_applies() {
+ return Err(Error::InvalidState);
+ }
+
// Step 2
- let mut end = self.dom_selection_end();
+ let mut end = self.selection_end();
// Step 3
- if end < start {
- end = start;
+ if let Some(s) = start {
+ if end < s {
+ end = s;
+ }
}
// Step 4
- self.set_selection_range(start, end, self.selection_direction());
+ self.set_selection_range(start, Some(end), Some(self.selection_direction()));
+ Ok(())
}
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionend
- fn dom_selection_end(&self) -> u32 {
- self.textinput().borrow().get_absolute_insertion_point() as u32
+ fn get_dom_selection_end(&self) -> Option {
+ // Step 1
+ if !self.selection_api_applies() {
+ return None;
+ }
+
+ // Steps 2-3
+ Some(self.selection_end())
}
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionend
- fn set_dom_selection_end(&self, end: u32) {
- self.set_selection_range(self.dom_selection_start(), end, self.selection_direction());
+ fn set_dom_selection_end(&self, end: Option) -> ErrorResult {
+ // Step 1
+ if !self.selection_api_applies() {
+ return Err(Error::InvalidState);
+ }
+
+ // Step 2
+ self.set_selection_range(Some(self.selection_start()), end, Some(self.selection_direction()));
+ Ok(())
}
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectiondirection
- fn dom_selection_direction(&self) -> DOMString {
- DOMString::from(self.selection_direction())
+ fn get_dom_selection_direction(&self) -> Option {
+ // Step 1
+ if !self.selection_api_applies() {
+ return None;
+ }
+
+ Some(DOMString::from(self.selection_direction()))
}
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectiondirection
- fn set_dom_selection_direction(&self, direction: DOMString) {
- self.textinput().borrow_mut().selection_direction = SelectionDirection::from(direction);
+ fn set_dom_selection_direction(&self, direction: Option) -> ErrorResult {
+ // Step 1
+ if !self.selection_api_applies() {
+ return Err(Error::InvalidState);
+ }
+
+ // Step 2
+ self.set_selection_range(
+ Some(self.selection_start()),
+ Some(self.selection_end()),
+ direction.map(|d| SelectionDirection::from(d))
+ );
+ Ok(())
}
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-setselectionrange
- fn set_dom_selection_range(&self, start: u32, end: u32, direction: Option) {
- // Step 4
- let direction = direction.map_or(SelectionDirection::None, |d| SelectionDirection::from(d));
+ fn set_dom_selection_range(&self, start: u32, end: u32, direction: Option) -> ErrorResult {
+ // Step 1
+ if !self.selection_api_applies() {
+ return Err(Error::InvalidState);
+ }
+
+ // Step 2
+ self.set_selection_range(Some(start), Some(end), direction.map(|d| SelectionDirection::from(d)));
+ Ok(())
+ }
- self.set_selection_range(start, end, direction);
+ fn selection_start(&self) -> u32 {
+ self.textinput().borrow().get_selection_start()
+ }
+
+ fn selection_end(&self) -> u32 {
+ self.textinput().borrow().get_absolute_insertion_point() as u32
}
fn selection_direction(&self) -> SelectionDirection {
@@ -66,12 +123,15 @@ pub trait TextControl: DerivedFrom + DerivedFrom {
}
// https://html.spec.whatwg.org/multipage/#set-the-selection-range
- fn set_selection_range(&self, start: u32, end: u32, direction: SelectionDirection) {
- // Step 5
- self.textinput().borrow_mut().selection_direction = direction;
+ fn set_selection_range(&self, start: Option, end: Option, direction: Option) {
+ // Step 1
+ let start = start.unwrap_or(0);
- // Step 3
- self.textinput().borrow_mut().set_selection_range(start, end);
+ // Step 2
+ let end = end.unwrap_or(0);
+
+ // Steps 3-5
+ self.textinput().borrow_mut().set_selection_range(start, end, direction.unwrap_or(SelectionDirection::None));
// Step 6
let window = window_from_node(self);
diff --git a/components/script/dom/webidls/HTMLInputElement.webidl b/components/script/dom/webidls/HTMLInputElement.webidl
index 29bc4b27737a..93a5a7f108b4 100644
--- a/components/script/dom/webidls/HTMLInputElement.webidl
+++ b/components/script/dom/webidls/HTMLInputElement.webidl
@@ -90,13 +90,17 @@ interface HTMLInputElement : HTMLElement {
readonly attribute NodeList labels;
//void select();
- attribute unsigned long selectionStart;
- attribute unsigned long selectionEnd;
- attribute DOMString selectionDirection;
+ [SetterThrows]
+ attribute unsigned long? selectionStart;
+ [SetterThrows]
+ attribute unsigned long? selectionEnd;
+ [SetterThrows]
+ attribute DOMString? selectionDirection;
//void setRangeText(DOMString replacement);
//void setRangeText(DOMString replacement, unsigned long start, unsigned long end,
// optional SelectionMode selectionMode = "preserve");
- void setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction);
+ [Throws]
+ void setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction);
// also has obsolete members
diff --git a/components/script/dom/webidls/HTMLTextAreaElement.webidl b/components/script/dom/webidls/HTMLTextAreaElement.webidl
index 2e2e12885590..f0e8a0be1181 100644
--- a/components/script/dom/webidls/HTMLTextAreaElement.webidl
+++ b/components/script/dom/webidls/HTMLTextAreaElement.webidl
@@ -51,11 +51,15 @@ interface HTMLTextAreaElement : HTMLElement {
readonly attribute NodeList labels;
// void select();
- attribute unsigned long selectionStart;
- attribute unsigned long selectionEnd;
- attribute DOMString selectionDirection;
+ [SetterThrows]
+ attribute unsigned long? selectionStart;
+ [SetterThrows]
+ attribute unsigned long? selectionEnd;
+ [SetterThrows]
+ attribute DOMString? selectionDirection;
// void setRangeText(DOMString replacement);
// void setRangeText(DOMString replacement, unsigned long start, unsigned long end,
// optional SelectionMode selectionMode = "preserve");
- void setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction);
+ [Throws]
+ void setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction);
};
diff --git a/components/script/textinput.rs b/components/script/textinput.rs
index 310e05664536..0fe0024a116b 100644
--- a/components/script/textinput.rs
+++ b/components/script/textinput.rs
@@ -21,7 +21,7 @@ pub enum Selection {
NotSelected
}
-#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)]
+#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)]
pub enum SelectionDirection {
Forward,
Backward,
@@ -825,7 +825,7 @@ impl TextInput {
}
}
- pub fn set_selection_range(&mut self, start: u32, end: u32) {
+ pub fn set_selection_range(&mut self, start: u32, end: u32, direction: SelectionDirection) {
let mut start = start as usize;
let mut end = end as usize;
let text_end = self.get_content().len();
@@ -837,7 +837,9 @@ impl TextInput {
start = end;
}
- match self.selection_direction {
+ self.selection_direction = direction;
+
+ match direction {
SelectionDirection::None |
SelectionDirection::Forward => {
self.selection_begin = Some(self.get_text_point_for_absolute_point(start));
diff --git a/tests/unit/script/textinput.rs b/tests/unit/script/textinput.rs
index 977b0e686c9a..5b98dc934c69 100644
--- a/tests/unit/script/textinput.rs
+++ b/tests/unit/script/textinput.rs
@@ -583,19 +583,19 @@ fn test_textinput_cursor_position_correct_after_clearing_selection() {
#[test]
fn test_textinput_set_selection_with_direction() {
let mut textinput = text_input(Lines::Single, "abcdef");
- textinput.selection_direction = SelectionDirection::Forward;
- textinput.set_selection_range(2, 6);
+ textinput.set_selection_range(2, 6, SelectionDirection::Forward);
assert_eq!(textinput.edit_point.line, 0);
assert_eq!(textinput.edit_point.index, 6);
+ assert_eq!(textinput.selection_direction, SelectionDirection::Forward);
assert!(textinput.selection_begin.is_some());
assert_eq!(textinput.selection_begin.unwrap().line, 0);
assert_eq!(textinput.selection_begin.unwrap().index, 2);
- textinput.selection_direction = SelectionDirection::Backward;
- textinput.set_selection_range(2, 6);
+ textinput.set_selection_range(2, 6, SelectionDirection::Backward);
assert_eq!(textinput.edit_point.line, 0);
assert_eq!(textinput.edit_point.index, 2);
+ assert_eq!(textinput.selection_direction, SelectionDirection::Backward);
assert!(textinput.selection_begin.is_some());
assert_eq!(textinput.selection_begin.unwrap().line, 0);
diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json
index e58fa12d536e..35c55c9a3171 100644
--- a/tests/wpt/metadata/MANIFEST.json
+++ b/tests/wpt/metadata/MANIFEST.json
@@ -542639,7 +542639,7 @@
"support"
],
"html/semantics/forms/textfieldselection/select-event.html": [
- "e4835db1c781cad4b259b782a57b452022a50d79",
+ "6232a1316c4221be0f2f28a91939adfbce5698f8",
"testharness"
],
"html/semantics/forms/textfieldselection/selection-after-content-change.html": [
@@ -542651,7 +542651,7 @@
"testharness"
],
"html/semantics/forms/textfieldselection/selection-not-application.html": [
- "3763f117f8973ca9a994354ccbf22cb7114ece7a",
+ "db63d0d1eedec810d4c7e1b38789be457e06e985",
"testharness"
],
"html/semantics/forms/textfieldselection/selection-start-end.html": [
diff --git a/tests/wpt/metadata/html/semantics/forms/textfieldselection/select-event.html.ini b/tests/wpt/metadata/html/semantics/forms/textfieldselection/select-event.html.ini
index 39e337a9fd6d..1f1def1f0dac 100644
--- a/tests/wpt/metadata/html/semantics/forms/textfieldselection/select-event.html.ini
+++ b/tests/wpt/metadata/html/semantics/forms/textfieldselection/select-event.html.ini
@@ -1,23 +1,146 @@
[select-event.html]
type: testharness
- [select() on textarea queues select event]
+ [textarea: select()]
expected: FAIL
- [select() on input type text queues select event]
+ [textarea: select() a second time (must not fire select)]
expected: FAIL
- [select() on input type search queues select event]
+ [textarea: selectionStart a second time (must not fire select)]
expected: FAIL
- [select() on input type tel queues select event]
+ [textarea: selectionEnd a second time (must not fire select)]
expected: FAIL
- [select() on input type url queues select event]
+ [textarea: selectionDirection a second time (must not fire select)]
expected: FAIL
- [select() on input type password queues select event]
+ [textarea: setSelectionRange() a second time (must not fire select)]
expected: FAIL
- [text field selection: select()]
+ [textarea: setRangeText()]
+ expected: FAIL
+
+ [textarea: setRangeText() a second time (must not fire select)]
+ expected: FAIL
+
+ [input type text: select()]
+ expected: FAIL
+
+ [input type text: select() a second time (must not fire select)]
+ expected: FAIL
+
+ [input type text: selectionStart a second time (must not fire select)]
+ expected: FAIL
+
+ [input type text: selectionEnd a second time (must not fire select)]
+ expected: FAIL
+
+ [input type text: selectionDirection a second time (must not fire select)]
+ expected: FAIL
+
+ [input type text: setSelectionRange() a second time (must not fire select)]
+ expected: FAIL
+
+ [input type text: setRangeText()]
+ expected: FAIL
+
+ [input type text: setRangeText() a second time (must not fire select)]
+ expected: FAIL
+
+ [input type search: select()]
+ expected: FAIL
+
+ [input type search: select() a second time (must not fire select)]
+ expected: FAIL
+
+ [input type search: selectionStart a second time (must not fire select)]
+ expected: FAIL
+
+ [input type search: selectionEnd a second time (must not fire select)]
+ expected: FAIL
+
+ [input type search: selectionDirection a second time (must not fire select)]
+ expected: FAIL
+
+ [input type search: setSelectionRange() a second time (must not fire select)]
+ expected: FAIL
+
+ [input type search: setRangeText()]
+ expected: FAIL
+
+ [input type search: setRangeText() a second time (must not fire select)]
+ expected: FAIL
+
+ [input type tel: select()]
+ expected: FAIL
+
+ [input type tel: select() a second time (must not fire select)]
+ expected: FAIL
+
+ [input type tel: selectionStart a second time (must not fire select)]
+ expected: FAIL
+
+ [input type tel: selectionEnd a second time (must not fire select)]
+ expected: FAIL
+
+ [input type tel: selectionDirection a second time (must not fire select)]
+ expected: FAIL
+
+ [input type tel: setSelectionRange() a second time (must not fire select)]
+ expected: FAIL
+
+ [input type tel: setRangeText()]
+ expected: FAIL
+
+ [input type tel: setRangeText() a second time (must not fire select)]
+ expected: FAIL
+
+ [input type url: select()]
+ expected: FAIL
+
+ [input type url: select() a second time (must not fire select)]
+ expected: FAIL
+
+ [input type url: selectionStart a second time (must not fire select)]
+ expected: FAIL
+
+ [input type url: selectionEnd a second time (must not fire select)]
+ expected: FAIL
+
+ [input type url: selectionDirection a second time (must not fire select)]
+ expected: FAIL
+
+ [input type url: setSelectionRange() a second time (must not fire select)]
+ expected: FAIL
+
+ [input type url: setRangeText()]
+ expected: FAIL
+
+ [input type url: setRangeText() a second time (must not fire select)]
+ expected: FAIL
+
+ [input type password: select()]
+ expected: FAIL
+
+ [input type password: select() a second time (must not fire select)]
+ expected: FAIL
+
+ [input type password: selectionStart a second time (must not fire select)]
+ expected: FAIL
+
+ [input type password: selectionEnd a second time (must not fire select)]
+ expected: FAIL
+
+ [input type password: selectionDirection a second time (must not fire select)]
+ expected: FAIL
+
+ [input type password: setSelectionRange() a second time (must not fire select)]
+ expected: FAIL
+
+ [input type password: setRangeText()]
+ expected: FAIL
+
+ [input type password: setRangeText() a second time (must not fire select)]
expected: FAIL
diff --git a/tests/wpt/metadata/html/semantics/forms/textfieldselection/selection-not-application.html.ini b/tests/wpt/metadata/html/semantics/forms/textfieldselection/selection-not-application.html.ini
index a97a4c9832b8..81dc9d94fb15 100644
--- a/tests/wpt/metadata/html/semantics/forms/textfieldselection/selection-not-application.html.ini
+++ b/tests/wpt/metadata/html/semantics/forms/textfieldselection/selection-not-application.html.ini
@@ -1,71 +1,74 @@
[selection-not-application.html]
type: testharness
- [text field selection for the input hidden]
+ [setRangeText on an input[type=hidden\] throws InvalidStateError]
expected: FAIL
- [text field selection for the input email]
+ [setRangeText on an input[type=email\] throws InvalidStateError]
expected: FAIL
- [text field selection for the input datetime]
+ [setRangeText on an input[type=datetime-local\] throws InvalidStateError]
expected: FAIL
- [text field selection for the input date]
+ [setRangeText on an input[type=date\] throws InvalidStateError]
expected: FAIL
- [text field selection for the input month]
+ [setRangeText on an input[type=month\] throws InvalidStateError]
expected: FAIL
- [text field selection for the input week]
+ [setRangeText on an input[type=week\] throws InvalidStateError]
expected: FAIL
- [text field selection for the input time]
+ [setRangeText on an input[type=time\] throws InvalidStateError]
expected: FAIL
- [text field selection for the input number]
+ [setRangeText on an input[type=number\] throws InvalidStateError]
expected: FAIL
- [text field selection for the input range]
+ [setRangeText on an input[type=range\] throws InvalidStateError]
expected: FAIL
- [text field selection for the input color]
+ [setRangeText on an input[type=color\] throws InvalidStateError]
expected: FAIL
- [text field selection for the input checkbox]
+ [setRangeText on an input[type=checkbox\] throws InvalidStateError]
expected: FAIL
- [text field selection for the input radio]
+ [setRangeText on an input[type=radio\] throws InvalidStateError]
expected: FAIL
- [text field selection for the input file]
+ [setRangeText on an input[type=file\] throws InvalidStateError]
expected: FAIL
- [text field selection for the input submit]
+ [setRangeText on an input[type=submit\] throws InvalidStateError]
expected: FAIL
- [text field selection for the input image]
+ [setRangeText on an input[type=image\] throws InvalidStateError]
expected: FAIL
- [text field selection for the input reset]
+ [setRangeText on an input[type=reset\] throws InvalidStateError]
expected: FAIL
- [text field selection for the input button]
+ [setRangeText on an input[type=button\] throws InvalidStateError]
expected: FAIL
- [text field selection for the input text]
+ [setRangeText on an input[type=text\] doesn't throw an exception]
expected: FAIL
- [text field selection for the input search]
+ [setRangeText on an input[type=search\] doesn't throw an exception]
expected: FAIL
- [text field selection for the input tel]
+ [setRangeText on an input[type=tel\] doesn't throw an exception]
expected: FAIL
- [text field selection for the input url]
+ [setRangeText on an input[type=url\] doesn't throw an exception]
expected: FAIL
- [text field selection for the input password]
+ [setRangeText on an input[type=password\] doesn't throw an exception]
expected: FAIL
- [text field selection for the input datetime-local]
+ [setRangeText on an input[type=null\] doesn't throw an exception]
+ expected: FAIL
+
+ [setRangeText on an input[type=aninvalidtype\] doesn't throw an exception]
expected: FAIL
diff --git a/tests/wpt/web-platform-tests/html/semantics/forms/textfieldselection/select-event.html b/tests/wpt/web-platform-tests/html/semantics/forms/textfieldselection/select-event.html
index 6cfe52e87fed..2fb018f82aab 100644
--- a/tests/wpt/web-platform-tests/html/semantics/forms/textfieldselection/select-event.html
+++ b/tests/wpt/web-platform-tests/html/semantics/forms/textfieldselection/select-event.html
@@ -47,10 +47,10 @@
}
];
-for (const el of els) {
+els.forEach((el) => {
const elLabel = el.localName === "textarea" ? "textarea" : "input type " + el.type;
- for (const action of actions) {
+ actions.forEach((action) => {
// promise_test instead of async_test is important because these need to happen in sequence (to test that events
// fire if and only if the selection changes).
promise_test(t => {
@@ -79,6 +79,6 @@
}, 200);
});
}, `${elLabel}: ${action.label} a second time (must not fire select)`);
- }
-}
+ });
+});
diff --git a/tests/wpt/web-platform-tests/html/semantics/forms/textfieldselection/selection-not-application.html b/tests/wpt/web-platform-tests/html/semantics/forms/textfieldselection/selection-not-application.html
index b0db8a96fabd..04b4fdd4f787 100644
--- a/tests/wpt/web-platform-tests/html/semantics/forms/textfieldselection/selection-not-application.html
+++ b/tests/wpt/web-platform-tests/html/semantics/forms/textfieldselection/selection-not-application.html
@@ -7,45 +7,90 @@