Fix two exceptions in JavascriptAutoComplete.js

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 <szuend@chromium.org>
Commit-Queue: Christy Chen <chrche@microsoft.com>
This commit is contained in:
Christy Chen
2020-10-02 16:42:51 +00:00
committed by Commit Bot
parent eee94d1e95
commit 01338eed61
@@ -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);