Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / canvas / canvas-fillStyle-strokeStyle-stringification.html
1 <!DOCTYPE html>
2 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script>
4 <script>
5 setup(function() {
6   window.ctx = document.createElement('canvas').getContext('2d');
7 });
8
9 test(function() {
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.');
14
15 test(function() {
16   ctx.fillStyle = "#008000";
17   ctx.fillStyle = {};
18   assert_equals(ctx.fillStyle, "#008000");
19 }, 'Non-CanvasGradient/Pattern object without explicit toString() does not affect the value of fillStyle.');
20
21 test(function() {
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.');
26
27 test(function() {
28   assert_throws(new Error(), function() {
29     ctx.fillStyle = { toString: function() { throw new Error("Exception"); } };
30   });
31 }, 'Rethrows exception thrown from toString() during stringification of non-CanvasGradient/Pattern object assigned to fillStyle.');
32
33 test(function() {
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.');
38
39 test(function() {
40   ctx.strokeStyle = "#008000";
41   ctx.strokeStyle = {};
42   assert_equals(ctx.strokeStyle, "#008000");
43 }, 'Non-CanvasGradient/Pattern object without explicit toString() does not affect the value of strokeStyle.');
44
45 test(function() {
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.');
50
51 test(function() {
52   assert_throws(new Error(), function() {
53     ctx.strokeStyle = { toString: function() { throw new Error("Exception"); } };
54   });
55 }, 'Rethrows exception thrown from toString() during stringification of non-CanvasGradient/Pattern object assigned to strokeStyle.');
56
57 </script>