3 <script src=
"../../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"../../../http/tests/inspector/elements-test.js"></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
);
23 InspectorTest
.runTestSuite([
24 function testDumpInitial(next
)
26 function callback(node
)
29 InspectorTest
.addResult("========= Original ========");
30 InspectorTest
.dumpElementsTree(targetNode
);
33 InspectorTest
.selectNodeWithId("node", callback
);
36 function testAttributeUpdated(next
)
40 InspectorTest
.domModel
.removeEventListener(WebInspector
.DOMModel
.Events
.AttrModified
, callback
);
41 InspectorTest
.addResult("===== On attribute set =====");
42 InspectorTest
.dumpElementsTree(targetNode
);
45 InspectorTest
.domModel
.addEventListener(WebInspector
.DOMModel
.Events
.AttrModified
, callback
);
46 InspectorTest
.evaluateInPage("setAttribute('name', 'value')");
49 function testAttributeSameValueNotUpdated(next
)
53 InspectorTest
.addResult("===== On attribute modified (should be 'newValue') =====");
54 InspectorTest
.dumpElementsTree(targetNode
);
55 InspectorTest
.domModel
.removeEventListener(WebInspector
.DOMModel
.Events
.AttrModified
, callback
);
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
)
69 InspectorTest
.domModel
.removeEventListener(WebInspector
.DOMModel
.Events
.AttrRemoved
, callback
);
70 InspectorTest
.addResult("=== On attribute removed ===");
71 InspectorTest
.dumpElementsTree(targetNode
);
74 InspectorTest
.domModel
.addEventListener(WebInspector
.DOMModel
.Events
.AttrRemoved
, callback
);
75 InspectorTest
.evaluateInPage("removeAttribute('name')");
78 function testSetAttributeValue(next
)
82 InspectorTest
.domModel
.removeEventListener(WebInspector
.DOMModel
.Events
.AttrModified
, callback
);
83 InspectorTest
.addResult("=== Set attribute value ===");
84 InspectorTest
.dumpElementsTree(targetNode
);
87 InspectorTest
.domModel
.addEventListener(WebInspector
.DOMModel
.Events
.AttrModified
, callback
);
88 targetNode
.setAttributeValue("foo", "bar");
91 function testSetAttributeText(next
)
95 InspectorTest
.domModel
.removeEventListener(WebInspector
.DOMModel
.Events
.AttrRemoved
, callback
);
96 InspectorTest
.addResult("=== Set attribute as text ===");
97 InspectorTest
.dumpElementsTree(targetNode
);
100 InspectorTest
.domModel
.addEventListener(WebInspector
.DOMModel
.Events
.AttrRemoved
, callback
);
101 targetNode
.setAttribute("foo", "foo2='baz2' foo3='baz3'");
104 function testRemoveAttributeAsText(next
)
108 InspectorTest
.domModel
.removeEventListener(WebInspector
.DOMModel
.Events
.AttrRemoved
, callback
);
109 InspectorTest
.addResult("=== Remove attribute as text ===");
110 InspectorTest
.dumpElementsTree(targetNode
);
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
);
127 targetNode
.setAttribute("foo2", "foo2='missingquote", callback
);
135 <body onload=
"runTest()">
137 Tests that elements panel updates dom tree structure upon setting attribute.
140 <div id=
"node"></div>