Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / elements / edit / set-attribute.html
bloba687335e651ca57d5d43cbf8b0ecf1e28ac75671
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>
7 function setAttribute(name, value)
9 var node = document.getElementById("node");
10 node.setAttribute(name, value);
13 function removeAttribute(name)
15 var node = document.getElementById("node");
16 node.removeAttribute(name);
19 function test()
21 var targetNode;
23 InspectorTest.runTestSuite([
24 function testDumpInitial(next)
26 function callback(node)
28 targetNode = node;
29 InspectorTest.addResult("========= Original ========");
30 InspectorTest.dumpElementsTree(targetNode);
31 next();
33 InspectorTest.selectNodeWithId("node", callback);
36 function testAttributeUpdated(next)
38 function callback()
40 InspectorTest.domModel.removeEventListener(WebInspector.DOMModel.Events.AttrModified, callback);
41 InspectorTest.addResult("===== On attribute set =====");
42 InspectorTest.dumpElementsTree(targetNode);
43 next();
45 InspectorTest.domModel.addEventListener(WebInspector.DOMModel.Events.AttrModified, callback);
46 InspectorTest.evaluateInPage("setAttribute('name', 'value')");
49 function testAttributeSameValueNotUpdated(next)
51 function callback()
53 InspectorTest.addResult("===== On attribute modified (should be 'newValue') =====");
54 InspectorTest.dumpElementsTree(targetNode);
55 InspectorTest.domModel.removeEventListener(WebInspector.DOMModel.Events.AttrModified, callback);
56 next();
58 InspectorTest.domModel.addEventListener(WebInspector.DOMModel.Events.AttrModified, callback);
59 // Setting the same property value should not result in the AttrModified event.
60 InspectorTest.evaluateInPage("setAttribute('name', 'value')");
61 InspectorTest.evaluateInPage("setAttribute('name', 'value')");
62 InspectorTest.evaluateInPage("setAttribute('name', 'newValue')");
65 function testAttributeRemoved(next)
67 function callback()
69 InspectorTest.domModel.removeEventListener(WebInspector.DOMModel.Events.AttrRemoved, callback);
70 InspectorTest.addResult("=== On attribute removed ===");
71 InspectorTest.dumpElementsTree(targetNode);
72 next();
74 InspectorTest.domModel.addEventListener(WebInspector.DOMModel.Events.AttrRemoved, callback);
75 InspectorTest.evaluateInPage("removeAttribute('name')");
78 function testSetAttributeValue(next)
80 function callback()
82 InspectorTest.domModel.removeEventListener(WebInspector.DOMModel.Events.AttrModified, callback);
83 InspectorTest.addResult("=== Set attribute value ===");
84 InspectorTest.dumpElementsTree(targetNode);
85 next();
87 InspectorTest.domModel.addEventListener(WebInspector.DOMModel.Events.AttrModified, callback);
88 targetNode.setAttributeValue("foo", "bar");
91 function testSetAttributeText(next)
93 function callback()
95 InspectorTest.domModel.removeEventListener(WebInspector.DOMModel.Events.AttrRemoved, callback);
96 InspectorTest.addResult("=== Set attribute as text ===");
97 InspectorTest.dumpElementsTree(targetNode);
98 next();
100 InspectorTest.domModel.addEventListener(WebInspector.DOMModel.Events.AttrRemoved, callback);
101 targetNode.setAttribute("foo", "foo2='baz2' foo3='baz3'");
104 function testRemoveAttributeAsText(next)
106 function callback()
108 InspectorTest.domModel.removeEventListener(WebInspector.DOMModel.Events.AttrRemoved, callback);
109 InspectorTest.addResult("=== Remove attribute as text ===");
110 InspectorTest.dumpElementsTree(targetNode);
111 next();
113 InspectorTest.domModel.addEventListener(WebInspector.DOMModel.Events.AttrRemoved, callback);
114 targetNode.setAttribute("foo3", "");
117 function testSetMalformedAttributeText(next)
119 function callback(error)
121 InspectorTest.addResult("Error: " + error);
122 InspectorTest.domModel.removeEventListener(WebInspector.DOMModel.Events.AttrModified, callback);
123 InspectorTest.addResult("=== Set malformed attribute as text ===");
124 InspectorTest.dumpElementsTree(targetNode);
125 next();
127 targetNode.setAttribute("foo2", "foo2='missingquote", callback);
132 </script>
133 </head>
135 <body onload="runTest()">
137 Tests that elements panel updates dom tree structure upon setting attribute.
138 </p>
140 <div id="node"></div>
142 </body>
143 </html>