| <!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> |