Commit 21ca2f19 authored by pfeldman@chromium.org's avatar pfeldman@chromium.org
Browse files

Web Inspector: document.open removes the documentElement, but does not clear the elements panel.

https://bugs.webkit.org/show_bug.cgi?id=84179

Reviewed by Yury Semikhatsky.

Source/WebCore:

Perform total update upon modifications of the document node.

Test: inspector/elements/delete-from-document.html

* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::didRemoveDOMNode):
* inspector/front-end/ElementsTreeOutline.js:

LayoutTests:

* http/tests/inspector/elements-test.js:
(initialize_ElementTest.InspectorTest.dumpElementsTree.print):
(initialize_ElementTest.InspectorTest.dumpElementsTree):
* inspector/elements/delete-from-document-expected.txt: Added.
* inspector/elements/delete-from-document.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114494 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1ed2613e
2012-04-17 Pavel Feldman <pfeldman@chromium.org>
Web Inspector: document.open removes the documentElement, but does not clear the elements panel.
https://bugs.webkit.org/show_bug.cgi?id=84179
Reviewed by Yury Semikhatsky.
* http/tests/inspector/elements-test.js:
(initialize_ElementTest.InspectorTest.dumpElementsTree.print):
(initialize_ElementTest.InspectorTest.dumpElementsTree):
* inspector/elements/delete-from-document-expected.txt: Added.
* inspector/elements/delete-from-document.html: Added.
2012-04-18 Max Feil <mfeil@rim.com> 2012-04-18 Max Feil <mfeil@rim.com>
   
[BlackBerry] Tab awareness for HTML5 concurrent audio [BlackBerry] Tab awareness for HTML5 concurrent audio
...@@ -311,14 +311,14 @@ InspectorTest.dumpStyleTreeItem = function(treeItem, prefix, depth) ...@@ -311,14 +311,14 @@ InspectorTest.dumpStyleTreeItem = function(treeItem, prefix, depth)
} }
}; };
InspectorTest.dumpElementsTree = function(rootNode) InspectorTest.dumpElementsTree = function(rootNode, depth)
{ {
function beautify(element) function beautify(element)
{ {
return element.textContent.replace(/\u200b/g, "").replace(/\n/g, "").trim(); return element.textContent.replace(/\u200b/g, "").replace(/\n/g, "").trim();
} }
function print(treeItem, prefix) function print(treeItem, prefix, depth)
{ {
if (treeItem.listItemElement) { if (treeItem.listItemElement) {
var expander; var expander;
...@@ -332,23 +332,22 @@ InspectorTest.dumpElementsTree = function(rootNode) ...@@ -332,23 +332,22 @@ InspectorTest.dumpElementsTree = function(rootNode)
InspectorTest.addResult(prefix + expander + beautify(treeItem.listItemElement)); InspectorTest.addResult(prefix + expander + beautify(treeItem.listItemElement));
} }
if (!treeItem.expanded) if (!treeItem.expanded)
return; return;
var children = treeItem.children; var children = treeItem.children;
for (var i = 0; children && i < children.length - 1; ++i) for (var i = 0; depth && children && i < children.length - 1; ++i)
print(children[i], prefix + " "); print(children[i], prefix + " ", depth - 1);
// Closing tag. // Closing tag.
if (children && children.length) if (children && children.length)
print(children[children.length - 1], prefix); print(children[children.length - 1], prefix, depth);
} }
WebInspector.panels.elements.treeOutline._updateModifiedNodes(); WebInspector.panels.elements.treeOutline._updateModifiedNodes();
var treeOutline = WebInspector.panels.elements.treeOutline; var treeOutline = WebInspector.panels.elements.treeOutline;
print(rootNode ? treeOutline.findTreeElement(rootNode) : treeOutline, ""); print(rootNode ? treeOutline.findTreeElement(rootNode) : treeOutline, "", depth || 10000);
}; };
InspectorTest.expandElementsTree = function(callback) InspectorTest.expandElementsTree = function(callback)
......
Tests that removing child from the document is handled properly in the elements panel.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
</head>
- <body onload="runTest()">
</body>
</html>
- <html>
- <head>
</head>
- <body onload="runTest()">
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/elements-test.js"></script>
<script>
function removeDoctype()
{
document.removeChild(document.firstChild);
}
function test()
{
InspectorTest.expandElementsTree(step1);
function step1()
{
InspectorTest.dumpElementsTree(null, 1);
InspectorTest.evaluateInPage("removeDoctype()", step2);
}
function step2()
{
InspectorTest.dumpElementsTree(null, 1);
InspectorTest.completeTest();
}
}
</script>
</head>
<body onload="runTest()">
<p>
Tests that removing child from the document is handled properly in the elements panel.
</p>
</body>
</html>
2012-04-17 Pavel Feldman <pfeldman@chromium.org>
Web Inspector: document.open removes the documentElement, but does not clear the elements panel.
https://bugs.webkit.org/show_bug.cgi?id=84179
Reviewed by Yury Semikhatsky.
Perform total update upon modifications of the document node.
Test: inspector/elements/delete-from-document.html
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::didRemoveDOMNode):
* inspector/front-end/ElementsTreeOutline.js:
2012-04-18 Max Feil <mfeil@rim.com> 2012-04-18 Max Feil <mfeil@rim.com>
   
[BlackBerry] Tab awareness for HTML5 concurrent audio [BlackBerry] Tab awareness for HTML5 concurrent audio
...@@ -1421,11 +1421,13 @@ void InspectorDOMAgent::didRemoveDOMNode(Node* node) ...@@ -1421,11 +1421,13 @@ void InspectorDOMAgent::didRemoveDOMNode(Node* node)
return; return;
ContainerNode* parent = node->parentNode(); ContainerNode* parent = node->parentNode();
int parentId = m_documentNodeToIdMap.get(parent);
// If parent is not mapped yet -> ignore the event. // If parent is not mapped yet -> ignore the event.
if (!parentId) if (!m_documentNodeToIdMap.contains(parent))
return; return;
int parentId = m_documentNodeToIdMap.get(parent);
if (m_domListener) if (m_domListener)
m_domListener->didRemoveDOMNode(node); m_domListener->didRemoveDOMNode(node);
......
...@@ -1846,6 +1846,13 @@ WebInspector.ElementsTreeUpdater.prototype = { ...@@ -1846,6 +1846,13 @@ WebInspector.ElementsTreeUpdater.prototype = {
for (var i = 0; i < this._recentlyModifiedNodes.length; ++i) { for (var i = 0; i < this._recentlyModifiedNodes.length; ++i) {
var parent = this._recentlyModifiedNodes[i].parent; var parent = this._recentlyModifiedNodes[i].parent;
if (parent === this._treeOutline._rootDOMNode) {
// Document's children have changed, perform total update.
this._treeOutline.update();
return;
}
var node = this._recentlyModifiedNodes[i].node; var node = this._recentlyModifiedNodes[i].node;
if (this._recentlyModifiedNodes[i].updated) { if (this._recentlyModifiedNodes[i].updated) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment