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

        - 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 CanvasRenderingContext2D attributes that take a DOMString.

        * fast/dom/canvasContext2d-element-attribute-js-null-expected.txt: Added.
        * fast/dom/canvasContext2d-element-attribute-js-null.html: 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 CanvasRenderingContext2D attributes.

        Test: fast/dom/canvasContext2d-element-attribute-js-null.html

        * html/CanvasRenderingContext2D.idl:

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

LayoutTests/ChangeLog
LayoutTests/fast/dom/canvasContext2d-element-attribute-js-null-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/canvasContext2d-element-attribute-js-null.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/html/CanvasRenderingContext2D.idl

index f606891fdf18388a3913d6ae82044f645d5bfd9b..26d4e3953344846125d15507de9b9bb3a003daff 100644 (file)
@@ -1,3 +1,15 @@
+2007-05-15  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Oliver.
+
+        - 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 CanvasRenderingContext2D attributes that take a DOMString.
+
+        * fast/dom/canvasContext2d-element-attribute-js-null-expected.txt: Added.
+        * fast/dom/canvasContext2d-element-attribute-js-null.html: Added.
+
 2007-05-15  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Oliver.
diff --git a/LayoutTests/fast/dom/canvasContext2d-element-attribute-js-null-expected.txt b/LayoutTests/fast/dom/canvasContext2d-element-attribute-js-null-expected.txt
new file mode 100644 (file)
index 0000000..bd5e97d
--- /dev/null
@@ -0,0 +1,8 @@
+This test setting various attributes of a CanvasRenderingContext2D to JavaScript null.
+
+TEST SUCCEEDED: The value was the string 'source-over'. [tested CanvasRenderingContext2D.globalCompositeOperation]
+TEST SUCCEEDED: The value was the string 'butt'. [tested CanvasRenderingContext2D.lineCap]
+TEST SUCCEEDED: The value was the string 'miter'. [tested CanvasRenderingContext2D.lineJoin]
+TEST SUCCEEDED: The value was the empty string. [tested CanvasRenderingContext2D.shadowColor]
+
+
diff --git a/LayoutTests/fast/dom/canvasContext2d-element-attribute-js-null.html b/LayoutTests/fast/dom/canvasContext2d-element-attribute-js-null.html
new file mode 100644 (file)
index 0000000..d9e7f7a
--- /dev/null
@@ -0,0 +1,78 @@
+<html>
+<head>
+    <style type="text/css">
+        .pass { color: green; }
+        .fail { color: red; }
+    </style>
+    <script>
+        function printOut(msg)
+        {
+            var console = document.getElementById("console");
+            var span = document.createElement('span');
+            span.innerHTML = msg + '<br>';
+            console.appendChild(span);
+        }
+
+        function resultStringifier(result)
+        {
+            if (result === "")
+                return "<b>the empty string</b>";
+            else if (result === undefined)
+                return "<b>undefined</b>";
+            else if (result === null)
+                return "<b>null</b>";
+            return "the string '" + result + "'";
+        }
+
+        function nullTestElementAttribute(elementType, element, attr, expected)
+        {
+            element[attr] = null;
+
+            var result;
+            if (element[attr] === expected)
+                result = "<span class='pass'>TEST SUCCEEDED:</span> The value was " + resultStringifier(expected) + ".";
+            else
+                result = "<span class='fail'>TEST FAILED:</span> 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 canvas = document.createElement('canvas');
+            var context = canvas.getContext("2d");
+
+            var listing = [
+                {
+                    type: 'CanvasRenderingContext2D',
+                    elementToUse: context,
+                    attributes: [
+                        {name: 'globalCompositeOperation', expectedNull: 'source-over'},
+                        {name: 'lineCap', expectedNull: 'butt'},
+                        {name: 'lineJoin', expectedNull: 'miter'},
+                        {name: 'shadowColor', 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 CanvasRenderingContext2D to JavaScript null.</p>
+    <div id="console"></div>
+</body>
+</html>
index 71e2ea8c44c732f035508c6ee79aec12bcc1554a..a78d2d0ec3955de2c8976ec3c4abb6172a20eb32 100644 (file)
@@ -1,3 +1,16 @@
+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 CanvasRenderingContext2D attributes.
+
+        Test: fast/dom/canvasContext2d-element-attribute-js-null.html
+
+        * html/CanvasRenderingContext2D.idl:
+
 2007-05-15  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Sam and Geoff.
index 166ce6a10692f78d4aca5b87efb0e6ba1795514a..ccf7acf24ee58ed7f733a5c37bbba453a5a58ce1 100644 (file)
@@ -39,20 +39,20 @@ module html {
         void translate(in float tx, in float ty);
 
         attribute float globalAlpha;
-        attribute DOMString globalCompositeOperation;
+        attribute [ConvertNullToNullString] DOMString globalCompositeOperation;
 
         CanvasGradient createLinearGradient(in float x0, in float y0, in float x1, in float y1);
         CanvasGradient createRadialGradient(in float x0, in float y0, in float r0, in float x1, in float y1, in float r1);
 
         attribute float lineWidth;
-        attribute DOMString lineCap;
-        attribute DOMString lineJoin;
+        attribute [ConvertNullToNullString] DOMString lineCap;
+        attribute [ConvertNullToNullString] DOMString lineJoin;
         attribute float miterLimit;
 
         attribute float shadowOffsetX;
         attribute float shadowOffsetY;
         attribute float shadowBlur;
-        attribute DOMString shadowColor;
+        attribute [ConvertNullToNullString] DOMString shadowColor;
 
         void clearRect(in float x, in float y, in float width, in float height)
             raises (DOMException);