OLD | NEW |
| (Empty) |
1 var initialize_SetOuterHTMLTest = function() { | |
2 | |
3 InspectorTest.events = []; | |
4 InspectorTest.containerId; | |
5 | |
6 InspectorTest.setUpTestSuite = function(next) | |
7 { | |
8 InspectorTest.expandElementsTree(step1); | |
9 | |
10 function step1() | |
11 { | |
12 InspectorTest.selectNodeWithId("container", step2); | |
13 } | |
14 | |
15 function step2(node) | |
16 { | |
17 InspectorTest.containerId = node.id; | |
18 InspectorTest.DOMAgent.getOuterHTML(InspectorTest.containerId, step3); | |
19 } | |
20 | |
21 function step3(error, text) | |
22 { | |
23 InspectorTest.containerText = text; | |
24 | |
25 for (var key in WebInspector.DOMModel.Events) { | |
26 var eventName = WebInspector.DOMModel.Events[key]; | |
27 InspectorTest.domModel.addEventListener(eventName, InspectorTest.rec
ordEvent.bind(InspectorTest, eventName)); | |
28 } | |
29 | |
30 next(); | |
31 } | |
32 } | |
33 | |
34 InspectorTest.recordEvent = function(eventName, event) | |
35 { | |
36 if (!event.data) | |
37 return; | |
38 var node = event.data.node || event.data; | |
39 var parent = event.data.parent; | |
40 for (var currentNode = parent || node; currentNode; currentNode = currentNod
e.parentNode) { | |
41 if (currentNode.getAttribute("id") === "output") | |
42 return; | |
43 } | |
44 InspectorTest.events.push("Event " + eventName + ": " + node.nodeName()); | |
45 } | |
46 | |
47 InspectorTest.patchOuterHTML = function(pattern, replacement, next) | |
48 { | |
49 InspectorTest.addResult("Replacing '" + pattern + "' with '" + replacement +
"'\n"); | |
50 InspectorTest.setOuterHTML(InspectorTest.containerText.replace(pattern, repl
acement), next); | |
51 } | |
52 | |
53 InspectorTest.patchOuterHTMLUseUndo = function(pattern, replacement, next) | |
54 { | |
55 InspectorTest.addResult("Replacing '" + pattern + "' with '" + replacement +
"'\n"); | |
56 InspectorTest.setOuterHTMLUseUndo(InspectorTest.containerText.replace(patter
n, replacement), next); | |
57 } | |
58 | |
59 InspectorTest.setOuterHTML = function(newText, next) | |
60 { | |
61 InspectorTest.innerSetOuterHTML(newText, false, bringBack); | |
62 | |
63 function bringBack() | |
64 { | |
65 InspectorTest.addResult("\nBringing things back\n"); | |
66 InspectorTest.innerSetOuterHTML(InspectorTest.containerText, true, next)
; | |
67 } | |
68 } | |
69 | |
70 InspectorTest.setOuterHTMLUseUndo = function(newText, next) | |
71 { | |
72 InspectorTest.innerSetOuterHTML(newText, false, bringBack); | |
73 | |
74 function bringBack() | |
75 { | |
76 InspectorTest.addResult("\nBringing things back\n"); | |
77 InspectorTest.domModel.undo(InspectorTest._dumpOuterHTML.bind(InspectorT
est, true, next)); | |
78 } | |
79 } | |
80 | |
81 InspectorTest.innerSetOuterHTML = function(newText, last, next) | |
82 { | |
83 InspectorTest.DOMAgent.setOuterHTML(InspectorTest.containerId, newText, Insp
ectorTest._dumpOuterHTML.bind(InspectorTest, last, next)); | |
84 } | |
85 | |
86 InspectorTest._dumpOuterHTML = function(last, next) | |
87 { | |
88 InspectorTest.RuntimeAgent.evaluate("document.getElementById(\"identity\").w
rapperIdentity", dumpIdentity); | |
89 function dumpIdentity(error, result) | |
90 { | |
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 = []; | |
96 } | |
97 | |
98 InspectorTest.DOMAgent.getOuterHTML(InspectorTest.containerId, callback); | |
99 | |
100 function callback(error, text) | |
101 { | |
102 InspectorTest.addResult("==========8<=========="); | |
103 InspectorTest.addResult(text); | |
104 InspectorTest.addResult("==========>8=========="); | |
105 if (last) | |
106 InspectorTest.addResult("\n\n\n"); | |
107 next(); | |
108 } | |
109 } | |
110 | |
111 }; | |
OLD | NEW |