Uncaught Exception: Can't make a ContentView for an unknown representedObject of...
authornvasilyev@apple.com <nvasilyev@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 May 2017 22:13:26 +0000 (22:13 +0000)
committernvasilyev@apple.com <nvasilyev@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 May 2017 22:13:26 +0000 (22:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167473
<rdar://problem/30249715>

Reviewed by Matt Baker.

When an indexed database is selected in the Storage navigation sidebar, show its host, security origin, and version.

Previously, selecting an indexed database didn't change the content view. It could lead to a misleading state
when an indexed database is selected in the sidebar, but the content view showed previously selected item such as
Cookies or Local Storage.

* UserInterface/Main.html:
* UserInterface/Views/ContentView.css:
(.content-view .details-section):
(.content-view .details-section > .content):
(.content-view .details-section > .content > .group > .row.simple > .label):
(.content-view .details-section:last-child):
* UserInterface/Views/ContentView.js:
(WebInspector.ContentView.createFromRepresentedObject):
(WebInspector.ContentView.isViewable):
* UserInterface/Views/IndexedDatabaseContentView.css: Added.
(.indexed-database.content-view):
(.indexed-database.content-view .indexed-database-details):
(.indexed-database.content-view .details-section > .header):
* UserInterface/Views/IndexedDatabaseContentView.js: Added.
(WebInspector.IndexedDatabaseContentView):
* UserInterface/Views/IndexedDatabaseDetailsSidebarPanel.js:
(WebInspector.IndexedDatabaseDetailsSidebarPanel.prototype.inspect):
Don't show the details sidebar for IndexedDB top level item since it has the same content as the content view.

* UserInterface/Views/StorageSidebarPanel.js:
(WebInspector.StorageSidebarPanel._treeSelectionDidChange):
* UserInterface/Views/StorageTabContentView.js:
(WebInspector.StorageTabContentView.prototype.canShowRepresentedObject):
(WebInspector.StorageTabContentView):

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Main.html
Source/WebInspectorUI/UserInterface/Views/ContentView.css
Source/WebInspectorUI/UserInterface/Views/ContentView.js
Source/WebInspectorUI/UserInterface/Views/IndexedDatabaseContentView.css [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Views/IndexedDatabaseContentView.js [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Views/IndexedDatabaseDetailsSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/StorageSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/StorageTabContentView.js

index 52fc2c1..924ded6 100644 (file)
@@ -1,3 +1,42 @@
+2017-05-03  Nikita Vasilyev  <nvasilyev@apple.com>
+
+        Uncaught Exception: Can't make a ContentView for an unknown representedObject of type: IndexedDatabase
+        https://bugs.webkit.org/show_bug.cgi?id=167473
+        <rdar://problem/30249715>
+
+        Reviewed by Matt Baker.
+
+        When an indexed database is selected in the Storage navigation sidebar, show its host, security origin, and version.
+
+        Previously, selecting an indexed database didn't change the content view. It could lead to a misleading state
+        when an indexed database is selected in the sidebar, but the content view showed previously selected item such as
+        Cookies or Local Storage.
+
+        * UserInterface/Main.html:
+        * UserInterface/Views/ContentView.css:
+        (.content-view .details-section):
+        (.content-view .details-section > .content):
+        (.content-view .details-section > .content > .group > .row.simple > .label):
+        (.content-view .details-section:last-child):
+        * UserInterface/Views/ContentView.js:
+        (WebInspector.ContentView.createFromRepresentedObject):
+        (WebInspector.ContentView.isViewable):
+        * UserInterface/Views/IndexedDatabaseContentView.css: Added.
+        (.indexed-database.content-view):
+        (.indexed-database.content-view .indexed-database-details):
+        (.indexed-database.content-view .details-section > .header):
+        * UserInterface/Views/IndexedDatabaseContentView.js: Added.
+        (WebInspector.IndexedDatabaseContentView):
+        * UserInterface/Views/IndexedDatabaseDetailsSidebarPanel.js:
+        (WebInspector.IndexedDatabaseDetailsSidebarPanel.prototype.inspect):
+        Don't show the details sidebar for IndexedDB top level item since it has the same content as the content view.
+
+        * UserInterface/Views/StorageSidebarPanel.js:
+        (WebInspector.StorageSidebarPanel._treeSelectionDidChange):
+        * UserInterface/Views/StorageTabContentView.js:
+        (WebInspector.StorageTabContentView.prototype.canShowRepresentedObject):
+        (WebInspector.StorageTabContentView):
+
 2017-05-03  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: 404 Image Load does not appear as a failure in Web Inspector
index 263852d..dbb83ae 100644 (file)
     <link rel="stylesheet" href="Views/IdleTreeElement.css">
     <link rel="stylesheet" href="Views/ImageResourceContentView.css">
     <link rel="stylesheet" href="Views/IndeterminateProgressSpinner.css">
+    <link rel="stylesheet" href="Views/IndexedDatabaseContentView.css">
     <link rel="stylesheet" href="Views/IndexedDatabaseObjectStoreContentView.css">
     <link rel="stylesheet" href="Views/InlineSwatch.css">
     <link rel="stylesheet" href="Views/InputPopover.css">
     <script src="Views/IdleTreeElement.js"></script>
     <script src="Views/ImageResourceContentView.js"></script>
     <script src="Views/IndeterminateProgressSpinner.js"></script>
+    <script src="Views/IndexedDatabaseContentView.js"></script>
     <script src="Views/IndexedDatabaseDetailsSidebarPanel.js"></script>
     <script src="Views/IndexedDatabaseEntryDataGridNode.js"></script>
     <script src="Views/IndexedDatabaseHostTreeElement.js"></script>
index aafa2ad..31b269c 100644 (file)
     margin-left: -16px;
     margin-right: -16px;
 }
+
+.content-view .details-section {
+    font-size: 11px;
+    background-color: initial;
+}
+
+.content-view .details-section > .content {
+    width: auto;
+}
+
+.content-view .details-section > .content > .group > .row.simple > .label {
+    width: auto;
+    font-weight: 600;
+}
+
+.content-view .details-section:last-child {
+    border-bottom: none;
+}
index 9bca8e7..a6879c6 100644 (file)
@@ -95,6 +95,9 @@ WebInspector.ContentView = class ContentView extends WebInspector.View
         if (representedObject instanceof WebInspector.DatabaseObject)
             return new WebInspector.DatabaseContentView(representedObject, extraArguments);
 
+        if (representedObject instanceof WebInspector.IndexedDatabase)
+            return new WebInspector.IndexedDatabaseContentView(representedObject, extraArguments);
+
         if (representedObject instanceof WebInspector.IndexedDatabaseObjectStore)
             return new WebInspector.IndexedDatabaseObjectStoreContentView(representedObject, extraArguments);
 
@@ -245,6 +248,8 @@ WebInspector.ContentView = class ContentView extends WebInspector.View
             return true;
         if (representedObject instanceof WebInspector.DatabaseObject)
             return true;
+        if (representedObject instanceof WebInspector.IndexedDatabase)
+            return true;
         if (representedObject instanceof WebInspector.IndexedDatabaseObjectStore)
             return true;
         if (representedObject instanceof WebInspector.IndexedDatabaseObjectStoreIndex)
diff --git a/Source/WebInspectorUI/UserInterface/Views/IndexedDatabaseContentView.css b/Source/WebInspectorUI/UserInterface/Views/IndexedDatabaseContentView.css
new file mode 100644 (file)
index 0000000..663a94d
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+.indexed-database.content-view {
+    -webkit-user-select: text;
+}
+
+.indexed-database.content-view .indexed-database-details {
+    margin: 0.4em 1.2em;
+}
+
+.indexed-database.content-view .details-section > .header {
+    display: none;
+}
diff --git a/Source/WebInspectorUI/UserInterface/Views/IndexedDatabaseContentView.js b/Source/WebInspectorUI/UserInterface/Views/IndexedDatabaseContentView.js
new file mode 100644 (file)
index 0000000..d6e9f39
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.IndexedDatabaseContentView = class IndexedDatabaseContentView extends WebInspector.ContentView
+{
+    constructor(database)
+    {
+        super(database);
+
+        this._element.classList.add("indexed-database");
+
+        this._databaseHostRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Host"));
+        this._databaseSecurityOriginRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Security Origin"));
+        this._databaseVersionRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Version"));
+        this._databaseGroup = new WebInspector.DetailsSectionGroup([this._databaseHostRow, this._databaseSecurityOriginRow, this._databaseVersionRow]);
+        this._databaseSection = new WebInspector.DetailsSection("indexed-database-details", WebInspector.UIString("Database"), [this._databaseGroup]);
+
+        this.element.append(this._databaseSection.element);
+
+        this._databaseHostRow.value = database.host;
+        this._databaseSecurityOriginRow.value = database.securityOrigin;
+        this._databaseVersionRow.value = database.version.toLocaleString();
+    }
+};
index 5b8ccea..e058d1b 100644 (file)
@@ -72,10 +72,7 @@ WebInspector.IndexedDatabaseDetailsSidebarPanel = class IndexedDatabaseDetailsSi
         this._index = null;
 
         for (let object of objects) {
-            if (object instanceof WebInspector.IndexedDatabase) {
-                console.assert(!this._database, "Shouldn't have multiple IndexedDatabase objects in the list.");
-                this._database = object;
-            } else if (object instanceof WebInspector.IndexedDatabaseObjectStore) {
+            if (object instanceof WebInspector.IndexedDatabaseObjectStore) {
                 console.assert(!this._database, "Shouldn't have multiple IndexedDatabase objects in the list.");
                 this._objectStore = object;
                 this._database = this._objectStore.parentDatabase;
index 55f9800..3c1c436 100644 (file)
@@ -178,13 +178,12 @@ WebInspector.StorageSidebarPanel = class StorageSidebarPanel extends WebInspecto
             return;
 
         if (treeElement instanceof WebInspector.FolderTreeElement || treeElement instanceof WebInspector.DatabaseHostTreeElement ||
-            treeElement instanceof WebInspector.IndexedDatabaseHostTreeElement || treeElement instanceof WebInspector.IndexedDatabaseTreeElement
-            || treeElement instanceof WebInspector.ApplicationCacheManifestTreeElement)
+            treeElement instanceof WebInspector.IndexedDatabaseHostTreeElement || treeElement instanceof WebInspector.ApplicationCacheManifestTreeElement)
             return;
 
         if (treeElement instanceof WebInspector.StorageTreeElement || treeElement instanceof WebInspector.DatabaseTableTreeElement ||
             treeElement instanceof WebInspector.DatabaseTreeElement || treeElement instanceof WebInspector.ApplicationCacheFrameTreeElement ||
-            treeElement instanceof WebInspector.IndexedDatabaseObjectStoreTreeElement || treeElement instanceof WebInspector.IndexedDatabaseObjectStoreIndexTreeElement) {
+            treeElement instanceof WebInspector.IndexedDatabaseTreeElement || treeElement instanceof WebInspector.IndexedDatabaseObjectStoreTreeElement || treeElement instanceof WebInspector.IndexedDatabaseObjectStoreIndexTreeElement) {
             WebInspector.showRepresentedObject(treeElement.representedObject);
             return;
         }
index 40467f0..87ead90 100644 (file)
@@ -64,7 +64,7 @@ WebInspector.StorageTabContentView = class StorageTabContentView extends WebInsp
         return representedObject instanceof WebInspector.DOMStorageObject || representedObject instanceof WebInspector.CookieStorageObject ||
             representedObject instanceof WebInspector.DatabaseTableObject || representedObject instanceof WebInspector.DatabaseObject ||
             representedObject instanceof WebInspector.ApplicationCacheFrame || representedObject instanceof WebInspector.IndexedDatabaseObjectStore ||
-            representedObject instanceof WebInspector.IndexedDatabaseObjectStoreIndex;
+            representedObject instanceof WebInspector.IndexedDatabase || representedObject instanceof WebInspector.IndexedDatabaseObjectStoreIndex;
     }
 };