62 lines
1.6 KiB
HTML
62 lines
1.6 KiB
HTML
<html>
|
|
<head>
|
|
<script>
|
|
function print(message, color)
|
|
{
|
|
var paragraph = document.createElement("div");
|
|
paragraph.appendChild(document.createTextNode(message));
|
|
paragraph.style.fontFamily = "monospace";
|
|
if (color)
|
|
paragraph.style.color = color;
|
|
document.getElementById("console").appendChild(paragraph);
|
|
}
|
|
|
|
function shouldBe(a, b)
|
|
{
|
|
var evalA;
|
|
try {
|
|
evalA = eval(a);
|
|
} catch(e) {
|
|
evalA = e;
|
|
}
|
|
|
|
if (evalA == b)
|
|
print("PASS: " + a + " should be " + b + " and is.", "green");
|
|
else
|
|
print("FAIL: " + a + " should be " + b + " but instead is " + evalA + ".", "red");
|
|
}
|
|
|
|
function test()
|
|
{
|
|
if (window.testRunner)
|
|
testRunner.dumpAsText();
|
|
|
|
print("[document with title 'title']");
|
|
doc = document.implementation.createHTMLDocument("title");
|
|
shouldBe("doc.title", "title");
|
|
shouldBe("doc.getElementsByTagName('html').length", 1);
|
|
shouldBe("doc.getElementsByTagName('head').length", 1);
|
|
shouldBe("doc.getElementsByTagName('title').length", 1);
|
|
shouldBe("doc.getElementsByTagName('body').length", 1);
|
|
|
|
print("[document with title '']");
|
|
doc = document.implementation.createHTMLDocument("");
|
|
shouldBe("doc.title", "");
|
|
|
|
print("[document with null title]");
|
|
doc = document.implementation.createHTMLDocument(null);
|
|
shouldBe("doc.title", "null");
|
|
}
|
|
</script>
|
|
</head>
|
|
|
|
<body onload="test();">
|
|
<p>This page tests the DOM createHTMLDocument method.</p>
|
|
<p>If the test passes, you'll see a series of 'PASS' messages below.</p>
|
|
<hr>
|
|
|
|
<div id='console'></div>
|
|
|
|
</body>
|
|
</html>
|