Commit 97380447 authored by Arthur Edelstein's avatar Arthur Edelstein Committed by Georg Koppen
Browse files

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

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.
parent 6c76c308
......@@ -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) {
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment