Bug 1373238 - make popup resize test not care about rounding errors so it works on local hidpi machines draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 09 Jun 2017 23:22:09 +0100
changeset 594800 524b091cae953abfd69caf5cce1170dd39c220a2
parent 594799 519cee927e2dbabbc69c0e45683b137f4f969df3
child 633530 b534f072ef4bc3e49167e556b2c1bf08e2c2e0ee
push id64147
push userbmo:gijskruitbosch+bugs@gmail.com
push dateThu, 15 Jun 2017 13:57:14 +0000
bugs1373238
milestone56.0a1
Bug 1373238 - make popup resize test not care about rounding errors so it works on local hidpi machines This lets me successfully run the tests on my hidpi machines. MozReview-Commit-ID: 3ojX1PYmBfq
browser/components/extensions/test/browser/browser_ext_browserAction_popup_resize.js
--- a/browser/components/extensions/test/browser/browser_ext_browserAction_popup_resize.js
+++ b/browser/components/extensions/test/browser/browser_ext_browserAction_popup_resize.js
@@ -24,17 +24,18 @@ add_task(async function testBrowserActio
 
   await extension.startup();
 
   let browser = await openPanel(extension, undefined, true);
 
   async function checkSize(expected) {
     let dims = await promiseContentDimensions(browser);
 
-    is(dims.window.innerHeight, expected, `Panel window should be ${expected}px tall`);
+    Assert.lessOrEqual(Math.abs(dims.window.innerHeight - expected), 1,
+                       `Panel window should be ${expected}px tall (was ${dims.window.innerHeight})`);
     is(dims.body.clientHeight, dims.body.scrollHeight,
       "Panel body should be tall enough to fit its contents");
 
     // Tolerate if it is 1px too wide, as that may happen with the current resizing method.
     ok(Math.abs(dims.window.innerWidth - expected) <= 1, `Panel window should be ${expected}px wide`);
     is(dims.body.clientWidth, dims.body.scrollWidth,
       "Panel body should be wide enough to fit its contents");
   }
@@ -165,17 +166,17 @@ async function testPopupSize(standardsMo
 
     let panelRect = panel.getBoundingClientRect();
     if (arrowSide == "top") {
       ok(panelRect.top, origPanelRect.top, "Panel has not moved downwards");
       ok(panelRect.bottom >= origPanelRect.bottom, `Panel has not shrunk from original size (${panelRect.bottom} >= ${origPanelRect.bottom})`);
 
       let screenBottom = browserWin.screen.availTop + browserWin.screen.availHeight;
       let panelBottom = browserWin.mozInnerScreenY + panelRect.bottom;
-      ok(panelBottom <= screenBottom, `Bottom of popup should be on-screen. (${panelBottom} <= ${screenBottom})`);
+      ok(Math.round(panelBottom) <= screenBottom, `Bottom of popup should be on-screen. (${panelBottom} <= ${screenBottom})`);
     } else {
       ok(panelRect.bottom, origPanelRect.bottom, "Panel has not moved upwards");
       ok(panelRect.top <= origPanelRect.top, `Panel has not shrunk from original size (${panelRect.top} <= ${origPanelRect.top})`);
 
       let panelTop = browserWin.mozInnerScreenY + panelRect.top;
       ok(panelTop >= browserWin.screen.availTop, `Top of popup should be on-screen. (${panelTop} >= ${browserWin.screen.availTop})`);
     }
   };
@@ -209,32 +210,32 @@ async function testPopupSize(standardsMo
 
   dims = await alterContent(browser, setClass, "big");
   let win = dims.window;
 
   ok(getHeight() > height, `Browser height should increase (${getHeight()} > ${height})`);
 
   is(win.innerWidth, innerWidth, "Window width should not change");
   ok(win.innerHeight >= innerHeight, `Window height should increase (${win.innerHeight} >= ${innerHeight})`);
-  is(win.scrollMaxY, 0, "Document should not be vertically scrollable");
+  Assert.lessOrEqual(win.scrollMaxY, 1, "Document should not be vertically scrollable");
 
   checkPanelPosition();
 
 
   info("Increase body children's width and height. " +
        "Expect them to wrap, and the frame to grow vertically rather than widen.");
 
   dims = await alterContent(browser, setClass, "bigger");
   win = dims.window;
 
   ok(getHeight() > height, `Browser height should increase (${getHeight()} > ${height})`);
 
   is(win.innerWidth, innerWidth, "Window width should not change");
   ok(win.innerHeight >= innerHeight, `Window height should increase (${win.innerHeight} >= ${innerHeight})`);
-  is(win.scrollMaxY, 0, "Document should not be vertically scrollable");
+  Assert.lessOrEqual(win.scrollMaxY, 1, "Document should not be vertically scrollable");
 
   checkPanelPosition();
 
 
   info("Increase body height beyond the height of the screen. " +
        "Expect the panel to grow to accommodate, but not larger than the height of the screen.");
 
   dims = await alterContent(browser, setClass, "huge");
@@ -253,17 +254,17 @@ async function testPopupSize(standardsMo
   info("Restore original styling. Expect original dimensions.");
   dims = await alterContent(browser, setClass, "");
   win = dims.window;
 
   is(getHeight(), height, "Browser height should return to its original value");
 
   is(win.innerWidth, innerWidth, "Window width should not change");
   is(win.innerHeight, innerHeight, "Window height should return to its original value");
-  is(win.scrollMaxY, 0, "Document should not be vertically scrollable");
+  Assert.lessOrEqual(win.scrollMaxY, 1, "Document should not be vertically scrollable");
 
   checkPanelPosition();
 
   await closeBrowserAction(extension, browserWin);
 
   if (overflowView) {
     overflowView.style.removeProperty("min-height");
   }