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

Reviewed by Timothy Hatcher.

* UserInterface/Views/ConsoleMessageView.js:
(WI.ConsoleMessageView.prototype._appendLocationLink):
(WI.ConsoleMessageView.prototype._linkifyLocation): Deleted.

* UserInterface/Base/Main.js:
(WI.linkifyLocation):
(WI.linkifySourceCode): Added.
Split the logic into two functions, as there's no need to re-fetch the `SourceCode` from a
given url if you already have the `SourceCode` in the caller.

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/Main.js
Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js

index 8c3dafb..d2b0bc1 100644 (file)
@@ -1,3 +1,21 @@
+2019-05-09  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Uncaught Exception: null is not an object (evaluating 'url.startsWith')
+        https://bugs.webkit.org/show_bug.cgi?id=196662
+        <rdar://problem/49659633>
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Views/ConsoleMessageView.js:
+        (WI.ConsoleMessageView.prototype._appendLocationLink):
+        (WI.ConsoleMessageView.prototype._linkifyLocation): Deleted.
+
+        * UserInterface/Base/Main.js:
+        (WI.linkifyLocation):
+        (WI.linkifySourceCode): Added.
+        Split the logic into two functions, as there's no need to re-fetch the `SourceCode` from a
+        given url if you already have the `SourceCode` in the caller.
+
 2019-05-08  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed, rolling out r244952.
index 0875955..625dd8c 100644 (file)
@@ -2849,17 +2849,20 @@ WI.createSourceCodeLocationLink = function(sourceCodeLocation, options = {})
 WI.linkifyLocation = function(url, sourceCodePosition, options = {})
 {
     var sourceCode = WI.sourceCodeForURL(url);
+    if (sourceCode)
+        return WI.linkifySourceCode(sourceCode);
 
-    if (!sourceCode) {
-        var anchor = document.createElement("a");
-        anchor.href = url;
-        anchor.lineNumber = sourceCodePosition.lineNumber;
-        if (options.className)
-            anchor.className = options.className;
-        anchor.append(WI.displayNameForURL(url) + ":" + sourceCodePosition.lineNumber);
-        return anchor;
-    }
+    var anchor = document.createElement("a");
+    anchor.href = url;
+    anchor.lineNumber = sourceCodePosition.lineNumber;
+    if (options.className)
+        anchor.className = options.className;
+    anchor.append(WI.displayNameForURL(url) + ":" + sourceCodePosition.lineNumber);
+    return anchor;
+};
 
+WI.linkifySourceCode = function(sourceCode, sourceCodePosition, options = {})
+{
     let sourceCodeLocation = sourceCode.createSourceCodeLocation(sourceCodePosition.lineNumber, sourceCodePosition.columnNumber);
     let linkElement = WI.createSourceCodeLocationLink(sourceCodeLocation, {
         ...options,
index 23ac06c..7f6f93b 100644 (file)
@@ -376,7 +376,11 @@ WI.ConsoleMessageView = class ConsoleMessageView extends WI.Object
                 if (result === WI.RemoteObject.SourceCodeLocationPromise.NoSourceFound || result === WI.RemoteObject.SourceCodeLocationPromise.MissingObjectId)
                     return;
 
-                var link = this._linkifyLocation(result.sourceCode.sourceURL || result.sourceCode.url, result.lineNumber, result.columnNumber);
+                let link = WI.linkifySourceCode(result.sourceCode, new WI.SourceCodePosition(result.lineNumber, result.columnNumber), {
+                    className: "console-message-url",
+                    ignoreNetworkTab: true,
+                    ignoreSearchTab: true,
+                });
                 link.classList.add("console-message-location");
 
                 if (this._element.hasChildNodes())
@@ -766,16 +770,6 @@ WI.ConsoleMessageView = class ConsoleMessageView extends WI.Object
         return url === "undefined" || url === "[native code]";
     }
 
-    _linkifyLocation(url, lineNumber, columnNumber)
-    {
-        const options = {
-            className: "console-message-url",
-            ignoreNetworkTab: true,
-            ignoreSearchTab: true,
-        };
-        return WI.linkifyLocation(url, new WI.SourceCodePosition(lineNumber, columnNumber), options);
-    }
-
     _userProvidedColumnNames(columnNamesArgument)
     {
         if (!columnNamesArgument)