Index: LayoutTests/fast/canvas/canvas-fillStyle-strokeStyle-stringification.html |
diff --git a/LayoutTests/fast/canvas/canvas-fillStyle-strokeStyle-stringification.html b/LayoutTests/fast/canvas/canvas-fillStyle-strokeStyle-stringification.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..db0b765d7164bd6bda8dfecd622c7585bbd3fd1e |
--- /dev/null |
+++ b/LayoutTests/fast/canvas/canvas-fillStyle-strokeStyle-stringification.html |
@@ -0,0 +1,57 @@ |
+<!DOCTYPE html> |
+<script src="../../resources/testharness.js"></script> |
+<script src="../../resources/testharnessreport.js"></script> |
+<script> |
+setup(function() { |
+ window.ctx = document.createElement('canvas').getContext('2d'); |
+}); |
+ |
+test(function() { |
+ ctx.fillStyle = "#800000"; |
+ ctx.fillStyle = { toString: function() { return "#008000"; } }; |
+ assert_equals(ctx.fillStyle, "#008000"); |
+}, 'Stringifies non-CanvasGradient/Pattern object assigned to fillStyle.'); |
+ |
+test(function() { |
+ ctx.fillStyle = "#008000"; |
+ ctx.fillStyle = {}; |
+ assert_equals(ctx.fillStyle, "#008000"); |
+}, 'Non-CanvasGradient/Pattern object without explicit toString() does not affect the value of fillStyle.'); |
+ |
+test(function() { |
+ ctx.fillStyle = "#008000"; |
+ ctx.fillStyle = 800000; |
+ assert_equals(ctx.fillStyle, "#008000"); |
+}, 'Stringified numbers don\'t yield a correct color when assigned to fillStyle.'); |
+ |
+test(function() { |
+ assert_throws(new Error(), function() { |
+ ctx.fillStyle = { toString: function() { throw new Error("Exception"); } }; |
+ }); |
+}, 'Rethrows exception thrown from toString() during stringification of non-CanvasGradient/Pattern object assigned to fillStyle.'); |
+ |
+test(function() { |
+ ctx.strokeStyle = "#800000"; |
+ ctx.strokeStyle = { toString: function() { return "#008000"; } }; |
+ assert_equals(ctx.strokeStyle, "#008000"); |
+}, 'Stringifies non-CanvasGradient/Pattern object assigned to strokeStyle.'); |
+ |
+test(function() { |
+ ctx.strokeStyle = "#008000"; |
+ ctx.strokeStyle = {}; |
+ assert_equals(ctx.strokeStyle, "#008000"); |
+}, 'Non-CanvasGradient/Pattern object without explicit toString() does not affect the value of strokeStyle.'); |
+ |
+test(function() { |
+ ctx.strokeStyle = "#008000"; |
+ ctx.strokeStyle = 800000; |
+ assert_equals(ctx.strokeStyle, "#008000"); |
+}, 'Stringified numbers don\'t yield a correct color when assigned to strokeStyle.'); |
+ |
+test(function() { |
+ assert_throws(new Error(), function() { |
+ ctx.strokeStyle = { toString: function() { throw new Error("Exception"); } }; |
+ }); |
+}, 'Rethrows exception thrown from toString() during stringification of non-CanvasGradient/Pattern object assigned to strokeStyle.'); |
+ |
+</script> |