2 <script src=
"../../resources/testharness.js"></script>
3 <script src=
"../../resources/testharnessreport.js"></script>
6 window
.ctx
= document
.createElement('canvas').getContext('2d');
10 ctx
.fillStyle
= "#800000";
11 ctx
.fillStyle
= { toString: function() { return "#008000"; } };
12 assert_equals(ctx
.fillStyle
, "#008000");
13 }, 'Stringifies non-CanvasGradient/Pattern object assigned to fillStyle.');
16 ctx
.fillStyle
= "#008000";
18 assert_equals(ctx
.fillStyle
, "#008000");
19 }, 'Non-CanvasGradient/Pattern object without explicit toString() does not affect the value of fillStyle.');
22 ctx
.fillStyle
= "#008000";
23 ctx
.fillStyle
= 800000;
24 assert_equals(ctx
.fillStyle
, "#008000");
25 }, 'Stringified numbers don\'t yield a correct color when assigned to fillStyle.');
28 assert_throws(new Error(), function() {
29 ctx
.fillStyle
= { toString: function() { throw new Error("Exception"); } };
31 }, 'Rethrows exception thrown from toString() during stringification of non-CanvasGradient/Pattern object assigned to fillStyle.');
34 ctx
.strokeStyle
= "#800000";
35 ctx
.strokeStyle
= { toString: function() { return "#008000"; } };
36 assert_equals(ctx
.strokeStyle
, "#008000");
37 }, 'Stringifies non-CanvasGradient/Pattern object assigned to strokeStyle.');
40 ctx
.strokeStyle
= "#008000";
42 assert_equals(ctx
.strokeStyle
, "#008000");
43 }, 'Non-CanvasGradient/Pattern object without explicit toString() does not affect the value of strokeStyle.');
46 ctx
.strokeStyle
= "#008000";
47 ctx
.strokeStyle
= 800000;
48 assert_equals(ctx
.strokeStyle
, "#008000");
49 }, 'Stringified numbers don\'t yield a correct color when assigned to strokeStyle.');
52 assert_throws(new Error(), function() {
53 ctx
.strokeStyle
= { toString: function() { throw new Error("Exception"); } };
55 }, 'Rethrows exception thrown from toString() during stringification of non-CanvasGradient/Pattern object assigned to strokeStyle.');