Commit 48c08d86 authored by Nicolas Chevobbe's avatar Nicolas Chevobbe
Browse files

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
parent d70c24af
Loading
Loading
Loading
Loading
+5 −20
Original line number Diff line number Diff line
@@ -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);
  }