Remove document as a parameter from a few internals methods
[WebKit-https.git] / LayoutTests / fast / dom / shadow / create-content-element.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <style>
5 /* relative positioning ensures underlying RenderLayer */
6 .container {
7     position: relative;
8 }
9 </style>
10 <script>
11 function log(message)
12 {
13     document.getElementById("console").innerHTML += (message + "\n");
14 }
15
16 function removeContainerLines(text)
17 {
18     var lines = text.split("\n");
19     lines.splice(0, 2);
20     return lines.join("\n");
21 }
22
23 function setupTargetTree()
24 {
25     var target = document.createElement("div");
26     target.innerHTML = "<span>content</span>";
27     var root = internals.ensureShadowRoot(target);
28     
29     var child0 = document.createElement("span");
30     child0.innerHTML = "Hello,";
31     root.appendChild(child0);
32     root.appendChild(window.internals.createContentElement());
33     var child1 = document.createElement("span");
34     child1.innerHTML = "World.";
35     root.appendChild(child1);
36
37     document.getElementById("target").appendChild(target);
38 }
39
40 function test()
41 {
42     testRunner.dumpAsText();
43     log("This test compares a shadow-based render tree with one for a refrence DOM tree.");
44     setupTargetTree();
45     var targetContainerRenderTree = window.internals.elementRenderTreeAsText(document.getElementById("targetContainer"));
46     var targetRenderTree = removeContainerLines(targetContainerRenderTree);
47     var refContainerRenderTree = window.internals.elementRenderTreeAsText(document.getElementById("refContainer"));
48     var refRenderTree = removeContainerLines(refContainerRenderTree);
49     if (targetRenderTree == refRenderTree)
50         log("PASS");
51     else {
52         log("FAIL");
53         log("Expected:");
54         log(refRenderTree);
55         log("Actual:");
56         log(targetRenderTree);
57     }
58     
59     document.getElementById("test").style.display = "none";
60 }
61 </script>
62 </head>
63 <body onload="test()">
64 <div id="test">
65 <div class="container" id="targetContainer"><div id="target"></div></div>
66 <div class="container" id="refContainer"><div><div><span>Hello,</span><span>content</span><span>World.</span></div></div></div>
67 </div>
68 <pre id="console"></pre>
69 </body>
70 </html>