Web Inspector: Error "null is not an object (evaluating 'syntaxTree.containersOfPosit...
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Jun 2019 01:21:08 +0000 (01:21 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Jun 2019 01:21:08 +0000 (01:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=199082

Reviewed by Matt Baker.

* UserInterface/Views/SourceCodeTextEditor.js:
(WI.SourceCodeTextEditor.prototype.textEditorExecutionHighlightRange):
The script syntax tree may be fetched even if the resource hasn't finished parsing (or had
a syntax error), so it's possible for it to be `null`.

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

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

index d645971..8a47811 100644 (file)
@@ -1,5 +1,17 @@
 2019-06-20  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: Error "null is not an object (evaluating 'syntaxTree.containersOfPosition')" when setting a breakpoint
+        https://bugs.webkit.org/show_bug.cgi?id=199082
+
+        Reviewed by Matt Baker.
+
+        * UserInterface/Views/SourceCodeTextEditor.js:
+        (WI.SourceCodeTextEditor.prototype.textEditorExecutionHighlightRange):
+        The script syntax tree may be fetched even if the resource hasn't finished parsing (or had
+        a syntax error), so it's possible for it to be `null`.
+
+2019-06-20  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: Dark Mode: inactive tab bar item should get darker on hover
         https://bugs.webkit.org/show_bug.cgi?id=199022
 
index 3df33b5..2e33989 100644 (file)
@@ -1437,6 +1437,12 @@ WI.SourceCodeTextEditor = class SourceCodeTextEditor extends WI.TextEditor
         };
 
         script.requestScriptSyntaxTree((syntaxTree) => {
+            // After requesting the tree, we still might get a null tree from a parse error.
+            if (!syntaxTree) {
+                callback(null);
+                return;
+            }
+
             // Convert to the position within the inline script before querying the AST.
             position = toInlineScriptPosition(position);
             let nodes = syntaxTree.containersOfPosition(position);