1 var initialize_SetOuterHTMLTest = function() {
3 InspectorTest.events = [];
4 InspectorTest.containerId;
6 InspectorTest.setUpTestSuite = function(next)
8 InspectorTest.expandElementsTree(step1);
12 InspectorTest.selectNodeWithId("container", step2);
17 InspectorTest.containerId = node.id;
18 InspectorTest.DOMAgent.getOuterHTML(InspectorTest.containerId, step3);
21 function step3(error, text)
23 InspectorTest.containerText = text;
25 for (var key in WebInspector.DOMModel.Events) {
26 var eventName = WebInspector.DOMModel.Events[key];
27 InspectorTest.domModel.addEventListener(eventName, InspectorTest.recordEvent.bind(InspectorTest, eventName));
34 InspectorTest.recordEvent = function(eventName, event)
36 if (!event.data || event.type === WebInspector.DOMModel.Events.MarkersChanged)
38 var node = event.data.node || event.data;
39 var parent = event.data.parent;
40 for (var currentNode = parent || node; currentNode; currentNode = currentNode.parentNode) {
41 if (currentNode.getAttribute("id") === "output")
44 InspectorTest.events.push("Event " + eventName + ": " + node.nodeName());
47 InspectorTest.patchOuterHTML = function(pattern, replacement, next)
49 InspectorTest.addResult("Replacing '" + pattern + "' with '" + replacement + "'\n");
50 InspectorTest.setOuterHTML(InspectorTest.containerText.replace(pattern, replacement), next);
53 InspectorTest.patchOuterHTMLUseUndo = function(pattern, replacement, next)
55 InspectorTest.addResult("Replacing '" + pattern + "' with '" + replacement + "'\n");
56 InspectorTest.setOuterHTMLUseUndo(InspectorTest.containerText.replace(pattern, replacement), next);
59 InspectorTest.setOuterHTML = function(newText, next)
61 InspectorTest.innerSetOuterHTML(newText, false, bringBack);
65 InspectorTest.addResult("\nBringing things back\n");
66 InspectorTest.innerSetOuterHTML(InspectorTest.containerText, true, next);
70 InspectorTest.setOuterHTMLUseUndo = function(newText, next)
72 InspectorTest.innerSetOuterHTML(newText, false, bringBack);
76 InspectorTest.addResult("\nBringing things back\n");
77 InspectorTest.domModel.undo(InspectorTest._dumpOuterHTML.bind(InspectorTest, true, next));
81 InspectorTest.innerSetOuterHTML = function(newText, last, next)
83 InspectorTest.DOMAgent.setOuterHTML(InspectorTest.containerId, newText, InspectorTest._dumpOuterHTML.bind(InspectorTest, last, next));
86 InspectorTest._dumpOuterHTML = function(last, next)
88 InspectorTest.RuntimeAgent.evaluate("document.getElementById(\"identity\").wrapperIdentity", dumpIdentity);
89 function dumpIdentity(error, result)
91 InspectorTest.addResult("Wrapper identity: " + result.value);
92 InspectorTest.events.sort();
93 for (var i = 0; i < InspectorTest.events.length; ++i)
94 InspectorTest.addResult(InspectorTest.events[i]);
95 InspectorTest.events = [];
98 InspectorTest.DOMAgent.getOuterHTML(InspectorTest.containerId, callback);
100 function callback(error, text)
102 InspectorTest.addResult("==========8<==========");
103 InspectorTest.addResult(text);
104 InspectorTest.addResult("==========>8==========");
106 InspectorTest.addResult("\n\n\n");