Title: [206243] trunk
Revision
206243
Author
cdu...@apple.com
Date
2016-09-21 16:50:24 -0700 (Wed, 21 Sep 2016)

Log 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:
- https://html.spec.whatwg.org/#htmlmeterelement

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:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (206242 => 206243)


--- trunk/LayoutTests/ChangeLog	2016-09-21 23:20:01 UTC (rev 206242)
+++ trunk/LayoutTests/ChangeLog	2016-09-21 23:50:24 UTC (rev 206243)
@@ -1,5 +1,17 @@
 2016-09-21  Chris Dumez  <cdu...@apple.com>
 
+        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.
+
+        Update existing test to reflect behavior change.
+
+        * fast/dom/HTMLMeterElement/script-tests/set-meter-properties.js:
+        * fast/dom/HTMLMeterElement/set-meter-properties-expected.txt:
+
+2016-09-21  Chris Dumez  <cdu...@apple.com>
+
         Fix serialization of HTML Element attributes
         https://bugs.webkit.org/show_bug.cgi?id=162356
 

Modified: trunk/LayoutTests/fast/dom/HTMLMeterElement/script-tests/set-meter-properties.js (206242 => 206243)


--- trunk/LayoutTests/fast/dom/HTMLMeterElement/script-tests/set-meter-properties.js	2016-09-21 23:20:01 UTC (rev 206242)
+++ trunk/LayoutTests/fast/dom/HTMLMeterElement/script-tests/set-meter-properties.js	2016-09-21 23:50:24 UTC (rev 206243)
@@ -77,22 +77,22 @@
 shouldBe("m.optimum", "12.5");
 
 debug("Set value to invalid value");
-shouldThrow('m.value = "value";', '"NotSupportedError (DOM Exception 9): The operation is not supported."');
+shouldThrowErrorName('m.value = "value";', 'TypeError');
 
 debug("Set min to NaN");
-shouldThrow('m.min = NaN;', '"NotSupportedError (DOM Exception 9): The operation is not supported."');
+shouldThrowErrorName('m.min = NaN;', 'TypeError');
 
 debug("Set max to Infinity");
-shouldThrow('m.max = Infinity;', '"NotSupportedError (DOM Exception 9): The operation is not supported."');
+shouldThrowErrorName('m.max = Infinity;', 'TypeError');
 
 debug("Set low to invalid value");
-shouldThrow('m.low = "low";', '"NotSupportedError (DOM Exception 9): The operation is not supported."');
+shouldThrowErrorName('m.low = "low";', 'TypeError');
 
 debug("Set high to NaN");
-shouldThrow('m.high = NaN;', '"NotSupportedError (DOM Exception 9): The operation is not supported."');
+shouldThrowErrorName('m.high = NaN;', 'TypeError');
 
 debug("Set optimum to Infinity");
-shouldThrow('m.optimum = Infinity;', '"NotSupportedError (DOM Exception 9): The operation is not supported."');
+shouldThrowErrorName('m.optimum = Infinity;', 'TypeError');
 
 debug("Set attributes to valid numbers");
 m.setAttribute("min", 0);

Modified: trunk/LayoutTests/fast/dom/HTMLMeterElement/set-meter-properties-expected.txt (206242 => 206243)


--- trunk/LayoutTests/fast/dom/HTMLMeterElement/set-meter-properties-expected.txt	2016-09-21 23:20:01 UTC (rev 206242)
+++ trunk/LayoutTests/fast/dom/HTMLMeterElement/set-meter-properties-expected.txt	2016-09-21 23:50:24 UTC (rev 206243)
@@ -44,17 +44,17 @@
 PASS m.high is 200.0
 PASS m.optimum is 12.5
 Set value to invalid value
-PASS m.value = "value"; threw exception NotSupportedError (DOM Exception 9): The operation is not supported..
+PASS m.value = "value"; threw exception TypeError: The provided value is non-finite.
 Set min to NaN
-PASS m.min = NaN; threw exception NotSupportedError (DOM Exception 9): The operation is not supported..
+PASS m.min = NaN; threw exception TypeError: The provided value is non-finite.
 Set max to Infinity
-PASS m.max = Infinity; threw exception NotSupportedError (DOM Exception 9): The operation is not supported..
+PASS m.max = Infinity; threw exception TypeError: The provided value is non-finite.
 Set low to invalid value
-PASS m.low = "low"; threw exception NotSupportedError (DOM Exception 9): The operation is not supported..
+PASS m.low = "low"; threw exception TypeError: The provided value is non-finite.
 Set high to NaN
-PASS m.high = NaN; threw exception NotSupportedError (DOM Exception 9): The operation is not supported..
+PASS m.high = NaN; threw exception TypeError: The provided value is non-finite.
 Set optimum to Infinity
-PASS m.optimum = Infinity; threw exception NotSupportedError (DOM Exception 9): The operation is not supported..
+PASS m.optimum = Infinity; threw exception TypeError: The provided value is non-finite.
 Set attributes to valid numbers
 PASS m.value is 5
 PASS m.max is 10

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (206242 => 206243)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-09-21 23:20:01 UTC (rev 206242)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-09-21 23:50:24 UTC (rev 206243)
@@ -1,5 +1,17 @@
 2016-09-21  Chris Dumez  <cdu...@apple.com>
 
+        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.
+
+        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:
+
+2016-09-21  Chris Dumez  <cdu...@apple.com>
+
         Fix serialization of HTML Element attributes
         https://bugs.webkit.org/show_bug.cgi?id=162356
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-meter-element/meter-expected.txt (206242 => 206243)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-meter-element/meter-expected.txt	2016-09-21 23:20:01 UTC (rev 206242)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-meter-element/meter-expected.txt	2016-09-21 23:50:24 UTC (rev 206243)
@@ -3,7 +3,6 @@
 
 PASS Default values 
 PASS Setting values to min, max, low, high and optimum 
-FAIL Invalid floating-point number values The operation is not supported.
 PASS max < min 
 PASS value < min 
 PASS value > max 
@@ -13,6 +12,7 @@
 PASS high > max 
 PASS optimum < min 
 PASS optimum > max 
+PASS Invalid floating-point number values 
 PASS value must be 0 when a string is given 
 PASS default value of min is 0 
 PASS If min is not specified and value is smaller than the default value of min (i.e. 0), the actual value must be 0 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-meter-element/meter.html (206242 => 206243)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-meter-element/meter.html	2016-09-21 23:20:01 UTC (rev 206242)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-meter-element/meter.html	2016-09-21 23:50:24 UTC (rev 206243)
@@ -42,7 +42,6 @@
       var meters = [
         {value: 0, expectedValue: 0, expectedMin: 0, expectedMax: 1.0, expectedLow: 0, expectedHigh: 1.0, expectedOptimum: 0.5, testname: "Default values"},
         {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"},
-        {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"},
         {value: 0, expectedValue: 0, min: 0, expectedMin: 0, max: -1.0, expectedMax: 0, expectedLow: 0, expectedHigh: 0, expectedOptimum: 0, testname: "max < min"},
         {value: 0, expectedValue: 10, min: 10, expectedMin: 10, max: 20, expectedMax: 20, expectedLow: 10, expectedHigh: 20, expectedOptimum: 15, testname: "value < min"},
         {value: 30, expectedValue: 20, min: 10, expectedMin: 10, max: 20, expectedMax: 20, expectedLow: 10, expectedHigh: 20, expectedOptimum: 15, testname: "value > max"},
@@ -71,6 +70,15 @@
           assert_equals(meter.optimum, m.expectedOptimum, "optimum value");
         }, m.testname);
       }
+      test(function() {
+          var meter = document.createElement("meter");
+          assert_throws(new TypeError(), function() { meter.value = "foobar"; }, "value attribute");
+          assert_throws(new TypeError(), function() { meter.min = "foobar"; }, "min attribute");
+          assert_throws(new TypeError(), function() { meter.max = "foobar"; }, "max attribute");
+          assert_throws(new TypeError(), function() { meter.low = "foobar"; }, "low attribute");
+          assert_throws(new TypeError(), function() { meter.high = "foobar"; }, "high attribute");
+          assert_throws(new TypeError(), function() { meter.optimum = "foobar"; }, "optimum attribute");
+      }, "Invalid floating-point number values");
 
     </script>
     <script type="text/_javascript_">

Modified: trunk/LayoutTests/platform/ios-simulator/imported/w3c/web-platform-tests/html/semantics/forms/the-meter-element/meter-expected.txt (206242 => 206243)


--- trunk/LayoutTests/platform/ios-simulator/imported/w3c/web-platform-tests/html/semantics/forms/the-meter-element/meter-expected.txt	2016-09-21 23:20:01 UTC (rev 206242)
+++ trunk/LayoutTests/platform/ios-simulator/imported/w3c/web-platform-tests/html/semantics/forms/the-meter-element/meter-expected.txt	2016-09-21 23:50:24 UTC (rev 206243)
@@ -3,7 +3,6 @@
 
 PASS Default values 
 PASS Setting values to min, max, low, high and optimum 
-FAIL Invalid floating-point number values The operation is not supported.
 PASS max < min 
 PASS value < min 
 PASS value > max 
@@ -13,6 +12,7 @@
 PASS high > max 
 PASS optimum < min 
 PASS optimum > max 
+PASS Invalid floating-point number values 
 PASS value must be 0 when a string is given 
 PASS default value of min is 0 
 PASS If min is not specified and value is smaller than the default value of min (i.e. 0), the actual value must be 0 

Modified: trunk/Source/WebCore/ChangeLog (206242 => 206243)


--- trunk/Source/WebCore/ChangeLog	2016-09-21 23:20:01 UTC (rev 206242)
+++ trunk/Source/WebCore/ChangeLog	2016-09-21 23:50:24 UTC (rev 206243)
@@ -1,3 +1,31 @@
+2016-09-21  Chris Dumez  <cdu...@apple.com>
+
+        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.
+
+        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:
+        - https://html.spec.whatwg.org/#htmlmeterelement
+
+        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:
+
 2016-09-21  Anders Carlsson  <ander...@apple.com>
 
         Fix open source build.

Modified: trunk/Source/WebCore/html/HTMLMeterElement.cpp (206242 => 206243)


--- trunk/Source/WebCore/html/HTMLMeterElement.cpp	2016-09-21 23:20:01 UTC (rev 206242)
+++ trunk/Source/WebCore/html/HTMLMeterElement.cpp	2016-09-21 23:50:24 UTC (rev 206243)
@@ -83,12 +83,8 @@
     return parseToDoubleForNumberType(attributeWithoutSynchronization(minAttr), 0);
 }
 
-void HTMLMeterElement::setMin(double min, ExceptionCode& ec)
+void HTMLMeterElement::setMin(double min)
 {
-    if (!std::isfinite(min)) {
-        ec = NOT_SUPPORTED_ERR;
-        return;
-    }
     setAttributeWithoutSynchronization(minAttr, AtomicString::number(min));
 }
 
@@ -97,12 +93,8 @@
     return std::max(parseToDoubleForNumberType(attributeWithoutSynchronization(maxAttr), std::max(1.0, min())), min());
 }
 
-void HTMLMeterElement::setMax(double max, ExceptionCode& ec)
+void HTMLMeterElement::setMax(double max)
 {
-    if (!std::isfinite(max)) {
-        ec = NOT_SUPPORTED_ERR;
-        return;
-    }
     setAttributeWithoutSynchronization(maxAttr, AtomicString::number(max));
 }
 
@@ -112,12 +104,8 @@
     return std::min(std::max(value, min()), max());
 }
 
-void HTMLMeterElement::setValue(double value, ExceptionCode& ec)
+void HTMLMeterElement::setValue(double value)
 {
-    if (!std::isfinite(value)) {
-        ec = NOT_SUPPORTED_ERR;
-        return;
-    }
     setAttributeWithoutSynchronization(valueAttr, AtomicString::number(value));
 }
 
@@ -127,12 +115,8 @@
     return std::min(std::max(low, min()), max());
 }
 
-void HTMLMeterElement::setLow(double low, ExceptionCode& ec)
+void HTMLMeterElement::setLow(double low)
 {
-    if (!std::isfinite(low)) {
-        ec = NOT_SUPPORTED_ERR;
-        return;
-    }
     setAttributeWithoutSynchronization(lowAttr, AtomicString::number(low));
 }
 
@@ -142,12 +126,8 @@
     return std::min(std::max(high, low()), max());
 }
 
-void HTMLMeterElement::setHigh(double high, ExceptionCode& ec)
+void HTMLMeterElement::setHigh(double high)
 {
-    if (!std::isfinite(high)) {
-        ec = NOT_SUPPORTED_ERR;
-        return;
-    }
     setAttributeWithoutSynchronization(highAttr, AtomicString::number(high));
 }
 
@@ -157,12 +137,8 @@
     return std::min(std::max(optimum, min()), max());
 }
 
-void HTMLMeterElement::setOptimum(double optimum, ExceptionCode& ec)
+void HTMLMeterElement::setOptimum(double optimum)
 {
-    if (!std::isfinite(optimum)) {
-        ec = NOT_SUPPORTED_ERR;
-        return;
-    }
     setAttributeWithoutSynchronization(optimumAttr, AtomicString::number(optimum));
 }
 

Modified: trunk/Source/WebCore/html/HTMLMeterElement.h (206242 => 206243)


--- trunk/Source/WebCore/html/HTMLMeterElement.h	2016-09-21 23:20:01 UTC (rev 206242)
+++ trunk/Source/WebCore/html/HTMLMeterElement.h	2016-09-21 23:50:24 UTC (rev 206243)
@@ -40,22 +40,22 @@
     };
 
     double min() const;
-    void setMin(double, ExceptionCode&);
+    void setMin(double);
 
     double max() const;
-    void setMax(double, ExceptionCode&);
+    void setMax(double);
 
     double value() const;
-    void setValue(double, ExceptionCode&);
+    void setValue(double);
 
     double low() const;
-    void setLow(double, ExceptionCode&);
+    void setLow(double);
 
     double high() const;
-    void setHigh(double, ExceptionCode&);
+    void setHigh(double);
 
     double optimum() const;
-    void setOptimum(double, ExceptionCode&);
+    void setOptimum(double);
 
     double valueRatio() const;
     GaugeRegion gaugeRegion() const;

Modified: trunk/Source/WebCore/html/HTMLMeterElement.idl (206242 => 206243)


--- trunk/Source/WebCore/html/HTMLMeterElement.idl	2016-09-21 23:20:01 UTC (rev 206242)
+++ trunk/Source/WebCore/html/HTMLMeterElement.idl	2016-09-21 23:50:24 UTC (rev 206243)
@@ -20,11 +20,11 @@
 [
     Conditional=METER_ELEMENT
 ] interface HTMLMeterElement : HTMLElement {
-    [SetterRaisesException] attribute unrestricted double value;
-    [SetterRaisesException] attribute unrestricted double min;
-    [SetterRaisesException] attribute unrestricted double max;
-    [SetterRaisesException] attribute unrestricted double low;
-    [SetterRaisesException] attribute unrestricted double high;
-    [SetterRaisesException] attribute unrestricted double optimum;
+    attribute double value;
+    attribute double min;
+    attribute double max;
+    attribute double low;
+    attribute double high;
+    attribute double optimum;
     readonly attribute NodeList labels;
 };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to