| ... | ... | @@ -633,9 +633,16 @@ class _RFPHelper { | 
| 633 | 633 |                lazy.logConsole.error(e);
 | 
| 634 | 634 |              }
 | 
| 635 | 635 |            }
 | 
| 636 |  | -          if (needToShrink) {
 | 
| 637 |  | -            win.shrinkToLetterbox();
 | 
| 638 |  | -            this._recordWindowSize(win);
 | 
|  | 636 | +          if (needToShrink && win.shrinkToLetterbox()) {
 | 
|  | 637 | +            win.addEventListener(
 | 
|  | 638 | +              "resize",
 | 
|  | 639 | +              () => {
 | 
|  | 640 | +                // We need to record the "new" initial size in this listener
 | 
|  | 641 | +                // because resized dimensions are not immediately available.
 | 
|  | 642 | +                RFPHelper._recordWindowSize(win);
 | 
|  | 643 | +              },
 | 
|  | 644 | +              { once: true }
 | 
|  | 645 | +            );
 | 
| 639 | 646 |            }
 | 
| 640 | 647 |          });
 | 
| 641 | 648 |        },
 | 
| ... | ... | @@ -741,23 +748,30 @@ class _RFPHelper { | 
| 741 | 748 |    }
 | 
| 742 | 749 |  
 | 
| 743 | 750 |    _recordWindowSize(aWindow) {
 | 
| 744 |  | -    aWindow._rfpOriginalSize = {
 | 
| 745 |  | -      width: aWindow.outerWidth,
 | 
| 746 |  | -      height: aWindow.outerHeight,
 | 
| 747 |  | -      containerHeight: aWindow.gBrowser.getBrowserContainer()?.clientHeight,
 | 
| 748 |  | -    };
 | 
| 749 |  | -    log("Recording original window size", aWindow._rfpOriginalSize);
 | 
|  | 751 | +    aWindow.promiseDocumentFlushed(() => {
 | 
|  | 752 | +      aWindow._rfpOriginalSize = {
 | 
|  | 753 | +        width: aWindow.outerWidth,
 | 
|  | 754 | +        height: aWindow.outerHeight,
 | 
|  | 755 | +        containerHeight: aWindow.gBrowser.getBrowserContainer()?.clientHeight,
 | 
|  | 756 | +      };
 | 
|  | 757 | +      log("Recording original window size", aWindow._rfpOriginalSize);
 | 
|  | 758 | +    });
 | 
| 750 | 759 |    }
 | 
| 751 | 760 |  
 | 
| 752 | 761 |    // We will attach this method to each browser window. When called
 | 
| 753 | 762 |    // it will instantly resize the window to exactly fit the selected
 | 
| 754 | 763 |    // (possibly letterboxed) browser.
 | 
|  | 764 | +  // Returns true if a window resize will occur, false otherwise.
 | 
| 755 | 765 |    shrinkToLetterbox() {
 | 
| 756 | 766 |      let { selectedBrowser } = this.gBrowser;
 | 
| 757 | 767 |      let stack = selectedBrowser.closest(".browserStack");
 | 
| 758 | 768 |      const outer = stack.getBoundingClientRect();
 | 
| 759 | 769 |      const inner = selectedBrowser.getBoundingClientRect();
 | 
| 760 |  | -    this.resizeBy(inner.width - outer.width, inner.height - outer.height);
 | 
|  | 770 | +    if (inner.width !== outer.witdh || inner.height !== outer.height) {
 | 
|  | 771 | +      this.resizeBy(inner.width - outer.width, inner.height - outer.height);
 | 
|  | 772 | +      return true;
 | 
|  | 773 | +    }
 | 
|  | 774 | +    return false;
 | 
| 761 | 775 |    }
 | 
| 762 | 776 |  
 | 
| 763 | 777 |    _onWindowDoubleClick(e) {
 |