LayoutTests:
authorweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 May 2007 03:35:24 +0000 (03:35 +0000)
committerweinig <weinig@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 May 2007 03:35:24 +0000 (03:35 +0000)
        Reviewed by Oliver.

        - Yet more tests for http://bugs.webkit.org/show_bug.cgi?id=13722
          Finish testing and fixing the setting of DOM attributes to JS null

          Tests for SVG attributes that take a DOMString.

        * fast/dom/svg-element-attribute-js-null-expected.txt: Added.
        * fast/dom/svg-element-attribute-js-null.xhtml: Added.

WebCore:

        Reviewed by Oliver.

        - Patch for http://bugs.webkit.org/show_bug.cgi?id=13722
          Finish testing and fixing the setting of DOM attributes to JS null

          Convert JS null to null string for SVG attributes.

        Test: fast/dom/svg-element-attribute-js-null.xhtml

        * ksvg2/svg/SVGAngle.idl:
        * ksvg2/svg/SVGElement.idl:
        * ksvg2/svg/SVGLength.idl:
        * ksvg2/svg/SVGScriptElement.idl:

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

LayoutTests/ChangeLog
LayoutTests/fast/dom/svg-element-attribute-js-null-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/svg-element-attribute-js-null.xhtml [new file with mode: 0644]
WebCore/ChangeLog
WebCore/ksvg2/svg/SVGAngle.idl
WebCore/ksvg2/svg/SVGElement.idl
WebCore/ksvg2/svg/SVGLength.idl
WebCore/ksvg2/svg/SVGScriptElement.idl

index 26d4e3953344846125d15507de9b9bb3a003daff..8497a4b061f67a7870a922921fbfcb04a78e4166 100644 (file)
@@ -1,3 +1,15 @@
+2007-05-15  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Oliver.
+
+        - Yet more tests for http://bugs.webkit.org/show_bug.cgi?id=13722
+          Finish testing and fixing the setting of DOM attributes to JS null
+
+          Tests for SVG attributes that take a DOMString.
+
+        * fast/dom/svg-element-attribute-js-null-expected.txt: Added.
+        * fast/dom/svg-element-attribute-js-null.xhtml: Added.
+
 2007-05-15  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Oliver.
diff --git a/LayoutTests/fast/dom/svg-element-attribute-js-null-expected.txt b/LayoutTests/fast/dom/svg-element-attribute-js-null-expected.txt
new file mode 100644 (file)
index 0000000..5bb0aba
--- /dev/null
@@ -0,0 +1,12 @@
+This test setting various attributes of a SVG elements to JavaScript null.
+
+TEST SUCCEEDED: The value was the empty string. [tested SVGElement.id]
+TEST SUCCEEDED: The value was the empty string. [tested SVGElement.xmlbase]
+
+TEST SUCCEEDED: The value was the string '0deg'. [tested SVGAngle.valueAsString]
+
+TEST SUCCEEDED: The value was the string '0'. [tested SVGLength.valueAsString]
+
+TEST SUCCEEDED: The value was the empty string. [tested SVGScriptElement.type]
+
+
diff --git a/LayoutTests/fast/dom/svg-element-attribute-js-null.xhtml b/LayoutTests/fast/dom/svg-element-attribute-js-null.xhtml
new file mode 100644 (file)
index 0000000..02c3702
--- /dev/null
@@ -0,0 +1,100 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+    <style type="text/css">
+        .pass { color: green; }
+        .fail { color: red; }
+    </style>
+    <script type="text/javascript" charset="utf-8">
+        function printOut(msg)
+        {
+            var console = document.getElementById("console");
+            var span = document.createElementNS('http://www.w3.org/1999/xhtml', 'span');
+            span.appendChild(document.createTextNode(msg));
+            span.appendChild(document.createElementNS('http://www.w3.org/1999/xhtml', 'br'));
+            console.appendChild(span);
+        }
+
+        function resultStringifier(result)
+        {
+            if (result === "")
+                return "the empty string";
+            else if (result === undefined)
+                return "undefined";
+            else if (result === null)
+                return "null";
+            return "the string '" + result + "'";
+        }
+
+        function nullTestElementAttribute(elementType, element, attr, expected)
+        {
+            element[attr] = null;
+
+            var result;
+            if (element[attr] === expected)
+                result = "TEST SUCCEEDED: The value was " + resultStringifier(expected) + ".";
+            else
+                result = "TEST FAILED: The value should have been " + resultStringifier(expected) + " but was " + resultStringifier(element[attr]) + ".";
+
+            result += " [tested " + elementType + "." + attr + "]";
+            printOut(result);
+        }
+        
+        function runTests()
+        {
+            if (window.layoutTestController)
+                layoutTestController.dumpAsText();
+
+            var svgNS = 'http://www.w3.org/2000/svg';
+            var svg = document.createElementNS(svgNS, 'svg');
+
+            var listing = [
+                {
+                    type: 'SVGElement',
+                    elementToUse: svg,
+                    attributes: [
+                        {name: 'id', expectedNull: ''},
+                        {name: 'xmlbase', expectedNull: ''}
+                    ]
+                },
+                {
+                    type: 'SVGAngle',
+                    elementToUse: svg.createSVGAngle(),
+                    attributes: [
+                        {name: 'valueAsString', expectedNull: '0deg'}
+                    ]
+                },
+                {
+                    type: 'SVGLength',
+                    elementToUse: svg.createSVGLength(),
+                    attributes: [
+                        {name: 'valueAsString', expectedNull: '0'}
+                    ]
+                },
+                {
+                    type: 'SVGScriptElement',
+                    elementToUse: document.createElementNS(svgNS, 'script'),
+                    attributes: [
+                        {name: 'type', expectedNull: ''}
+                    ]
+                }
+            ];
+
+            for (element in listing) {
+                var type = listing[element].type;
+                var elementToUse = listing[element].elementToUse;
+                var attrs = listing[element].attributes;
+                for (attr in attrs) {
+                    nullTestElementAttribute(type, elementToUse, attrs[attr].name, attrs[attr].expectedNull);
+                }
+                printOut('');
+            }
+        }
+        
+    </script>
+</head>
+
+<body onload="runTests();">
+    <p>This test setting various attributes of a SVG elements to JavaScript null.</p>
+    <div id="console"></div>
+</body>
+</html>
index a78d2d0ec3955de2c8976ec3c4abb6172a20eb32..e290894fb108d29a5dc81d501c5849c0a823a00d 100644 (file)
@@ -1,3 +1,19 @@
+2007-05-15  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Oliver.
+
+        - Patch for http://bugs.webkit.org/show_bug.cgi?id=13722
+          Finish testing and fixing the setting of DOM attributes to JS null
+
+          Convert JS null to null string for SVG attributes.
+
+        Test: fast/dom/svg-element-attribute-js-null.xhtml
+
+        * ksvg2/svg/SVGAngle.idl:
+        * ksvg2/svg/SVGElement.idl:
+        * ksvg2/svg/SVGLength.idl:
+        * ksvg2/svg/SVGScriptElement.idl:
+
 2007-05-15  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Oliver.
index 15431ceedd4b75dbfdec4e25aa21c181aabe62c3..98a131545c9533f0b016a12d1fec9dc64e958cbd 100644 (file)
@@ -35,7 +35,7 @@ module svg {
         readonly attribute unsigned short unitType;
                  attribute float          value;
                  attribute float          valueInSpecifiedUnits;
-                 attribute DOMString      valueAsString;
+                 attribute [ConvertNullToNullString] DOMString      valueAsString;
         
         void newValueSpecifiedUnits(in unsigned short unitType, 
                                     in float valueInSpecifiedUnits);
index fb1202607b28fc7d21b68738b2fe76f2ac664791..b15447e331d99c10c3559c1835820b8662cbc66f 100644 (file)
@@ -25,9 +25,9 @@
 module svg {
 
     interface [GenerateNativeConverter, Conditional=SVG] SVGElement : Element {
-                 attribute DOMString id
+                 attribute [ConvertNullToNullString] DOMString id
                      setter raises(DOMException);
-                 attribute DOMString xmlbase
+                 attribute [ConvertNullToNullString] DOMString xmlbase
                      setter raises(DOMException);
         readonly attribute SVGSVGElement ownerSVGElement;
         readonly attribute SVGElement viewportElement;
index 4d46e42a1b2f9c47b5ebeac5c4de47f6d189addb..be0fd6501938198e462f7a7482158ded0db9885a 100644 (file)
@@ -41,7 +41,7 @@ module svg {
         readonly attribute unsigned short unitType;
                  attribute float          value;
                  attribute float          valueInSpecifiedUnits;
-                 attribute DOMString      valueAsString;
+                 attribute [ConvertNullToNullString] DOMString      valueAsString;
 
         void newValueSpecifiedUnits(in unsigned short unitType, 
                                     in float valueInSpecifiedUnits);
index 4e7df072cbb67a0773b130ceaa03816c4a1db588..da2e03435cc4f7d1f7ffd9a26060d4d91c8c4528 100644 (file)
@@ -28,7 +28,7 @@ module svg {
     interface [Conditional=SVG] SVGScriptElement : SVGElement,
                                                    SVGURIReference,
                                                    SVGExternalResourcesRequired {
-                 attribute DOMString type
+                 attribute [ConvertNullToNullString] DOMString type
                      /*setter raises(DOMException)*/;
     };