Bug 1300784 - Follow-up: update browser_selectpopup.js to handle floating point values for bounding client rects. r?jaws draft
authorMike Conley <mconley@mozilla.com>
Fri, 06 Jan 2017 16:12:55 -0500
changeset 458578 ab5923f265e59d65f0a6a1eba37c8eec5a47a3d5
parent 458577 d0e29ecc80835bf227f623643518ec0cf2d01364
child 458579 5db8d25354893ca0705b155d8696529d25b4377b
push id40986
push usermconley@mozilla.com
push dateTue, 10 Jan 2017 15:30:59 +0000
reviewersjaws
bugs1300784
milestone53.0a1
Bug 1300784 - Follow-up: update browser_selectpopup.js to handle floating point values for bounding client rects. r?jaws MozReview-Commit-ID: 5O2lmNOZHZD
browser/base/content/test/general/browser_selectpopup.js
--- a/browser/base/content/test/general/browser_selectpopup.js
+++ b/browser/base/content/test/general/browser_selectpopup.js
@@ -442,19 +442,24 @@ function* performLargePopupTests(win) {
     ok(rect.top >= browserRect.top, "Popup top position in within browser area");
     ok(rect.bottom <= browserRect.bottom, "Popup bottom position in within browser area");
 
     // Don't check the scroll position for the last step as the popup will be cut off.
     if (positions.length > 0) {
       let cs = win.getComputedStyle(selectPopup);
       let bpBottom = parseFloat(cs.paddingBottom) + parseFloat(cs.borderBottomWidth);
 
-      is(selectPopup.childNodes[60].getBoundingClientRect().bottom,
-         selectPopup.getBoundingClientRect().bottom - bpBottom,
-         "Popup scroll at correct position " + bpBottom);
+      // Some of the styles applied to the menuitems are percentages, meaning
+      // that the final layout calculations returned by getBoundingClientRect()
+      // might return floating point values. We don't care about sub-pixel
+      // accuracy, and only care about the final pixel value, so we add a
+      // fuzz-factor of 1.
+      SimpleTest.isfuzzy(selectPopup.childNodes[60].getBoundingClientRect().bottom,
+                         selectPopup.getBoundingClientRect().bottom - bpBottom,
+                         1, "Popup scroll at correct position " + bpBottom);
     }
 
     yield hideSelectPopup(selectPopup, "enter", win);
 
     position = positions.shift();
     if (!position) {
       break;
     }