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