DevTools: Error for Tooltip in altered DOM

When the DOM is mutating and the user is hovering over the
DOM tree, because the tooltip to display is fetched and displayed
asynchronously, there is a race condition in which the tree
element may be removed from the DOM and the time the pop-over is
ready to display. In this case, the <li> in the DOM may fail to
be found, and therefore an exception may be raised. Although
the typings for this are indicated in the DOM Node prototype
addition (enclosingNodeOrSelfWithNodeName), in that the function
might return a null-value, that case wasn't previously handled
in this code path.

Change-Id: I0fcb3f13431b29894e3830ae801ec6a4a9305a26
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1872444
Reviewed-by: Lorne Mitchell <lomitch@microsoft.com>
Reviewed-by: John Emau <John.Emau@microsoft.com>
Commit-Queue: John Emau <John.Emau@microsoft.com>
This commit is contained in:
Rob Paveza
2019-10-21 22:56:24 +00:00
committed by Commit Bot
parent 4bf2164e8d
commit f4ef6c7416
@@ -582,6 +582,9 @@ Elements.ElementsTreeOutline = class extends UI.TreeOutline {
box: link.boxInWindow(),
show: async popover => {
const listItem = link.enclosingNodeOrSelfWithNodeName('li');
if (!listItem) {
return false;
}
const node = /** @type {!Elements.ElementsTreeElement} */ (listItem.treeElement).node();
const precomputedFeatures = await Components.ImagePreview.loadDimensionsForNode(node);
const preview = await Components.ImagePreview.build(