Bug 1733039 - [devtools] Fix walkerFront#findNodeFront method for EFT/Fission. r=ochameau.

The top-level target walker was used to find elements, where we should use the
walker front of the nodeFront we have at hand.
The function was also checking if the node we're searching was associated with
this walker, which, with EFT, won't be the case as soon as we have to go through
an iframe.

Differential Revision: https://phabricator.services.mozilla.com/D126909
This commit is contained in:
Nicolas Chevobbe 2021-10-04 06:10:51 +00:00
Родитель dba9e436d3
Коммит edccb66d0f
1 изменённых файлов: 5 добавлений и 20 удалений

Просмотреть файл

@ -407,10 +407,12 @@ class WalkerFront extends FrontClassWithSpec(walkerSpec) {
if (!selector) {
return nodeFront;
}
nodeFront = await this.querySelector(nodeFront, selector);
nodeFront = await nodeFront.walkerFront.querySelector(
nodeFront,
selector
);
// It's possible the containing iframe isn't available by the time
// this.querySelector is called, which causes the re-selected node to be
// walkerFront.querySelector is called, which causes the re-selected node to be
// unavailable. There also isn't a way for us to know when all iframes on the page
// have been created after a reload. Because of this, we should should bail here.
if (!nodeFront) {
@ -444,23 +446,6 @@ class WalkerFront extends FrontClassWithSpec(walkerSpec) {
return querySelectors(nodeFront) || nodeFront;
};
const nodeFront = await this.getRootNode();
// If rootSelectors are [frameSelector1, ..., frameSelectorN, rootSelector]
// we expect that [frameSelector1, ..., frameSelectorN] will also be in
// nodeSelectors.
// Otherwise it means the nodeSelectors target a node outside of this walker
// and we should return null.
const rootFrontSelectors = await nodeFront.getAllSelectors();
for (let i = 0; i < rootFrontSelectors.length - 1; i++) {
if (rootFrontSelectors[i] !== nodeSelectors[i]) {
return null;
}
}
// The query will start from the walker's rootNode, remove all the
// "frameSelectors".
nodeSelectors.splice(0, rootFrontSelectors.length - 1);
return querySelectors(nodeFront);
}