8e2ea88422aba9fe5ebc106734386a63e8df6c34
[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.addResult("========= Original ========");
40     InspectorTest.dumpDOMAgentTree();
41
42     InspectorTest.evaluateInPage("appendChild()", step1);
43
44     function step1()
45     {
46         InspectorTest.addResult("Appended");
47         InspectorTest.evaluateInPage("removeChild()", step2);
48     }
49
50     function step2()
51     {
52         InspectorTest.addResult("Removed");
53         InspectorTest.evaluateInPage("modifyAttribute()", step3);
54     }
55
56     function step3()
57     {
58         InspectorTest.addResult("Attribute modified");
59         InspectorTest.completeTest();
60     }
61 }
62
63 </script>
64 </head>
65
66 <body onload="runTest()">
67 <p>
68 Tests that elements panel does not receive events upon changes to the undiscovered nodes.
69 </p>
70
71 <div>
72 <div id="hidden">
73 </div>
74 </div>
75
76 </body>
77 </html>