Bug 1476647 - Fix TableWidget scroll position calculation;r=miker draft
authorJulian Descottes <jdescottes@mozilla.com>
Wed, 18 Jul 2018 18:01:29 +0200
changeset 820225 faeb2d7e4a207f8380082e0070599a130b32098f
parent 819645 8dab948a10f073a46f13f55f94d1f6514c7360ac
push id116754
push userjdescottes@mozilla.com
push dateThu, 19 Jul 2018 06:39:25 +0000
reviewersmiker
bugs1476647
milestone63.0a1
Bug 1476647 - Fix TableWidget scroll position calculation;r=miker MozReview-Commit-ID: Kn9PQMXG8bC
devtools/client/shared/widgets/TableWidget.js
devtools/client/storage/test/browser_storage_overflow.js
--- a/devtools/client/shared/widgets/TableWidget.js
+++ b/devtools/client/shared/widgets/TableWidget.js
@@ -1000,21 +1000,19 @@ TableWidget.prototype = {
     clearNamedTimeout("table-scroll");
     setNamedTimeout("table-scroll", AFTER_SCROLL_DELAY, this.afterScroll);
   },
 
   /**
    * Emits the "scroll-end" event when the whole table is scrolled
    */
   afterScroll: function() {
-    const scrollHeight = this.tbody.getBoundingClientRect().height -
-        this.tbody.querySelector(".table-widget-column-header").clientHeight;
-
+    const maxScrollTop = this.tbody.scrollHeight - this.tbody.clientHeight;
     // Emit scroll-end event when 9/10 of the table is scrolled
-    if (this.tbody.scrollTop >= 0.9 * scrollHeight) {
+    if (this.tbody.scrollTop >= 0.9 * maxScrollTop) {
       this.emit("scroll-end");
     }
   }
 };
 
 TableWidget.EVENTS = EVENTS;
 
 module.exports.TableWidget = TableWidget;
--- a/devtools/client/storage/test/browser_storage_overflow.js
+++ b/devtools/client/storage/test/browser_storage_overflow.js
@@ -2,16 +2,36 @@
 // inspector table.
 "use strict";
 
 const ITEMS_PER_PAGE = 50;
 
 add_task(async function() {
   await openTabAndSetupStorage(MAIN_DOMAIN + "storage-overflow.html");
 
+  info("Run the tests with short DevTools");
+  await runTests();
+
+  info("Close Toolbox");
+  const target = TargetFactory.forTab(gBrowser.selectedTab);
+  await gDevTools.closeToolbox(target);
+
+  info("Set a toolbox height of 1000px");
+  await pushPref("devtools.toolbox.footer.height", 1000);
+
+  info("Open storage panel again");
+  await openStoragePanel();
+
+  info("Run the tests with tall DevTools");
+  await runTests();
+
+  await finishTests();
+});
+
+async function runTests() {
   gUI.tree.expandAll();
   await selectTreeItem(["localStorage", "http://test1.example.org"]);
   checkCellLength(ITEMS_PER_PAGE);
 
   await scroll();
   checkCellLength(ITEMS_PER_PAGE * 2);
 
   await scroll();
@@ -20,19 +40,17 @@ add_task(async function() {
   // Check that the columns are sorted in a human readable way (ascending).
   checkCellValues("ASC");
 
   // Sort descending.
   clickColumnHeader("name");
 
   // Check that the columns are sorted in a human readable way (descending).
   checkCellValues("DEC");
-
-  await finishTests();
-});
+}
 
 function checkCellLength(len) {
   const cells = gPanelWindow.document
                           .querySelectorAll("#name .table-widget-cell");
   const msg = `Table should initially display ${len} items`;
 
   is(cells.length, len, msg);
 }