Web Inspector: searching document with no documentElement results in 0x0 access.
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Apr 2012 09:20:40 +0000 (09:20 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Apr 2012 09:20:40 +0000 (09:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83483

Reviewed by Yury Semikhatsky.

Source/WebCore:

Added the null check.

Test: inspector/elements/dom-search-crash.html

* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::performSearch):

LayoutTests:

* inspector/elements/dom-search-crash-expected.txt: Added.
* inspector/elements/dom-search-crash.html: Added.
* inspector/elements/resources/dom-search-crash-iframe.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@113700 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/inspector/elements/dom-search-crash-expected.txt [new file with mode: 0644]
LayoutTests/inspector/elements/dom-search-crash.html [new file with mode: 0644]
LayoutTests/inspector/elements/resources/dom-search-crash-iframe.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorDOMAgent.cpp

index f7d0956..9f8835e 100644 (file)
@@ -1,3 +1,14 @@
+2012-04-09  Pavel Feldman  <pfeldman@chromium.org>
+
+        Web Inspector: searching document with no documentElement results in 0x0 access.
+        https://bugs.webkit.org/show_bug.cgi?id=83483
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/elements/dom-search-crash-expected.txt: Added.
+        * inspector/elements/dom-search-crash.html: Added.
+        * inspector/elements/resources/dom-search-crash-iframe.html: Added.
+
 2012-04-10  Philippe Normand  <pnormand@igalia.com>
 
         Unreviewed, GTK baselines for two new tests.
diff --git a/LayoutTests/inspector/elements/dom-search-crash-expected.txt b/LayoutTests/inspector/elements/dom-search-crash-expected.txt
new file mode 100644 (file)
index 0000000..6d8998a
--- /dev/null
@@ -0,0 +1,8 @@
+Tests that elements panel search is not crashing on documentElement-less cases.
+
+
+
+Running: testSetUp
+
+Running: testNoCrash
+
diff --git a/LayoutTests/inspector/elements/dom-search-crash.html b/LayoutTests/inspector/elements/dom-search-crash.html
new file mode 100644 (file)
index 0000000..06841ba
--- /dev/null
@@ -0,0 +1,29 @@
+<html>
+<head>
+<script src="../../http/tests/inspector/inspector-test.js"></script>
+<script>
+function test()
+{
+    InspectorTest.runTestSuite([
+        function testSetUp(next)
+        {
+            WebInspector.showPanel("elements");
+            WebInspector.domAgent.requestDocument(next);
+        },
+
+        function testNoCrash(next)
+        {
+            WebInspector.domAgent.performSearch("FooBar", next);
+        }
+    ]);
+}
+</script>
+</head>
+
+<body>
+<p>
+Tests that elements panel search is not crashing on documentElement-less cases.
+</p>
+<iframe src="resources/dom-search-crash-iframe.html" onload="runTest()"></iframe>
+</body>
+</html>
diff --git a/LayoutTests/inspector/elements/resources/dom-search-crash-iframe.html b/LayoutTests/inspector/elements/resources/dom-search-crash-iframe.html
new file mode 100644 (file)
index 0000000..33f71de
--- /dev/null
@@ -0,0 +1,3 @@
+<script>
+document.documentElement.parentNode.removeChild(document.documentElement);
+</script>
index e115a70..f03c46d 100644 (file)
@@ -1,3 +1,17 @@
+2012-04-09  Pavel Feldman  <pfeldman@chromium.org>
+
+        Web Inspector: searching document with no documentElement results in 0x0 access.
+        https://bugs.webkit.org/show_bug.cgi?id=83483
+
+        Reviewed by Yury Semikhatsky.
+
+        Added the null check.
+
+        Test: inspector/elements/dom-search-crash.html
+
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::performSearch):
+
 2012-04-10  Patrick Gansterer  <paroga@webkit.org>
 
         [CMake] Add missing source files to build system
index 9145b76..3879f63 100644 (file)
@@ -819,6 +819,8 @@ void InspectorDOMAgent::performSearch(ErrorString*, const String& whitespaceTrim
     for (Vector<Document*>::iterator it = docs.begin(); it != docs.end(); ++it) {
         Document* document = *it;
         Node* node = document->documentElement();
+        if (!node)
+            continue;
 
         // Manual plain text search.
         while ((node = node->traverseNextNode(document->documentElement()))) {