Web Inspector: Uncaught Exception: null is not an object (evaluating 'resource.parent...
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 May 2019 00:32:09 +0000 (00:32 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 May 2019 00:32:09 +0000 (00:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196572
<rdar://problem/49578338>

Reviewed by Timothy Hatcher.

* UserInterface/Views/SourcesNavigationSidebarPanel.js:
(WI.SourcesNavigationSidebarPanel.prototype._addResource):

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/SourcesNavigationSidebarPanel.js

index c7b04d0..eafa215 100644 (file)
@@ -1,5 +1,16 @@
 2019-05-09  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: Uncaught Exception: null is not an object (evaluating 'resource.parentFrame.securityOrigin')
+        https://bugs.webkit.org/show_bug.cgi?id=196572
+        <rdar://problem/49578338>
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Views/SourcesNavigationSidebarPanel.js:
+        (WI.SourcesNavigationSidebarPanel.prototype._addResource):
+
+2019-05-09  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: REGRESSION: unable to expand/collapse non-selectable WI.TreeOutline
         https://bugs.webkit.org/show_bug.cgi?id=197591
 
index f0e94fb..a21bae8 100644 (file)
@@ -668,16 +668,27 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W
                 origin = resource.urlComponents.scheme + "://" + resource.urlComponents.host;
                 if (resource.urlComponents.port)
                     origin += ":" + resource.urlComponents.port;
-            } else
+            } else if (resource.parentFrame)
                 origin = resource.parentFrame.securityOrigin;
 
-            let frameTreeElement = this._originTreeElementMap.get(origin);
-            if (!frameTreeElement) {
-                frameTreeElement = new WI.FolderTreeElement(origin, origin === resource.parentFrame.securityOrigin ? resource.parentFrame : null);
-                this._originTreeElementMap.set(origin, frameTreeElement);
+            let parentTreeElement = null;
+            if (origin) {
+                let frameTreeElement = this._originTreeElementMap.get(origin);
+                if (!frameTreeElement) {
+                    frameTreeElement = new WI.FolderTreeElement(origin, origin === resource.parentFrame.securityOrigin ? resource.parentFrame : null);
+                    this._originTreeElementMap.set(origin, frameTreeElement);
 
-                let index = insertionIndexForObjectInListSortedByFunction(frameTreeElement, this._resourcesTreeOutline.children, this._boundCompareTreeElements);
-                this._resourcesTreeOutline.insertChild(frameTreeElement, index);
+                    let index = insertionIndexForObjectInListSortedByFunction(frameTreeElement, this._resourcesTreeOutline.children, this._boundCompareTreeElements);
+                    this._resourcesTreeOutline.insertChild(frameTreeElement, index);
+                }
+
+                let subpath = resource.urlComponents.path;
+                if (subpath && subpath[0] === "/")
+                    subpath = subpath.substring(1);
+
+                parentTreeElement = frameTreeElement.createFoldersAsNeededForSubpath(subpath);
+            } else {
+                parentTreeElement = this._resourcesTreeOutline;
             }
 
             let resourceTreeElement = null;
@@ -686,13 +697,8 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W
             else
                 resourceTreeElement = new WI.ResourceTreeElement(resource, resource, {allowDirectoryAsName: true, hideOrigin: true});
 
-            let subpath = resource.urlComponents.path;
-            if (subpath && subpath[0] === "/")
-                subpath = subpath.substring(1);
-
-            let parent = frameTreeElement.createFoldersAsNeededForSubpath(subpath);
-            let index = insertionIndexForObjectInListSortedByFunction(resourceTreeElement, parent.children, this._boundCompareTreeElements);
-            parent.insertChild(resourceTreeElement, index);
+            let index = insertionIndexForObjectInListSortedByFunction(resourceTreeElement, parentTreeElement.children, this._boundCompareTreeElements);
+            parentTreeElement.insertChild(resourceTreeElement, index);
         }
 
         if (resource.type === WI.Resource.Type.Document || resource.type === WI.Resource.Type.Script) {