[tbb-commits] [Git][tpo/applications/tor-browser][tor-browser-115.10.0esr-13.5-1] 2 commits: fixup! Bug 31286: Implementation of bridge, proxy, and firewall settings in...

Pier Angelo Vendrame (@pierov) git at gitlab.torproject.org
Mon Apr 22 07:22:27 UTC 2024



Pier Angelo Vendrame pushed to branch tor-browser-115.10.0esr-13.5-1 at The Tor Project / Applications / Tor Browser


Commits:
a9c02248 by Henry Wilkes at 2024-04-22T07:22:05+00:00
fixup! Bug 31286: Implementation of bridge, proxy, and firewall settings in about:preferences#connection

Bug 42533: Only update the internal loxId *after* the Lox.activeLoxId
has changed. In particular, we want to ensure that the data associated
with the new loxId (invites and event data) is set before we fetch them.

- - - - -
4006866f by Henry Wilkes at 2024-04-22T07:22:05+00:00
fixup! Lox integration

Bug 42533: Add notification for when the activeLoxId changes.

- - - - -


3 changed files:

- browser/components/torpreferences/content/connectionPane.js
- browser/components/torpreferences/content/loxInviteDialog.js
- toolkit/components/lox/Lox.sys.mjs


Changes:

=====================================
browser/components/torpreferences/content/connectionPane.js
=====================================
@@ -1317,6 +1317,7 @@ const gLoxStatus = {
     });
 
     Services.obs.addObserver(this, TorSettingsTopics.SettingsChanged);
+    Services.obs.addObserver(this, LoxTopics.UpdateActiveLoxId);
     Services.obs.addObserver(this, LoxTopics.UpdateEvents);
     Services.obs.addObserver(this, LoxTopics.UpdateNextUnlock);
     Services.obs.addObserver(this, LoxTopics.UpdateRemainingInvites);
@@ -1333,6 +1334,7 @@ const gLoxStatus = {
    */
   uninit() {
     Services.obs.removeObserver(this, TorSettingsTopics.SettingsChanged);
+    Services.obs.removeObserver(this, LoxTopics.UpdateActiveLoxId);
     Services.obs.removeObserver(this, LoxTopics.UpdateEvents);
     Services.obs.removeObserver(this, LoxTopics.UpdateNextUnlock);
     Services.obs.removeObserver(this, LoxTopics.UpdateRemainingInvites);
@@ -1343,12 +1345,17 @@ const gLoxStatus = {
     switch (topic) {
       case TorSettingsTopics.SettingsChanged:
         const { changes } = subject.wrappedJSObject;
-        if (
-          changes.includes("bridges.source") ||
-          changes.includes("bridges.lox_id")
-        ) {
+        if (changes.includes("bridges.source")) {
           this._updateLoxId();
         }
+        // NOTE: We do not call _updateLoxId when "bridges.lox_id" is in the
+        // changes. Instead we wait until LoxTopics.UpdateActiveLoxId to ensure
+        // that the Lox module has responded to the change in ID strictly
+        // *before* we do. In particular, we want to make sure the invites and
+        // event data has been cleared.
+        break;
+      case LoxTopics.UpdateActiveLoxId:
+        this._updateLoxId();
         break;
       case LoxTopics.UpdateNextUnlock:
         this._updateNextUnlock();
@@ -1378,9 +1385,7 @@ const gLoxStatus = {
    */
   async _updateLoxId() {
     let loxId =
-      TorSettings.bridges.source === TorBridgeSource.Lox
-        ? TorSettings.bridges.lox_id
-        : "";
+      TorSettings.bridges.source === TorBridgeSource.Lox ? Lox.activeLoxId : "";
     if (loxId === this._loxId) {
       return;
     }


=====================================
browser/components/torpreferences/content/loxInviteDialog.js
=====================================
@@ -104,6 +104,7 @@ const gLoxInvites = {
     // NOTE: TorSettings should already be initialized when this dialog is
     // opened.
     Services.obs.addObserver(this, TorSettingsTopics.SettingsChanged);
+    Services.obs.addObserver(this, LoxTopics.UpdateActiveLoxId);
     Services.obs.addObserver(this, LoxTopics.UpdateRemainingInvites);
     Services.obs.addObserver(this, LoxTopics.NewInvite);
 
@@ -119,6 +120,7 @@ const gLoxInvites = {
    */
   uninit() {
     Services.obs.removeObserver(this, TorSettingsTopics.SettingsChanged);
+    Services.obs.removeObserver(this, LoxTopics.UpdateActiveLoxId);
     Services.obs.removeObserver(this, LoxTopics.UpdateRemainingInvites);
     Services.obs.removeObserver(this, LoxTopics.NewInvite);
   },
@@ -127,13 +129,13 @@ const gLoxInvites = {
     switch (topic) {
       case TorSettingsTopics.SettingsChanged:
         const { changes } = subject.wrappedJSObject;
-        if (
-          changes.includes("bridges.source") ||
-          changes.includes("bridges.lox_id")
-        ) {
+        if (changes.includes("bridges.source")) {
           this._updateLoxId();
         }
         break;
+      case LoxTopics.UpdateActiveLoxId:
+        this._updateLoxId();
+        break;
       case LoxTopics.UpdateRemainingInvites:
         this._updateRemainingInvites();
         break;
@@ -155,9 +157,7 @@ const gLoxInvites = {
    */
   _updateLoxId() {
     const loxId =
-      TorSettings.bridges.source === TorBridgeSource.Lox
-        ? TorSettings.bridges.lox_id
-        : "";
+      TorSettings.bridges.source === TorBridgeSource.Lox ? Lox.activeLoxId : "";
     if (!loxId || (this._loxId !== null && loxId !== this._loxId)) {
       // No lox id, or it changed. Close this dialog.
       this._dialog.cancelDialog();


=====================================
toolkit/components/lox/Lox.sys.mjs
=====================================
@@ -55,6 +55,8 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
 });
 
 export const LoxTopics = Object.freeze({
+  // Whenever the activeLoxId value changes.
+  UpdateActiveLoxId: "lox:update-active-lox-id",
   // Whenever the bridges *might* have changed.
   // getBridges only uses #credentials, so this will only fire when it changes.
   UpdateBridges: "lox:update-bridges",
@@ -141,6 +143,10 @@ class LoxImpl {
    */
   #activeLoxId = null;
 
+  get activeLoxId() {
+    return this.#activeLoxId;
+  }
+
   /**
    * Update the active lox id.
    */
@@ -164,6 +170,8 @@ class LoxImpl {
       this.#store();
     }
     this.#activeLoxId = loxId;
+
+    Services.obs.notifyObservers(null, LoxTopics.UpdateActiveLoxId);
   }
 
   observe(subject, topic, data) {



View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/00e009df2d38975ffa60f64a6fd8e9d4e60787a7...4006866f6958a8a127496203bcb90011fecbbd9e

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/00e009df2d38975ffa60f64a6fd8e9d4e60787a7...4006866f6958a8a127496203bcb90011fecbbd9e
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/20240422/a091ebd5/attachment-0001.htm>


More information about the tbb-commits mailing list