OLD | NEW |
| (Empty) |
1 function initialize_EditDOMTests() | |
2 { | |
3 | |
4 // Preload codemirror which is used for "Edit as HTML". | |
5 InspectorTest.preloadPanel("sources"); | |
6 | |
7 InspectorTest.doAddAttribute = function(testName, dataNodeId, attributeText, nex
t) | |
8 { | |
9 InspectorTest.domActionTestForNodeId(testName, dataNodeId, testBody, next); | |
10 | |
11 function testBody(node, done) | |
12 { | |
13 var editorElement = InspectorTest.editNodePart(node, "webkit-html-attrib
ute"); | |
14 editorElement.dispatchEvent(InspectorTest.createKeyEvent("U+0009")); //
Tab | |
15 | |
16 InspectorTest.runAfterPendingDispatches(testContinuation); | |
17 | |
18 function testContinuation() | |
19 { | |
20 var editorElement = WebInspector.panels.elements._treeOutlines[0]._s
hadowRoot.getSelection().anchorNode.parentElement; | |
21 editorElement.textContent = attributeText; | |
22 editorElement.dispatchEvent(InspectorTest.createKeyEvent("Enter")); | |
23 InspectorTest.addSniffer(WebInspector.ElementsTreeOutline.prototype,
"_updateModifiedNodes", done); | |
24 } | |
25 } | |
26 } | |
27 | |
28 InspectorTest.domActionTestForNodeId = function(testName, dataNodeId, testBody,
next) | |
29 { | |
30 function callback(testNode, continuation) | |
31 { | |
32 InspectorTest.selectNodeWithId(dataNodeId, continuation); | |
33 } | |
34 InspectorTest.domActionTest(testName, callback, testBody, next); | |
35 } | |
36 | |
37 InspectorTest.domActionTest = function(testName, dataNodeSelectionCallback, test
Body, next) | |
38 { | |
39 var testNode = InspectorTest.expandedNodeWithId(testName); | |
40 InspectorTest.addResult("==== before ===="); | |
41 InspectorTest.dumpElementsTree(testNode); | |
42 | |
43 dataNodeSelectionCallback(testNode, step0); | |
44 | |
45 function step0(node) | |
46 { | |
47 InspectorTest.runAfterPendingDispatches(step1.bind(null, node)); | |
48 } | |
49 | |
50 function step1(node) | |
51 { | |
52 testBody(node, step2); | |
53 } | |
54 | |
55 function step2() | |
56 { | |
57 InspectorTest.addResult("==== after ===="); | |
58 InspectorTest.dumpElementsTree(testNode); | |
59 next(); | |
60 } | |
61 } | |
62 | |
63 InspectorTest.editNodePart = function(node, className) | |
64 { | |
65 var treeElement = InspectorTest.firstElementsTreeOutline().findTreeElement(n
ode); | |
66 var textElement = treeElement.listItemElement.getElementsByClassName(classNa
me)[0]; | |
67 if (!textElement && treeElement.childrenListElement) | |
68 textElement = treeElement.childrenListElement.getElementsByClassName(cla
ssName)[0]; | |
69 treeElement._startEditingTarget(textElement); | |
70 return textElement; | |
71 } | |
72 | |
73 InspectorTest.editNodePartAndRun = function(node, className, newValue, step2, us
eSniffer) | |
74 { | |
75 var editorElement = InspectorTest.editNodePart(node, className); | |
76 editorElement.textContent = newValue; | |
77 editorElement.dispatchEvent(InspectorTest.createKeyEvent("Enter")); | |
78 if (useSniffer) | |
79 InspectorTest.addSniffer(WebInspector.ElementsTreeOutline.prototype, "_u
pdateModifiedNodes", step2); | |
80 else | |
81 InspectorTest.runAfterPendingDispatches(step2); | |
82 } | |
83 | |
84 } | |
OLD | NEW |