Closed Bug 1774436 Opened 3 years ago Closed 2 months ago

Move the private "#getBrowsingContext" helper method to the RootBiDiModule class

Categories

(Remote Protocol :: WebDriver BiDi, task, P2)

task
Points:
2

Tracking

(firefox146 fixed)

RESOLVED FIXED
146 Branch
Tracking Status
firefox146 --- fixed

People

(Reporter: jdescottes, Assigned: whimboo)

References

Details

(Whiteboard: [webdriver:m18])

Attachments

(1 file)

We currently have a private helper in the root browsingContext module for BiDi which follows https://w3c.github.io/webdriver-bidi/#get-a-browsing-context: https://searchfox.org/mozilla-central/source/remote/webdriver-bidi/modules/root/browsingContext.jsm#429-454

  /**
   * Retrieves a browsing context based on its id.
   *
   * @param {Number} contextId
   *     Id of the browsing context.
   * @returns {BrowsingContext=}
   *     The browsing context or null if <var>contextId</var> is null.
   * @throws {NoSuchFrameError}
   *     If the browsing context cannot be found.
   */
  #getBrowsingContext(contextId) {
    // The WebDriver BiDi specification expects null to be
    // returned if no browsing context id has been specified.
    if (contextId === null) {
      return null;
    }

    const context = lazy.TabManager.getBrowsingContextById(contextId);
    if (context === null) {
      throw new lazy.error.NoSuchFrameError(
        `Browsing Context with id ${contextId} not found`
      );
    }

    return context;
  }

Getting a browsing context is useful for commands outside of the browsingContext module (eg it's part of getting a realm from a target, relevant in the script module). It would make sense to extract it as a shared helper. To be clear this should probably not be in a BiDi MessageHandler module, but rather in a regular jsm so that we can use the helper with minimal overhead anywhere in the webdriver-bidi codebase.

Points: --- → 1
Priority: -- → P3

This method should actually be moved to the RootBiDiModule.sys.mjs module so that it can be used by all the different WebDriver BiDi root modules without having to specify it in each of these modules as what we do these days.

I would like to have it for bug 1944568 so that we can specify which commands are allowed to run in the parent process and have this check at a single location.

Blocks: 1944568
Assignee: nobody → hskupin
Status: NEW → ASSIGNED
Summary: Move browsingContext #getBrowsingContext to a shared helper → Move the private "#getBrowsingContext" helper method to the RootBiDiModule class
Points: 1 → 2
Priority: P3 → P2
Whiteboard: [webdriver:m18]
Pushed by hskupin@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/2dd7e21d0a0c https://hg.mozilla.org/integration/autoland/rev/1cdd7a456f2b [webdriver-bidi] Move the private "#getBrowsingContext" helper method to the RootBiDiModule class. r=jdescottes
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 146 Branch
Blocks: 1851788
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: