Bug 1590050 - Walker findNodeFront should use selectors relevant to its rootNode r=rcaliman

Depends on D49939

Small fix on the findNodeFront helper. The walker should be able to calculate its depth without relying on consumers to remove selectors from the array passed to findNodeFront.

Differential Revision: https://phabricator.services.mozilla.com/D49940

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Julian Descottes 2019-10-27 15:53:07 +00:00
Родитель 00444e4c1d
Коммит ffb4c71377
2 изменённых файлов: 9 добавлений и 4 удалений

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

@ -729,10 +729,6 @@ DevTools.prototype = {
); );
const inspector = toolbox.getCurrentPanel(); const inspector = toolbox.getCurrentPanel();
// If the toolbox has been switched into a nested frame, we should first remove
// selectors according to the frame depth.
nodeSelectors.splice(0, toolbox.selectedFrameDepth);
// new-node-front tells us when the node has been selected, whether the // new-node-front tells us when the node has been selected, whether the
// browser is remote or not. // browser is remote or not.
const onNewNode = inspector.selection.once("new-node-front"); const onNewNode = inspector.selection.once("new-node-front");

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

@ -507,6 +507,15 @@ class WalkerFront extends FrontClassWithSpec(walkerSpec) {
return querySelectors(nodeFront); return querySelectors(nodeFront);
}; };
const nodeFront = await this.getRootNode(); const nodeFront = await this.getRootNode();
// Check the "depth" of the walker.
// The `nodeSelectors` array starts from the topmost document, if the walker
// is targetting a nested iframe, the selectors needed to reach this iframe
// need to be excluded from the query.
const rootFrontSelectors = await nodeFront.getAllSelectors();
const walkerDepth = rootFrontSelectors.length - 1;
nodeSelectors.splice(0, walkerDepth);
return querySelectors(nodeFront); return querySelectors(nodeFront);
} }
} }