Commit 489ac60e authored by Karl Tomlinson's avatar Karl Tomlinson
Browse files

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
parent 0bf97182
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -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);
});