diff --git a/devtools/client/framework/devtools.js b/devtools/client/framework/devtools.js index 359de0d80b31..f157c7731158 100644 --- a/devtools/client/framework/devtools.js +++ b/devtools/client/framework/devtools.js @@ -729,10 +729,6 @@ DevTools.prototype = { ); 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 // browser is remote or not. const onNewNode = inspector.selection.once("new-node-front"); diff --git a/devtools/shared/fronts/walker.js b/devtools/shared/fronts/walker.js index 4e393a58602f..4b9885cff752 100644 --- a/devtools/shared/fronts/walker.js +++ b/devtools/shared/fronts/walker.js @@ -507,6 +507,15 @@ class WalkerFront extends FrontClassWithSpec(walkerSpec) { return querySelectors(nodeFront); }; 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); } }