[tbb-commits] [Git][tpo/applications/tor-browser][tor-browser-115.9.0esr-13.5-1] Bug 1886852 - Avoid registering unnecessary MessageManager listeners when SHIP is enabled, r=smaug!

ma1 (@ma1) git at gitlab.torproject.org
Fri Mar 22 08:24:55 UTC 2024



ma1 pushed to branch tor-browser-115.9.0esr-13.5-1 at The Tor Project / Applications / Tor Browser


Commits:
b7fc915f by Nika Layzell at 2024-03-21T22:41:17+01:00
Bug 1886852 - Avoid registering unnecessary MessageManager listeners when SHIP is enabled, r=smaug!

Differential Revision: https://phabricator.services.mozilla.com/D205377
- - - - -


1 changed file:

- browser/components/sessionstore/SessionStore.sys.mjs


Changes:

=====================================
browser/components/sessionstore/SessionStore.sys.mjs
=====================================
@@ -1422,6 +1422,13 @@ var SessionStoreInternal = {
    * and thus enables communication with OOP tabs.
    */
   receiveMessage(aMessage) {
+    if (Services.appinfo.sessionHistoryInParent) {
+      throw new Error(
+        `received unexpected message '${aMessage.name}' with ` +
+          `sessionHistoryInParent enabled`
+      );
+    }
+
     // If we got here, that means we're dealing with a frame message
     // manager message, so the target will be a <xul:browser>.
     var browser = aMessage.target;
@@ -1600,14 +1607,14 @@ var SessionStoreInternal = {
     // internal data about the window.
     aWindow.__SSi = this._generateWindowID();
 
-    let mm = aWindow.getGroupMessageManager("browsers");
-    MESSAGES.forEach(msg => {
-      let listenWhenClosed = CLOSED_MESSAGES.has(msg);
-      mm.addMessageListener(msg, this, listenWhenClosed);
-    });
-
-    // Load the frame script after registering listeners.
     if (!Services.appinfo.sessionHistoryInParent) {
+      let mm = aWindow.getGroupMessageManager("browsers");
+      MESSAGES.forEach(msg => {
+        let listenWhenClosed = CLOSED_MESSAGES.has(msg);
+        mm.addMessageListener(msg, this, listenWhenClosed);
+      });
+
+      // Load the frame script after registering listeners.
       mm.loadFrameScript(
         "chrome://browser/content/content-sessionStore.js",
         true,
@@ -2083,8 +2090,10 @@ var SessionStoreInternal = {
     // Cache the window state until it is completely gone.
     DyingWindowCache.set(aWindow, winData);
 
-    let mm = aWindow.getGroupMessageManager("browsers");
-    MESSAGES.forEach(msg => mm.removeMessageListener(msg, this));
+    if (!Services.appinfo.sessionHistoryInParent) {
+      let mm = aWindow.getGroupMessageManager("browsers");
+      MESSAGES.forEach(msg => mm.removeMessageListener(msg, this));
+    }
 
     this._saveableClosedWindowData.delete(winData);
     delete aWindow.__SSi;



View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/b7fc915f3ed100830bd8574a62f9cd653c1ec250

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/b7fc915f3ed100830bd8574a62f9cd653c1ec250
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tbb-commits/attachments/20240322/d8c530da/attachment-0001.htm>


More information about the tbb-commits mailing list