[tbb-commits] [Git][tpo/applications/tor-browser][base-browser-102.9.0esr-12.5-1] fixup! Bug 40926: Implemented the New Identity feature

Pier Angelo Vendrame (@pierov) git at gitlab.torproject.org
Tue Apr 4 09:52:01 UTC 2023



Pier Angelo Vendrame pushed to branch base-browser-102.9.0esr-12.5-1 at The Tor Project / Applications / Tor Browser


Commits:
adbf9acf by Pier Angelo Vendrame at 2023-04-04T09:51:56+00:00
fixup! Bug 40926: Implemented the New Identity feature

Bug 41711: Wait for the new window when doing new identity


(cherry picked from commit d23d3f2cf3cc5cb1d9895108b67489314501dd20)
- - - - -


1 changed file:

- browser/components/newidentity/content/newidentity.js


Changes:

=====================================
browser/components/newidentity/content/newidentity.js
=====================================
@@ -57,6 +57,7 @@ XPCOMUtils.defineLazyGetter(this, "NewIdentityButton", () => {
     );
     const consoleOptions = {
       maxLogLevel: "info",
+      maxLogLevelPref: "browser.new_identity.log_level",
       prefix: "NewIdentity",
     };
     return new ConsoleAPI(consoleOptions);
@@ -68,12 +69,11 @@ XPCOMUtils.defineLazyGetter(this, "NewIdentityButton", () => {
 
   class NewIdentityImpl {
     async run() {
-      logger.debug("Disabling JS");
       this.disableAllJS();
       await this.clearState();
-      this.broadcast();
-      this.openNewWindow();
+      await this.openNewWindow();
       this.closeOldWindow();
+      this.broadcast();
     }
 
     // Disable JS (as a defense-in-depth measure)
@@ -389,7 +389,7 @@ XPCOMUtils.defineLazyGetter(this, "NewIdentityButton", () => {
       logger.info("Calling the clearDataService");
       const flags =
         Services.clearData.CLEAR_ALL ^ Services.clearData.CLEAR_PASSWORDS;
-      return new Promise((resolve, reject) => {
+      return new Promise(resolve => {
         Services.clearData.deleteData(flags, {
           onDataDeleted(code) {
             if (code !== Cr.NS_OK) {
@@ -425,11 +425,16 @@ XPCOMUtils.defineLazyGetter(this, "NewIdentityButton", () => {
 
     openNewWindow() {
       logger.info("Opening a new window");
-      // Open a new window with the default homepage
-      // We could pass {private: true} but we do not because we enforce
-      // browser.privatebrowsing.autostart = true.
-      // What about users that change settings?
-      OpenBrowserWindow();
+      return new Promise(resolve => {
+        // Open a new window with the default homepage
+        // We could pass {private: true} but we do not because we enforce
+        // browser.privatebrowsing.autostart = true.
+        // What about users that change settings?
+        const win = OpenBrowserWindow();
+        // This mechanism to know when the new window is ready is used by
+        // OpenBrowserWindow itself (see its definition in browser.js).
+        win.addEventListener("MozAfterPaint", () => resolve(), { once: true });
+      });
     }
 
     closeOldWindow() {



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

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/adbf9acfde8816fabf7f103c5ad9fae34fcd0d46
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/20230404/b6a47e22/attachment-0001.htm>


More information about the tbb-commits mailing list