Skip to content

Commit

Permalink
Fix #2757: Test input/textarea.selection{Direction,Start,End} not thr…
Browse files Browse the repository at this point in the history
…owing

This tests whatwg/html#1006.
  • Loading branch information
zcorpan committed Apr 13, 2016
1 parent d4d95f0 commit 1075654
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
44 changes: 37 additions & 7 deletions html/dom/interfaces.html
Original file line number Diff line number Diff line change
Expand Up @@ -1663,9 +1663,9 @@ <h1>HTML IDL tests</h1>
readonly attribute NodeList labels;

void select();
attribute unsigned long selectionStart;
attribute unsigned long selectionEnd;
attribute DOMString selectionDirection;
attribute unsigned long? selectionStart;
attribute unsigned long? selectionEnd;
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);
Expand Down Expand Up @@ -1786,9 +1786,9 @@ <h1>HTML IDL tests</h1>
readonly attribute NodeList labels;

void select();
attribute unsigned long selectionStart;
attribute unsigned long selectionEnd;
attribute DOMString selectionDirection;
attribute unsigned long? selectionStart;
attribute unsigned long? selectionEnd;
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);
Expand Down Expand Up @@ -3190,6 +3190,13 @@ <h1>HTML IDL tests</h1>
iframe.hidden = true;
document.body.appendChild(iframe);
}, {explicit_done:true});

function createInput(type) {
var input = document.createElement('input');
input.type = type;
return input;
}

window.onload = function() {
idlArray.add_objects({
NodeList: ['document.getElementsByName("name")'],
Expand Down Expand Up @@ -3351,7 +3358,30 @@ <h1>HTML IDL tests</h1>
HTMLFieldsetElement: ['document.createElement("fieldset")'],
HTMLLegendElement: ['document.createElement("legend")'],
HTMLLabelElement: ['document.createElement("label")'],
HTMLInputElement: ['document.createElement("input")'],
HTMLInputElement: [
'document.createElement("input")',
'createInput("hidden")',
'createInput("search")',
'createInput("tel")',
'createInput("url")',
'createInput("email")',
'createInput("password")',
'createInput("date")',
'createInput("month")',
'createInput("week")',
'createInput("time")',
'createInput("datetime-local")',
'createInput("number")',
'createInput("range")',
'createInput("color")',
'createInput("checkbox")',
'createInput("radio")',
'createInput("file")',
'createInput("submit")',
'createInput("image")',
'createInput("reset")',
'createInput("button")'
],
HTMLButtonElement: ['document.createElement("button")'],
HTMLSelectElement: ['document.createElement("select")'],
HTMLDataListElement: ['document.createElement("datalist")'],
Expand Down
8 changes: 6 additions & 2 deletions html/semantics/forms/the-input-element/selection.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
input.selectionStart = 0;
a = input.selectionEnd;
input.selectionEnd = 0;
a = input.selectionDirection;
input.selectionDirection = "none";
input.setSelectionRange(0, 0);
input.setRangeText('', 0, 0);

Expand All @@ -118,10 +120,12 @@
input.type = type;
assert_equals(input.type, type, "the given input type is not supported");

assert_throws("INVALID_STATE_ERR", function() { var a = input.selectionStart; });
assert_equals(input.selectionStart, null, 'getting input.selectionStart');
assert_throws("INVALID_STATE_ERR", function() { input.selectionStart = 0; });
assert_throws("INVALID_STATE_ERR", function() { var a = input.selectionEnd; });
assert_equals(input.selectionEnd, null, 'getting input.selectionEnd');
assert_throws("INVALID_STATE_ERR", function() { input.selectionEnd = 0; });
assert_equals(input.selectionDirection, null, 'getting input.selectionDirection');
assert_throws("INVALID_STATE_ERR", function() { input.selectionDirection = "none"; });
assert_throws("INVALID_STATE_ERR", function() { input.setSelectionRange(0, 0); });
assert_throws("INVALID_STATE_ERR", function() { input.setRangeText('', 0, 0); });

Expand Down

0 comments on commit 1075654

Please sign in to comment.