RESOLVED FIXED 206019
Setting currentScale to non-finite values should throw TypeError
https://bugs.webkit.org/show_bug.cgi?id=206019
Summary Setting currentScale to non-finite values should throw TypeError
Sunny He
Reported 2020-01-09 11:21:57 PST
SVG2 spec 5.14.2 Interface SVGSVGElement (https://www.w3.org/TR/SVG2/struct.html#__svg__SVGSVGElement__currentScale) defines currentScale to be float, not unrestricted float. Chrome and Firefox throw TypeError if currentScale is set to NaN or Inf, WebKit silently sets currentScale to NaN.
Attachments
Patch (5.06 KB, patch)
2020-01-09 11:29 PST, Sunny He
no flags
Patch (5.21 KB, patch)
2020-01-09 13:13 PST, Sunny He
no flags
Patch (4.61 KB, patch)
2020-01-17 11:10 PST, Sunny He
no flags
Radar WebKit Bug Importer
Comment 1 2020-01-09 11:22:23 PST
Sunny He
Comment 2 2020-01-09 11:29:10 PST
Said Abou-Hallawa
Comment 3 2020-01-09 12:40:54 PST
Comment on attachment 387247 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=387247&action=review > Source/WebCore/ChangeLog:6 > + Align SVGElement currentScale definition to SVG2 section 5.14.2. Please add a link to the specs: https://www.w3.org/TR/SVG2/struct.html#InterfaceSVGSVGElement. > LayoutTests/svg/dom/set-currentScale-nonfinite.html:15 > + svgvar.currentScale = 1.0; > + shouldBe('svgvar.currentScale', '1.0') Maybe you need to add semicolon at the end each statement just for consistency. > LayoutTests/svg/dom/set-currentScale-nonfinite.html:46 > + testFailed('set currentScale to Infinity without error') svgvar.currentScale is set to character 'a' not Infinity. > LayoutTests/svg/dom/set-currentScale-nonfinite.html:49 > + testPassed('set currentScale to Infinity throws TypeError') Ditto.
Sunny He
Comment 4 2020-01-09 13:13:35 PST
Dean Jackson
Comment 5 2020-01-11 12:50:51 PST
Comment on attachment 387258 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=387258&action=review > LayoutTests/svg/dom/set-currentScale-nonfinite.html:24 > + try { > + svgvar.currentScale = undefined; > + testFailed('set currentScale to undefined without error'); > + } catch(e) { > + if (e instanceof TypeError) > + testPassed('set currentScale to undefined throws TypeError'); > + } > + shouldBe('svgvar.currentScale', '1.0'); This is fine, but maybe you could have avoided the duplication: const testIncorrectScaleValue = (value, description) => { try { svgvar.currentScale = value; testFailed(`Setting currentScale to ${description} should have thrown an exception.`); } catch (e) { if (e instanceof TypeError) testPassed(`Setting currentScale to ${description} threw an exception.`); } shouldBe('svgvar.currentScale', '1.0'); }; testIncorrectScaleValue(undefined, "undefined"); testIncorrectScaleValue(NaN, "NaN"); testIncorrectScaleValue(Infinity, "Infinity"); testIncorrectScaleValue("a", "a string");
Sunny He
Comment 6 2020-01-17 11:10:36 PST
WebKit Commit Bot
Comment 7 2020-01-21 10:58:42 PST
Comment on attachment 388065 [details] Patch Clearing flags on attachment: 388065 Committed r254863: <https://trac.webkit.org/changeset/254863>
WebKit Commit Bot
Comment 8 2020-01-21 10:58:44 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.