Changeset 203836 in webkit


Ignore:
Timestamp:
Jul 28, 2016 1:54:03 PM (8 years ago)
Author:
Chris Dumez
Message:

2 first parameters to input.setSelectionRange() should be mandatory
https://bugs.webkit.org/show_bug.cgi?id=160310

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Rebaseline W3C test now that more checks are passing.

  • web-platform-tests/html/dom/interfaces-expected.txt:

Source/WebCore:

2 first parameters to input.setSelectionRange() should be mandatory:

Calling this method without the 2 first parameters makes little
sense.

Firefox agrees with the specification, Chrome does not.

No new tests, rebaselined existing test.

  • bindings/js/JSHTMLInputElementCustom.cpp:

(WebCore::JSHTMLInputElement::setSelectionRange):

  • html/HTMLInputElement.idl:

Source/WebInspectorUI:

Update WebInspector accordingly.

  • UserInterface/Models/NativeFunctionParameters.js:

LayoutTests:

Update existing test to reflect behavior change.

  • fast/dom/non-numeric-values-numeric-parameters-expected.txt:
  • fast/dom/script-tests/non-numeric-values-numeric-parameters.js:
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r203833 r203836  
     12016-07-28  Chris Dumez  <cdumez@apple.com>
     2
     3        2 first parameters to input.setSelectionRange() should be mandatory
     4        https://bugs.webkit.org/show_bug.cgi?id=160310
     5
     6        Reviewed by Alex Christensen.
     7
     8        Update existing test to reflect behavior change.
     9
     10        * fast/dom/non-numeric-values-numeric-parameters-expected.txt:
     11        * fast/dom/script-tests/non-numeric-values-numeric-parameters.js:
     12
    1132016-07-28  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt

    r203833 r203836  
    2929PASS nonNumericPolicy('document.images.item(x)') is 'any type allowed (but not omitted)'
    3030PASS nonNumericPolicy('document.createElement("input").setSelectionRange(x, 0)') is 'any type allowed'
    31 PASS nonNumericPolicy('document.createElement("input").setSelectionRange(0, x)') is 'any type allowed'
     31PASS nonNumericPolicy('document.createElement("input").setSelectionRange(0, x)') is 'any type allowed (but not omitted)'
    3232PASS nonNumericPolicy('createHTMLOptionsCollection().add(document.createElement("option"), x)') is 'any type allowed'
    3333PASS nonNumericPolicy('createHTMLOptionsCollection().remove(x)') is 'any type allowed'
  • trunk/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js

    r203833 r203836  
    241241
    242242shouldBe("nonNumericPolicy('document.createElement(\"input\").setSelectionRange(x, 0)')", "'any type allowed'");
    243 shouldBe("nonNumericPolicy('document.createElement(\"input\").setSelectionRange(0, x)')", "'any type allowed'");
     243shouldBe("nonNumericPolicy('document.createElement(\"input\").setSelectionRange(0, x)')", "'any type allowed (but not omitted)'");
    244244
    245245// HTMLOptionsCollection
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r203833 r203836  
     12016-07-28  Chris Dumez  <cdumez@apple.com>
     2
     3        2 first parameters to input.setSelectionRange() should be mandatory
     4        https://bugs.webkit.org/show_bug.cgi?id=160310
     5
     6        Reviewed by Alex Christensen.
     7
     8        Rebaseline W3C test now that more checks are passing.
     9
     10        * web-platform-tests/html/dom/interfaces-expected.txt:
     11
    1122016-07-28  Chris Dumez  <cdumez@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt

    r203833 r203836  
    27772777PASS HTMLInputElement interface: operation setRangeText(DOMString)
    27782778PASS HTMLInputElement interface: operation setRangeText(DOMString,unsigned long,unsigned long,SelectionMode)
    2779 FAIL HTMLInputElement interface: operation setSelectionRange(unsigned long,unsigned long,DOMString) assert_equals: property has wrong .length expected 2 but got 0
     2779PASS HTMLInputElement interface: operation setSelectionRange(unsigned long,unsigned long,DOMString)
    27802780PASS HTMLInputElement interface: attribute align
    27812781PASS HTMLInputElement interface: attribute useMap
     
    28432843PASS HTMLInputElement interface: calling setRangeText(DOMString,unsigned long,unsigned long,SelectionMode) on document.createElement("input") with too few arguments must throw TypeError
    28442844PASS HTMLInputElement interface: document.createElement("input") must inherit property "setSelectionRange" with the proper type (55)
    2845 FAIL HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on document.createElement("input") with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    2846             fn.apply(obj, args);
    2847         }" did not throw
     2845PASS HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on document.createElement("input") with too few arguments must throw TypeError
    28482846PASS HTMLInputElement interface: document.createElement("input") must inherit property "align" with the proper type (56)
    28492847PASS HTMLInputElement interface: document.createElement("input") must inherit property "useMap" with the proper type (57)
     
    29112909PASS HTMLInputElement interface: calling setRangeText(DOMString,unsigned long,unsigned long,SelectionMode) on createInput("text") with too few arguments must throw TypeError
    29122910PASS HTMLInputElement interface: createInput("text") must inherit property "setSelectionRange" with the proper type (55)
    2913 FAIL HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("text") with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    2914             fn.apply(obj, args);
    2915         }" did not throw
     2911PASS HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("text") with too few arguments must throw TypeError
    29162912PASS HTMLInputElement interface: createInput("text") must inherit property "align" with the proper type (56)
    29172913PASS HTMLInputElement interface: createInput("text") must inherit property "useMap" with the proper type (57)
     
    30453041PASS HTMLInputElement interface: calling setRangeText(DOMString,unsigned long,unsigned long,SelectionMode) on createInput("search") with too few arguments must throw TypeError
    30463042PASS HTMLInputElement interface: createInput("search") must inherit property "setSelectionRange" with the proper type (55)
    3047 FAIL HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("search") with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    3048             fn.apply(obj, args);
    3049         }" did not throw
     3043PASS HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("search") with too few arguments must throw TypeError
    30503044PASS HTMLInputElement interface: createInput("search") must inherit property "align" with the proper type (56)
    30513045PASS HTMLInputElement interface: createInput("search") must inherit property "useMap" with the proper type (57)
     
    31133107PASS HTMLInputElement interface: calling setRangeText(DOMString,unsigned long,unsigned long,SelectionMode) on createInput("tel") with too few arguments must throw TypeError
    31143108PASS HTMLInputElement interface: createInput("tel") must inherit property "setSelectionRange" with the proper type (55)
    3115 FAIL HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("tel") with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    3116             fn.apply(obj, args);
    3117         }" did not throw
     3109PASS HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("tel") with too few arguments must throw TypeError
    31183110PASS HTMLInputElement interface: createInput("tel") must inherit property "align" with the proper type (56)
    31193111PASS HTMLInputElement interface: createInput("tel") must inherit property "useMap" with the proper type (57)
     
    31813173PASS HTMLInputElement interface: calling setRangeText(DOMString,unsigned long,unsigned long,SelectionMode) on createInput("url") with too few arguments must throw TypeError
    31823174PASS HTMLInputElement interface: createInput("url") must inherit property "setSelectionRange" with the proper type (55)
    3183 FAIL HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("url") with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    3184             fn.apply(obj, args);
    3185         }" did not throw
     3175PASS HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("url") with too few arguments must throw TypeError
    31863176PASS HTMLInputElement interface: createInput("url") must inherit property "align" with the proper type (56)
    31873177PASS HTMLInputElement interface: createInput("url") must inherit property "useMap" with the proper type (57)
     
    32493239PASS HTMLInputElement interface: calling setRangeText(DOMString,unsigned long,unsigned long,SelectionMode) on createInput("email") with too few arguments must throw TypeError
    32503240PASS HTMLInputElement interface: createInput("email") must inherit property "setSelectionRange" with the proper type (55)
    3251 FAIL HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("email") with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    3252             fn.apply(obj, args);
    3253         }" did not throw
     3241PASS HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("email") with too few arguments must throw TypeError
    32543242PASS HTMLInputElement interface: createInput("email") must inherit property "align" with the proper type (56)
    32553243PASS HTMLInputElement interface: createInput("email") must inherit property "useMap" with the proper type (57)
     
    33173305PASS HTMLInputElement interface: calling setRangeText(DOMString,unsigned long,unsigned long,SelectionMode) on createInput("password") with too few arguments must throw TypeError
    33183306PASS HTMLInputElement interface: createInput("password") must inherit property "setSelectionRange" with the proper type (55)
    3319 FAIL HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("password") with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    3320             fn.apply(obj, args);
    3321         }" did not throw
     3307PASS HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("password") with too few arguments must throw TypeError
    33223308PASS HTMLInputElement interface: createInput("password") must inherit property "align" with the proper type (56)
    33233309PASS HTMLInputElement interface: createInput("password") must inherit property "useMap" with the proper type (57)
     
    33853371PASS HTMLInputElement interface: calling setRangeText(DOMString,unsigned long,unsigned long,SelectionMode) on createInput("date") with too few arguments must throw TypeError
    33863372PASS HTMLInputElement interface: createInput("date") must inherit property "setSelectionRange" with the proper type (55)
    3387 FAIL HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("date") with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    3388             fn.apply(obj, args);
    3389         }" did not throw
     3373PASS HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("date") with too few arguments must throw TypeError
    33903374PASS HTMLInputElement interface: createInput("date") must inherit property "align" with the proper type (56)
    33913375PASS HTMLInputElement interface: createInput("date") must inherit property "useMap" with the proper type (57)
     
    34533437PASS HTMLInputElement interface: calling setRangeText(DOMString,unsigned long,unsigned long,SelectionMode) on createInput("month") with too few arguments must throw TypeError
    34543438PASS HTMLInputElement interface: createInput("month") must inherit property "setSelectionRange" with the proper type (55)
    3455 FAIL HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("month") with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    3456             fn.apply(obj, args);
    3457         }" did not throw
     3439PASS HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("month") with too few arguments must throw TypeError
    34583440PASS HTMLInputElement interface: createInput("month") must inherit property "align" with the proper type (56)
    34593441PASS HTMLInputElement interface: createInput("month") must inherit property "useMap" with the proper type (57)
     
    35213503PASS HTMLInputElement interface: calling setRangeText(DOMString,unsigned long,unsigned long,SelectionMode) on createInput("week") with too few arguments must throw TypeError
    35223504PASS HTMLInputElement interface: createInput("week") must inherit property "setSelectionRange" with the proper type (55)
    3523 FAIL HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("week") with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    3524             fn.apply(obj, args);
    3525         }" did not throw
     3505PASS HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("week") with too few arguments must throw TypeError
    35263506PASS HTMLInputElement interface: createInput("week") must inherit property "align" with the proper type (56)
    35273507PASS HTMLInputElement interface: createInput("week") must inherit property "useMap" with the proper type (57)
     
    35893569PASS HTMLInputElement interface: calling setRangeText(DOMString,unsigned long,unsigned long,SelectionMode) on createInput("time") with too few arguments must throw TypeError
    35903570PASS HTMLInputElement interface: createInput("time") must inherit property "setSelectionRange" with the proper type (55)
    3591 FAIL HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("time") with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    3592             fn.apply(obj, args);
    3593         }" did not throw
     3571PASS HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("time") with too few arguments must throw TypeError
    35943572PASS HTMLInputElement interface: createInput("time") must inherit property "align" with the proper type (56)
    35953573PASS HTMLInputElement interface: createInput("time") must inherit property "useMap" with the proper type (57)
     
    36573635PASS HTMLInputElement interface: calling setRangeText(DOMString,unsigned long,unsigned long,SelectionMode) on createInput("datetime-local") with too few arguments must throw TypeError
    36583636PASS HTMLInputElement interface: createInput("datetime-local") must inherit property "setSelectionRange" with the proper type (55)
    3659 FAIL HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("datetime-local") with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    3660             fn.apply(obj, args);
    3661         }" did not throw
     3637PASS HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("datetime-local") with too few arguments must throw TypeError
    36623638PASS HTMLInputElement interface: createInput("datetime-local") must inherit property "align" with the proper type (56)
    36633639PASS HTMLInputElement interface: createInput("datetime-local") must inherit property "useMap" with the proper type (57)
     
    37253701PASS HTMLInputElement interface: calling setRangeText(DOMString,unsigned long,unsigned long,SelectionMode) on createInput("number") with too few arguments must throw TypeError
    37263702PASS HTMLInputElement interface: createInput("number") must inherit property "setSelectionRange" with the proper type (55)
    3727 FAIL HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("number") with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    3728             fn.apply(obj, args);
    3729         }" did not throw
     3703PASS HTMLInputElement interface: calling setSelectionRange(unsigned long,unsigned long,DOMString) on createInput("number") with too few arguments must throw TypeError
    37303704PASS HTMLInputElement interface: createInput("number") must inherit property "align" with the proper type (56)
    37313705PASS HTMLInputElement interface: createInput("number") must inherit property "useMap" with the proper type (57)
  • trunk/Source/WebCore/ChangeLog

    r203835 r203836  
     12016-07-28  Chris Dumez  <cdumez@apple.com>
     2
     3        2 first parameters to input.setSelectionRange() should be mandatory
     4        https://bugs.webkit.org/show_bug.cgi?id=160310
     5
     6        Reviewed by Alex Christensen.
     7
     8        2 first parameters to input.setSelectionRange() should be mandatory:
     9        - https://html.spec.whatwg.org/multipage/forms.html#htmlinputelement
     10
     11        Calling this method without the 2 first parameters makes little
     12        sense.
     13
     14        Firefox agrees with the specification, Chrome does not.
     15
     16        No new tests, rebaselined existing test.
     17
     18        * bindings/js/JSHTMLInputElementCustom.cpp:
     19        (WebCore::JSHTMLInputElement::setSelectionRange):
     20        * html/HTMLInputElement.idl:
     21
    1222016-07-28  Anders Carlsson  <andersca@apple.com>
    223
  • trunk/Source/WebCore/bindings/js/JSHTMLInputElementCustom.cpp

    r191887 r203836  
    9292JSValue JSHTMLInputElement::setSelectionRange(ExecState& state)
    9393{
     94    if (UNLIKELY(state.argumentCount() < 2))
     95        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
     96
    9497    HTMLInputElement& input = wrapped();
    9598    if (!input.canHaveSelection())
    9699        return throwTypeError(&state);
    97100
    98     int start = state.argument(0).toInt32(&state);
    99     int end = state.argument(1).toInt32(&state);
    100     String direction = state.argument(2).toString(&state)->value(&state);
     101    int start = state.uncheckedArgument(0).toInt32(&state);
     102    int end = state.uncheckedArgument(1).toInt32(&state);
     103    String direction = state.argument(2).toWTFString(&state);
    101104
    102105    input.setSelectionRange(start, end, direction);
  • trunk/Source/WebCore/html/HTMLInputElement.idl

    r203427 r203836  
    9797    [Custom] void setSelectionRange(long start, long end);
    9898#else
    99     [Custom] void setSelectionRange(optional long start,
    100                                     optional long end,
    101                                     optional DOMString direction);
     99    [Custom] void setSelectionRange(long start, long end, optional DOMString direction);
    102100#endif
    103101
  • trunk/Source/WebInspectorUI/ChangeLog

    r203833 r203836  
     12016-07-28  Chris Dumez  <cdumez@apple.com>
     2
     3        2 first parameters to input.setSelectionRange() should be mandatory
     4        https://bugs.webkit.org/show_bug.cgi?id=160310
     5
     6        Reviewed by Alex Christensen.
     7
     8        Update WebInspector accordingly.
     9
     10        * UserInterface/Models/NativeFunctionParameters.js:
     11
    1122016-07-28  Chris Dumez  <cdumez@apple.com>
    213
  • trunk/Source/WebInspectorUI/UserInterface/Models/NativeFunctionParameters.js

    r203833 r203836  
    910910        setCustomValidity: "error",
    911911        setRangeText: "replacement",
    912         setSelectionRange: "[start], [end], [direction]",
     912        setSelectionRange: "start, end, [direction]",
    913913        stepDown: "[n]",
    914914        stepUp: "[n]",
Note: See TracChangeset for help on using the changeset viewer.