summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/canvas/canvas-fillStyle-strokeStyle-stringification.html
blob: db0b765d7164bd6bda8dfecd622c7585bbd3fd1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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>