Implement HTMLTextArea.setSelectionRange

This commit is contained in:
Alberto Corona 2016-03-15 09:03:05 -05:00 committed by Adrian Utrilla
parent db4481b450
commit 5e863f2eb8
No known key found for this signature in database
GPG key ID: 0B30B0FE149E7525
7 changed files with 150 additions and 178 deletions

View file

@ -13,17 +13,17 @@ use msg::constellation_msg::CONTROL;
use msg::constellation_msg::SUPER;
use msg::constellation_msg::{Key, KeyModifiers};
use script::clipboard_provider::DummyClipboardContext;
use script::textinput::{TextInput, TextPoint, Selection, Lines, Direction};
use script::textinput::{TextInput, TextPoint, Selection, Lines, Direction, SelectionDirection};
use util::str::DOMString;
fn text_input(lines: Lines, s: &str) -> TextInput<DummyClipboardContext> {
TextInput::new(lines, DOMString::from(s), DummyClipboardContext::new(""), None)
TextInput::new(lines, DOMString::from(s), DummyClipboardContext::new(""), None, SelectionDirection::None)
}
#[test]
fn test_set_content_ignores_max_length() {
let mut textinput = TextInput::new(
Lines::Single, DOMString::from(""), DummyClipboardContext::new(""), Some(1)
Lines::Single, DOMString::from(""), DummyClipboardContext::new(""), Some(1), SelectionDirection::None
);
textinput.set_content(DOMString::from("mozilla rocks"));
@ -36,7 +36,8 @@ fn test_textinput_when_inserting_multiple_lines_over_a_selection_respects_max_le
Lines::Multiple,
DOMString::from("hello\nworld"),
DummyClipboardContext::new(""),
Some(17)
Some(17),
SelectionDirection::None,
);
textinput.edit_point = TextPoint { line: 0, index: 1 };
@ -59,7 +60,8 @@ fn test_textinput_when_inserting_multiple_lines_still_respects_max_length() {
Lines::Multiple,
DOMString::from("hello\nworld"),
DummyClipboardContext::new(""),
Some(17)
Some(17),
SelectionDirection::None
);
textinput.edit_point = TextPoint { line: 1, index: 0 };
@ -75,7 +77,8 @@ fn test_textinput_when_content_is_already_longer_than_max_length_and_theres_no_s
Lines::Single,
DOMString::from("abc"),
DummyClipboardContext::new(""),
Some(1)
Some(1),
SelectionDirection::None,
);
textinput.insert_char('a');
@ -89,7 +92,8 @@ fn test_multi_line_textinput_with_maxlength_doesnt_allow_appending_characters_wh
Lines::Multiple,
DOMString::from("abc\nd"),
DummyClipboardContext::new(""),
Some(5)
Some(5),
SelectionDirection::None,
);
textinput.insert_char('a');
@ -103,7 +107,8 @@ fn test_single_line_textinput_with_max_length_doesnt_allow_appending_characters_
Lines::Single,
DOMString::from("abcde"),
DummyClipboardContext::new(""),
Some(5)
Some(5),
SelectionDirection::None,
);
textinput.edit_point = TextPoint { line: 0, index: 1 };
@ -123,7 +128,8 @@ fn test_single_line_textinput_with_max_length_multibyte() {
Lines::Single,
DOMString::from(""),
DummyClipboardContext::new(""),
Some(2)
Some(2),
SelectionDirection::None,
);
textinput.insert_char('á');
@ -140,7 +146,8 @@ fn test_single_line_textinput_with_max_length_multi_code_unit() {
Lines::Single,
DOMString::from(""),
DummyClipboardContext::new(""),
Some(3)
Some(3),
SelectionDirection::None,
);
textinput.insert_char('\u{10437}');
@ -159,7 +166,8 @@ fn test_single_line_textinput_with_max_length_inside_char() {
Lines::Single,
DOMString::from("\u{10437}"),
DummyClipboardContext::new(""),
Some(1)
Some(1),
SelectionDirection::None,
);
textinput.insert_char('x');
@ -172,7 +180,8 @@ fn test_single_line_textinput_with_max_length_doesnt_allow_appending_characters_
Lines::Single,
DOMString::from("a"),
DummyClipboardContext::new(""),
Some(1)
Some(1),
SelectionDirection::None,
);
textinput.insert_char('b');
@ -388,7 +397,8 @@ fn test_clipboard_paste() {
let mut textinput = TextInput::new(Lines::Single,
DOMString::from("defg"),
DummyClipboardContext::new("abc"),
None);
None,
SelectionDirection::None);
assert_eq!(textinput.get_content(), "defg");
assert_eq!(textinput.edit_point.index, 0);
textinput.handle_keydown_aux(Key::V, MODIFIERS);

View file

@ -4836,24 +4836,12 @@
[HTMLTextAreaElement interface: operation select()]
expected: FAIL
[HTMLTextAreaElement interface: attribute selectionStart]
expected: FAIL
[HTMLTextAreaElement interface: attribute selectionEnd]
expected: FAIL
[HTMLTextAreaElement interface: attribute selectionDirection]
expected: FAIL
[HTMLTextAreaElement interface: operation setRangeText(DOMString)]
expected: FAIL
[HTMLTextAreaElement interface: operation setRangeText(DOMString,unsigned long,unsigned long,SelectionMode)]
expected: FAIL
[HTMLTextAreaElement interface: operation setSelectionRange(unsigned long,unsigned long,DOMString)]
expected: FAIL
[HTMLTextAreaElement interface: document.createElement("textarea") must inherit property "autocomplete" with the proper type (0)]
expected: FAIL
@ -4899,15 +4887,6 @@
[HTMLTextAreaElement interface: document.createElement("textarea") must inherit property "select" with the proper type (26)]
expected: FAIL
[HTMLTextAreaElement interface: document.createElement("textarea") must inherit property "selectionStart" with the proper type (27)]
expected: FAIL
[HTMLTextAreaElement interface: document.createElement("textarea") must inherit property "selectionEnd" with the proper type (28)]
expected: FAIL
[HTMLTextAreaElement interface: document.createElement("textarea") must inherit property "selectionDirection" with the proper type (29)]
expected: FAIL
[HTMLTextAreaElement interface: document.createElement("textarea") must inherit property "setRangeText" with the proper type (30)]
expected: FAIL
@ -4920,12 +4899,6 @@
[HTMLTextAreaElement interface: calling setRangeText(DOMString,unsigned long,unsigned long,SelectionMode) on document.createElement("textarea") with too few arguments must throw TypeError]
expected: FAIL
[HTMLTextAreaElement interface: document.createElement("textarea") must inherit property "setSelectionRange" with the proper type (32)]
expected: FAIL
[HTMLTextAreaElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on document.createElement("textarea") with too few arguments must throw TypeError]
expected: FAIL
[HTMLKeygenElement interface: existence and properties of interface object]
expected: FAIL

View file

@ -1,59 +0,0 @@
[textfieldselection-setSelectionRange.html]
type: testharness
[textarea typeof(input.setSelectionRange)']
expected: FAIL
[textarea setSelectionRange return void]
expected: FAIL
[textarea setSelectionRange(0,1)]
expected: FAIL
[textarea setSelectionRange(0,textarea.value.length+1)]
expected: FAIL
[textarea setSelectionRange(2,2)]
expected: FAIL
[textarea setSelectionRange(2,1)]
expected: FAIL
[textarea direction of setSelectionRange(0,1,"backward")]
expected: FAIL
[textarea direction of setSelectionRange(0,1,"forward")]
expected: FAIL
[textarea direction of setSelectionRange(0,1,"none")]
expected: FAIL
[textarea direction of setSelectionRange(0,1,"hoge")]
expected: FAIL
[textarea direction of setSelectionRange(0,1,"BACKWARD")]
expected: FAIL
[textarea direction of setSelectionRange(0,1)]
expected: FAIL
[textarea setSelectionRange("string",1)]
expected: FAIL
[textarea setSelectionRange(true,1)]
expected: FAIL
[textarea setSelectionRange([\],1)]
expected: FAIL
[textarea setSelectionRange({},1)]
expected: FAIL
[textarea setSelectionRange(NaN,1)]
expected: FAIL
[textarea setSelectionRange(null,1)]
expected: FAIL
[textarea setSelectionRange(undefined,1)]
expected: FAIL