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

Commits:

1 changed file:

Changes:

  • toolkit/torbutton/chrome/content/torbutton.js
    ... ... @@ -871,6 +871,13 @@ var torbutton_new_circuit;
    871 871
         onLocationChange(aProgress, aRequest, aURI) {},
    
    872 872
         onStateChange(aProgress, aRequest, aFlag, aStatus) {
    
    873 873
           if (aFlag & Ci.nsIWebProgressListener.STATE_STOP) {
    
    874
    +        window.promiseDocumentFlushed(() => {
    
    875
    +          // Here we're guaranteed to read the "final" (!) initial size, rather than [1, 1].
    
    876
    +          torbutton_resizelistener.originalSize = {
    
    877
    +            width: window.outerWidth,
    
    878
    +            height: window.outerHeight,
    
    879
    +          };
    
    880
    +        });
    
    874 881
             m_tb_resize_handler = async function() {
    
    875 882
               // Wait for end of execution queue to ensure we have correct windowState.
    
    876 883
               await new Promise(resolve => setTimeout(resolve, 0));
    
    ... ... @@ -878,17 +885,18 @@ var torbutton_new_circuit;
    878 885
                 window.windowState === window.STATE_MAXIMIZED ||
    
    879 886
                 window.windowState === window.STATE_FULLSCREEN
    
    880 887
               ) {
    
    888
    +            const kRemainingWarnings =
    
    889
    +              "extensions.torbutton.maximize_warnings_remaining";
    
    881 890
                 if (
    
    882
    -              m_tb_prefs.getBoolPref(
    
    891
    +              Services.prefs.getBoolPref(
    
    883 892
                     "extensions.torbutton.resize_new_windows"
    
    884 893
                   ) &&
    
    885
    -              m_tb_prefs.getIntPref(
    
    886
    -                "extensions.torbutton.maximize_warnings_remaining"
    
    887
    -              ) > 0
    
    894
    +              Services.prefs.getIntPref(kRemainingWarnings) > 0
    
    888 895
                 ) {
    
    889 896
                   // Do not add another notification if one is already showing.
    
    890 897
                   const kNotificationName = "torbutton-maximize-notification";
    
    891
    -              let box = gBrowser.getNotificationBox();
    
    898
    +
    
    899
    +              const box = gNotificationBox;
    
    892 900
                   if (box.getNotificationWithValue(kNotificationName)) {
    
    893 901
                     return;
    
    894 902
                   }
    
    ... ... @@ -908,38 +916,53 @@ var torbutton_new_circuit;
    908 916
                   }
    
    909 917
     
    
    910 918
                   // No need to get "OK" translated again.
    
    911
    -              let sbSvc = Services.strings;
    
    912
    -              let bundle = sbSvc.createBundle(
    
    919
    +              const bundle = Services.strings.createBundle(
    
    913 920
                     "chrome://global/locale/commonDialogs.properties"
    
    914 921
                   );
    
    915
    -              let button_label = bundle.GetStringFromName("OK");
    
    922
    +
    
    923
    +              const decreaseWarningsCount = () => {
    
    924
    +                const currentCount = Services.prefs.getIntPref(
    
    925
    +                  kRemainingWarnings
    
    926
    +                );
    
    927
    +                if (currentCount > 0) {
    
    928
    +                  Services.prefs.setIntPref(
    
    929
    +                    kRemainingWarnings,
    
    930
    +                    currentCount - 1
    
    931
    +                  );
    
    932
    +                }
    
    933
    +              };
    
    916 934
     
    
    917 935
                   let buttons = [
    
    918 936
                     {
    
    919
    -                  label: button_label,
    
    937
    +                  label: bundle.GetStringFromName("OK"),
    
    920 938
                       accessKey: "O",
    
    921 939
                       popup: null,
    
    922 940
                       callback() {
    
    923
    -                    m_tb_prefs.setIntPref(
    
    924
    -                      "extensions.torbutton.maximize_warnings_remaining",
    
    925
    -                      m_tb_prefs.getIntPref(
    
    926
    -                        "extensions.torbutton.maximize_warnings_remaining"
    
    927
    -                      ) - 1
    
    928
    -                    );
    
    941
    +                    // reset notification timer to work-around resize race conditions
    
    942
    +                    m_tb_resize_date = Date.now();
    
    943
    +                    // restore the original (rounded) size we had stored on window startup
    
    944
    +                    let { originalSize } = torbutton_resizelistener;
    
    945
    +                    window.resizeTo(originalSize.width, originalSize.height);
    
    929 946
                       },
    
    930 947
                     },
    
    931 948
                   ];
    
    932 949
     
    
    933
    -              let priority = box.PRIORITY_WARNING_LOW;
    
    934
    -              let message = torbutton_get_property_string(
    
    950
    +              const label = torbutton_get_property_string(
    
    935 951
                     "torbutton.maximize_warning"
    
    936 952
                   );
    
    937 953
     
    
    938 954
                   box.appendNotification(
    
    939
    -                message,
    
    940 955
                     kNotificationName,
    
    941
    -                null,
    
    942
    -                priority,
    
    956
    +                {
    
    957
    +                  label,
    
    958
    +                  priority: box.PRIORITY_WARNING_LOW,
    
    959
    +                  eventCallback(event) {
    
    960
    +                    if (event === "dismissed") {
    
    961
    +                      // user manually dismissed the notification
    
    962
    +                      decreaseWarningsCount();
    
    963
    +                    }
    
    964
    +                  },
    
    965
    +                },
    
    943 966
                     buttons
    
    944 967
                   );
    
    945 968
                 }