Changeset 276146 in webkit


Ignore:
Timestamp:
Apr 16, 2021, 11:07:23 AM (4 years ago)
Author:
Devin Rousso
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/JavaScriptBreakpointTreeElement.js:

(WI.JavaScriptBreakpointTreeElement.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)

Location:
trunk/Source/WebInspectorUI
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r276144 r276146  
     12021-04-16  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Uncaught Exception: null is not an object (evaluating 'this._listeners.get')
     4        https://bugs.webkit.org/show_bug.cgi?id=224651
     5
     6        Reviewed by BJ Burg.
     7
     8        * UserInterface/Base/Object.js:
     9        (WI.Object.removeEventListener):
     10        Add early-return checks just in case `_listeners` or `listenersForEventType` is falsy. While
     11        ideally it would be the case that these would never be falsy, the logic of Web Inspector is
     12        complex and far reaching, so better safe than sorry.
     13
     14        * UserInterface/Views/TreeElement.js:
     15        (WI.TreeElement.prototype._detach):
     16        * UserInterface/Views/AuditTreeElement.js:
     17        (WI.AuditTreeElement.prototype.ondetach):
     18        * UserInterface/Views/BootstrapScriptTreeElement.js:
     19        (WI.BootstrapScriptTreeElement.prototype.ondetach):
     20        * UserInterface/Views/BreakpointTreeElement.js:
     21        (WI.BreakpointTreeElement.prototype.ondetach):
     22        * UserInterface/Views/DOMTreeElement.js:
     23        (WI.DOMTreeElement.prototype.ondetach):
     24        * UserInterface/Views/FrameTreeElement.js:
     25        (WI.FrameTreeElement.prototype.ondetach):
     26        * UserInterface/Views/JavaScriptBreakpointTreeElement.js:
     27        (WI.JavaScriptBreakpointTreeElement.prototype.ondetach):
     28        * UserInterface/Views/LocalResourceOverrideTreeElement.js:
     29        (WI.LocalResourceOverrideTreeElement.prototype.ondetach):
     30        * UserInterface/Views/ShaderProgramTreeElement.js:
     31        (WI.ShaderProgramTreeElement.prototype.ondetach):
     32        * UserInterface/Views/WebSocketResourceTreeElement.js:
     33        (WI.WebSocketResourceTreeElement.prototype.ondetach):
     34        Add FIXME comments warning of this issue so that future changes can take it into account.
     35        <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
     36
    1372021-04-16  Devin Rousso  <drousso@apple.com>
    238
  • trunk/Source/WebInspectorUI/UserInterface/Base/Object.js

    r274303 r276146  
    7979        console.assert(typeof thisObject === "object" || window.InspectorTest || window.ProtocolTest, this, eventType, listener, thisObject);
    8080
     81        if (!this._listeners)
     82            return;
     83
    8184        thisObject ??= this;
    8285
    8386        let listenersForEventType = this._listeners.get(eventType);
    8487        console.assert(listenersForEventType, this, eventType, listener, thisObject);
     88        if (!listenersForEventType)
     89            return;
    8590
    8691        let didDelete = false;
  • trunk/Source/WebInspectorUI/UserInterface/Views/AuditTreeElement.js

    r269359 r276146  
    9898    ondetach()
    9999    {
     100        // FIXME: <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
     101
    100102        if (this.representedObject instanceof WI.AuditTestBase) {
    101103            this.representedObject.removeEventListener(WI.AuditTestBase.Event.DisabledChanged, this._handleTestDisabledChanged, this);
  • trunk/Source/WebInspectorUI/UserInterface/Views/BootstrapScriptTreeElement.js

    r253402 r276146  
    5353    ondetach()
    5454    {
     55        // FIXME: <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
     56
    5557        WI.NetworkManager.removeEventListener(WI.NetworkManager.Event.BootstrapScriptEnabledChanged, this._handleNetworkManagerBootstrapScriptEnabledChanged, this);
    5658
  • trunk/Source/WebInspectorUI/UserInterface/Views/BreakpointTreeElement.js

    r269359 r276146  
    112112    ondetach()
    113113    {
     114        // FIXME: <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
     115
    114116        super.ondetach();
    115117
  • trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js

    r274592 r276146  
    456456    ondetach()
    457457    {
     458        // FIXME: <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
     459
    458460        if (this.representedObject.layoutContextType === WI.DOMNode.LayoutContextType.Grid) {
    459461            WI.overlayManager.removeEventListener(WI.OverlayManager.Event.GridOverlayShown, this._updateGridBadgeStatus, this);
  • trunk/Source/WebInspectorUI/UserInterface/Views/FrameTreeElement.js

    r265714 r276146  
    122122    ondetach()
    123123    {
     124        // FIXME: <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
     125
    124126        if (this.listItemElement) {
    125127            WI.cssManager.removeEventListener(WI.CSSManager.Event.StyleSheetAdded, this._styleSheetAdded, this);
  • trunk/Source/WebInspectorUI/UserInterface/Views/JavaScriptBreakpointTreeElement.js

    r269359 r276146  
    6060    ondetach()
    6161    {
     62        // FIXME: <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
     63
    6264        if (!this.breakpoint.special)
    6365            this.breakpoint.removeEventListener(WI.JavaScriptBreakpoint.Event.LocationDidChange, this._breakpointLocationDidChange, this);
  • trunk/Source/WebInspectorUI/UserInterface/Views/LocalResourceOverrideTreeElement.js

    r270604 r276146  
    5757    ondetach()
    5858    {
     59        // FIXME: <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
     60
    5961        this._localResourceOverride.removeEventListener(WI.LocalResourceOverride.Event.DisabledChanged, this._handleLocalResourceOverrideDisabledChanged, this);
    6062
  • trunk/Source/WebInspectorUI/UserInterface/Views/ShaderProgramTreeElement.js

    r250258 r276146  
    6161    ondetach()
    6262    {
     63        // FIXME: <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
     64
    6365        // FIXME: add support for disabling/highlighting WebGPU shader pipelines.
    6466        let contextType = this.representedObject.canvas.contextType;
  • trunk/Source/WebInspectorUI/UserInterface/Views/TreeElement.js

    r272371 r276146  
    291291    _detach()
    292292    {
     293        // FIXME: <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
    293294        if (this.ondetach)
    294295            this.ondetach(this);
  • trunk/Source/WebInspectorUI/UserInterface/Views/WebSocketResourceTreeElement.js

    r220119 r276146  
    3939    ondetach()
    4040    {
     41        // FIXME: <https://webkit.org/b/224652> (Web Inspector: Tree Outlines: `ondetach` can be called without `onattach` ever being called)
     42
    4143        super.ondetach();
    4244
Note: See TracChangeset for help on using the changeset viewer.