Title: [276146] trunk/Source/WebInspectorUI
Revision
276146
Author
[email protected]
Date
2021-04-16 11:07:23 -0700 (Fri, 16 Apr 2021)

Log Message

Web Inspector: Uncaught Exception: null is not an object (evaluating 'this._listeners.get')
https://bugs.webkit.org/show_bug.cgi?id=224651

Reviewed by BJ Burg.

* UserInterface/Base/Object.js:
(WI.Object.removeEventListener):
Add early-return checks just in case `_listeners` or `listenersForEventType` is falsy. While
ideally it would be the case that these would never be falsy, the logic of Web Inspector is
complex and far reaching, so better safe than sorry.

* UserInterface/Views/TreeElement.js:
(WI.TreeElement.prototype._detach):
* UserInterface/Views/AuditTreeElement.js:
(WI.AuditTreeElement.prototype.ondetach):
* UserInterface/Views/BootstrapScriptTreeElement.js:
(WI.BootstrapScriptTreeElement.prototype.ondetach):
* UserInterface/Views/BreakpointTreeElement.js:
(WI.BreakpointTreeElement.prototype.ondetach):
* UserInterface/Views/DOMTreeElement.js:
(WI.DOMTreeElement.prototype.ondetach):
* UserInterface/Views/FrameTreeElement.js:
(WI.FrameTreeElement.prototype.ondetach):
* UserInterface/Views/_javascript_BreakpointTreeElement.js:
(WI._javascript_BreakpointTreeElement.prototype.ondetach):
* UserInterface/Views/LocalResourceOverrideTreeElement.js:
(WI.LocalResourceOverrideTreeElement.prototype.ondetach):
* UserInterface/Views/ShaderProgramTreeElement.js:
(WI.ShaderProgramTreeElement.prototype.ondetach):
* UserInterface/Views/WebSocketResourceTreeElement.js:
(WI.WebSocketResourceTreeElement.prototype.ondetach):
Add FIXME comments warning of this issue so that future changes can take it into account.
<https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (276145 => 276146)


--- trunk/Source/WebInspectorUI/ChangeLog	2021-04-16 18:02:48 UTC (rev 276145)
+++ trunk/Source/WebInspectorUI/ChangeLog	2021-04-16 18:07:23 UTC (rev 276146)
@@ -1,5 +1,41 @@
 2021-04-16  Devin Rousso  <[email protected]>
 
+        Web Inspector: Uncaught Exception: null is not an object (evaluating 'this._listeners.get')
+        https://bugs.webkit.org/show_bug.cgi?id=224651
+
+        Reviewed by BJ Burg.
+
+        * UserInterface/Base/Object.js:
+        (WI.Object.removeEventListener):
+        Add early-return checks just in case `_listeners` or `listenersForEventType` is falsy. While
+        ideally it would be the case that these would never be falsy, the logic of Web Inspector is
+        complex and far reaching, so better safe than sorry.
+
+        * UserInterface/Views/TreeElement.js:
+        (WI.TreeElement.prototype._detach):
+        * UserInterface/Views/AuditTreeElement.js:
+        (WI.AuditTreeElement.prototype.ondetach):
+        * UserInterface/Views/BootstrapScriptTreeElement.js:
+        (WI.BootstrapScriptTreeElement.prototype.ondetach):
+        * UserInterface/Views/BreakpointTreeElement.js:
+        (WI.BreakpointTreeElement.prototype.ondetach):
+        * UserInterface/Views/DOMTreeElement.js:
+        (WI.DOMTreeElement.prototype.ondetach):
+        * UserInterface/Views/FrameTreeElement.js:
+        (WI.FrameTreeElement.prototype.ondetach):
+        * UserInterface/Views/_javascript_BreakpointTreeElement.js:
+        (WI._javascript_BreakpointTreeElement.prototype.ondetach):
+        * UserInterface/Views/LocalResourceOverrideTreeElement.js:
+        (WI.LocalResourceOverrideTreeElement.prototype.ondetach):
+        * UserInterface/Views/ShaderProgramTreeElement.js:
+        (WI.ShaderProgramTreeElement.prototype.ondetach):
+        * UserInterface/Views/WebSocketResourceTreeElement.js:
+        (WI.WebSocketResourceTreeElement.prototype.ondetach):
+        Add FIXME comments warning of this issue so that future changes can take it into account.
+        <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
+
+2021-04-16  Devin Rousso  <[email protected]>
+
         Web Inspector: Sources: don't show the create local override contextmenu if the navigation item is disabled
         https://bugs.webkit.org/show_bug.cgi?id=224647
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Object.js (276145 => 276146)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Object.js	2021-04-16 18:02:48 UTC (rev 276145)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Object.js	2021-04-16 18:07:23 UTC (rev 276146)
@@ -78,10 +78,15 @@
         console.assert(typeof listener === "function", this, eventType, listener, thisObject);
         console.assert(typeof thisObject === "object" || window.InspectorTest || window.ProtocolTest, this, eventType, listener, thisObject);
 
+        if (!this._listeners)
+            return;
+
         thisObject ??= this;
 
         let listenersForEventType = this._listeners.get(eventType);
         console.assert(listenersForEventType, this, eventType, listener, thisObject);
+        if (!listenersForEventType)
+            return;
 
         let didDelete = false;
         for (let data of listenersForEventType) {

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/AuditTreeElement.js (276145 => 276146)


--- trunk/Source/WebInspectorUI/UserInterface/Views/AuditTreeElement.js	2021-04-16 18:02:48 UTC (rev 276145)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/AuditTreeElement.js	2021-04-16 18:07:23 UTC (rev 276146)
@@ -97,6 +97,8 @@
 
     ondetach()
     {
+        // FIXME: <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
+
         if (this.representedObject instanceof WI.AuditTestBase) {
             this.representedObject.removeEventListener(WI.AuditTestBase.Event.DisabledChanged, this._handleTestDisabledChanged, this);
             this.representedObject.removeEventListener(WI.AuditTestBase.Event.ResultChanged, this._handleTestResultChanged, this);

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/BootstrapScriptTreeElement.js (276145 => 276146)


--- trunk/Source/WebInspectorUI/UserInterface/Views/BootstrapScriptTreeElement.js	2021-04-16 18:02:48 UTC (rev 276145)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/BootstrapScriptTreeElement.js	2021-04-16 18:07:23 UTC (rev 276146)
@@ -52,6 +52,8 @@
 
     ondetach()
     {
+        // FIXME: <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
+
         WI.NetworkManager.removeEventListener(WI.NetworkManager.Event.BootstrapScriptEnabledChanged, this._handleNetworkManagerBootstrapScriptEnabledChanged, this);
 
         super.ondetach();

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/BreakpointTreeElement.js (276145 => 276146)


--- trunk/Source/WebInspectorUI/UserInterface/Views/BreakpointTreeElement.js	2021-04-16 18:02:48 UTC (rev 276145)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/BreakpointTreeElement.js	2021-04-16 18:07:23 UTC (rev 276146)
@@ -111,6 +111,8 @@
 
     ondetach()
     {
+        // FIXME: <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
+
         super.ondetach();
 
         this._breakpoint.removeEventListener(WI.Breakpoint.Event.DisabledStateDidChange, this.updateStatus, this);

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js (276145 => 276146)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js	2021-04-16 18:02:48 UTC (rev 276145)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js	2021-04-16 18:07:23 UTC (rev 276146)
@@ -455,6 +455,8 @@
 
     ondetach()
     {
+        // FIXME: <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
+
         if (this.representedObject.layoutContextType === WI.DOMNode.LayoutContextType.Grid) {
             WI.overlayManager.removeEventListener(WI.OverlayManager.Event.GridOverlayShown, this._updateGridBadgeStatus, this);
             WI.overlayManager.removeEventListener(WI.OverlayManager.Event.GridOverlayHidden, this._updateGridBadgeStatus, this);

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/FrameTreeElement.js (276145 => 276146)


--- trunk/Source/WebInspectorUI/UserInterface/Views/FrameTreeElement.js	2021-04-16 18:02:48 UTC (rev 276145)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/FrameTreeElement.js	2021-04-16 18:07:23 UTC (rev 276146)
@@ -121,6 +121,8 @@
 
     ondetach()
     {
+        // FIXME: <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
+
         if (this.listItemElement) {
             WI.cssManager.removeEventListener(WI.CSSManager.Event.StyleSheetAdded, this._styleSheetAdded, this);
             WI.cssManager.removeEventListener(WI.CSSManager.Event.StyleSheetRemoved, this._styleSheetRemoved, this);

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/_javascript_BreakpointTreeElement.js (276145 => 276146)


--- trunk/Source/WebInspectorUI/UserInterface/Views/_javascript_BreakpointTreeElement.js	2021-04-16 18:02:48 UTC (rev 276145)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/_javascript_BreakpointTreeElement.js	2021-04-16 18:07:23 UTC (rev 276146)
@@ -59,6 +59,8 @@
 
     ondetach()
     {
+        // FIXME: <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
+
         if (!this.breakpoint.special)
             this.breakpoint.removeEventListener(WI._javascript_Breakpoint.Event.LocationDidChange, this._breakpointLocationDidChange, this);
         this.breakpoint.removeEventListener(WI._javascript_Breakpoint.Event.ResolvedStateDidChange, this.updateStatus, this);

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LocalResourceOverrideTreeElement.js (276145 => 276146)


--- trunk/Source/WebInspectorUI/UserInterface/Views/LocalResourceOverrideTreeElement.js	2021-04-16 18:02:48 UTC (rev 276145)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LocalResourceOverrideTreeElement.js	2021-04-16 18:07:23 UTC (rev 276146)
@@ -56,6 +56,8 @@
 
     ondetach()
     {
+        // FIXME: <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
+
         this._localResourceOverride.removeEventListener(WI.LocalResourceOverride.Event.DisabledChanged, this._handleLocalResourceOverrideDisabledChanged, this);
 
         WI.Frame.removeEventListener(WI.Frame.Event.MainResourceDidChange, this._handleFrameMainResourceDidChange, this);

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ShaderProgramTreeElement.js (276145 => 276146)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ShaderProgramTreeElement.js	2021-04-16 18:02:48 UTC (rev 276145)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ShaderProgramTreeElement.js	2021-04-16 18:07:23 UTC (rev 276146)
@@ -60,6 +60,8 @@
 
     ondetach()
     {
+        // FIXME: <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
+
         // FIXME: add support for disabling/highlighting WebGPU shader pipelines.
         let contextType = this.representedObject.canvas.contextType;
         if (contextType === WI.Canvas.ContextType.WebGL || contextType === WI.Canvas.ContextType.WebGL2)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TreeElement.js (276145 => 276146)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TreeElement.js	2021-04-16 18:02:48 UTC (rev 276145)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TreeElement.js	2021-04-16 18:07:23 UTC (rev 276146)
@@ -290,6 +290,7 @@
 
     _detach()
     {
+        // FIXME: <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
         if (this.ondetach)
             this.ondetach(this);
         if (this._listItemNode && this._listItemNode.parentNode)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/WebSocketResourceTreeElement.js (276145 => 276146)


--- trunk/Source/WebInspectorUI/UserInterface/Views/WebSocketResourceTreeElement.js	2021-04-16 18:02:48 UTC (rev 276145)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/WebSocketResourceTreeElement.js	2021-04-16 18:07:23 UTC (rev 276146)
@@ -38,6 +38,8 @@
 
     ondetach()
     {
+        // FIXME: <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
+
         super.ondetach();
 
         this.resource.removeEventListener(WI.WebSocketResource.Event.ReadyStateChanged, this._updateConnectionStatus, this);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to