Esempio n. 1
0
add_task(function *() {
  ok(utils.breakdownEquals(breakdowns.allocationStack.breakdown, {
    by: "allocationStack",
    then: { by: "count", count: true, bytes: true },
    noStack: { by: "count", count: true, bytes: true },
  }), "utils.breakdownEquals() passes with preset"),

  ok(!utils.breakdownEquals(breakdowns.allocationStack.breakdown, {
    by: "allocationStack",
    then: { by: "count", count: false, bytes: true },
    noStack: { by: "count", count: true, bytes: true },
  }), "utils.breakdownEquals() fails when deep properties do not match");

  ok(!utils.breakdownEquals(breakdowns.allocationStack.breakdown, {
    by: "allocationStack",
    then: { by: "count", bytes: true },
    noStack: { by: "count", count: true, bytes: true },
  }), "utils.breakdownEquals() fails when deep properties are missing.");

  let s1 = utils.createSnapshot();
  let s2 = utils.createSnapshot();
  ok(s1.state, states.SAVING, "utils.createSnapshot() creates snapshot in saving state");
  ok(s1.id !== s2.id, "utils.createSnapshot() creates snapshot with unique ids");

  ok(utils.breakdownEquals(utils.breakdownNameToSpec("coarseType"), breakdowns.coarseType.breakdown),
    "utils.breakdownNameToSpec() works for presets");
  ok(utils.breakdownEquals(utils.breakdownNameToSpec("coarseType"), breakdowns.coarseType.breakdown),
    "utils.breakdownNameToSpec() works for presets");

  let custom = { by: "internalType", then: { by: "count", bytes: true }};
  Preferences.set("devtools.memory.custom-breakdowns", JSON.stringify({ "My Breakdown": custom }));

  ok(utils.breakdownEquals(utils.getCustomBreakdowns()["My Breakdown"], custom),
    "utils.getCustomBreakdowns() returns custom breakdowns");
});
Esempio n. 2
0
add_task(function *() {
  ok(utils.breakdownEquals(breakdowns.allocationStack.breakdown, {
    by: "allocationStack",
    then: { by: "count", count: true, bytes: true },
    noStack: { by: "count", count: true, bytes: true },
  }), "utils.breakdownEquals() passes with preset"),

  ok(!utils.breakdownEquals(breakdowns.allocationStack.breakdown, {
    by: "allocationStack",
    then: { by: "count", count: false, bytes: true },
    noStack: { by: "count", count: true, bytes: true },
  }), "utils.breakdownEquals() fails when deep properties do not match");

  ok(!utils.breakdownEquals(breakdowns.allocationStack.breakdown, {
    by: "allocationStack",
    then: { by: "count", bytes: true },
    noStack: { by: "count", count: true, bytes: true },
  }), "utils.breakdownEquals() fails when deep properties are missing.");

  let s1 = utils.createSnapshot({});
  let s2 = utils.createSnapshot({});
  equal(s1.state, states.SAVING, "utils.createSnapshot() creates snapshot in saving state");
  ok(s1.id !== s2.id, "utils.createSnapshot() creates snapshot with unique ids");

  ok(utils.breakdownEquals(utils.breakdownNameToSpec("coarseType"), breakdowns.coarseType.breakdown),
    "utils.breakdownNameToSpec() works for presets");
  ok(utils.breakdownEquals(utils.breakdownNameToSpec("coarseType"), breakdowns.coarseType.breakdown),
    "utils.breakdownNameToSpec() works for presets");

  let custom = { by: "internalType", then: { by: "count", bytes: true }};
  Preferences.set("devtools.memory.custom-breakdowns", JSON.stringify({ "My Breakdown": custom }));

  ok(utils.breakdownEquals(utils.getCustomBreakdowns()["My Breakdown"], custom),
    "utils.getCustomBreakdowns() returns custom breakdowns");

  ok(true, "test formatNumber util functions");
  equal(utils.formatNumber(12), "12", "formatNumber returns 12 for 12");

  equal(utils.formatNumber(0), "0", "formatNumber returns 0 for 0");
  equal(utils.formatNumber(-0), "0", "formatNumber returns 0 for -0");
  equal(utils.formatNumber(+0), "0", "formatNumber returns 0 for +0");

  equal(utils.formatNumber(1234567), "1 234 567",
    "formatNumber adds a space every 3rd digit");
  equal(utils.formatNumber(12345678), "12 345 678",
    "formatNumber adds a space every 3rd digit");
  equal(utils.formatNumber(123456789), "123 456 789",
    "formatNumber adds a space every 3rd digit");

  equal(utils.formatNumber(12, true), "+12",
    "formatNumber can display number sign");
  equal(utils.formatNumber(-12, true), "-12",
    "formatNumber can display number sign (negative)");

  ok(true, "test formatPercent util functions");
  equal(utils.formatPercent(12), "12%", "formatPercent returns 12% for 12");
  equal(utils.formatPercent(12345), "12 345%",
    "formatPercent returns 12 345% for 12345");
});
Esempio n. 3
0
/**
 * Sets breakdown and waits for currently selected breakdown to use it
 * and be completed the census.
 */
function setBreakdown (window, type) {
  info(`Setting breakdown to ${type}...`);
  let { gStore, gHeapAnalysesClient } = window;
  // XXX: Should handle this via clicking the DOM, but React doesn't
  // fire the onChange event, so just change it in the store.
  // window.document.querySelector(`.select-breakdown`).value = type;
  gStore.dispatch(require("devtools/client/memory/actions/breakdown")
                         .setBreakdownAndRefresh(gHeapAnalysesClient, breakdownNameToSpec(type)));

  return waitUntilState(window.gStore, () => {
    let selected = window.gStore.getState().snapshots.find(s => s.selected);
    return selected.state === states.SAVED_CENSUS &&
           breakdownEquals(breakdownNameToSpec(type), selected.census.breakdown);
  });
}
Esempio n. 4
0
 return waitUntilState(window.gStore, () => {
   let selected = window.gStore.getState().snapshots.find(s => s.selected);
   return selected.state === states.SAVED_CENSUS &&
          breakdownEquals(breakdownNameToSpec(type), selected.census.breakdown);
 });