Disallow setting SVGElement currentScale to non-finite values
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jan 2020 18:58:36 +0000 (18:58 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Jan 2020 18:58:36 +0000 (18:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=206019

Align SVGElement currentScale definition to SVG2 section 5.14.2
(https://www.w3.org/TR/SVG2/struct.html#InterfaceSVGSVGElement)

Patch by Sunny He <sunny_he@apple.com> on 2020-01-21
Reviewed by Darin Adler.

Source/WebCore:

Test: svg/dom/set-currentScale-nonfinite.html

* svg/SVGSVGElement.idl:

LayoutTests:

* svg/dom/set-currentScale-nonfinite-expected.txt: Added.
* svg/dom/set-currentScale-nonfinite.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254863 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/svg/dom/set-currentScale-nonfinite-expected.txt [new file with mode: 0644]
LayoutTests/svg/dom/set-currentScale-nonfinite.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/svg/SVGSVGElement.idl

index e1b50c9..b68f470 100644 (file)
@@ -1,3 +1,16 @@
+2020-01-21  Sunny He  <sunny_he@apple.com>
+
+        Disallow setting SVGElement currentScale to non-finite values
+        https://bugs.webkit.org/show_bug.cgi?id=206019
+
+        Align SVGElement currentScale definition to SVG2 section 5.14.2
+        (https://www.w3.org/TR/SVG2/struct.html#InterfaceSVGSVGElement)
+
+        Reviewed by Darin Adler.
+
+        * svg/dom/set-currentScale-nonfinite-expected.txt: Added.
+        * svg/dom/set-currentScale-nonfinite.html: Added.
+
 2020-01-21  Noam Rosenthal  <noam@webkit.org>
 
         -webkit-image-set should support all the image functions WebKit supports, not just url()
diff --git a/LayoutTests/svg/dom/set-currentScale-nonfinite-expected.txt b/LayoutTests/svg/dom/set-currentScale-nonfinite-expected.txt
new file mode 100644 (file)
index 0000000..c7e1953
--- /dev/null
@@ -0,0 +1,18 @@
+This test checks that setting currentScale fails for non-finite values
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS svgvar.currentScale is 1.0
+PASS Setting currentScale to undefined threw an exception.
+PASS svgvar.currentScale is 1.0
+PASS Setting currentScale to NaN threw an exception.
+PASS svgvar.currentScale is 1.0
+PASS Setting currentScale to Infinity threw an exception.
+PASS svgvar.currentScale is 1.0
+PASS Setting currentScale to a string threw an exception.
+PASS svgvar.currentScale is 1.0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/svg/dom/set-currentScale-nonfinite.html b/LayoutTests/svg/dom/set-currentScale-nonfinite.html
new file mode 100644 (file)
index 0000000..dfd8b64
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+    <svg id="svgvar"></svg>
+</body>
+<script>
+    description("This test checks that setting currentScale fails for non-finite values");
+
+    var svgvar = document.getElementById('svgvar');
+
+    svgvar.currentScale = 1.0;
+    shouldBe('svgvar.currentScale', '1.0');
+
+    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");
+
+    var successfullyParsed = true;
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</html>
index 8f64d23..76f9f9e 100644 (file)
@@ -1,3 +1,17 @@
+2020-01-21  Sunny He  <sunny_he@apple.com>
+
+        Disallow setting SVGElement currentScale to non-finite values
+        https://bugs.webkit.org/show_bug.cgi?id=206019
+
+        Align SVGElement currentScale definition to SVG2 section 5.14.2
+        (https://www.w3.org/TR/SVG2/struct.html#InterfaceSVGSVGElement)
+
+        Reviewed by Darin Adler.
+
+        Test: svg/dom/set-currentScale-nonfinite.html
+
+        * svg/SVGSVGElement.idl:
+
 2020-01-21  Noam Rosenthal  <noam@webkit.org>
 
         -webkit-image-set should support all the image functions WebKit supports, not just url()
index 683414d..c41ac4b 100644 (file)
@@ -33,7 +33,7 @@
     [SameObject] readonly attribute SVGAnimatedLength width;
     [SameObject] readonly attribute SVGAnimatedLength height;
 
-    attribute unrestricted float currentScale;
+    attribute float currentScale;
     [SameObject] readonly attribute SVGPoint currentTranslate;
     
     readonly attribute boolean useCurrentView;