2011-02-17 Ilya Tikhonovsky <loislo@chromium.org>
[WebKit-https.git] / LayoutTests / inspector / elements / mutate-unknown-node.html
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/elements-test.js"></script>
5 <script>
6
7 function appendChild()
8 {
9     var hidden = document.getElementById("hidden");
10     var child = document.createElement("div");
11     child.setAttribute("id", "appended");
12     hidden.appendChild(child);
13 }
14
15 function removeChild()
16 {
17     var child = document.getElementById("appended");
18     child.parentNode.removeChild(child);
19 }
20
21 function modifyAttribute()
22 {
23     var hidden = document.getElementById("hidden");
24     hidden.setAttribute("foo", "bar");
25 }
26
27 function test()
28 {
29     function listener(type, event)
30     {
31         InspectorTest.addResult("DOMAgent event fired. Should only happen once for output node: " + type + " " + event.target.nodeName + "#" + event.target.getAttribute("id"));
32     }
33
34     WebInspector.domAgent.document.addEventListener("DOMAttrModified", listener.bind(this, "DOMAttrModified"));
35     WebInspector.domAgent.document.addEventListener("DOMCharacterDataModified", listener.bind(this, "DOMCharacterDataModified"));
36     WebInspector.domAgent.document.addEventListener("DOMNodeInserted", listener.bind(this, "DOMNodeInserted"));
37     WebInspector.domAgent.document.addEventListener("DOMNodeRemoved", listener.bind(this, "DOMNodeRemoved"));
38
39     InspectorTest.evaluateInPage("appendChild()", step1);
40
41     function step1()
42     {
43         InspectorTest.addResult("Appended");
44         InspectorTest.evaluateInPage("removeChild()", step2);
45     }
46
47     function step2()
48     {
49         InspectorTest.addResult("Removed");
50         InspectorTest.evaluateInPage("modifyAttribute()", step3);
51     }
52
53     function step3()
54     {
55         InspectorTest.addResult("Attribute modified");
56         InspectorTest.evaluateInPage("true", step4);
57     }
58
59     function step4()
60     {
61         InspectorTest.addResult("========= Result DOMAgent tree ========");
62         InspectorTest.dumpDOMAgentTree();
63
64         InspectorTest.completeTest();
65     }
66 }
67
68 </script>
69 </head>
70
71 <body onload="runTest()">
72 <p>
73 Tests that elements panel does not receive events upon changes to the undiscovered nodes.
74 </p>
75
76 <div>
77 <div id="hidden">
78 </div>
79 </div>
80
81 </body>
82 </html>