Diff
Modified: trunk/LayoutTests/ChangeLog (279046 => 279047)
--- trunk/LayoutTests/ChangeLog 2021-06-18 20:41:38 UTC (rev 279046)
+++ trunk/LayoutTests/ChangeLog 2021-06-19 02:16:19 UTC (rev 279047)
@@ -1,3 +1,15 @@
+2021-06-18 Chris Dumez <[email protected]>
+
+ [WebIDL] Assigning a value outside the float range to a 'float' attribute should throw a TypeError
+ https://bugs.webkit.org/show_bug.cgi?id=227146
+
+ Reviewed by Sam Weinig.
+
+ Add layout test coverage.
+
+ * js/dom/webidl-type-mapping-expected.txt:
+ * js/dom/webidl-type-mapping.html:
+
2021-06-18 Ryan Haddad <[email protected]>
[iOS 14-Simulator WK2] editing/deleting/smart-delete-paragraph-004.html is a flaky failure
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (279046 => 279047)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-06-18 20:41:38 UTC (rev 279046)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-06-19 02:16:19 UTC (rev 279047)
@@ -1,3 +1,14 @@
+2021-06-18 Chris Dumez <[email protected]>
+
+ [WebIDL] Assigning a value outside the float range to a 'float' attribute should throw a TypeError
+ https://bugs.webkit.org/show_bug.cgi?id=227146
+
+ Reviewed by Sam Weinig.
+
+ Rebaseline WPT test that is now fully passing.
+
+ * web-platform-tests/webaudio/the-audio-api/the-pannernode-interface/pannernode-setposition-throws-expected.txt:
+
2021-06-18 Oriol Brufau <[email protected]>
[css-logical] Fix cssom "set a CSS declaration" for logical properties
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-pannernode-interface/pannernode-setposition-throws-expected.txt (279046 => 279047)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-pannernode-interface/pannernode-setposition-throws-expected.txt 2021-06-18 20:41:38 UTC (rev 279046)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-pannernode-interface/pannernode-setposition-throws-expected.txt 2021-06-19 02:16:19 UTC (rev 279047)
@@ -1,8 +1,8 @@
-FAIL setPosition x assert_throws_js: function "() => panner.setPosition(2 * FLT_MAX, 0, 0)" did not throw
-FAIL setPosition y assert_throws_js: function "() => panner.setPosition(0, -2 * FLT_MAX, 0)" did not throw
-FAIL setPosition z assert_throws_js: function "() => panner.setPosition(0, 0, 2 * FLT_MAX)" did not throw
-FAIL setOrientation x assert_throws_js: function "() => panner.setOrientation(-2 * FLT_MAX, 0, 0)" did not throw
-FAIL setOrientation y assert_throws_js: function "() => panner.setOrientation(0, 2 * FLT_MAX, 0)" did not throw
-FAIL setOrientation z assert_throws_js: function "() => panner.setOrientation(0, 0, -2 * FLT_MAX)" did not throw
+PASS setPosition x
+PASS setPosition y
+PASS setPosition z
+PASS setOrientation x
+PASS setOrientation y
+PASS setOrientation z
Modified: trunk/LayoutTests/js/dom/webidl-type-mapping-expected.txt (279046 => 279047)
--- trunk/LayoutTests/js/dom/webidl-type-mapping-expected.txt 2021-06-18 20:41:38 UTC (rev 279046)
+++ trunk/LayoutTests/js/dom/webidl-type-mapping-expected.txt 2021-06-19 02:16:19 UTC (rev 279047)
@@ -1007,6 +1007,39 @@
PASS converter.testEnforceRangeUnsignedShort = undefined threw exception TypeError: Value NaN is outside the range [0, 65535].
PASS converter.testEnforceRangeUnsignedShort = {valueOf:function(){throw new Error('custom');}} threw exception Error: custom.
+PASS 'testFloat' in converter is true
+PASS typeof converter.testFloat === 'number' is true
+converter.testFloat = -0
+PASS converter.testFloat is -0
+converter.testFloat = -1.5
+PASS converter.testFloat is -1.5
+converter.testFloat = 1.5
+PASS converter.testFloat is 1.5
+PASS converter.testFloat = Infinity threw exception TypeError: The provided value is non-finite.
+PASS converter.testFloat = -Infinity threw exception TypeError: The provided value is non-finite.
+PASS converter.testFloat = NaN threw exception TypeError: The provided value is non-finite.
+PASS converter.testFloat = 2 * FLT_MAX threw exception TypeError: The provided value is outside the range of a float.
+PASS converter.testFloat = -2 * FLT_MAX threw exception TypeError: The provided value is outside the range of a float.
+
+PASS 'testUnrestrictedFloat' in converter is true
+PASS typeof converter.testUnrestrictedFloat === 'number' is true
+converter.testUnrestrictedFloat = -0
+PASS converter.testUnrestrictedFloat is -0
+converter.testUnrestrictedFloat = -1.5
+PASS converter.testUnrestrictedFloat is -1.5
+converter.testUnrestrictedFloat = 1.5
+PASS converter.testUnrestrictedFloat is 1.5
+converter.testUnrestrictedFloat = Infinity
+PASS converter.testUnrestrictedFloat is Infinity
+converter.testUnrestrictedFloat = -Infinity
+PASS converter.testUnrestrictedFloat is -Infinity
+converter.testUnrestrictedFloat = NaN
+PASS converter.testUnrestrictedFloat is NaN
+converter.testUnrestrictedFloat = 2 * FLT_MAX
+PASS converter.testUnrestrictedFloat is Infinity
+converter.testUnrestrictedFloat = -2 * FLT_MAX
+PASS converter.testUnrestrictedFloat is -Infinity
+
converter.testUSVString = '!@#123ABCabc\x00\x80\xFF\r\n\t'
converter.testString = '!@#123ABCabc\x00\x80\xFF\r\n\t'
PASS converter.testUSVString is "!@#123ABCabc\u0000ÿ\r\n\t"
Modified: trunk/LayoutTests/js/dom/webidl-type-mapping.html (279046 => 279047)
--- trunk/LayoutTests/js/dom/webidl-type-mapping.html 2021-06-18 20:41:38 UTC (rev 279046)
+++ trunk/LayoutTests/js/dom/webidl-type-mapping.html 2021-06-19 02:16:19 UTC (rev 279047)
@@ -555,6 +555,31 @@
convertThrows(type, "{valueOf:function(){throw new Error('custom');}}");
debug("");
+const FLT_MAX = 3.40282e+38;
+type = "testFloat";
+verifyAttribute(type);
+convert(type, "-0", "-0");
+convert(type, "-1.5", "-1.5");
+convert(type, "1.5", "1.5");
+convertThrows(type, "Infinity");
+convertThrows(type, "-Infinity");
+convertThrows(type, "NaN");
+convertThrows(type, "2 * FLT_MAX");
+convertThrows(type, "-2 * FLT_MAX");
+debug("");
+
+type = "testUnrestrictedFloat";
+verifyAttribute(type);
+convert(type, "-0", "-0");
+convert(type, "-1.5", "-1.5");
+convert(type, "1.5", "1.5");
+convert(type, "Infinity");
+convert(type, "-Infinity");
+convert(type, "NaN");
+convert(type, "2 * FLT_MAX", "Infinity");
+convert(type, "-2 * FLT_MAX", "-Infinity");
+debug("");
+
evalAndLog("converter.testUSVString = '!@#123ABCabc\\x00\\x80\\xFF\\r\\n\\t'");
evalAndLog("converter.testString = '!@#123ABCabc\\x00\\x80\\xFF\\r\\n\\t'");
shouldBeEqualToString("converter.testUSVString", "!@#123ABCabc\x00\x80\xFF\r\n\t");
Modified: trunk/Source/WebCore/ChangeLog (279046 => 279047)
--- trunk/Source/WebCore/ChangeLog 2021-06-18 20:41:38 UTC (rev 279046)
+++ trunk/Source/WebCore/ChangeLog 2021-06-19 02:16:19 UTC (rev 279047)
@@ -1,3 +1,32 @@
+2021-06-18 Chris Dumez <[email protected]>
+
+ [WebIDL] Assigning a value outside the float range to a 'float' attribute should throw a TypeError
+ https://bugs.webkit.org/show_bug.cgi?id=227146
+
+ Reviewed by Sam Weinig.
+
+ Assigning a value outside the float range to a 'float' attribute should throw a TypeError, as per:
+ - https://heycam.github.io/webidl/#es-float
+
+ Blink follows the specification but WebKit was just casting the double to a float. This patch
+ addresses this issue.
+
+ This patch also makes sure that values outside the float range properly get resolved to -Infinity
+ or Infinity if the attribute is of type 'unrestricted float', as per:
+ - https://heycam.github.io/webidl/#es-unrestricted-float
+
+ No new tests, updated existing tests.
+
+ * bindings/js/JSDOMConvertNumbers.h:
+ (WebCore::Converter<IDLFloat>::convert):
+ (WebCore::Converter<IDLUnrestrictedFloat>::convert):
+ * testing/TypeConversions.h:
+ (WebCore::TypeConversions::testFloat const):
+ (WebCore::TypeConversions::setTestFloat):
+ (WebCore::TypeConversions::testUnrestrictedFloat const):
+ (WebCore::TypeConversions::setTestUnrestrictedFloat):
+ * testing/TypeConversions.idl:
+
2021-06-18 Soujyu TANAKA <[email protected]>
[Curl] Add curl option CURLOPT_NOSIGNAL to omit numerous sigaction calls
Modified: trunk/Source/WebCore/bindings/js/JSDOMConvertNumbers.h (279046 => 279047)
--- trunk/Source/WebCore/bindings/js/JSDOMConvertNumbers.h 2021-06-18 20:41:38 UTC (rev 279046)
+++ trunk/Source/WebCore/bindings/js/JSDOMConvertNumbers.h 2021-06-19 02:16:19 UTC (rev 279047)
@@ -292,6 +292,8 @@
auto scope = DECLARE_THROW_SCOPE(vm);
double number = value.toNumber(&lexicalGlobalObject);
RETURN_IF_EXCEPTION(scope, 0.0);
+ if (UNLIKELY(number < std::numeric_limits<float>::lowest() || number > std::numeric_limits<float>::max()))
+ throwTypeError(&lexicalGlobalObject, scope, "The provided value is outside the range of a float");
if (UNLIKELY(!std::isfinite(number)))
throwNonFiniteTypeError(lexicalGlobalObject, scope);
return static_cast<float>(number);
@@ -318,7 +320,16 @@
static float convert(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSValue value)
{
- return static_cast<float>(value.toNumber(&lexicalGlobalObject));
+ JSC::VM& vm = JSC::getVM(&lexicalGlobalObject);
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ double number = value.toNumber(&lexicalGlobalObject);
+ RETURN_IF_EXCEPTION(scope, 0.0);
+
+ if (UNLIKELY(number < std::numeric_limits<float>::lowest()))
+ return -std::numeric_limits<float>::infinity();
+ if (UNLIKELY(number > std::numeric_limits<float>::max()))
+ return std::numeric_limits<float>::infinity();
+ return static_cast<float>(number);
}
};
Modified: trunk/Source/WebCore/testing/TypeConversions.h (279046 => 279047)
--- trunk/Source/WebCore/testing/TypeConversions.h 2021-06-18 20:41:38 UTC (rev 279046)
+++ trunk/Source/WebCore/testing/TypeConversions.h 2021-06-19 02:16:19 UTC (rev 279047)
@@ -105,6 +105,11 @@
unsigned long long testClampUnsignedLongLong() { return m_unsignedLongLong; }
void setTestClampUnsignedLongLong(unsigned long long value) { m_unsignedLongLong = value; }
+ float testFloat() const { return m_float; }
+ void setTestFloat(float testFloat) { m_float = testFloat; }
+ float testUnrestrictedFloat() const { return m_unrestrictedFloat; }
+ void setTestUnrestrictedFloat(float unrestrictedFloat) { m_unrestrictedFloat = unrestrictedFloat; }
+
const String& testString() const { return m_string; }
void setTestString(const String& string) { m_string = string; }
const String& testUSVString() const { return m_usvstring; }
@@ -157,6 +162,8 @@
unsigned m_unsignedLong { 0 };
long long m_longLong { 0 };
unsigned long long m_unsignedLongLong { 0 };
+ float m_float { 0 };
+ float m_unrestrictedFloat { 0 };
String m_string;
String m_usvstring;
String m_byteString;
Modified: trunk/Source/WebCore/testing/TypeConversions.idl (279046 => 279047)
--- trunk/Source/WebCore/testing/TypeConversions.idl 2021-06-18 20:41:38 UTC (rev 279046)
+++ trunk/Source/WebCore/testing/TypeConversions.idl 2021-06-19 02:16:19 UTC (rev 279047)
@@ -61,6 +61,9 @@
readonly attribute unrestricted double testQuietNaNUnrestrictedDouble;
readonly attribute unrestricted double testPureNaNUnrestrictedDouble;
+ attribute float testFloat;
+ attribute unrestricted float testUnrestrictedFloat;
+
attribute DOMString testString;
attribute ByteString testByteString;
attribute USVString testUSVString;