Changeset 206243 in webkit


Ignore:
Timestamp:
Sep 21, 2016 4:50:24 PM (8 years ago)
Author:
Chris Dumez
Message:

Setting HTMLMeterElement's attributes to non-finite values throws wrong exception type
https://bugs.webkit.org/show_bug.cgi?id=162364

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Merge meter test changes from https://github.com/w3c/web-platform-tests/pull/3791.

  • web-platform-tests/html/semantics/forms/the-meter-element/meter-expected.txt:
  • web-platform-tests/html/semantics/forms/the-meter-element/meter.html:

Source/WebCore:

Setting HTMLMeterElement's attributes to non-finite values throws wrong exception type.
It should throw a TypeError because their type is 'double' but we throw a
NOT_SUPPORTED_ERR.

Specification:

Firefox and Chrome agree with the specification.

No new tests, updated existing test.

  • html/HTMLMeterElement.cpp:

(WebCore::HTMLMeterElement::setMin):
(WebCore::HTMLMeterElement::setMax):
(WebCore::HTMLMeterElement::setValue):
(WebCore::HTMLMeterElement::setLow):
(WebCore::HTMLMeterElement::setHigh):
(WebCore::HTMLMeterElement::setOptimum):

  • html/HTMLMeterElement.h:
  • html/HTMLMeterElement.idl:

LayoutTests:

Update existing test to reflect behavior change.

  • fast/dom/HTMLMeterElement/script-tests/set-meter-properties.js:
  • fast/dom/HTMLMeterElement/set-meter-properties-expected.txt:
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r206240 r206243  
     12016-09-21  Chris Dumez  <cdumez@apple.com>
     2
     3        Setting HTMLMeterElement's attributes to non-finite values throws wrong exception type
     4        https://bugs.webkit.org/show_bug.cgi?id=162364
     5
     6        Reviewed by Darin Adler.
     7
     8        Update existing test to reflect behavior change.
     9
     10        * fast/dom/HTMLMeterElement/script-tests/set-meter-properties.js:
     11        * fast/dom/HTMLMeterElement/set-meter-properties-expected.txt:
     12
    1132016-09-21  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/LayoutTests/fast/dom/HTMLMeterElement/script-tests/set-meter-properties.js

    r203333 r206243  
    7878
    7979debug("Set value to invalid value");
    80 shouldThrow('m.value = "value";', '"NotSupportedError (DOM Exception 9): The operation is not supported."');
     80shouldThrowErrorName('m.value = "value";', 'TypeError');
    8181
    8282debug("Set min to NaN");
    83 shouldThrow('m.min = NaN;', '"NotSupportedError (DOM Exception 9): The operation is not supported."');
     83shouldThrowErrorName('m.min = NaN;', 'TypeError');
    8484
    8585debug("Set max to Infinity");
    86 shouldThrow('m.max = Infinity;', '"NotSupportedError (DOM Exception 9): The operation is not supported."');
     86shouldThrowErrorName('m.max = Infinity;', 'TypeError');
    8787
    8888debug("Set low to invalid value");
    89 shouldThrow('m.low = "low";', '"NotSupportedError (DOM Exception 9): The operation is not supported."');
     89shouldThrowErrorName('m.low = "low";', 'TypeError');
    9090
    9191debug("Set high to NaN");
    92 shouldThrow('m.high = NaN;', '"NotSupportedError (DOM Exception 9): The operation is not supported."');
     92shouldThrowErrorName('m.high = NaN;', 'TypeError');
    9393
    9494debug("Set optimum to Infinity");
    95 shouldThrow('m.optimum = Infinity;', '"NotSupportedError (DOM Exception 9): The operation is not supported."');
     95shouldThrowErrorName('m.optimum = Infinity;', 'TypeError');
    9696
    9797debug("Set attributes to valid numbers");
  • trunk/LayoutTests/fast/dom/HTMLMeterElement/set-meter-properties-expected.txt

    r203333 r206243  
    4545PASS m.optimum is 12.5
    4646Set value to invalid value
    47 PASS m.value = "value"; threw exception NotSupportedError (DOM Exception 9): The operation is not supported..
     47PASS m.value = "value"; threw exception TypeError: The provided value is non-finite.
    4848Set min to NaN
    49 PASS m.min = NaN; threw exception NotSupportedError (DOM Exception 9): The operation is not supported..
     49PASS m.min = NaN; threw exception TypeError: The provided value is non-finite.
    5050Set max to Infinity
    51 PASS m.max = Infinity; threw exception NotSupportedError (DOM Exception 9): The operation is not supported..
     51PASS m.max = Infinity; threw exception TypeError: The provided value is non-finite.
    5252Set low to invalid value
    53 PASS m.low = "low"; threw exception NotSupportedError (DOM Exception 9): The operation is not supported..
     53PASS m.low = "low"; threw exception TypeError: The provided value is non-finite.
    5454Set high to NaN
    55 PASS m.high = NaN; threw exception NotSupportedError (DOM Exception 9): The operation is not supported..
     55PASS m.high = NaN; threw exception TypeError: The provided value is non-finite.
    5656Set optimum to Infinity
    57 PASS m.optimum = Infinity; threw exception NotSupportedError (DOM Exception 9): The operation is not supported..
     57PASS m.optimum = Infinity; threw exception TypeError: The provided value is non-finite.
    5858Set attributes to valid numbers
    5959PASS m.value is 5
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r206240 r206243  
     12016-09-21  Chris Dumez  <cdumez@apple.com>
     2
     3        Setting HTMLMeterElement's attributes to non-finite values throws wrong exception type
     4        https://bugs.webkit.org/show_bug.cgi?id=162364
     5
     6        Reviewed by Darin Adler.
     7
     8        Merge meter test changes from https://github.com/w3c/web-platform-tests/pull/3791.
     9
     10        * web-platform-tests/html/semantics/forms/the-meter-element/meter-expected.txt:
     11        * web-platform-tests/html/semantics/forms/the-meter-element/meter.html:
     12
    1132016-09-21  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-meter-element/meter-expected.txt

    r203333 r206243  
    44PASS Default values
    55PASS Setting values to min, max, low, high and optimum
    6 FAIL Invalid floating-point number values The operation is not supported.
    76PASS max < min
    87PASS value < min
     
    1413PASS optimum < min
    1514PASS optimum > max
     15PASS Invalid floating-point number values
    1616PASS value must be 0 when a string is given
    1717PASS default value of min is 0
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-meter-element/meter.html

    r189476 r206243  
    4343        {value: 0, expectedValue: 0, expectedMin: 0, expectedMax: 1.0, expectedLow: 0, expectedHigh: 1.0, expectedOptimum: 0.5, testname: "Default values"},
    4444        {value: 3, expectedValue: 3, min: -10.1, expectedMin: -10.1, max: 10.1, expectedMax: 10.1, low: -9.1, expectedLow: -9.1, high: 9.1, expectedHigh: 9.1, optimum: 3, expectedOptimum: 3, testname: "Setting values to min, max, low, high and optimum"},
    45         {value: "foobar", expectedValue: 0, min: "foobar", expectedMin: 0, max: "foobar", expectedMax: 1.0, low: "foobar", expectedLow: 0, high: "foobar", expectedHigh: 1.0, optimum: "foobar", expectedOptimum: 0.5, testname: "Invalid floating-point number values"},
    4645        {value: 0, expectedValue: 0, min: 0, expectedMin: 0, max: -1.0, expectedMax: 0, expectedLow: 0, expectedHigh: 0, expectedOptimum: 0, testname: "max < min"},
    4746        {value: 0, expectedValue: 10, min: 10, expectedMin: 10, max: 20, expectedMax: 20, expectedLow: 10, expectedHigh: 20, expectedOptimum: 15, testname: "value < min"},
     
    7271        }, m.testname);
    7372      }
     73      test(function() {
     74          var meter = document.createElement("meter");
     75          assert_throws(new TypeError(), function() { meter.value = "foobar"; }, "value attribute");
     76          assert_throws(new TypeError(), function() { meter.min = "foobar"; }, "min attribute");
     77          assert_throws(new TypeError(), function() { meter.max = "foobar"; }, "max attribute");
     78          assert_throws(new TypeError(), function() { meter.low = "foobar"; }, "low attribute");
     79          assert_throws(new TypeError(), function() { meter.high = "foobar"; }, "high attribute");
     80          assert_throws(new TypeError(), function() { meter.optimum = "foobar"; }, "optimum attribute");
     81      }, "Invalid floating-point number values");
    7482
    7583    </script>
  • trunk/LayoutTests/platform/ios-simulator/imported/w3c/web-platform-tests/html/semantics/forms/the-meter-element/meter-expected.txt

    r205579 r206243  
    44PASS Default values
    55PASS Setting values to min, max, low, high and optimum
    6 FAIL Invalid floating-point number values The operation is not supported.
    76PASS max < min
    87PASS value < min
     
    1413PASS optimum < min
    1514PASS optimum > max
     15PASS Invalid floating-point number values
    1616PASS value must be 0 when a string is given
    1717PASS default value of min is 0
  • trunk/Source/WebCore/ChangeLog

    r206242 r206243  
     12016-09-21  Chris Dumez  <cdumez@apple.com>
     2
     3        Setting HTMLMeterElement's attributes to non-finite values throws wrong exception type
     4        https://bugs.webkit.org/show_bug.cgi?id=162364
     5
     6        Reviewed by Darin Adler.
     7
     8        Setting HTMLMeterElement's attributes to non-finite values throws wrong exception type.
     9        It should throw a TypeError because their type is 'double' but we throw a
     10        NOT_SUPPORTED_ERR.
     11
     12        Specification:
     13        - https://html.spec.whatwg.org/#htmlmeterelement
     14
     15        Firefox and Chrome agree with the specification.
     16
     17        No new tests, updated existing test.
     18
     19        * html/HTMLMeterElement.cpp:
     20        (WebCore::HTMLMeterElement::setMin):
     21        (WebCore::HTMLMeterElement::setMax):
     22        (WebCore::HTMLMeterElement::setValue):
     23        (WebCore::HTMLMeterElement::setLow):
     24        (WebCore::HTMLMeterElement::setHigh):
     25        (WebCore::HTMLMeterElement::setOptimum):
     26        * html/HTMLMeterElement.h:
     27        * html/HTMLMeterElement.idl:
     28
    1292016-09-21  Anders Carlsson  <andersca@apple.com>
    230
  • trunk/Source/WebCore/html/HTMLMeterElement.cpp

    r203324 r206243  
    8484}
    8585
    86 void HTMLMeterElement::setMin(double min, ExceptionCode& ec)
    87 {
    88     if (!std::isfinite(min)) {
    89         ec = NOT_SUPPORTED_ERR;
    90         return;
    91     }
     86void HTMLMeterElement::setMin(double min)
     87{
    9288    setAttributeWithoutSynchronization(minAttr, AtomicString::number(min));
    9389}
     
    9894}
    9995
    100 void HTMLMeterElement::setMax(double max, ExceptionCode& ec)
    101 {
    102     if (!std::isfinite(max)) {
    103         ec = NOT_SUPPORTED_ERR;
    104         return;
    105     }
     96void HTMLMeterElement::setMax(double max)
     97{
    10698    setAttributeWithoutSynchronization(maxAttr, AtomicString::number(max));
    10799}
     
    113105}
    114106
    115 void HTMLMeterElement::setValue(double value, ExceptionCode& ec)
    116 {
    117     if (!std::isfinite(value)) {
    118         ec = NOT_SUPPORTED_ERR;
    119         return;
    120     }
     107void HTMLMeterElement::setValue(double value)
     108{
    121109    setAttributeWithoutSynchronization(valueAttr, AtomicString::number(value));
    122110}
     
    128116}
    129117
    130 void HTMLMeterElement::setLow(double low, ExceptionCode& ec)
    131 {
    132     if (!std::isfinite(low)) {
    133         ec = NOT_SUPPORTED_ERR;
    134         return;
    135     }
     118void HTMLMeterElement::setLow(double low)
     119{
    136120    setAttributeWithoutSynchronization(lowAttr, AtomicString::number(low));
    137121}
     
    143127}
    144128
    145 void HTMLMeterElement::setHigh(double high, ExceptionCode& ec)
    146 {
    147     if (!std::isfinite(high)) {
    148         ec = NOT_SUPPORTED_ERR;
    149         return;
    150     }
     129void HTMLMeterElement::setHigh(double high)
     130{
    151131    setAttributeWithoutSynchronization(highAttr, AtomicString::number(high));
    152132}
     
    158138}
    159139
    160 void HTMLMeterElement::setOptimum(double optimum, ExceptionCode& ec)
    161 {
    162     if (!std::isfinite(optimum)) {
    163         ec = NOT_SUPPORTED_ERR;
    164         return;
    165     }
     140void HTMLMeterElement::setOptimum(double optimum)
     141{
    166142    setAttributeWithoutSynchronization(optimumAttr, AtomicString::number(optimum));
    167143}
  • trunk/Source/WebCore/html/HTMLMeterElement.h

    r203264 r206243  
    4141
    4242    double min() const;
    43     void setMin(double, ExceptionCode&);
     43    void setMin(double);
    4444
    4545    double max() const;
    46     void setMax(double, ExceptionCode&);
     46    void setMax(double);
    4747
    4848    double value() const;
    49     void setValue(double, ExceptionCode&);
     49    void setValue(double);
    5050
    5151    double low() const;
    52     void setLow(double, ExceptionCode&);
     52    void setLow(double);
    5353
    5454    double high() const;
    55     void setHigh(double, ExceptionCode&);
     55    void setHigh(double);
    5656
    5757    double optimum() const;
    58     void setOptimum(double, ExceptionCode&);
     58    void setOptimum(double);
    5959
    6060    double valueRatio() const;
  • trunk/Source/WebCore/html/HTMLMeterElement.idl

    r168302 r206243  
    2121    Conditional=METER_ELEMENT
    2222] interface HTMLMeterElement : HTMLElement {
    23     [SetterRaisesException] attribute unrestricted double value;
    24     [SetterRaisesException] attribute unrestricted double min;
    25     [SetterRaisesException] attribute unrestricted double max;
    26     [SetterRaisesException] attribute unrestricted double low;
    27     [SetterRaisesException] attribute unrestricted double high;
    28     [SetterRaisesException] attribute unrestricted double optimum;
     23    attribute double value;
     24    attribute double min;
     25    attribute double max;
     26    attribute double low;
     27    attribute double high;
     28    attribute double optimum;
    2929    readonly attribute NodeList labels;
    3030};
Note: See TracChangeset for help on using the changeset viewer.