Closed Bug 1601161 Opened 6 years ago Closed 5 years ago

Remove unnecessary domain instance checks after "domains.get()"

Categories

(Remote Protocol :: Agent, enhancement, P3)

enhancement

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: impossibus, Unassigned, Mentored)

Details

(Whiteboard: [lang=js])

User Story

Check the following URL to get familiar with the remote agent:
https://firefox-source-docs.mozilla.org/remote/index.html

We see a pattern in Domain subclass code like:

 const Runtime = this.session.domains.get("Runtime");
    if (!Runtime) {
      throw new Error("Runtime domain is not instantiated");
    }

To avoid repetition, we could throw the error directly in Domains.get

Actually while working on the new IO domain I had to debug exactly this get() method yesterday. And at the moment we actually implicitly create a new instance of the domain if none is available yet for the given session. If instantiation fails get() will throw an error itself. As such we won't need this extra check at all. Means we can remove it from everywhere it has been added.

Here the locations that need to be checked:
https://searchfox.org/mozilla-central/search?q=domains.get&case=false&regexp=false&path=remote%2F

Mentor: hskupin
User Story: (updated)
Summary: Throw error if a domain is not instantiated → Remove unnecessary domain instance checks after "domains.get()"
Whiteboard: [lang=js]

I'm new to open source. Can I be assigned to this bug?

Feel free to work on this bug. When you upload a patch the bug will automatically be assigned to you. Check the user story field and the link in how to get started.

I've looked at the user story but I'm still don't know what changes I have to make. Can you guide me?

Oh, that's interesting. As it looks like we actually fixed that already with some other patch, so that none of the formerly mentioned instances (see my comment 1) have this extra check. Sorry for taking your time here.

If you are interested in a different bug, there is bug 1631570, which is a good starter.

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.