<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<body>
<script>
test(function(t) {
var ctx = document.createElement('canvas').getContext('2d');
// Clear rect with height = width = 0.
ctx.fillStyle = 'red';
ctx.fillRect(0, 0, 1, 1);
ctx.clearRect(0, 0, 0, 0);
var imageData = ctx.getImageData(0, 0, 1, 1);
var imgdata = imageData.data;
assert_equals(imgdata[0], 255);
assert_equals(imgdata[1], 0);
assert_equals(imgdata[2], 0);
ctx.clearRect(0, 0, 1, 1);
// Clear rect with height = 0, width = 1.
ctx.fillStyle = 'red';
ctx.fillRect(0, 0, 1, 1);
ctx.clearRect(0, 0, 1, 0);
var imageData = ctx.getImageData(0, 0, 1, 1);
var imgdata = imageData.data;
assert_equals(imgdata[0], 255);
assert_equals(imgdata[1], 0);
assert_equals(imgdata[2], 0);
ctx.clearRect(0, 0, 1, 1);
// Clear rect with height = 1, width = 0.
ctx.fillStyle = 'red';
ctx.fillRect(0, 0, 1, 1);
ctx.clearRect(0, 0, 0, 1);
var imageData = ctx.getImageData(0, 0, 1, 1);
var imgdata = imageData.data;
assert_equals(imgdata[0], 255);
assert_equals(imgdata[1], 0);
assert_equals(imgdata[2], 0);
}, "Series of tests to ensure correct behavior of canvas.clearRect().");
</script>
</body>