1 function initialize_EditDOMTests()
4 // Preload codemirror which is used for "Edit as HTML".
5 InspectorTest.preloadPanel("sources");
7 InspectorTest.doAddAttribute = function(testName, dataNodeId, attributeText, next)
9 InspectorTest.domActionTestForNodeId(testName, dataNodeId, testBody, next);
11 function testBody(node, done)
13 var editorElement = InspectorTest.editNodePart(node, "webkit-html-attribute");
14 editorElement.dispatchEvent(InspectorTest.createKeyEvent("U+0009")); // Tab
16 InspectorTest.runAfterPendingDispatches(testContinuation);
18 function testContinuation()
20 var editorElement = WebInspector.panels.elements._treeOutlines[0]._shadowRoot.getSelection().anchorNode.parentElement;
21 editorElement.textContent = attributeText;
22 editorElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
23 InspectorTest.addSniffer(WebInspector.ElementsTreeOutline.prototype, "_updateModifiedNodes", done);
28 InspectorTest.domActionTestForNodeId = function(testName, dataNodeId, testBody, next)
30 function callback(testNode, continuation)
32 InspectorTest.selectNodeWithId(dataNodeId, continuation);
34 InspectorTest.domActionTest(testName, callback, testBody, next);
37 InspectorTest.domActionTest = function(testName, dataNodeSelectionCallback, testBody, next)
39 var testNode = InspectorTest.expandedNodeWithId(testName);
40 InspectorTest.addResult("==== before ====");
41 InspectorTest.dumpElementsTree(testNode);
43 dataNodeSelectionCallback(testNode, step0);
47 InspectorTest.runAfterPendingDispatches(step1.bind(null, node));
52 testBody(node, step2);
57 InspectorTest.addResult("==== after ====");
58 InspectorTest.dumpElementsTree(testNode);
63 InspectorTest.editNodePart = function(node, className)
65 var treeElement = InspectorTest.firstElementsTreeOutline().findTreeElement(node);
66 var textElement = treeElement.listItemElement.getElementsByClassName(className)[0];
67 if (!textElement && treeElement.childrenListElement)
68 textElement = treeElement.childrenListElement.getElementsByClassName(className)[0];
69 treeElement._startEditingTarget(textElement);
73 InspectorTest.editNodePartAndRun = function(node, className, newValue, step2, useSniffer)
75 var editorElement = InspectorTest.editNodePart(node, className);
76 editorElement.textContent = newValue;
77 editorElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
79 InspectorTest.addSniffer(WebInspector.ElementsTreeOutline.prototype, "_updateModifiedNodes", step2);
81 InspectorTest.runAfterPendingDispatches(step2);