Commit e01a3953 authored by Julian Descottes's avatar Julian Descottes
Browse files

Bug 1745242 - [devtools] Cache not showing more than 50 items r=Honza

parent 20ad601f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ support-files =
  storage-cache-basic-iframe.html
  storage-cache-basic.html
  storage-cache-error.html
  storage-cache-overflow.html
  storage-complex-keys.html
  storage-complex-values.html
  storage-cookies.html
@@ -47,6 +48,7 @@ tags = usercontextid
skip-if =
  !fission # Bug 1685474
  win10_2004 # Bug 1723573
[browser_storage_cache_overflow.js]
[browser_storage_cookies_add.js]
[browser_storage_cookies_delete_all.js]
[browser_storage_cookies_domain.js]
+26 −0
Original line number Diff line number Diff line
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// Test endless scrolling when a lot of items are present in the storage
// inspector table for Cache storage.
"use strict";

const ITEMS_PER_PAGE = 50;

add_task(async function() {
  await openTabAndSetupStorage(
    URL_ROOT_COM_SSL + "storage-cache-overflow.html"
  );

  gUI.tree.expandAll();

  await selectTreeItem(["Cache", "https://example.com", "lorem"]);
  checkCellLength(ITEMS_PER_PAGE);

  await scroll();
  checkCellLength(ITEMS_PER_PAGE * 2);

  info("Close Toolbox");
  await gDevTools.closeToolboxForTab(gBrowser.selectedTab);
});
+7 −4
Original line number Diff line number Diff line
@@ -1059,10 +1059,13 @@ async function performAdd(store) {
  is(rowId, value, `Row '${rowId}' was successfully added.`);
}

// Cell css selector that can be used to count or select cells.
// The selector is restricted to a single column to avoid counting duplicates.
const CELL_SELECTOR =
  "#storage-table .table-widget-wrapper:first-child .table-widget-cell";

function checkCellLength(len) {
  const cells = gPanelWindow.document.querySelectorAll(
    "#name .table-widget-cell"
  );
  const cells = gPanelWindow.document.querySelectorAll(CELL_SELECTOR);
  const msg = `Table should initially display ${len} items`;

  is(cells.length, len, msg);
@@ -1071,7 +1074,7 @@ function checkCellLength(len) {
async function scroll() {
  const $ = id => gPanelWindow.document.querySelector(id);
  const table = $("#storage-table .table-widget-body");
  const cell = $("#name .table-widget-cell");
  const cell = $(CELL_SELECTOR);
  const cellHeight = cell.getBoundingClientRect().height;

  const onStoresUpdate = gUI.once("store-objects-updated");
+24 −0
Original line number Diff line number Diff line
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Storage inspector test for Cache</title>
</head>
<body>
  <h1>Cache overflow</h1>
<script>
  "use strict";
  async function setup() { // eslint-disable-line no-unused-vars
    caches.open("lorem").then(cache => {
      for (let i = 0; i < 100; i++) {
        cache.add(`storage-blank.html?${i}`);
      }
    });
  }
  function clear() { // eslint-disable-line no-unused-vars
    caches.delete("lorem");
  }
</script>

</body>
</html>
+8 −1
Original line number Diff line number Diff line
@@ -439,7 +439,14 @@ StorageActors.defaults = function(typeName, observationTopics) {
          }
        }

        if (this.typeName === "Cache") {
          // Cache storage contains several items per name but misses a custom
          // `getObjectsSize` implementation, as implemented for IndexedDB.
          // See Bug 1745242.
          toReturn.total = toReturn.data.length;
        } else {
          toReturn.total = this.getObjectsSize(host, names, options);
        }
      } else {
        let obj = await this.getValuesForHost(
          host,