From 01338eed617b14dd0df3f84d22f9499302da1dee Mon Sep 17 00:00:00 2001 From: Christy Chen Date: Thu, 1 Oct 2020 16:41:55 -0700 Subject: [PATCH] Fix two exceptions in JavascriptAutoComplete.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. "Cannot read property 'length' of null" at line 95 Event though the args has a length of 1, that item could be null and causing a[0].length to throw an error. 2. "Cannot read property 'className' of null" at line 148 The receiverObj has a type of RemoteObject | null. We do an early return in the case of null. Change-Id: I6b43248fd16c0867f9d4b1252621f5d4c8bbb551 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2444012 Reviewed-by: Simon Zünd Commit-Queue: Christy Chen --- front_end/object_ui/JavaScriptAutocomplete.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/front_end/object_ui/JavaScriptAutocomplete.js b/front_end/object_ui/JavaScriptAutocomplete.js index 8e709a3b57..056c3e8181 100644 --- a/front_end/object_ui/JavaScriptAutocomplete.js +++ b/front_end/object_ui/JavaScriptAutocomplete.js @@ -92,7 +92,7 @@ export class JavaScriptAutocomplete { return (result && !result.exceptionDetails && result.object) ? result.object : null; }, functionCall.functionName); executionContext.runtimeModel.releaseObjectGroup('argumentsHint'); - if (!args.length || (args.length === 1 && !args[0].length)) { + if (!args.length || (args.length === 1 && (!args[0] || !args[0].length))) { return null; } return {args, argumentIndex: functionCall.argumentIndex}; @@ -145,6 +145,9 @@ export class JavaScriptAutocomplete { return uniqueSignatures; } const receiverObj = await receiverObjGetter(); + if (!receiverObj) { + return []; + } const className = receiverObj.className; if (javaScriptMetadata.signaturesForInstanceMethod(name, className)) { return javaScriptMetadata.signaturesForInstanceMethod(name, className);