Diff
Modified: trunk/LayoutTests/ChangeLog (131454 => 131455)
--- trunk/LayoutTests/ChangeLog 2012-10-16 14:49:31 UTC (rev 131454)
+++ trunk/LayoutTests/ChangeLog 2012-10-16 14:52:57 UTC (rev 131455)
@@ -1,3 +1,24 @@
+2012-10-16 Alexander Pavlov <[email protected]>
+
+ Web Inspector: [Elements] Double-click to live edit style tags changes text to 'undefined' in some situations
+ https://bugs.webkit.org/show_bug.cgi?id=99336
+
+ Reviewed by Vsevolod Vlasov.
+
+ Change the DOM tree dump format to include newlines replaced by '\n's.
+
+ * http/tests/inspector/elements-test.js:
+ (initialize_ElementTest.InspectorTest.dumpElementsTree):
+ * inspector/elements/edit-dom-actions-expected.txt:
+ * inspector/elements/edit-dom-actions.html:
+ * inspector/elements/elements-panel-limited-children-expected.txt:
+ * inspector/elements/elements-panel-structure-expected.txt:
+ * inspector/elements/iframe-load-event-expected.txt:
+ * inspector/elements/insert-node-expected.txt:
+ * inspector/elements/perform-undo-undo-expected.txt:
+ * inspector/elements/user-properties-expected.txt:
+ * inspector/styles/force-pseudo-state-expected.txt:
+
2012-10-16 Sudarsana Nagineni <[email protected]>
[GTK] Update baselines for failing svg test after r131435
Modified: trunk/LayoutTests/http/tests/inspector/elements-test.js (131454 => 131455)
--- trunk/LayoutTests/http/tests/inspector/elements-test.js 2012-10-16 14:49:31 UTC (rev 131454)
+++ trunk/LayoutTests/http/tests/inspector/elements-test.js 2012-10-16 14:52:57 UTC (rev 131455)
@@ -333,7 +333,7 @@
{
function beautify(element)
{
- return element.textContent.replace(/\u200b/g, "").replace(/\n/g, "").trim();
+ return element.innerText.replace(/\u200b/g, "").replace(/\n/g, "\\n").trim();
}
function dumpMap(name, map)
Modified: trunk/LayoutTests/inspector/elements/edit-dom-actions-expected.txt (131454 => 131455)
--- trunk/LayoutTests/inspector/elements/edit-dom-actions-expected.txt 2012-10-16 14:49:31 UTC (rev 131454)
+++ trunk/LayoutTests/inspector/elements/edit-dom-actions-expected.txt 2012-10-16 14:52:57 UTC (rev 131455)
@@ -40,11 +40,11 @@
Running: testSetNodeValue
==== before ====
- <div id="testSetNodeValue">
- <div id="node-to-set-value">Text</div>
+ <div id="node-to-set-value">\n Text\n </div>
</div>
==== after ====
- <div id="testSetNodeValue">
- <div id="node-to-set-value">Edited Text</div>
+ <div id="node-to-set-value"> \n Edited Text \n </div>
</div>
Running: testSetAttribute
@@ -114,3 +114,17 @@
<div id="node-with-invisible-chars">A#nbsp;B#ensp;C#emsp;D#thinsp;E#zwnj;F#zwj;G#rlm;H#lrm;I</div>
</div>
+Running: testEditScript
+==== before ====
+- <div id="testEditScript">
+ - <script id="node-to-edit-script">
+ \n var i = 0;\n var j = 5;\n for (; i < j; ++i) {\n // Do nothing.\n }\n\n
+ </script>
+ </div>
+==== after ====
+- <div id="testEditScript">
+ - <script id="node-to-edit-script">
+ var i = 0;\n var j = 0;\n
+ </script>
+ </div>
+
Modified: trunk/LayoutTests/inspector/elements/edit-dom-actions.html (131454 => 131455)
--- trunk/LayoutTests/inspector/elements/edit-dom-actions.html 2012-10-16 14:49:31 UTC (rev 131454)
+++ trunk/LayoutTests/inspector/elements/edit-dom-actions.html 2012-10-16 14:52:57 UTC (rev 131455)
@@ -55,7 +55,7 @@
function testBody(node, done)
{
- editNodePartAndRun(node, "webkit-html-text-node", "Edited Text", done);
+ editNodePartAndRun(node, "webkit-html-text-node", " \n Edited Text \n ", done);
}
},
@@ -177,6 +177,16 @@
InspectorTest.runAfterPendingDispatches(InspectorTest.expandElementsTree.bind(InspectorTest, done));
}
}
+ },
+
+ function testEditScript(next)
+ {
+ domActionTestForNodeId("testEditScript", "node-to-edit-script", testBody, next);
+
+ function testBody(node, done)
+ {
+ editNodePartAndRun(node, "webkit-html-text-node", "\n var i = 0;\n var j = 0;\n", done);
+ }
}
]);
@@ -219,6 +229,8 @@
{
var treeElement = WebInspector.panels.elements.treeOutline.findTreeElement(node);
var textElement = treeElement.listItemElement.getElementsByClassName(className)[0];
+ if (!textElement && treeElement.childrenListElement)
+ textElement = treeElement.childrenListElement.getElementsByClassName(className)[0];
treeElement._startEditingTarget(textElement);
return textElement;
}
@@ -257,7 +269,9 @@
</div>
<div id="testSetNodeValue">
- <div id="node-to-set-value">Text</div>
+ <div id="node-to-set-value">
+ Text
+ </div>
</div>
<div id="testSetAttribute">
@@ -280,6 +294,18 @@
<div id="node-with-invisible-chars">A B C D E‌F‍G‏H‎I</div>
</div>
+ <div id="testEditScript">
+ <script id="node-to-edit-script">
+
+ var i = 0;
+ var j = 5;
+ for (; i < j; ++i) {
+ // Do nothing.
+ }
+
+ </script>
+ </div>
+
<div id="testEditCommentAsHTML">
<!-- Comment -->
</div>
Modified: trunk/LayoutTests/inspector/elements/elements-panel-limited-children-expected.txt (131454 => 131455)
--- trunk/LayoutTests/inspector/elements/elements-panel-limited-children-expected.txt 2012-10-16 14:49:31 UTC (rev 131454)
+++ trunk/LayoutTests/inspector/elements/elements-panel-limited-children-expected.txt 2012-10-16 14:52:57 UTC (rev 131455)
@@ -21,7 +21,7 @@
<div id="id5">5</div>
Show All Nodes (5 More)
</div>
- <p>Tests that src and href element targets are rewritten properly.</p>
+ <p>\nTests that src and href element targets are rewritten properly.\n</p>
</body>
</html>
=========== Modified children ===========
@@ -36,7 +36,7 @@
<div id="id5">5</div>
Show All Nodes (6 More)
</div>
- <p>Tests that src and href element targets are rewritten properly.</p>
+ <p>\nTests that src and href element targets are rewritten properly.\n</p>
+ <div>…</div>
</body>
</html>
@@ -57,7 +57,7 @@
<div id="id10">10</div>
<a></a>
</div>
- <p>Tests that src and href element targets are rewritten properly.</p>
+ <p>\nTests that src and href element targets are rewritten properly.\n</p>
+ <div>…</div>
</body>
</html>
Modified: trunk/LayoutTests/inspector/elements/elements-panel-structure-expected.txt (131454 => 131455)
--- trunk/LayoutTests/inspector/elements/elements-panel-structure-expected.txt 2012-10-16 14:49:31 UTC (rev 131454)
+++ trunk/LayoutTests/inspector/elements/elements-panel-structure-expected.txt 2012-10-16 14:52:57 UTC (rev 131455)
@@ -7,11 +7,11 @@
<script src=""
<script src=""
- <script>
- function test(){ InspectorTest.expandElementsTree(step1); function step1() { InspectorTest.dumpElementsTree(); InspectorTest.completeTest(); }}
+ \nfunction test()\n{\n InspectorTest.expandElementsTree(step1);\n\n function step1()\n {\n InspectorTest.dumpElementsTree();\n InspectorTest.completeTest();\n }\n}\n\n
</script>
</head>
- <body _onload_="runTest()">
- <p>Tests that elements panel shows DOM tree structure.</p>
+ <p>\nTests that elements panel shows DOM tree structure.\n</p>
- <div id="level1">
- <div id="level2">
""Quoted Text". Special characters: ><"'    ​‌‍‎‏ ‪‫‬‭‮"
Modified: trunk/LayoutTests/inspector/elements/iframe-load-event-expected.txt (131454 => 131455)
--- trunk/LayoutTests/inspector/elements/iframe-load-event-expected.txt 2012-10-16 14:49:31 UTC (rev 131454)
+++ trunk/LayoutTests/inspector/elements/iframe-load-event-expected.txt 2012-10-16 14:52:57 UTC (rev 131455)
@@ -12,9 +12,9 @@
</head>
- <body>
- <p>
- "Tests that iframe content is available after iframe's load event fired. See "
+ "\nTests that iframe content is available after iframe's load event fired. See "
<a href="" 76552</a>
- "."
+ ".\n"
</p>
- <iframe id="myframe" src="" _onload_="runTest()">
- #document
Modified: trunk/LayoutTests/inspector/elements/insert-node-expected.txt (131454 => 131455)
--- trunk/LayoutTests/inspector/elements/insert-node-expected.txt 2012-10-16 14:49:31 UTC (rev 131454)
+++ trunk/LayoutTests/inspector/elements/insert-node-expected.txt 2012-10-16 14:52:57 UTC (rev 131455)
@@ -60,7 +60,7 @@
<div id="child1"></div>
<div id="child-middle"></div>
<div id="child2"></div>
- - <div id="child3">First text</div>
+ - <div id="child3">
"First text"
</div>
<div id="child-after"></div>
Modified: trunk/LayoutTests/inspector/elements/perform-undo-undo-expected.txt (131454 => 131455)
--- trunk/LayoutTests/inspector/elements/perform-undo-undo-expected.txt 2012-10-16 14:49:31 UTC (rev 131454)
+++ trunk/LayoutTests/inspector/elements/perform-undo-undo-expected.txt 2012-10-16 14:52:57 UTC (rev 131455)
@@ -1,11 +1,11 @@
Tests that client can call undo multiple times with non-empty history.
========= Original ========
- <div style="display:none" id="container"></div>
+ <div style="display:none" id="container">\n</div>
===== Modified element =====
- <div style="display:none" id="container" foo="bar"></div>
+ <div style="display:none" id="container" foo="bar">\n</div>
===== Undo 1 =====
- <div style="display:none" id="container"></div>
+ <div style="display:none" id="container">\n</div>
===== Undo 2 =====
- <div style="display:none" id="container"></div>
+ <div style="display:none" id="container">\n</div>
Modified: trunk/LayoutTests/inspector/elements/user-properties-expected.txt (131454 => 131455)
--- trunk/LayoutTests/inspector/elements/user-properties-expected.txt 2012-10-16 14:49:31 UTC (rev 131454)
+++ trunk/LayoutTests/inspector/elements/user-properties-expected.txt 2012-10-16 14:52:57 UTC (rev 131455)
@@ -9,7 +9,7 @@
<script src=""
</head>
- <body _onload_="runTest()"> [descendantUserAttributeCounters:[attr1=1]]
- <p>Tests that DOMNode properly tracks own and descendants' user properties.</p>
+ <p>\nTests that DOMNode properly tracks own and descendants' user properties.\n</p>
- <div id="container"> [descendantUserAttributeCounters:[attr1=1]]
<div id="child1"></div>
- <div id="child2"> [descendantUserAttributeCounters:[attr1=1]]
@@ -27,7 +27,7 @@
<script src=""
</head>
- <body _onload_="runTest()"> [descendantUserAttributeCounters:[attr1=1,attr2=1]]
- <p>Tests that DOMNode properly tracks own and descendants' user properties.</p>
+ <p>\nTests that DOMNode properly tracks own and descendants' user properties.\n</p>
- <div id="container"> [descendantUserAttributeCounters:[attr1=1,attr2=1]]
<div id="child1"></div>
- <div id="child2"> [userProperties:[attr2=value], descendantUserAttributeCounters:[attr1=1]]
@@ -45,7 +45,7 @@
<script src=""
</head>
- <body _onload_="runTest()"> [descendantUserAttributeCounters:[attr1=2,attr2=1]]
- <p>Tests that DOMNode properly tracks own and descendants' user properties.</p>
+ <p>\nTests that DOMNode properly tracks own and descendants' user properties.\n</p>
- <div id="container"> [descendantUserAttributeCounters:[attr1=2,attr2=1]]
<div id="child1"></div>
- <div id="child2"> [userProperties:[attr2=value,attr1=true], descendantUserAttributeCounters:[attr1=1]]
@@ -63,7 +63,7 @@
<script src=""
</head>
- <body _onload_="runTest()"> [descendantUserAttributeCounters:[attr1=2,attr2=1]]
- <p>Tests that DOMNode properly tracks own and descendants' user properties.</p>
+ <p>\nTests that DOMNode properly tracks own and descendants' user properties.\n</p>
- <div id="container"> [descendantUserAttributeCounters:[attr1=2,attr2=1]]
<div id="child1"></div>
- <div id="child2"> [userProperties:[attr2=value,attr1=true], descendantUserAttributeCounters:[attr1=1]]
@@ -81,7 +81,7 @@
<script src=""
</head>
- <body _onload_="runTest()"> [descendantUserAttributeCounters:[attr1=2,attr2=1]]
- <p>Tests that DOMNode properly tracks own and descendants' user properties.</p>
+ <p>\nTests that DOMNode properly tracks own and descendants' user properties.\n</p>
- <div id="container"> [descendantUserAttributeCounters:[attr1=2,attr2=1]]
<div id="child1"></div>
- <div id="child2"> [userProperties:[attr2=anotherValue,attr1=true], descendantUserAttributeCounters:[attr1=1]]
@@ -99,7 +99,7 @@
<script src=""
</head>
- <body _onload_="runTest()"> [descendantUserAttributeCounters:[attr1=1,attr2=1]]
- <p>Tests that DOMNode properly tracks own and descendants' user properties.</p>
+ <p>\nTests that DOMNode properly tracks own and descendants' user properties.\n</p>
- <div id="container"> [descendantUserAttributeCounters:[attr1=1,attr2=1]]
<div id="child1"></div>
- <div id="child2"> [userProperties:[attr2=anotherValue,attr1=true]]
@@ -117,7 +117,7 @@
<script src=""
</head>
- <body _onload_="runTest()"> [descendantUserAttributeCounters:[attr1=1,attr2=1]]
- <p>Tests that DOMNode properly tracks own and descendants' user properties.</p>
+ <p>\nTests that DOMNode properly tracks own and descendants' user properties.\n</p>
- <div id="container"> [descendantUserAttributeCounters:[attr1=1,attr2=1]]
<div id="child1"></div>
- <div id="child2"> [userProperties:[attr2=anotherValue,attr1=true]]
@@ -135,7 +135,7 @@
<script src=""
</head>
- <body _onload_="runTest()">
- <p>Tests that DOMNode properly tracks own and descendants' user properties.</p>
+ <p>\nTests that DOMNode properly tracks own and descendants' user properties.\n</p>
- <div id="container">
<div id="child1"></div>
</div>
Modified: trunk/LayoutTests/inspector/styles/force-pseudo-state-expected.txt (131454 => 131455)
--- trunk/LayoutTests/inspector/styles/force-pseudo-state-expected.txt 2012-10-16 14:49:31 UTC (rev 131454)
+++ trunk/LayoutTests/inspector/styles/force-pseudo-state-expected.txt 2012-10-16 14:52:57 UTC (rev 131455)
@@ -28,7 +28,7 @@
- <html> [descendantUserAttributeCounters:[pseudoState=1]]
+ <head>…</head>
- <body id="mainBody" class="main1 main2 mainpage" _onload_="runTest()" style="font-weight: normal; width: 85%; background-image: url(bar.png)"> [descendantUserAttributeCounters:[pseudoState=1]]
- <p>Tests that forced element state is reflected in the DOM tree and Styles pane.</p>
+ <p>\nTests that forced element state is reflected in the DOM tree and Styles pane.\n</p>
<div id="div">Test text</div> [userProperties:[pseudoState=hover,active]]
</body>
</html>
@@ -78,7 +78,7 @@
- <html> [descendantUserAttributeCounters:[pseudoState=1]]
+ <head>…</head>
- <body id="mainBody" class="main1 main2 mainpage" _onload_="runTest()" style="font-weight: normal; width: 85%; background-image: url(bar.png)"> [descendantUserAttributeCounters:[pseudoState=1]]
- <p>Tests that forced element state is reflected in the DOM tree and Styles pane.</p>
+ <p>\nTests that forced element state is reflected in the DOM tree and Styles pane.\n</p>
<div id="div">Test text</div> [userProperties:[pseudoState=active,focus]]
+ <div>…</div>
</body>
@@ -102,7 +102,7 @@
- <html>
+ <head>…</head>
- <body id="mainBody" class="main1 main2 mainpage" _onload_="runTest()" style="font-weight: normal; width: 85%; background-image: url(bar.png)">
- <p>Tests that forced element state is reflected in the DOM tree and Styles pane.</p>
+ <p>\nTests that forced element state is reflected in the DOM tree and Styles pane.\n</p>
<div id="div">Test text</div>
+ <div>…</div>
</body>
Modified: trunk/Source/WebCore/ChangeLog (131454 => 131455)
--- trunk/Source/WebCore/ChangeLog 2012-10-16 14:49:31 UTC (rev 131454)
+++ trunk/Source/WebCore/ChangeLog 2012-10-16 14:52:57 UTC (rev 131455)
@@ -1,3 +1,17 @@
+2012-10-16 Alexander Pavlov <[email protected]>
+
+ Web Inspector: [Elements] Double-click to live edit style tags changes text to 'undefined' in some situations
+ https://bugs.webkit.org/show_bug.cgi?id=99336
+
+ Reviewed by Vsevolod Vlasov.
+
+ Before editing text nodes, set their textContent to the nodeValue() of the corresponding WebInspector.DOMNode in the UI.
+ Drive-by: fix text node editing artifact in the DOM tree.
+
+ * inspector/front-end/ElementsTreeOutline.js:
+ (WebInspector.ElementsTreeElement.prototype._startEditingTextNode):
+ (WebInspector.ElementsTreeElement.prototype._tagNameEditingCommitted):
+
2012-10-16 Mike West <[email protected]>
Web Inspector: Whitelist safe styles for 'console.log('%c...', ...)'.
Modified: trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js (131454 => 131455)
--- trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js 2012-10-16 14:49:31 UTC (rev 131454)
+++ trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js 2012-10-16 14:52:57 UTC (rev 131455)
@@ -1316,21 +1316,33 @@
return true;
},
- _startEditingTextNode: function(textNode)
+ /**
+ * @param {Element} textNodeElement
+ */
+ _startEditingTextNode: function(textNodeElement)
{
- if (WebInspector.isBeingEdited(textNode))
+ if (WebInspector.isBeingEdited(textNodeElement))
return true;
- var container = textNode.enclosingNodeOrSelfWithClass("webkit-html-text-node");
+ var textNode = this.representedObject;
+ // We only show text nodes inline in elements if the element only
+ // has a single child, and that child is a text node.
+ if (textNode.nodeType() === Node.ELEMENT_NODE && textNode.firstChild)
+ textNode = textNode.firstChild;
+
+ var container = textNodeElement.enclosingNodeOrSelfWithClass("webkit-html-text-node");
if (container)
- container.innerText = textNode._originalContent; // Strip the CSS or JS highlighting if present.
- var config = new WebInspector.EditingConfig(this._textNodeEditingCommitted.bind(this), this._editingCancelled.bind(this));
- this._editing = WebInspector.startEditing(textNode, config);
- window.getSelection().setBaseAndExtent(textNode, 0, textNode, 1);
+ container.textContent = textNode.nodeValue(); // Strip the CSS or JS highlighting if present.
+ var config = new WebInspector.EditingConfig(this._textNodeEditingCommitted.bind(this, textNode), this._editingCancelled.bind(this));
+ this._editing = WebInspector.startEditing(textNodeElement, config);
+ window.getSelection().setBaseAndExtent(textNodeElement, 0, textNodeElement, 1);
return true;
},
+ /**
+ * @param {Element=} tagNameElement
+ */
_startEditingTagName: function(tagNameElement)
{
if (!tagNameElement) {
@@ -1554,21 +1566,26 @@
this.representedObject.setNodeName(newText, changeTagNameCallback);
},
- _textNodeEditingCommitted: function(element, newText)
+ /**
+ * @param {WebInspector.DOMNode} textNode
+ * @param {Element} element
+ * @param {string} newText
+ */
+ _textNodeEditingCommitted: function(textNode, element, newText)
{
this._editing = false;
- var textNode;
- if (this.representedObject.nodeType() === Node.ELEMENT_NODE) {
- // We only show text nodes inline in elements if the element only
- // has a single child, and that child is a text node.
- textNode = this.representedObject.firstChild;
- } else if (this.representedObject.nodeType() == Node.TEXT_NODE)
- textNode = this.representedObject;
-
- textNode.setNodeValue(newText, this.updateTitle.bind(this));
+ function callback()
+ {
+ this.updateTitle();
+ }
+ textNode.setNodeValue(newText, callback.bind(this));
},
+ /**
+ * @param {Element} element
+ * @param {*} context
+ */
_editingCancelled: function(element, context)
{
this._editing = false;
@@ -1767,7 +1784,7 @@
this._buildTagDOM(info.titleDOM, tagName, false, false, linkify);
var textChild = this._singleTextChild(node);
- var showInlineText = textChild && textChild.nodeValue().length < Preferences.maxInlineTextChildLength;
+ var showInlineText = textChild && textChild.nodeValue().length < Preferences.maxInlineTextChildLength && !this.hasChildren;
if (!this.expanded && (!showInlineText && (this.treeOutline.isXMLMimeType || !WebInspector.ElementsTreeElement.ForbiddenClosingTagElements[tagName]))) {
if (this.hasChildren) {
@@ -1784,7 +1801,6 @@
if (showInlineText) {
var textNodeElement = info.titleDOM.createChild("span", "webkit-html-text-node");
textNodeElement.textContent = this._convertWhitespaceToEntities(textChild.nodeValue());
- textNodeElement._originalContent = textChild.nodeValue();
info.titleDOM.appendChild(document.createTextNode("\u200B"));
this._buildTagDOM(info.titleDOM, tagName, true, false);
info.hasChildren = false;
@@ -1808,7 +1824,6 @@
info.titleDOM.appendChild(document.createTextNode("\""));
var textNodeElement = info.titleDOM.createChild("span", "webkit-html-text-node");
textNodeElement.textContent = this._convertWhitespaceToEntities(node.nodeValue());
- textNodeElement._originalContent = node.nodeValue();
info.titleDOM.appendChild(document.createTextNode("\""));
}
break;