blob: 60d9d83da6907244e46d0de7b1488b3ba12dc08b [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 === null)
return "<b>null</b>";
else if (result === undefined)
return "<b>undefined</b>";
return "the string '" + result + "'";
}
function nullTestDocumentAttribute(documentType, doc, attr, expected)
{
doc[attr] = null;
var result;
if (doc[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(doc[attr]) + ".";
result += " [tested " + documentType + "." + attr + "]";
printOut(result);
}
function runTests()
{
if (window.layoutTestController)
layoutTestController.dumpAsText();
// Others to test:
// Functions
var xmlDoc = document.implementation.createDocument(null, null, null);
var htmlDoc = document.implementation.createHTMLDocument('A Title');
htmlDoc.body = htmlDoc.createElement('body');
var listing = [
{
typeName: 'Document',
docToUse: xmlDoc,
attributes: [
{name: 'xmlVersion', expectedNull: null},
{name: 'documentURI', expectedNull: null},
{name: 'charset', expectedNull: undefined},
{name: 'selectedStylesheetSet', expectedNull: null}
]
},
{
typeName: 'HTMLDocument',
docToUse: htmlDoc,
attributes: [
{name: 'title', expectedNull: ''},
{name: 'cookie', expectedNull: ''},
{name: 'bgColor', expectedNull: ''},
{name: 'fgColor', expectedNull: ''},
{name: 'alinkColor', expectedNull: ''},
{name: 'linkColor', expectedNull: ''},
{name: 'vlinkColor', expectedNull: ''},
{name: 'dir', expectedNull: ''},
{name: 'designMode', expectedNull: 'off'}
]
}
];
for (doc in listing) {
var typeName = listing[doc].typeName;
var docToUse = listing[doc].docToUse;
var attrs = listing[doc].attributes;
for (attr in attrs) {
nullTestDocumentAttribute(typeName, docToUse, attrs[attr].name, attrs[attr].expectedNull);
}
printOut('');
}
}
</script>
</head>
<body onload="runTests()">
<p>This test setting various attributes of documents to JavaScript null.</p>
<div id="console"></div>
</body>
</html>