[automation] Add null check in AutomationNode.getNodeFromTree.

We wrote some automated UI tests using the Chrome automation framework,
but encountered some errors happening inside the JavaScript code for
AutomationNode: https://crbug.com/893957#c24

The error is:

    TypeError: Method called without a valid receiver (this). Did you
    forget to call .bind()?"

After codesearching, this error seems to occur when we pass an invalid
object to the "privates" function [1].

From the JavaScript stack trace, it looks like this is the line in
AutomationNode.getNodeFromTree that raises the error:

    privates(AutomationRootNodeImpl.get(treeId)).impl

which suggests AutomationRootNodeImpl.get(treeId) was null.

I'm not familiar enough with this code to figure out the root cause,
so I'll just add an additional null check to prevent this error from
happening again.

[1] https://cs.chromium.org/chromium/src/extensions/renderer/module_system.cc?type=cs&sq=package:chromium&g=0&l=666

Bug: 893957
Change-Id: I3d4d6edb6d22eabf85a9b5b4399c1a75cf16956b
Reviewed-on: https://chromium-review.googlesource.com/c/1393683
Reviewed-by: David Tseng <dtseng@chromium.org>
Commit-Queue: Darren Shen <shend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#620486}
1 file changed