Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / dom / implementation-createHTMLDocument.html
1 <html>
2 <head>
3 <script>
4 function print(message, color) 
5 {
6     var paragraph = document.createElement("div");
7     paragraph.appendChild(document.createTextNode(message));
8     paragraph.style.fontFamily = "monospace";
9     if (color)
10         paragraph.style.color = color;
11     document.getElementById("console").appendChild(paragraph);
12 }
13
14 function shouldBe(a, b)
15 {
16     var evalA;
17     try {
18         evalA = eval(a);
19     } catch(e) {
20         evalA = e;
21     }
22     
23     if (evalA == b)
24         print("PASS: " + a + " should be " + b + " and is.", "green");
25     else
26         print("FAIL: " + a + " should be " + b + " but instead is " + evalA + ".", "red");
27 }
28
29 function test() 
30 {
31     if (window.testRunner)
32         testRunner.dumpAsText();
33         
34     print("[document with title 'title']");
35     doc = document.implementation.createHTMLDocument("title");
36     shouldBe("doc.title", "title");
37     shouldBe("doc.getElementsByTagName('html').length", 1);
38     shouldBe("doc.getElementsByTagName('head').length", 1);
39     shouldBe("doc.getElementsByTagName('title').length", 1);
40     shouldBe("doc.getElementsByTagName('body').length", 1);
41     
42     print("[document with title '']");
43     doc = document.implementation.createHTMLDocument("");
44     shouldBe("doc.title", "");
45     shouldBe("doc.getElementsByTagName('title').item(0).firstChild.data", "");
46
47     print("[document with null title]");
48     doc = document.implementation.createHTMLDocument(null);
49     shouldBe("doc.title", "null");
50 }
51 </script>
52 </head>
53
54 <body onload="test();">
55 <p>This page tests the DOM createHTMLDocument method.</p>
56 <p>If the test passes, you'll see a series of 'PASS' messages below.</p>
57 <hr>
58
59 <div id='console'></div>
60
61 </body>
62 </html>