Closed Bug 1676671 Opened 4 years ago Closed 3 years ago

Refactor registration of browsers

Categories

(Remote Protocol :: Marionette, task, P2)

Default
task

Tracking

(Fission Milestone:M7, firefox85 fixed)

RESOLVED FIXED
85 Branch
Fission Milestone M7
Tracking Status
firefox85 --- fixed

People

(Reporter: whimboo, Assigned: jdescottes)

References

Details

(Whiteboard: [marionette-fission-mvp])

Attachments

(4 files, 2 obsolete files)

Currently the initial registration of browsers as done in WebDriver:NewSession is backed by Promises using the message manager from the framescript. When we want to stop running the framescript, that code needs to be refactored or at least conditionally executed if actors aren't enabled.

When actors are enabled we have to find a new way to register all open browsers. Given that actors are no longer immediately created we have no messages coming in from all the existent browsers anymore like for framescripts. So we need a different way in registering those.

In a proof of concept the following code actually works for content browsers as part of open tabs:

  if (MarionettePrefs.useActors) {
    for (let win of this.windows) {
      const tabBrowser = browser.getTabBrowser(win);
      for (const tab of tabBrowser.tabs) {
        const contentBrowser = browser.getBrowserForTab(tab);
        this.registerBrowser(contentBrowser.browsingContext.id, contentBrowser);
      }
    }
  } else {
    await registerBrowsers;
    await browserListening;
  }

But it misses remote browsers outside of tabs (note: we don't support those anyway right now).

Priority: P3 → P2

Tracking marionette-fission-mvp bugs for Fission Beta milestone (M7).

Fission Milestone: --- → M7
Assignee: nobody → jdescottes
Status: NEW → ASSIGNED

Note that this also needs an update within setWindowHandle(). Sorry that I missed that before.

Here the appropriate PoC:

    if (!MarionettePrefs.useActors) {
      if (registerBrowsers && browserListening) {
        await registerBrowsers;
        const id = await browserListening;
        this.contentBrowsingContext = BrowsingContext.get(id);
      } else {
        this.contentBrowsingContext = null;
      }
    } else {
      if (winProperties.hasTabBrowser) {
        const tabBrowser = browser.getTabBrowser(winProperties.win);
        const contentBrowser = tabBrowser.selectedBrowser;
        logger.trace(pprint`** content browser: ${contentBrowser}`);
        this.contentBrowsingContext = contentBrowser.browsingContext;
        logger.trace(pprint`** content browsing context: ${this.contentBrowsingContext.id}`);

        this.registerBrowser(this.contentBrowsingContext.id, contentBrowser);
      } else {
        this.contentBrowsingContext = null;
      }

It actually would be good to do some more refactoring especially for registerBrowser(), which actually only needs the content browser to be passed over. The browsing context id it could automatically determine.

Summary: Refactor initial registration of browsers → Refactor registration of browsers
Status: ASSIGNED → NEW
Assignee: jdescottes → nobody

Previously unassigned myself because I was busy with DevTools tasks, which I should have mentioned here.
I cleared up my DevTools queue, so I am able to work on this now.

Assignee: nobody → jdescottes
Status: NEW → ASSIGNED
Attachment #9191326 - Attachment description: Bug 1676671 - [marionette] Stop emitting Marionette:Register from the framescript when using JSWindowActors → Bug 1676671 - [marionette] Stop listening to Marionette:Register when using JSWindowActors
Attachment #9191326 - Attachment is obsolete: true
Pushed by jdescottes@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/efa50f96f8ac
[marionette] Register browsers without framescript events when using JSWindowActors r=marionette-reviewers,maja_zf,whimboo
https://hg.mozilla.org/integration/autoland/rev/68192555c760
[marionette] Refactor driver::registerBrowser and browser::register to infer id from browser element r=marionette-reviewers,maja_zf,whimboo
https://hg.mozilla.org/integration/autoland/rev/94f71a0d5ee5
[marionette] Remove unused knownFrames array from browser.js r=marionette-reviewers,maja_zf
https://hg.mozilla.org/integration/autoland/rev/e8d3e51c0440
[marionette] Remove unused return value from driver::registerBrowser r=marionette-reviewers,maja_zf

Julian, this is caused by a remoteness change. That part I recently mentioned on the reviews:
https://treeherder.mozilla.org/logviewer?job_id=324171355&repo=autoland&lineNumber=1963

I assume we miss to update a browser entry for the correct top-level browsing context. Can you add a new Mn unit test for it please?

(In reply to Henrik Skupin (:whimboo) [⌚️UTC+2] (away 12/07 - 12/11) from comment #12)

Julian, this is caused by a remoteness change. That part I recently mentioned on the reviews:
https://treeherder.mozilla.org/logviewer?job_id=324171355&repo=autoland&lineNumber=1963

I assume we miss to update a browser entry for the correct top-level browsing context. Can you add a new Mn unit test for it please?

Thanks for the heads up. I believe we need to update the registered id when we detect a remoteness change, around https://searchfox.org/mozilla-central/rev/4415bec7a49c50a338167d9c8934527b9cae59d0/testing/marionette/driver.js#921

A local quick fix seems to take care of the test failure. I'll write a test for it tomorrow.

Flags: needinfo?(jdescottes)
Depends on: 1681885
Blocks: 1681968
Blocks: 1681973
Attachment #9192648 - Attachment is obsolete: true
Whiteboard: [marionette-fission-mvp] → [marionette-fission-reserve]
Pushed by jdescottes@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/18bbd9323bc9
[marionette] Register browsers without framescript events when using JSWindowActors r=marionette-reviewers,maja_zf,whimboo
https://hg.mozilla.org/integration/autoland/rev/a0f2b8899193
[marionette] Refactor driver::registerBrowser and browser::register to infer id from browser element r=marionette-reviewers,maja_zf,whimboo
https://hg.mozilla.org/integration/autoland/rev/8852c35eb897
[marionette] Remove unused knownFrames array from browser.js r=marionette-reviewers,maja_zf
https://hg.mozilla.org/integration/autoland/rev/95cb222955ef
[marionette] Remove unused return value from driver::registerBrowser r=marionette-reviewers,maja_zf
Regressions: 1682116
Whiteboard: [marionette-fission-reserve] → [marionette-fission-mvp]
Regressions: 1682242
Regressions: 1682768
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: