Commit 47c99b51 authored by Nick Fitzgerald's avatar Nick Fitzgerald
Browse files

Bug 1028418 - Part 6: Fix GC + SavedFrame test that made assumptions that are no longer true; r=shu

parent 0d13e50d
Loading
Loading
Loading
Loading
+68 −57
Original line number Diff line number Diff line
@@ -3,14 +3,19 @@

const FUZZ_FACTOR = 3;

function assertAboutEq(actual, expected) {
  if (Math.abs(actual - expected) > FUZZ_FACTOR)
    throw new Error("Assertion failed: expected about " + expected + ", got " + actual +
                    ". FUZZ_FACTOR = " + FUZZ_FACTOR);
function isAboutEq(actual, expected) {
  return Math.abs(actual - expected) <= FUZZ_FACTOR;
}

var stacks = [];

(function () {
  // Use an IIFE here so that we don't keep these saved stacks alive in the
  // frame cache when we test that they all go away at the end of the test.

  var startCount = getSavedFrameCount();
  print("startCount = " + startCount);

  stacks.push(saveStack());
  stacks.push(saveStack());
  stacks.push(saveStack());
@@ -63,7 +68,13 @@ stacks.push(saveStack());
  stacks.push(saveStack());
  stacks.push(saveStack());

assertAboutEq(getSavedFrameCount(), 50);
  gc();

  var endCount = getSavedFrameCount();
  print("endCount = " + endCount);

  assertEq(isAboutEq(endCount - startCount, 50), true);
}());

while (stacks.length) {
  stacks.pop();
@@ -73,4 +84,4 @@ gc();
stacks = null;
gc();

assertAboutEq(getSavedFrameCount(), 0);
assertEq(isAboutEq(getSavedFrameCount(), 0), true);