Bug 1585008 - Part 3: Update mouse resize tests. r=bradwerth
authorMicah Tigley <mtigley@mozilla.com>
Fri, 10 Jan 2020 17:49:24 +0000
changeset 509847 49fcf58f986612c60d2c20d5f241c84315aef2df
parent 509846 b9b06de796d7232ea8f7fd232868a8695705eada
child 509848 8ac68bcb41316043ddfdf332b97acacc4ccb8e64
push id37004
push usershindli@mozilla.com
push dateSat, 11 Jan 2020 09:48:29 +0000
treeherdermozilla-central@fb64636dad2c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbradwerth
bugs1585008
milestone74.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1585008 - Part 3: Update mouse resize tests. r=bradwerth Depends on D59204 Differential Revision: https://phabricator.services.mozilla.com/D59392
devtools/client/responsive/test/browser/browser_mouse_resize.js
devtools/client/responsive/test/browser/head.js
devtools/client/responsive/ui.js
--- a/devtools/client/responsive/test/browser/browser_mouse_resize.js
+++ b/devtools/client/responsive/test/browser/browser_mouse_resize.js
@@ -1,43 +1,47 @@
 /* Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const TEST_URL = "data:text/html;charset=utf-8,";
 
-addRDMTask(TEST_URL, async function({ ui, manager }) {
-  const store = ui.toolWindow.store;
+addRDMTask(
+  TEST_URL,
+  async function({ ui, manager }) {
+    const store = ui.toolWindow.store;
 
-  // Wait until the viewport has been added
-  await waitUntilState(store, state => state.viewports.length == 1);
-
-  await setViewportSize(ui, manager, 300, 300);
+    // Wait until the viewport has been added
+    await waitUntilState(store, state => state.viewports.length == 1);
 
-  // Do horizontal + vertical resize
-  await testViewportResize(
-    ui,
-    ".viewport-resize-handle",
-    [10, 10],
-    [320, 310],
-    [10, 10]
-  );
+    await setViewportSize(ui, manager, 300, 300);
+
+    // Do horizontal + vertical resize
+    await testViewportResize(
+      ui,
+      ".viewport-resize-handle",
+      [10, 10],
+      [320, 310],
+      [10, 10]
+    );
 
-  // Do horizontal resize
-  await testViewportResize(
-    ui,
-    ".viewport-horizontal-resize-handle",
-    [-10, 10],
-    [300, 310],
-    [-10, 0]
-  );
+    // Do horizontal resize
+    await testViewportResize(
+      ui,
+      ".viewport-horizontal-resize-handle",
+      [-10, 10],
+      [300, 310],
+      [-10, 0]
+    );
 
-  // Do vertical resize
-  await testViewportResize(
-    ui,
-    ".viewport-vertical-resize-handle",
-    [-10, -10],
-    [300, 300],
-    [0, -10],
-    ui
-  );
-});
+    // Do vertical resize
+    await testViewportResize(
+      ui,
+      ".viewport-vertical-resize-handle",
+      [-10, -10],
+      [300, 300],
+      [0, -10],
+      ui
+    );
+  },
+  true
+);
--- a/devtools/client/responsive/test/browser/head.js
+++ b/devtools/client/responsive/test/browser/head.js
@@ -324,17 +324,18 @@ function dragElementBy(selector, x, y, w
 
 async function testViewportResize(
   ui,
   selector,
   moveBy,
   expectedViewportSize,
   expectedHandleMove
 ) {
-  const win = ui.toolWindow;
+  const win = ui.getBrowserWindow();
+
   const resized = waitForViewportResizeTo(ui, ...expectedViewportSize);
   const startRect = dragElementBy(selector, ...moveBy, win);
   await resized;
 
   const endRect = getElRect(selector, win);
   is(
     endRect.left - startRect.left,
     expectedHandleMove[0],
--- a/devtools/client/responsive/ui.js
+++ b/devtools/client/responsive/ui.js
@@ -1015,11 +1015,22 @@ class ResponsiveUI {
   }
 
   /**
    * Helper for getting the initial viewport orientation.
    */
   getInitialViewportOrientation(viewport) {
     return getOrientation(viewport, viewport);
   }
+
+  /**
+   * Helper for tests to get the browser's window.
+   */
+  getBrowserWindow() {
+    if (!this.isBrowserUIEnabled) {
+      return this.toolWindow;
+    }
+
+    return this.browserWindow;
+  }
 }
 
 module.exports = ResponsiveUI;