blob: bdab984bbb5f45e6b5d42027201a4dc91c711ecf [file] [log] [blame]
<html>
<head>
<style type="text/css">
.pass { color: green; }
.fail { color: red; }
</style>
<script>
function printOut(msg)
{
var console = document.getElementById("console");
var span = document.createElement('span');
span.innerHTML = msg + '<br>';
console.appendChild(span);
}
function resultStringifier(result)
{
if (result === "")
return "<b>the empty string</b>";
else if (result === undefined)
return "<b>undefined</b>";
else if (result === null)
return "<b>null</b>";
return "the string '" + result + "'";
}
function nullTestElementAttribute(elementType, element, attr, expected)
{
element[attr] = null;
var result;
if (element[attr] === expected)
result = "<span class='pass'>TEST SUCCEEDED:</span> The value was " + resultStringifier(expected) + ".";
else
result = "<span class='fail'>TEST FAILED:</span> The value should have been " + resultStringifier(expected) + " but was " + resultStringifier(element[attr]) + ".";
result += " [tested " + elementType + "." + attr + "]";
printOut(result);
}
function runTests()
{
if (window.testRunner)
testRunner.dumpAsText();
var canvas = document.createElement('canvas');
var context = canvas.getContext("2d");
var listing = [
{
type: 'CanvasRenderingContext2D',
elementToUse: context,
attributes: [
{name: 'globalCompositeOperation', expectedNull: 'source-over'},
{name: 'lineCap', expectedNull: 'butt'},
{name: 'lineJoin', expectedNull: 'miter'},
{name: 'shadowColor', expectedNull: 'rgba(0, 0, 0, 0)'}
]
}
];
for (element in listing) {
var type = listing[element].type;
var elementToUse = listing[element].elementToUse;
var attrs = listing[element].attributes;
for (attr in attrs) {
nullTestElementAttribute(type, elementToUse, attrs[attr].name, attrs[attr].expectedNull);
}
printOut('');
}
}
</script>
</head>
<body onload="runTests()">
<p>This test setting various attributes of a CanvasRenderingContext2D to JavaScript null.</p>
<div id="console"></div>
</body>
</html>