From 1075654f7740e4a1bc04c403d81f511aa8c8837d Mon Sep 17 00:00:00 2001 From: Simon Pieters Date: Wed, 13 Apr 2016 12:48:44 +0200 Subject: [PATCH] Fix #2757: Test input/textarea.selection{Direction,Start,End} not throwing This tests https://github.com/whatwg/html/pull/1006. --- html/dom/interfaces.html | 44 ++++++++++++++++--- .../forms/the-input-element/selection.html | 8 +++- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/html/dom/interfaces.html b/html/dom/interfaces.html index 4ef858637693af..93bf20563c553d 100644 --- a/html/dom/interfaces.html +++ b/html/dom/interfaces.html @@ -1663,9 +1663,9 @@

HTML IDL tests

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); @@ -1786,9 +1786,9 @@

HTML IDL tests

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); @@ -3190,6 +3190,13 @@

HTML IDL tests

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")'], @@ -3351,7 +3358,30 @@

HTML IDL tests

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")'], diff --git a/html/semantics/forms/the-input-element/selection.html b/html/semantics/forms/the-input-element/selection.html index 694051dbf298dd..4ed4bc9141ce60 100644 --- a/html/semantics/forms/the-input-element/selection.html +++ b/html/semantics/forms/the-input-element/selection.html @@ -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); @@ -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); });