<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<body>
<script>
test(function(t) {
var ctx = document.createElement('canvas').getContext('2d');
ctx.fillStyle = 'red';
ctx.fillRect(0, 0, 1, 1);
assert_equals(ctx.fillStyle, '#ff0000');
var imageData = ctx.getImageData(0, 0, 2, 1).data;
assert_array_equals(imageData.slice(0,4), [255, 0, 0, 255]);
assert_array_equals(imageData.slice(4), [0, 0, 0, 0]);
ctx.strokeStyle = 'green';
ctx.lineWidth = 10;
ctx.fillStyle = 'red';
ctx.fillText("X", 0, 0);
assert_equals(ctx.strokeStyle, '#008000');
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(10, 10);
ctx.stroke();
imageData = ctx.getImageData(2, 2, 1, 1).data;
assert_array_equals(imageData, [0, 128, 0, 255]);
ctx.strokeStyle = 'red';
ctx.lineWidth = 100;
ctx.fillStyle = 'green';
ctx.strokeText("X", 0, 0);
assert_equals(ctx.fillStyle, '#008000');
ctx.fillRect(0, 0, 10, 10);
imageData = ctx.getImageData(2, 2, 1, 1).data;
assert_array_equals(imageData, [0, 128, 0, 255]);
}, "Test that the rendering context's strokeStyle and fillStyle are intact after calling strokeText() and fillText()");
</script>
</body>