Commit 73923d06 authored by Agi Sferro's avatar Agi Sferro
Browse files

Bug 1673316 - Ensure docShellIsActive is preserved when switching process. r=snorp

I'm not a fan of accessing private bits like `docShellIsActive` in tests like
that but it's both:

1) very important, if we don't correctly activate docShell performance will be
   very poor

2) stable, this API is not likely to change, and if it changes it
   should be easy to get whatever the replacement is

Differential Revision: https://phabricator.services.mozilla.com/D94874
parent c8201ae6
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -186,9 +186,18 @@ var ModuleManager = {
    this.forEach(module => {
    this.forEach(module => {
      module.onDestroyBrowser();
      module.onDestroyBrowser();
    });
    });

    // TODO: Bug 1673683: `docShellIsActive` is sometimes not preserved when
    // switching process.
    this.docShellIsActiveWhileSwitchingProcess = this.browser.docShellIsActive;
  },
  },


  didChangeBrowserRemoteness() {
  didChangeBrowserRemoteness() {
    debug`DidChangeBrowserRemoteness`;

    this.browser.docShellIsActive = this.docShellIsActiveWhileSwitchingProcess;
    this.docShellIsActiveWhileSwitchingProcess = undefined;

    this.forEach(module => {
    this.forEach(module => {
      if (module.impl) {
      if (module.impl) {
        module.impl.onInitBrowser();
        module.impl.onInitBrowser();
+3 −0
Original line number Original line Diff line number Diff line
@@ -23,6 +23,9 @@ const APIS = {
  GetPrefs({ prefs }) {
  GetPrefs({ prefs }) {
    return browser.test.getPrefs(prefs);
    return browser.test.getPrefs(prefs);
  },
  },
  GetActive({ tab }) {
    return browser.test.getActive(tab.id);
  },
  RemoveCertOverride({ host, port }) {
  RemoveCertOverride({ host, port }) {
    browser.test.removeCertOverride(host, port);
    browser.test.removeCertOverride(host, port);
  },
  },
+5 −0
Original line number Original line Diff line number Diff line
@@ -180,6 +180,11 @@ this.test = class extends ExtensionAPI {
          });
          });
        },
        },


        async getActive(tabId) {
          const tab = context.extension.tabManager.get(tabId);
          return tab.browser.docShellIsActive;
        },

        async flushApzRepaints(tabId) {
        async flushApzRepaints(tabId) {
          const tab = context.extension.tabManager.get(tabId);
          const tab = context.extension.tabManager.get(tabId);
          const { browsingContext } = tab.browser;
          const { browsingContext } = tab.browser;
+12 −0
Original line number Original line Diff line number Diff line
@@ -133,6 +133,18 @@
          }
          }
        ]
        ]
      },
      },
      {
        "name": "getActive",
        "type": "function",
        "async": true,
        "description": "Returns true if the docShell is active for given tab.",
        "parameters": [
          {
            "type": "number",
            "name": "tabId"
          }
        ]
      },
      {
      {
        "name": "getPidForTab",
        "name": "getPidForTab",
        "type": "function",
        "type": "function",
+4 −0
Original line number Original line Diff line number Diff line
@@ -191,6 +191,10 @@ open class BaseSessionTest(noErrorCollector: Boolean = false) {


    fun GeckoSession.flushApzRepaints() = sessionRule.flushApzRepaints(this)
    fun GeckoSession.flushApzRepaints() = sessionRule.flushApzRepaints(this)


    var GeckoSession.active: Boolean
            get() = sessionRule.getActive(this)
            set(value) = setActive(value)

    @Suppress("UNCHECKED_CAST")
    @Suppress("UNCHECKED_CAST")
    fun Any?.asJsonArray(): JSONArray = this as JSONArray
    fun Any?.asJsonArray(): JSONArray = this as JSONArray


Loading