Skip to content

Commit

Permalink
Fix web-platform-tests#2757: Test input/textarea.selection{Direction,…
Browse files Browse the repository at this point in the history
…Start,End} not throwing (web-platform-tests#2825)

This tests whatwg/html#1006.
  • Loading branch information
zcorpan authored and arronei committed Jun 14, 2016
1 parent 1d16588 commit aa699d2
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 9 deletions.
45 changes: 38 additions & 7 deletions html/dom/interfaces.html
Original file line number Diff line number Diff line change
Expand Up @@ -1655,9 +1655,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 @@ -1778,9 +1778,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 @@ -3187,6 +3187,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 @@ -3292,7 +3299,31 @@ <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("text")',
'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 aa699d2

Please sign in to comment.