Title: [149200] trunk
Revision
149200
Author
[email protected]
Date
2013-04-26 11:57:35 -0700 (Fri, 26 Apr 2013)

Log Message

Web Inspector: Crash due to null items from getDOMStorageItems
https://bugs.webkit.org/show_bug.cgi?id=115176

Patch by Konrad Piascik <[email protected]> on 2013-04-26
Reviewed by Joseph Pecoraro.

Source/WebCore:

findStorageArea was returning a null storageArea causing the items
input paramater to not be set.  This was happening without any error
being set at all.  Set an error to prevent a crash when we try to
convert the result to a JSON string.

Added tests to check if session and local storage are empty that
they are still functional.

* inspector/InspectorDOMStorageAgent.cpp:
(WebCore::InspectorDOMStorageAgent::getDOMStorageItems):

LayoutTests:

Tests to check that if local and session storage are empty
that they still work corerctly.

* inspector/storage-panel-dom-storage-empty-expected.txt: Added.
* inspector/storage-panel-dom-storage-empty.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (149199 => 149200)


--- trunk/LayoutTests/ChangeLog	2013-04-26 18:40:29 UTC (rev 149199)
+++ trunk/LayoutTests/ChangeLog	2013-04-26 18:57:35 UTC (rev 149200)
@@ -1,3 +1,16 @@
+2013-04-26  Konrad Piascik  <[email protected]>
+
+        Web Inspector: Crash due to null items from getDOMStorageItems
+        https://bugs.webkit.org/show_bug.cgi?id=115176
+
+        Reviewed by Joseph Pecoraro.
+
+        Tests to check that if local and session storage are empty
+        that they still work corerctly.
+
+        * inspector/storage-panel-dom-storage-empty-expected.txt: Added.
+        * inspector/storage-panel-dom-storage-empty.html: Added.
+
 2013-04-26  Eric Carlson  <[email protected]>
 
         [Mac] media/track/track-mode.html sometimes trigger InvalidStateError

Added: trunk/LayoutTests/inspector/storage-panel-dom-storage-empty-expected.txt (0 => 149200)


--- trunk/LayoutTests/inspector/storage-panel-dom-storage-empty-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/storage-panel-dom-storage-empty-expected.txt	2013-04-26 18:57:35 UTC (rev 149200)
@@ -0,0 +1,11 @@
+Test that storage panel is present and that it contains no data for local and session DOM storages.
+
+Populated local and session storage
+Did show: Local storage
+Did show: Session storage
+Local storage content: 
+KeyValue pairs: 
+Session storage content: 
+KeyValue pairs: 
+DONE
+

Added: trunk/LayoutTests/inspector/storage-panel-dom-storage-empty.html (0 => 149200)


--- trunk/LayoutTests/inspector/storage-panel-dom-storage-empty.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/storage-panel-dom-storage-empty.html	2013-04-26 18:57:35 UTC (rev 149200)
@@ -0,0 +1,70 @@
+<html>
+<head>
+<script src=""
+<script>
+
+function clearDOMStorage()
+{
+    localStorage.clear();
+    sessionStorage.clear();
+}
+
+function test()
+{
+    WebInspector.showPanel("resources");
+
+    InspectorTest.evaluateInPage("clearDOMStorage()", function(result) {
+        InspectorTest.addResult("Populated local and session storage");
+    });
+    function name(storage)
+    {
+        return storage.isLocalStorage ? "Local storage" : "Session storage";
+    }
+
+    function dumpDataGridContent(dataGrid)
+    {
+        var nodes = dataGrid.rootNode().children;
+        var rows = [];
+        for (var i = 0; i < nodes.length; ++i) {
+            var node = nodes[i];
+            rows.push(node._data.key + node._data.value);
+        }
+        rows.sort();
+        InspectorTest.addResult("KeyValue pairs: " + rows.join(''));
+    }
+
+    InspectorTest.runAfterPendingDispatches(function() {
+        var storages = WebInspector.domStorageModel.storages();
+        if (storages) {
+            for (var i = 0; i < storages.length; i++) {
+                var storage = storages[i];
+                WebInspector.panels.resources._showDOMStorage(storage);
+                InspectorTest.addResult("Did show: " + name(storage));
+            }
+        } else
+            InspectorTest.addResult("FAIL: no DOM storages found.");
+
+        InspectorTest.runAfterPendingDispatches(function() {
+            var storages = WebInspector.domStorageModel.storages();
+            for (var i = 0; i < storages.length; i++) {
+                var storage = storages[i];
+                InspectorTest.addResult(name(storage) + " content: ");
+                var view = WebInspector.panels.resources._domStorageViews.get(storage);
+                dumpDataGridContent(view._dataGrid);
+            }
+            InspectorTest.addResult("DONE");
+            InspectorTest.completeTest();
+        });
+    });
+}
+
+</script>
+</head>
+
+<body _onload_="runTest()">
+<p>
+Test that storage panel is present and that it contains no data for local and session DOM storages.
+</p>
+
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (149199 => 149200)


--- trunk/Source/WebCore/ChangeLog	2013-04-26 18:40:29 UTC (rev 149199)
+++ trunk/Source/WebCore/ChangeLog	2013-04-26 18:57:35 UTC (rev 149200)
@@ -1,3 +1,21 @@
+2013-04-26  Konrad Piascik  <[email protected]>
+
+        Web Inspector: Crash due to null items from getDOMStorageItems
+        https://bugs.webkit.org/show_bug.cgi?id=115176
+
+        Reviewed by Joseph Pecoraro.
+
+        findStorageArea was returning a null storageArea causing the items
+        input paramater to not be set.  This was happening without any error
+        being set at all.  Set an error to prevent a crash when we try to
+        convert the result to a JSON string.
+
+        Added tests to check if session and local storage are empty that
+        they are still functional.
+
+        * inspector/InspectorDOMStorageAgent.cpp:
+        (WebCore::InspectorDOMStorageAgent::getDOMStorageItems):
+
 2013-04-26  Martin Robinson  <[email protected]>
 
         Remove the remaining Skia #ifdefs

Modified: trunk/Source/WebCore/inspector/InspectorDOMStorageAgent.cpp (149199 => 149200)


--- trunk/Source/WebCore/inspector/InspectorDOMStorageAgent.cpp	2013-04-26 18:40:29 UTC (rev 149199)
+++ trunk/Source/WebCore/inspector/InspectorDOMStorageAgent.cpp	2013-04-26 18:57:35 UTC (rev 149200)
@@ -118,8 +118,11 @@
 {
     Frame* frame;
     RefPtr<StorageArea> storageArea = findStorageArea(errorString, storageId, frame);
-    if (!storageArea)
+    if (!storageArea) {
+        if (errorString)
+            *errorString = "No StorageArea for given storageId";
         return;
+    }
 
     RefPtr<TypeBuilder::Array<TypeBuilder::Array<String> > > storageItems = TypeBuilder::Array<TypeBuilder::Array<String> >::create();
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to