Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2757: Test input/textarea.selection{Direction,Start,End} not throwing #2825

Merged
merged 2 commits into from
May 12, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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")',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding an explicit text entry would be good, IMHO.

'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