summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/dom/implementation-createHTMLDocument.html
blob: 0686dfac467eb13f4acd9b34e53913de3acf9f1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<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", "");
    shouldBe("doc.getElementsByTagName('title').item(0).firstChild.data", "");

    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>