Commit 548bf863 authored by Julian Descottes's avatar Julian Descottes
Browse files

Bug 1832028 - [bidi] Throw NoSuchElement if ElementOrigin's node is not an...

Bug 1832028 - [bidi] Throw NoSuchElement if ElementOrigin's node is not an element r=webdriver-reviewers,whimboo

At the moment the actions module would already throw an InvalidArgument error, but for BiDi we want explicitly to throw NoSuchElement in this case.

Differential Revision: https://phabricator.services.mozilla.com/D178185
parent 90a78fbb
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
  action: "chrome://remote/content/shared/webdriver/Actions.sys.mjs",
  deserialize: "chrome://remote/content/webdriver-bidi/RemoteValue.sys.mjs",
  element: "chrome://remote/content/marionette/element.sys.mjs",
  error: "chrome://remote/content/shared/webdriver/Errors.sys.mjs",
});

@@ -85,9 +86,17 @@ class InputModule extends WindowGlobalBiDiModule {
    }

    const realm = this.messageHandler.getRealm();
    return lazy.deserialize(realm, sharedReference, {

    const element = lazy.deserialize(realm, sharedReference, {
      nodeCache: this.nodeCache,
    });
    if (!lazy.element.isElement(element)) {
      throw new lazy.error.NoSuchElementError(
        `No element found for shared id: ${sharedReference.sharedId}`
      );
    }

    return element;
  }
}