Bug 1372309 - make popup resize test not care about rounding errors so it works on local hidpi machines, r?aswan draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 09 Jun 2017 23:22:09 +0100
changeset 593931 39883ad49a9e7ca20409d26806196506208c1e17
parent 593717 b266a8d8fd595b84a7d6218d7b8c6b7af0b5027c
child 593932 f3b0885d3478dad4c4e3a90c590c54a777c7da01
push id63876
push userbmo:gijskruitbosch+bugs@gmail.com
push dateWed, 14 Jun 2017 09:23:16 +0000
reviewersaswan
bugs1372309
milestone56.0a1
Bug 1372309 - make popup resize test not care about rounding errors so it works on local hidpi machines, r?aswan This means I can actually successfully run the tests without photon 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");
   }
@@ -161,17 +162,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})`);
     }
   };
@@ -205,32 +206,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");
@@ -249,17 +250,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);
 
   await extension.unload();
 }