Skip to content
Permalink
Browse files
2011-03-14 Pavel Feldman <pfeldman@chromium.org>
        Reviewed by Yury Semikhatsky.

        Web Inspector: add tests for edit dom operations.
        https://bugs.webkit.org/show_bug.cgi?id=56248

        * inspector/elements/edit-dom-actions-expected.txt: Added.
        * inspector/elements/edit-dom-actions.html: Added.
2011-03-14  Pavel Feldman  <pfeldman@chromium.org>

        Reviewed by Yury Semikhatsky.

        Web Inspector: add tests for edit dom operations.
        https://bugs.webkit.org/show_bug.cgi?id=56248

        Test: inspector/elements/edit-dom-actions.html

        * inspector/Inspector.idl:
        * inspector/InspectorDOMAgent.cpp:
        (WebCore::InspectorDOMAgent::assertNode):
        (WebCore::InspectorDOMAgent::assertElement):
        (WebCore::InspectorDOMAgent::assertHTMLElement):
        (WebCore::InspectorDOMAgent::nodeToSelectOn):
        (WebCore::InspectorDOMAgent::querySelector):
        (WebCore::InspectorDOMAgent::querySelectorAll):
        (WebCore::InspectorDOMAgent::setAttribute):
        (WebCore::InspectorDOMAgent::removeAttribute):
        (WebCore::InspectorDOMAgent::getOuterHTML):
        (WebCore::InspectorDOMAgent::setOuterHTML):
        * inspector/InspectorDOMAgent.h:
        * inspector/front-end/DOMAgent.js:
        (WebInspector.DOMNode.prototype.setAttribute):
        (WebInspector.DOMNode.prototype.removeAttribute):
        * inspector/front-end/inspector.js:
        (WebInspector.startEditing.defaultFinishHandler):

Canonical link: https://commits.webkit.org/70893@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@81009 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
pavelfeldman committed Mar 14, 2011
1 parent c91b1a4 commit 07af0bff723d170a667dcf5b840f43b37f705dcb
Showing 9 changed files with 403 additions and 59 deletions.
@@ -1,3 +1,13 @@
2011-03-14 Pavel Feldman <pfeldman@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: add tests for edit dom operations.
https://bugs.webkit.org/show_bug.cgi?id=56248

* inspector/elements/edit-dom-actions-expected.txt: Added.
* inspector/elements/edit-dom-actions.html: Added.

2011-03-14 David Levin <levin@chromium.org>

Fix typo TEXT vs TEST.
@@ -0,0 +1,81 @@
Tests that user can mutate DOM by means of elements panel.

Edited Text
Span contents

Running: testSetUp

Running: testRemove
==== before ====
- <div id="testRemove">
<div id="node-to-remove"></div>
</div>
==== after ====
- <div id="testRemove">
</div>

Running: testSetNodeName
==== before ====
- <div id="testSetNodeName">
<div id="node-to-set-name"></div>
</div>
==== after ====
- <div id="testSetNodeName">
<span id="node-to-set-name" ></span>
</div>

Running: testSetNodeValue
==== before ====
- <div id="testSetNodeValue">
<div id="node-to-set-value">Text</div>
</div>
==== after ====
- <div id="testSetNodeValue">
<div id="node-to-set-value">Edited Text</div>
</div>

Running: testSetAttribute
==== before ====
- <div id="testSetAttribute">
<div foo="attribute value" id="node-to-set-attribute"></div>
</div>
==== after ====
- <div id="testSetAttribute">
<div id="node-to-set-attribute" bar="edited attribute"></div>
</div>

Running: testRemoveAttribute
==== before ====
- <div id="testRemoveAttribute">
<div foo="attribute value" id="node-to-remove-attribute"></div>
</div>
==== after ====
- <div id="testRemoveAttribute">
<div id="node-to-remove-attribute"></div>
</div>

Running: testAddAttribute
==== before ====
- <div id="testAddAttribute">
<div id="node-to-add-attribute"></div>
</div>
==== after ====
- <div id="testAddAttribute">
<div id="node-to-add-attribute" newattr="new-value"></div>
</div>

Running: testEditAsHTML
==== before ====
- <div id="testEditAsHTML">
- <div id="node-to-edit-as-html">
<span id="span">Text</span>
</div>
</div>
<div id="node-to-edit-as-html"><span id="span">Text</span></div>
==== after ====
- <div id="testEditAsHTML">
- <div foo="bar">
<span id="inner-span">Span contents</span>
</div>
</div>

@@ -0,0 +1,189 @@
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/elements-test.js"></script>
<script>

function test()
{
// Save time on style updates.
WebInspector.StylesSidebarPane.prototype.update = function() {};
WebInspector.MetricsSidebarPane.prototype.update = function() {};

InspectorTest.runTestSuite([
function testSetUp(next)
{
InspectorTest.expandElementsTree(next);
},

function testRemove(next)
{
domActionTest("testRemove", "node-to-remove", testBody, next);

function testBody(node, done)
{
var treeElement = WebInspector.panels.elements.treeOutline.findTreeElement(node);
treeElement.remove();
InspectorTest.runAfterPendingDispatches(done);
}
},

function testSetNodeName(next)
{
domActionTest("testSetNodeName", "node-to-set-name", testBody, next);

function testBody(node, done)
{
editNodePartAndRun(node, "webkit-html-tag-name", "span", done);
}
},

function testSetNodeValue(next)
{
domActionTest("testSetNodeValue", "node-to-set-value", testBody, next);

function testBody(node, done)
{
editNodePartAndRun(node, "webkit-html-text-node", "Edited Text", done);
}
},

function testSetAttribute(next)
{
domActionTest("testSetAttribute", "node-to-set-attribute", testBody, next);

function testBody(node, done)
{
editNodePartAndRun(node, "webkit-html-attribute", "bar=\"edited attribute\"", done);
}
},

function testRemoveAttribute(next)
{
domActionTest("testRemoveAttribute", "node-to-remove-attribute", testBody, next);

function testBody(node, done)
{
editNodePartAndRun(node, "webkit-html-attribute", "", done);
}
},

function testAddAttribute(next)
{
domActionTest("testAddAttribute", "node-to-add-attribute", testBody, next);

function testBody(node, done)
{
editNodePart(node, "webkit-html-attribute");

var editorElement = window.getSelection().anchorNode.parentElement;
editorElement.dispatchEvent(InspectorTest.createKeyEvent("U+0009")); // Tab

var editorElement = window.getSelection().anchorNode.parentElement;
editorElement.textContent = "newattr=\"new-value\"";
editorElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
InspectorTest.runAfterPendingDispatches(done);
}
},

function testEditAsHTML(next)
{
domActionTest("testEditAsHTML", "node-to-edit-as-html", testBody, next);

function testBody(node, done)
{
var treeElement = WebInspector.panels.elements.treeOutline.findTreeElement(node);
treeElement._editAsHTML();
InspectorTest.runAfterPendingDispatches(step2);

function step2()
{
InspectorTest.addResult(treeElement._htmlEditElement.textContent);
treeElement._htmlEditElement.textContent = "<div foo=\"bar\"><span id=\"inner-span\">Span contents</span></div>";
var event = InspectorTest.createKeyEvent("Enter");
event.isMetaOrCtrlForTest = true;
treeElement._htmlEditElement.dispatchEvent(event);
InspectorTest.runAfterPendingDispatches(done);
}
}
}
]);

function domActionTest(testName, dataNode, testBody, next)
{
var testNode = InspectorTest.expandedNodeWithId(testName);
InspectorTest.addResult("==== before ====");
InspectorTest.dumpElementsTree(testNode);

InspectorTest.selectNodeWithId(dataNode, step1);

function step1(node)
{
testBody(node, step2);
}

function step2()
{
InspectorTest.addResult("==== after ====");
InspectorTest.dumpElementsTree(testNode);
next();
}
}

function editNodePart(node, className)
{
var treeElement = WebInspector.panels.elements.treeOutline.findTreeElement(node);
var textElement = treeElement.listItemElement.getElementsByClassName(className)[0];
treeElement._startEditingTarget(textElement);
}

function editNodePartAndRun(node, className, newValue, step2)
{
editNodePart(node, className);

var editorElement = window.getSelection().anchorNode.parentElement;
editorElement.textContent = newValue;
editorElement.dispatchEvent(InspectorTest.createKeyEvent("Enter"));
InspectorTest.runAfterPendingDispatches(step2);
}
}

</script>
</head>

<body onload="runTest()">
<p>
Tests that user can mutate DOM by means of elements panel.
</p>

<div>
<div id="testRemove">
<div id="node-to-remove"></div>
</div>

<div id="testSetNodeName">
<div id="node-to-set-name"></div>
</div>

<div id="testSetNodeValue">
<div id="node-to-set-value">Text</div>
</div>

<div id="testSetAttribute">
<div foo="attribute value" id="node-to-set-attribute"></div>
</div>

<div id="testRemoveAttribute">
<div foo="attribute value" id="node-to-remove-attribute"></div>
</div>

<div id="testAddAttribute">
<div id="node-to-add-attribute"></div>
</div>

<div id="testEditAsHTML">
<div id="node-to-edit-as-html"><span id="span">Text</span></div>
</div>
</div>
</body>
</html>
@@ -1,3 +1,31 @@
2011-03-14 Pavel Feldman <pfeldman@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: add tests for edit dom operations.
https://bugs.webkit.org/show_bug.cgi?id=56248

Test: inspector/elements/edit-dom-actions.html

* inspector/Inspector.idl:
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::assertNode):
(WebCore::InspectorDOMAgent::assertElement):
(WebCore::InspectorDOMAgent::assertHTMLElement):
(WebCore::InspectorDOMAgent::nodeToSelectOn):
(WebCore::InspectorDOMAgent::querySelector):
(WebCore::InspectorDOMAgent::querySelectorAll):
(WebCore::InspectorDOMAgent::setAttribute):
(WebCore::InspectorDOMAgent::removeAttribute):
(WebCore::InspectorDOMAgent::getOuterHTML):
(WebCore::InspectorDOMAgent::setOuterHTML):
* inspector/InspectorDOMAgent.h:
* inspector/front-end/DOMAgent.js:
(WebInspector.DOMNode.prototype.setAttribute):
(WebInspector.DOMNode.prototype.removeAttribute):
* inspector/front-end/inspector.js:
(WebInspector.startEditing.defaultFinishHandler):

2011-03-14 Brady Eidson <beidson@apple.com>

Reviewed by Dan Bernstein.
@@ -146,8 +146,8 @@ module core {
void setNodeValue(in long nodeId, in String value, out boolean success);
void removeNode(in long nodeId, out long outNodeId);

void setAttribute(in long elementId, in String name, in String value, out boolean success);
void removeAttribute(in long elementId, in String name, out boolean success);
void setAttribute(in long elementId, in String name, in String value);
void removeAttribute(in long elementId, in String name);

void getEventListenersForNode(in long nodeId, out Array listenersArray);
void copyNode(in long nodeId);
@@ -157,6 +157,7 @@ module core {

void performSearch(in String query, in boolean runSynchronously);
void searchCanceled();

void pushNodeByPathToFrontend(in String path, out long nodeId);
void resolveNode(in long nodeId, in String objectGroup, out Value result);
void pushNodeToFrontend(in Object objectId, out long nodeId);

0 comments on commit 07af0bf

Please sign in to comment.