[tor-commits] [tor-browser] 36/37: Bug 1745595 - wait for resize to complete before testing className. r=Mardak, a=RyanVM

gitolite role git at cupani.torproject.org
Wed Jun 22 18:27:45 UTC 2022


This is an automated email from the git hooks/post-receive script.

richard pushed a commit to branch tor-browser-91.11.0esr-11.5-1
in repository tor-browser.

commit 489ac60e609d031635691111fa37e14b06055040
Author: Karl Tomlinson <karlt+ at karlt.net>
AuthorDate: Fri Jun 17 08:03:19 2022 +1200

    Bug 1745595 - wait for resize to complete before testing className. r=Mardak, a=RyanVM
    
    This uses the same approach as in D147730.
    The test was removed on newer branches by D127252.
    
    Differential Revision: https://phabricator.services.mozilla.com/D149576
---
 .../browser_browserGlue_upgradeDialog_resize.js      | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/browser/components/tests/browser/browser_browserGlue_upgradeDialog_resize.js b/browser/components/tests/browser/browser_browserGlue_upgradeDialog_resize.js
index 83caabd70d8c3..865f0f6c1a743 100644
--- a/browser/components/tests/browser/browser_browserGlue_upgradeDialog_resize.js
+++ b/browser/components/tests/browser/browser_browserGlue_upgradeDialog_resize.js
@@ -14,10 +14,26 @@ add_task(async function regular_mode() {
   Assert.equal(className, "", "No classes set on body");
 });
 
+function promiseResize(win, width, height) {
+  if (win.outerWidth == width && win.outerHeight == height) {
+    return Promise.resolve();
+  }
+  return new Promise(resolve => {
+    // More than one "resize" might be received if the window was recently
+    // created.
+    win.addEventListener("resize", () => {
+      if (win.outerWidth == width && win.outerHeight == height) {
+        resolve();
+      }
+    });
+    win.resizeTo(width, height);
+  });
+}
+
 add_task(async function compact_mode() {
   // Shrink the window for this test.
   const { outerHeight, outerWidth } = window;
-  window.resizeTo(outerWidth, 500);
+  await promiseResize(window, outerWidth, 500);
 
   let className;
   await showAndWaitForDialog(async win => {
@@ -28,5 +44,5 @@ add_task(async function compact_mode() {
 
   Assert.equal(className, "compact", "Set class on body");
 
-  window.resizeTo(outerWidth, outerHeight);
+  await promiseResize(window, outerWidth, outerHeight);
 });

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tor-commits mailing list