Web Inspector: Uncaught Exception opening Web Inspector to Debugger Tab
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Nov 2018 21:13:27 +0000 (21:13 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Nov 2018 21:13:27 +0000 (21:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192174

Reviewed by Devin Rousso.

* UserInterface/Protocol/InspectorBackend.js:
(InspectorBackendClass.prototype.runAfterPendingDispatches):
Dispatch the callback with a timeout if there is no backend target yet
so it doesn't get lost.

* UserInterface/Protocol/Connection.js:
(InspectorBackend.Connection.prototype.runAfterPendingDispatches):
Change the ambiguous name "script" to the more familiar "callback".

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Protocol/Connection.js
Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js

index 6282205..fccfa0d 100644 (file)
@@ -1,3 +1,19 @@
+2018-11-30  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Uncaught Exception opening Web Inspector to Debugger Tab
+        https://bugs.webkit.org/show_bug.cgi?id=192174
+
+        Reviewed by Devin Rousso.
+
+        * UserInterface/Protocol/InspectorBackend.js:
+        (InspectorBackendClass.prototype.runAfterPendingDispatches):
+        Dispatch the callback with a timeout if there is no backend target yet
+        so it doesn't get lost.
+
+        * UserInterface/Protocol/Connection.js:
+        (InspectorBackend.Connection.prototype.runAfterPendingDispatches):
+        Change the ambiguous name "script" to the more familiar "callback".
+
 2018-11-30  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: replace all unicode characters with the escaped character code
index 91624c2..4e2e403 100644 (file)
@@ -38,7 +38,7 @@ InspectorBackend.Connection = class InspectorBackendConnection
     {
         this._pendingResponses = new Map;
         this._agents = {};
-        this._deferredScripts = [];
+        this._deferredCallbacks = [];
         this._target = null;
     }
 
@@ -72,14 +72,14 @@ InspectorBackend.Connection = class InspectorBackendConnection
             this._dispatchEvent(messageObject);
     }
 
-    runAfterPendingDispatches(script)
+    runAfterPendingDispatches(callback)
     {
-        console.assert(typeof script === "function");
+        console.assert(typeof callback === "function");
 
         if (!this._pendingResponses.size)
-            script.call(this);
+            callback.call(this);
         else
-            this._deferredScripts.push(script);
+            this._deferredCallbacks.push(callback);
     }
 
     // Protected
@@ -130,7 +130,7 @@ InspectorBackend.Connection = class InspectorBackendConnection
         for (let tracer of InspectorBackend.activeTracers)
             tracer.logDidHandleResponse(this, messageObject, {rtt: roundTripTime, dispatch: processingTime});
 
-        if (this._deferredScripts.length && !this._pendingResponses.size)
+        if (this._deferredCallbacks.length && !this._pendingResponses.size)
             this._flushPendingScripts();
     }
 
@@ -267,8 +267,8 @@ InspectorBackend.Connection = class InspectorBackendConnection
     {
         console.assert(this._pendingResponses.size === 0);
 
-        let scriptsToRun = this._deferredScripts;
-        this._deferredScripts = [];
+        let scriptsToRun = this._deferredCallbacks;
+        this._deferredCallbacks = [];
         for (let script of scriptsToRun)
             script.call(this);
     }
index 882d8c4..ce6e97e 100644 (file)
@@ -172,10 +172,15 @@ InspectorBackendClass = class InspectorBackendClass
         InspectorBackend.backendConnection.dispatch(message);
     }
 
-    runAfterPendingDispatches(script)
+    runAfterPendingDispatches(callback)
     {
+        if (!WI.mainTarget) {
+            callback();
+            return;
+        }
+
         // FIXME: Should this respect pending dispatches in all connections?
-        WI.mainTarget.connection.runAfterPendingDispatches(script);
+        WI.mainTarget.connection.runAfterPendingDispatches(callback);
     }
 
     activateDomain(domainName, activationDebuggableTypes)