Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Unified Diff: LayoutTests/fast/canvas/canvas-fillStyle-strokeStyle-stringification.html

Issue 237743007: Handle the DOMString case of CRC2D.fillStyle/strokeStyle correctly (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add tests for objects without (explicit) toString. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
« no previous file with comments | « no previous file | Source/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698