[tbb-commits] [torbutton/maint-1.9.7] Bug 22989: Fix dimensions of new windows on macOS.

gk at torproject.org gk at torproject.org
Wed Aug 23 12:34:08 UTC 2017


commit 6aa6d6ef1355179d7198f0eb09405ac0968ba4e7
Author: Arthur Edelstein <arthuredelstein at gmail.com>
Date:   Mon Aug 14 15:56:00 2017 -0700

    Bug 22989: Fix dimensions of new windows on macOS.
    
    Before this patch, a new Tor Browser window, non-maximized,
    was showing a "don't maximize this window" notification briefly
    as soon as it was first displayed. Worse, the notification box
    that appears causes the window height to increase by 10 or 11
    pixels and thus breaks our desired window dimension rounding.
    
    Our intended behavior is that this notification only be shown
    when the window is maximized by the user. I discovered that,
    on macOS, windowState === window.STATE_MAXIMIZED for a short
    time when the window is first created. Then it rapidly changes
    to windowState === window.STATE_NORMAL. So I added a `setTimeout`
    promise to postpone checking the window size until after
    window creation "settles" and that seems to be enough to ensure
    we avoid showing the spurious notification box at window
    creation.
    
    Also fixes Bug 22543, "Tor Browser 7.0 shows window
    resize warning on every new window for a few seconds". And
    fixes issues raised in comments 2 and 3 in that ticket as well.
---
 src/chrome/content/torbutton.js | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 0c297aa..11f4b61 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -2123,7 +2123,9 @@ var torbutton_resizelistener =
   onLocationChange: function(aProgress, aRequest, aURI) {},
   onStateChange: function(aProgress, aRequest, aFlag, aStatus) {
     if (aFlag & Ci.nsIWebProgressListener.STATE_STOP) {
-      m_tb_resize_handler = function() {
+      m_tb_resize_handler = async function() {
+        // Wait for end of execution queue to ensure we have correct windowState.
+        await new Promise(resolve => setTimeout(resolve, 0));
         if (window.windowState === 1) {
           if (m_tb_prefs.
               getIntPref("extensions.torbutton.maximize_warnings_remaining") > 0) {



More information about the tbb-commits mailing list