Backed out 3 changesets (bug 1542744) for causing perma mochitest failures in /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/StaticPrefList CLOSED TREE
authorshindli <shindli@mozilla.com>
Wed, 15 May 2019 01:41:06 +0300
changeset 532696 836dbcf0ffca6983f099c5ba35daca24963367e2
parent 532695 111e20704621e675651da2586a55fd7139610c27
child 532697 db85e84612070c8cd9c75a7cc1b0a50bb5ed2d38
push id11270
push userrgurzau@mozilla.com
push dateWed, 15 May 2019 15:07:19 +0000
treeherdermozilla-beta@571bc76da583 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1542744
milestone68.0a1
backs outf94b6f3a7fff9783dded2b404b84c0500c4182f2
c51b622bb1fe7e0d21df71a02c7f07f03f1e46fe
aedbe6cdd06fdda240d262c366c594a463df71d0
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 3 changesets (bug 1542744) for causing perma mochitest failures in /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/StaticPrefList CLOSED TREE Backed out changeset f94b6f3a7fff (bug 1542744) Backed out changeset c51b622bb1fe (bug 1542744) Backed out changeset aedbe6cdd06f (bug 1542744)
modules/libpref/init/StaticPrefList.h
toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp
toolkit/components/url-classifier/nsUrlClassifierPrefixSet.h
toolkit/components/url-classifier/tests/gtest/TestVariableLengthPrefixSet.cpp
--- a/modules/libpref/init/StaticPrefList.h
+++ b/modules/libpref/init/StaticPrefList.h
@@ -2576,23 +2576,16 @@ VARCACHE_PREF(
 
 // Blocked plugin content
 VARCACHE_PREF(
   "browser.safebrowsing.blockedURIs.enabled",
    browser_safebrowsing_blockedURIs_enabled,
   bool, true
 )
 
-// Maximum size for an array to store the safebrowsing prefixset.
-VARCACHE_PREF(
-  "browser.safebrowsing.prefixset.max_array_size",
-   browser_safebrowsing_prefixset_max_array_size,
-  uint32_t, 512*1024
-)
-
 // When this pref is enabled document loads with a mismatched
 // Cross-Origin header will fail to load
 VARCACHE_PREF("browser.tabs.remote.useCrossOriginPolicy",
               browser_tabs_remote_useCrossOriginPolicy,
               bool, false
 )
 
 // Prevent system colors from being exposed to CSS or canvas.
--- a/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp
@@ -1,28 +1,28 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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/. */
 
 #include "nsUrlClassifierPrefixSet.h"
 #include "nsIUrlClassifierPrefixSet.h"
+#include "crc32c.h"
 #include "nsCOMPtr.h"
 #include "nsDebug.h"
 #include "nsPrintfCString.h"
 #include "nsTArray.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsThreadUtils.h"
 #include "nsNetUtil.h"
 #include "nsISeekableStream.h"
 #include "nsIBufferedStreams.h"
 #include "mozilla/MemoryReporting.h"
-#include "mozilla/StaticPrefs.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/Logging.h"
 #include "mozilla/Unused.h"
 #include <algorithm>
 
 using namespace mozilla;
 
 // MOZ_LOG=UrlClassifierPrefixSet:5
@@ -30,19 +30,32 @@ static LazyLogModule gUrlClassifierPrefi
 #define LOG(args) \
   MOZ_LOG(gUrlClassifierPrefixSetLog, mozilla::LogLevel::Debug, args)
 #define LOG_ENABLED() \
   MOZ_LOG_TEST(gUrlClassifierPrefixSetLog, mozilla::LogLevel::Debug)
 
 NS_IMPL_ISUPPORTS(nsUrlClassifierPrefixSet, nsIUrlClassifierPrefixSet,
                   nsIMemoryReporter)
 
+template <typename T>
+static void CalculateTArrayChecksum(const nsTArray<T>& aArray,
+                                    uint32_t* outChecksum) {
+  *outChecksum = ~0;
+
+  for (size_t i = 0; i < aArray.Length(); i++) {
+    const T& element = aArray[i];
+    const void* pointer = &element;
+    *outChecksum = ComputeCrc32c(
+        *outChecksum, reinterpret_cast<const uint8_t*>(pointer), sizeof(void*));
+  }
+}
 
 nsUrlClassifierPrefixSet::nsUrlClassifierPrefixSet()
     : mLock("nsUrlClassifierPrefixSet.mLock"),
+      mIndexDeltasChecksum(~0),
       mTotalPrefixes(0) {}
 
 NS_IMETHODIMP
 nsUrlClassifierPrefixSet::Init(const nsACString& aName) {
   mName = aName;
   mMemoryReportPath = nsPrintfCString(
       "explicit/storage/prefix-set/%s",
       (!aName.IsEmpty() ? PromiseFlatCString(aName).get() : "?!"));
@@ -54,16 +67,17 @@ nsUrlClassifierPrefixSet::Init(const nsA
 
 nsUrlClassifierPrefixSet::~nsUrlClassifierPrefixSet() {
   UnregisterWeakMemoryReporter(this);
 }
 
 void nsUrlClassifierPrefixSet::Clear() {
   LOG(("[%s] Clearing PrefixSet", mName.get()));
   mIndexDeltas.Clear();
+  mIndexDeltasChecksum = ~0;
   mIndexPrefixes.Clear();
   mTotalPrefixes = 0;
 }
 
 NS_IMETHODIMP
 nsUrlClassifierPrefixSet::SetPrefixes(const uint32_t* aArray,
                                       uint32_t aLength) {
   MutexAutoLock lock(mLock);
@@ -73,119 +87,79 @@ nsUrlClassifierPrefixSet::SetPrefixes(co
 
   if (aLength > 0) {
     rv = MakePrefixSet(aArray, aLength);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       Clear();  // clear out any leftovers
     }
   }
 
-  MOZ_ASSERT_IF(mIndexDeltas.IsEmpty(),
-                mIndexPrefixes.Length() == mTotalPrefixes);
-  MOZ_ASSERT_IF(!mIndexDeltas.IsEmpty(),
-                mIndexPrefixes.Length() == mIndexDeltas.Length());
+  MOZ_ASSERT(mIndexPrefixes.Length() == mIndexDeltas.Length());
   return rv;
 }
 
 nsresult nsUrlClassifierPrefixSet::MakePrefixSet(const uint32_t* aPrefixes,
                                                  uint32_t aLength) {
   mLock.AssertCurrentThreadOwns();
 
   MOZ_ASSERT(aPrefixes);
   MOZ_ASSERT(aLength > 0);
 
 #ifdef DEBUG
   for (uint32_t i = 1; i < aLength; i++) {
     MOZ_ASSERT(aPrefixes[i] >= aPrefixes[i - 1]);
   }
 #endif
 
-  uint32_t totalDeltas = 0;
+  mIndexPrefixes.AppendElement(aPrefixes[0]);
+  mIndexDeltas.AppendElement();
 
-  // Request one memory space to store all the prefixes may lead to
-  // memory allocation failure on certain platforms(See Bug 1046038).
-  // So if required size to store all the prefixes exceeds defined
-  // threshold(512k), we divide prefixes into delta chunks instead. Note that
-  // the potential overhead of this approach is that it may reuqire more memory
-  // compared to store all prefixes in one array because of jemalloc's
-  // implementation.
-  if (aLength * sizeof(uint32_t) <
-      StaticPrefs::browser_safebrowsing_prefixset_max_array_size()) {
-    // Not over the threshold, store all prefixes into mIndexPrefixes.
-    // mIndexDeltas is empty in this case.
-    mIndexPrefixes.SetCapacity(aLength);
-    for (uint32_t i = 0; i < aLength; i++) {
-      mIndexPrefixes.AppendElement(aPrefixes[i]);
-    }
-  } else {
-    // Apply delta algorithm to split prefixes into smaller delta chunk.
-
-    // We estimate the capacity of mIndexPrefixes & mIndexDeltas by assuming
-    // each element in mIndexDeltas stores DELTAS_LIMITS deltas, so the
-    // number of indexed prefixes is round up of
-    // TotalPrefixes / (DELTA_LIMIT + 1)
-    // The estimation only works when the number of prefixes are over a
-    // certain limit, which means, arrays in mIndexDeltas are always full.
-    uint32_t estimateCapacity =
-        (aLength + (DELTAS_LIMIT + 1) - 1) / (DELTAS_LIMIT + 1);
-    mIndexPrefixes.SetCapacity(estimateCapacity);
-    mIndexDeltas.SetCapacity(estimateCapacity);
-
-    mIndexPrefixes.AppendElement(aPrefixes[0]);
-    mIndexDeltas.AppendElement();
-    mIndexDeltas.LastElement().SetCapacity(DELTAS_LIMIT);
+  uint32_t numOfDeltas = 0;
+  uint32_t totalDeltas = 0;
+  uint32_t previousItem = aPrefixes[0];
+  for (uint32_t i = 1; i < aLength; i++) {
+    if ((numOfDeltas >= DELTAS_LIMIT) ||
+        (aPrefixes[i] - previousItem >= MAX_INDEX_DIFF)) {
+      // Compact the previous element.
+      // Note there is always at least one element when we get here,
+      // because we created the first element before the loop.
+      if (!mIndexDeltas.AppendElement(fallible)) {
+        return NS_ERROR_OUT_OF_MEMORY;
+      }
 
-    uint32_t numOfDeltas = 0;
-    uint32_t previousItem = aPrefixes[0];
-    for (uint32_t i = 1; i < aLength; i++) {
-      if ((numOfDeltas >= DELTAS_LIMIT) ||
-          (aPrefixes[i] - previousItem >= MAX_INDEX_DIFF)) {
-        // Compact the previous element.
-        // Note there is always at least one element when we get here,
-        // because we created the first element before the loop.
-        mIndexDeltas.LastElement().Compact();
-        if (!mIndexDeltas.AppendElement(fallible)) {
-          return NS_ERROR_OUT_OF_MEMORY;
-        }
-        mIndexDeltas.LastElement().SetCapacity(DELTAS_LIMIT);
-
-        if (!mIndexPrefixes.AppendElement(aPrefixes[i], fallible)) {
-          return NS_ERROR_OUT_OF_MEMORY;
-        }
+      if (!mIndexPrefixes.AppendElement(aPrefixes[i], fallible)) {
+        return NS_ERROR_OUT_OF_MEMORY;
+      }
 
-        numOfDeltas = 0;
-      } else {
-        uint16_t delta = aPrefixes[i] - previousItem;
-        if (!mIndexDeltas.LastElement().AppendElement(delta, fallible)) {
-          return NS_ERROR_OUT_OF_MEMORY;
-        }
+      numOfDeltas = 0;
+    } else {
+      uint16_t delta = aPrefixes[i] - previousItem;
+      if (!mIndexDeltas.LastElement().AppendElement(delta, fallible)) {
+        return NS_ERROR_OUT_OF_MEMORY;
+      }
 
-        numOfDeltas++;
-        totalDeltas++;
-      }
-      previousItem = aPrefixes[i];
+      numOfDeltas++;
+      totalDeltas++;
     }
-
-    mIndexDeltas.LastElement().Compact();
-    mIndexDeltas.Compact();
-    mIndexPrefixes.Compact();
-
-    MOZ_ASSERT(mIndexPrefixes.Length() == mIndexDeltas.Length());
+    previousItem = aPrefixes[i];
   }
 
-  if (totalDeltas == 0) {
-    // We have to clear mIndexDeltas here because it is still possible
-    // that the delta generation algorithm produces no deltas at all. When that
-    // happens, mIndexDeltas is not empty, which conflicts with the assumption
-    // that when there is no delta, mIndexDeltas is empty.
-    mIndexDeltas.Clear();
-  }
   mTotalPrefixes = aLength;
 
-  LOG(("Total number of indices: %d", aLength));
+  mIndexDeltas.LastElement().Compact();
+
+  // The hdr pointer of the last element of nsTArray may change after calling
+  // mIndexDeltas.LastElement().Compact(), so calculate checksum after the call.
+  CalculateTArrayChecksum(mIndexDeltas, &mIndexDeltasChecksum);
+
+  mIndexDeltas.Compact();
+  mIndexPrefixes.Compact();
+  MOZ_ASSERT(mIndexPrefixes.Length() == mIndexDeltas.Length());
+
+  LOG(("Total number of indices: %d (crc=%u)", aLength, mIndexDeltasChecksum));
   LOG(("Total number of deltas: %d", totalDeltas));
   LOG(("Total number of delta chunks: %zu", mIndexDeltas.Length()));
 
   return NS_OK;
 }
 
 nsresult nsUrlClassifierPrefixSet::GetPrefixesNative(
     FallibleTArray<uint32_t>& outArray) {
@@ -201,20 +175,16 @@ nsresult nsUrlClassifierPrefixSet::GetPr
   for (uint32_t i = 0; i < prefixIdxLength; i++) {
     uint32_t prefix = mIndexPrefixes[i];
 
     if (prefixCnt >= mTotalPrefixes) {
       return NS_ERROR_FAILURE;
     }
     outArray[prefixCnt++] = prefix;
 
-    if (mIndexDeltas.IsEmpty()) {
-      continue;
-    }
-
     for (uint32_t j = 0; j < mIndexDeltas[i].Length(); j++) {
       prefix += mIndexDeltas[i][j];
       if (prefixCnt >= mTotalPrefixes) {
         return NS_ERROR_FAILURE;
       }
       outArray[prefixCnt++] = prefix;
     }
   }
@@ -297,25 +267,22 @@ nsUrlClassifierPrefixSet::Contains(uint3
 
   uint32_t i = BinSearch(0, mIndexPrefixes.Length() - 1, target);
   if (mIndexPrefixes[i] > target && i > 0) {
     i--;
   }
 
   // Now search through the deltas for the target.
   uint32_t diff = target - mIndexPrefixes[i];
-
-  if (!mIndexDeltas.IsEmpty()) {
-    uint32_t deltaSize = mIndexDeltas[i].Length();
-    uint32_t deltaIndex = 0;
+  uint32_t deltaSize = mIndexDeltas[i].Length();
+  uint32_t deltaIndex = 0;
 
-    while (diff > 0 && deltaIndex < deltaSize) {
-      diff -= mIndexDeltas[i][deltaIndex];
-      deltaIndex++;
-    }
+  while (diff > 0 && deltaIndex < deltaSize) {
+    diff -= mIndexDeltas[i][deltaIndex];
+    deltaIndex++;
   }
 
   if (diff == 0) {
     *aFound = true;
   }
 
   return NS_OK;
 }
@@ -382,174 +349,152 @@ nsresult nsUrlClassifierPrefixSet::LoadP
   uint32_t read;
 
   nsresult rv =
       in->Read(reinterpret_cast<char*>(&magic), sizeof(uint32_t), &read);
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(read == sizeof(uint32_t), NS_ERROR_FAILURE);
 
   if (magic == PREFIXSET_VERSION_MAGIC) {
-    // Read the number of indexed prefixes
     uint32_t indexSize;
+    uint32_t deltaSize;
+
     rv = in->Read(reinterpret_cast<char*>(&indexSize), sizeof(uint32_t), &read);
     NS_ENSURE_SUCCESS(rv, rv);
     NS_ENSURE_TRUE(read == sizeof(uint32_t), NS_ERROR_FAILURE);
 
-    // Read the number of delta prefixes
-    uint32_t deltaSize;
     rv = in->Read(reinterpret_cast<char*>(&deltaSize), sizeof(uint32_t), &read);
     NS_ENSURE_SUCCESS(rv, rv);
     NS_ENSURE_TRUE(read == sizeof(uint32_t), NS_ERROR_FAILURE);
 
     if (indexSize == 0) {
       LOG(("[%s] Stored PrefixSet is empty!", mName.get()));
       return NS_OK;
     }
 
-    if (!mIndexPrefixes.SetLength(indexSize, fallible)) {
+    if (deltaSize > (indexSize * DELTAS_LIMIT)) {
+      return NS_ERROR_FILE_CORRUPTED;
+    }
+
+    nsTArray<uint32_t> indexStarts;
+    if (!indexStarts.SetLength(indexSize, fallible) ||
+        !mIndexPrefixes.SetLength(indexSize, fallible) ||
+        !mIndexDeltas.SetLength(indexSize, fallible)) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
 
     mTotalPrefixes = indexSize;
-    if (deltaSize > (indexSize * DELTAS_LIMIT)) {
-      return NS_ERROR_FILE_CORRUPTED;
-    }
 
-    // Read index prefixes
     uint32_t toRead = indexSize * sizeof(uint32_t);
     rv = in->Read(reinterpret_cast<char*>(mIndexPrefixes.Elements()), toRead,
                   &read);
     NS_ENSURE_SUCCESS(rv, rv);
     NS_ENSURE_TRUE(read == toRead, NS_ERROR_FAILURE);
 
-    if (deltaSize) {
-      nsTArray<uint32_t> indexStarts;
-
-      if (!indexStarts.SetLength(indexSize, fallible) ||
-          !mIndexDeltas.SetLength(indexSize, fallible)) {
-        return NS_ERROR_OUT_OF_MEMORY;
-      }
+    rv = in->Read(reinterpret_cast<char*>(indexStarts.Elements()), toRead,
+                  &read);
+    NS_ENSURE_SUCCESS(rv, rv);
+    NS_ENSURE_TRUE(read == toRead, NS_ERROR_FAILURE);
 
-      // Read index start array to construct mIndexDeltas
-      rv = in->Read(reinterpret_cast<char*>(indexStarts.Elements()), toRead,
-                    &read);
-      NS_ENSURE_SUCCESS(rv, rv);
-      NS_ENSURE_TRUE(read == toRead, NS_ERROR_FAILURE);
-
-      if (indexStarts[0] != 0) {
+    if (indexSize != 0 && indexStarts[0] != 0) {
+      return NS_ERROR_FILE_CORRUPTED;
+    }
+    for (uint32_t i = 0; i < indexSize; i++) {
+      uint32_t numInDelta = i == indexSize - 1
+                                ? deltaSize - indexStarts[i]
+                                : indexStarts[i + 1] - indexStarts[i];
+      if (numInDelta > DELTAS_LIMIT) {
         return NS_ERROR_FILE_CORRUPTED;
       }
-
-      for (uint32_t i = 0; i < indexSize; i++) {
-        uint32_t numInDelta = i == indexSize - 1
-                                  ? deltaSize - indexStarts[i]
-                                  : indexStarts[i + 1] - indexStarts[i];
-        if (numInDelta > DELTAS_LIMIT) {
-          return NS_ERROR_FILE_CORRUPTED;
+      if (numInDelta > 0) {
+        if (!mIndexDeltas[i].SetLength(numInDelta, fallible)) {
+          return NS_ERROR_OUT_OF_MEMORY;
         }
-        if (numInDelta > 0) {
-          if (!mIndexDeltas[i].SetLength(numInDelta, fallible)) {
-            return NS_ERROR_OUT_OF_MEMORY;
-          }
-          mTotalPrefixes += numInDelta;
-          toRead = numInDelta * sizeof(uint16_t);
-          rv = in->Read(reinterpret_cast<char*>(mIndexDeltas[i].Elements()),
-                        toRead, &read);
-          NS_ENSURE_SUCCESS(rv, rv);
-          NS_ENSURE_TRUE(read == toRead, NS_ERROR_FAILURE);
-        }
+        mTotalPrefixes += numInDelta;
+        toRead = numInDelta * sizeof(uint16_t);
+        rv = in->Read(reinterpret_cast<char*>(mIndexDeltas[i].Elements()),
+                      toRead, &read);
+        NS_ENSURE_SUCCESS(rv, rv);
+        NS_ENSURE_TRUE(read == toRead, NS_ERROR_FAILURE);
       }
-    } else {
-      mIndexDeltas.Clear();
     }
   } else {
     LOG(("[%s] Version magic mismatch, not loading", mName.get()));
     return NS_ERROR_FILE_CORRUPTED;
   }
 
-  MOZ_ASSERT_IF(mIndexDeltas.IsEmpty(),
-                mIndexPrefixes.Length() == mTotalPrefixes);
-  MOZ_ASSERT_IF(!mIndexDeltas.IsEmpty(),
-                mIndexPrefixes.Length() == mIndexDeltas.Length());
+  MOZ_ASSERT(mIndexPrefixes.Length() == mIndexDeltas.Length());
   LOG(("[%s] Loading PrefixSet successful (%u total prefixes)", mName.get(),
        mTotalPrefixes));
 
   return NS_OK;
 }
 
 uint32_t nsUrlClassifierPrefixSet::CalculatePreallocateSize() const {
   uint32_t fileSize = 4 * sizeof(uint32_t);
   MOZ_RELEASE_ASSERT(mTotalPrefixes >= mIndexPrefixes.Length());
   uint32_t deltas = mTotalPrefixes - mIndexPrefixes.Length();
-  fileSize += mIndexPrefixes.Length() * sizeof(uint32_t);
-  if (deltas) {
-    MOZ_ASSERT(mIndexPrefixes.Length() == mIndexDeltas.Length());
-
-    fileSize += mIndexPrefixes.Length() * sizeof(uint32_t);
-    fileSize += mIndexDeltas.Length() * sizeof(uint32_t);
-    fileSize += deltas * sizeof(uint16_t);
-  }
+  fileSize += 2 * mIndexPrefixes.Length() * sizeof(uint32_t);
+  fileSize += deltas * sizeof(uint16_t);
   return fileSize;
 }
 
 nsresult nsUrlClassifierPrefixSet::WritePrefixes(
     nsCOMPtr<nsIOutputStream>& out) const {
   MutexAutoLock lock(mLock);
 
-  MOZ_ASSERT_IF(mIndexDeltas.IsEmpty(),
-                mIndexPrefixes.Length() == mTotalPrefixes);
-  MOZ_ASSERT_IF(!mIndexDeltas.IsEmpty(),
-                mIndexPrefixes.Length() == mIndexDeltas.Length());
+  mCanary.Check();
 
-  mCanary.Check();
+  // In Bug 1362761, crashes happened while reading mIndexDeltas[i].
+  // We suspect that this is due to memory corruption so to test this
+  // hypothesis, we will crash the browser. Once we have established
+  // memory corruption as the root cause, we can attempt to gracefully
+  // handle this.
+  uint32_t checksum;
+  CalculateTArrayChecksum(mIndexDeltas, &checksum);
+  if (checksum != mIndexDeltasChecksum) {
+    LOG(("[%s] The contents of mIndexDeltas doesn't match the checksum!",
+         mName.get()));
+    MOZ_CRASH("Memory corruption detected in mIndexDeltas.");
+  }
 
   uint32_t written;
   uint32_t writelen = sizeof(uint32_t);
   const uint32_t magic = PREFIXSET_VERSION_MAGIC;
   nsresult rv =
       out->Write(reinterpret_cast<const char*>(&magic), writelen, &written);
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(written == writelen, NS_ERROR_FAILURE);
 
   const uint32_t indexSize = mIndexPrefixes.Length();
-  if (mIndexDeltas.IsEmpty()) {
-    if (NS_WARN_IF(mTotalPrefixes != indexSize)) {
-      LOG(("[%s] mIndexPrefixes doesn't have the same length as mTotalPrefixes",
-           mName.get()));
-      return NS_ERROR_FAILURE;
-    }
-  } else {
-    if (NS_WARN_IF(mIndexDeltas.Length() != indexSize)) {
-      LOG(("[%s] mIndexPrefixes doesn't have the same length as mIndexDeltas",
-           mName.get()));
-      return NS_ERROR_FAILURE;
-    }
+  if (NS_WARN_IF(mIndexDeltas.Length() != indexSize)) {
+    LOG(("[%s] mIndexPrefixes doesn't have the same length as mIndexDeltas",
+         mName.get()));
+    return NS_ERROR_FAILURE;
   }
   uint32_t totalDeltas = 0;
 
   // Store the shape of mIndexDeltas by noting at which "count" of total
   // indexes a new subarray starts. This is slightly cumbersome but keeps
   // file format compatibility.
   // If we ever update the format, we can gain space by storing the delta
   // subarray sizes, which fit in bytes.
   nsTArray<uint32_t> indexStarts;
-  if (!mIndexDeltas.IsEmpty()) {
-    if (!indexStarts.SetCapacity(indexSize + 1, fallible)) {
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
-    indexStarts.AppendElement(0);
+  if (!indexStarts.SetCapacity(indexSize + 1, fallible)) {
+    return NS_ERROR_OUT_OF_MEMORY;
+  }
+  indexStarts.AppendElement(0);
 
-    for (uint32_t i = 0; i < indexSize; i++) {
-      uint32_t deltaLength = mIndexDeltas[i].Length();
-      totalDeltas += deltaLength;
-      indexStarts.AppendElement(totalDeltas);
-    }
-    indexStarts.RemoveElementAt(indexSize);  // we don't use the last element
-    MOZ_ASSERT(indexStarts.Length() == indexSize);
+  for (uint32_t i = 0; i < indexSize; i++) {
+    uint32_t deltaLength = mIndexDeltas[i].Length();
+    totalDeltas += deltaLength;
+    indexStarts.AppendElement(totalDeltas);
   }
+  indexStarts.RemoveElementAt(indexSize);  // we don't use the last element
+  MOZ_ASSERT(indexStarts.Length() == indexSize);
 
   rv =
       out->Write(reinterpret_cast<const char*>(&indexSize), writelen, &written);
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(written == writelen, NS_ERROR_FAILURE);
 
   rv = out->Write(reinterpret_cast<const char*>(&totalDeltas), writelen,
                   &written);
@@ -557,23 +502,22 @@ nsresult nsUrlClassifierPrefixSet::Write
   NS_ENSURE_TRUE(written == writelen, NS_ERROR_FAILURE);
 
   writelen = indexSize * sizeof(uint32_t);
   rv = out->Write(reinterpret_cast<const char*>(mIndexPrefixes.Elements()),
                   writelen, &written);
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(written == writelen, NS_ERROR_FAILURE);
 
-  if (!mIndexDeltas.IsEmpty()) {
-    MOZ_ASSERT(!indexStarts.IsEmpty() && totalDeltas > 0);
-    rv = out->Write(reinterpret_cast<const char*>(indexStarts.Elements()),
-                    writelen, &written);
-    NS_ENSURE_SUCCESS(rv, rv);
-    NS_ENSURE_TRUE(written == writelen, NS_ERROR_FAILURE);
+  rv = out->Write(reinterpret_cast<const char*>(indexStarts.Elements()),
+                  writelen, &written);
+  NS_ENSURE_SUCCESS(rv, rv);
+  NS_ENSURE_TRUE(written == writelen, NS_ERROR_FAILURE);
 
+  if (totalDeltas > 0) {
     for (uint32_t i = 0; i < indexSize; i++) {
       writelen = mIndexDeltas[i].Length() * sizeof(uint16_t);
       rv = out->Write(reinterpret_cast<const char*>(mIndexDeltas[i].Elements()),
                       writelen, &written);
       NS_ENSURE_SUCCESS(rv, rv);
       NS_ENSURE_TRUE(written == writelen, NS_ERROR_FAILURE);
     }
   }
--- a/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.h
+++ b/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.h
@@ -71,19 +71,18 @@ class nsUrlClassifierPrefixSet final : p
   mutable mozilla::Mutex mLock;
   // list of fully stored prefixes, that also form the
   // start of a run of deltas in mIndexDeltas.
   nsTArray<uint32_t> mIndexPrefixes;
   // array containing arrays of deltas from indices.
   // Index to the place that matches the closest lower
   // prefix from mIndexPrefix. Then every "delta" corresponds
   // to a prefix in the PrefixSet.
-  // This array could be empty when we decide to store all the prefixes
-  // in mIndexPrefixes.
   nsTArray<nsTArray<uint16_t> > mIndexDeltas;
+  uint32_t mIndexDeltasChecksum;
 
   // how many prefixes we have.
   uint32_t mTotalPrefixes;
 
   nsCString mName;
   nsCString mMemoryReportPath;
   mozilla::CorruptionCanary mCanary;
 };
--- a/toolkit/components/url-classifier/tests/gtest/TestVariableLengthPrefixSet.cpp
+++ b/toolkit/components/url-classifier/tests/gtest/TestVariableLengthPrefixSet.cpp
@@ -4,38 +4,35 @@
 
 #include <mozilla/RefPtr.h>
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsClassHashtable.h"
 #include "VariableLengthPrefixSet.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsIFile.h"
-#include "mozilla/Preferences.h"
 #include "gtest/gtest.h"
 
 using namespace mozilla::safebrowsing;
 
-namespace {
-
 // Create fullhash by appending random characters.
-nsCString CreateFullHash(const nsACString& in) {
+static nsCString CreateFullHash(const nsACString& in) {
   nsCString out(in);
   out.SetLength(32);
   for (size_t i = in.Length(); i < 32; i++) {
     out.SetCharAt(char(rand() % 256), i);
   }
 
   return out;
 }
 
 // This function generate N prefixes with size between MIN and MAX.
 // The output array will not be cleared, random result will append to it
-void RandomPrefixes(uint32_t N, uint32_t MIN, uint32_t MAX,
-                    _PrefixArray& array) {
+static void RandomPrefixes(uint32_t N, uint32_t MIN, uint32_t MAX,
+                           _PrefixArray& array) {
   array.SetCapacity(array.Length() + N);
 
   uint32_t range = (MAX - MIN + 1);
 
   for (uint32_t i = 0; i < N; i++) {
     uint32_t prefixSize = (rand() % range) + MIN;
     _Prefix prefix;
     prefix.SetLength(prefixSize);
@@ -53,17 +50,17 @@ void RandomPrefixes(uint32_t N, uint32_t
       }
     }
   }
 }
 
 // This test loops through all the prefixes and converts each prefix to
 // fullhash by appending random characters, each converted fullhash
 // should at least match its original length in the prefixSet.
-void DoExpectedLookup(LookupCacheV4* cache, _PrefixArray& array) {
+static void DoExpectedLookup(LookupCacheV4* cache, _PrefixArray& array) {
   uint32_t matchLength = 0;
   for (uint32_t i = 0; i < array.Length(); i++) {
     const nsCString& prefix = array[i];
     Completion complete;
     complete.Assign(CreateFullHash(prefix));
 
     // Find match for prefix-generated full hash
     bool has, confirmed;
@@ -86,17 +83,18 @@ void DoExpectedLookup(LookupCacheV4* cac
           break;
         }
       }
       ASSERT_TRUE(found);
     }
   }
 }
 
-void DoRandomLookup(LookupCacheV4* cache, uint32_t N, _PrefixArray& array) {
+static void DoRandomLookup(LookupCacheV4* cache, uint32_t N,
+                           _PrefixArray& array) {
   for (uint32_t i = 0; i < N; i++) {
     // Random 32-bytes test fullhash
     char buf[32];
     for (uint32_t j = 0; j < 32; j++) {
       buf[j] = (char)(rand() % 256);
     }
 
     // Get the expected result.
@@ -114,226 +112,284 @@ void DoRandomLookup(LookupCacheV4* cache
     uint32_t matchLength = 0;
     cache->Has(complete, &has, &matchLength, &confirmed);
 
     ASSERT_TRUE(expected.IsEmpty() ? !matchLength
                                    : expected.Contains(matchLength));
   }
 }
 
-already_AddRefed<LookupCacheV4> SetupLookupCache(const nsACString& aName) {
+static already_AddRefed<LookupCacheV4> SetupLookupCache(
+    const nsACString& aName) {
   nsCOMPtr<nsIFile> rootDir;
   NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(rootDir));
 
   nsAutoCString provider("test");
   RefPtr<LookupCacheV4> lookup = new LookupCacheV4(aName, provider, rootDir);
   lookup->Init();
 
   return lookup.forget();
 }
 
-};  // namespace
+// Test setting prefix set with only 4-bytes prefixes
+TEST(UrlClassifierVLPrefixSet, FixedLengthSet)
+{
+  srand(time(nullptr));
 
-class UrlClassifierPrefixSetTest : public ::testing::TestWithParam<uint32_t> {
- protected:
-  void SetUp() override {
-    // max_array_size to 0 means we are testing delta algorithm here.
-    static const char prefKey[] =
-        "browser.safebrowsing.prefixset.max_array_size";
-    Preferences::SetUint(prefKey, GetParam());
-
-    mCache = SetupLookupCache(NS_LITERAL_CSTRING("test"));
-  }
-
-  void TearDown() override {
-    mCache = nullptr;
-    mArray.Clear();
-    mMap.Clear();
-  }
+  RefPtr<LookupCacheV4> cache = SetupLookupCache(NS_LITERAL_CSTRING("test"));
 
-  nsresult SetupPrefixes(_PrefixArray&& aArray) {
-    mArray = std::move(aArray);
-    SetupPrefixMap(mArray, mMap);
-    return mCache->Build(mMap);
-  }
-
-  void SetupPrefixesAndVerify(_PrefixArray& aArray) {
-    mArray = aArray;
-    SetupPrefixMap(mArray, mMap);
+  PrefixStringMap map;
+  _PrefixArray array = {
+      _Prefix("alph"), _Prefix("brav"), _Prefix("char"),
+      _Prefix("delt"), _Prefix("echo"), _Prefix("foxt"),
+  };
 
-    ASSERT_TRUE(NS_SUCCEEDED(mCache->Build(mMap)));
-    Verify();
-  }
-
-  void SetupPrefixesAndVerify(_PrefixArray&& aArray) {
-    nsresult rv = SetupPrefixes(std::move(aArray));
-    ASSERT_TRUE(NS_SUCCEEDED(rv));
-    Verify();
-  }
+  SetupPrefixMap(array, map);
+  cache->Build(map);
 
-  void SetupRandomPrefixesAndVerify(uint32_t N, uint32_t MIN, uint32_t MAX) {
-    srand(time(nullptr));
-    RandomPrefixes(N, MIN, MAX, mArray);
-    SetupPrefixMap(mArray, mMap);
-
-    ASSERT_TRUE(NS_SUCCEEDED(mCache->Build(mMap)));
-    Verify();
-  }
+  DoExpectedLookup(cache, array);
+  DoRandomLookup(cache, 1000, array);
+  CheckContent(cache, array);
 
-  void Verify() {
-    DoExpectedLookup(mCache, mArray);
-    DoRandomLookup(mCache, 1000, mArray);
-    CheckContent(mCache, mArray);
-  }
-
-  RefPtr<LookupCacheV4> mCache;
-  _PrefixArray mArray;
-  PrefixStringMap mMap;
-};
+  // Run random test
+  array.Clear();
+  map.Clear();
 
-// Test setting prefix set with only 4-bytes prefixes
-TEST_P(UrlClassifierPrefixSetTest, FixedLengthSet) {
-  SetupPrefixesAndVerify({
-      _Prefix("alph"),
-      _Prefix("brav"),
-      _Prefix("char"),
-      _Prefix("delt"),
-      _Prefix("echo"),
-      _Prefix("foxt"),
-  });
-}
+  RandomPrefixes(1500, 4, 4, array);
 
-TEST_P(UrlClassifierPrefixSetTest, FixedLengthRandomSet) {
-  SetupRandomPrefixesAndVerify(1500, 4, 4);
-}
+  SetupPrefixMap(array, map);
+  cache->Build(map);
 
-TEST_P(UrlClassifierPrefixSetTest, FixedLengthRandomLargeSet) {
-  SetupRandomPrefixesAndVerify(15000, 4, 4);
-}
-
-TEST_P(UrlClassifierPrefixSetTest, FixedLengthTinySet) {
-  SetupPrefixesAndVerify({
-      _Prefix("tiny"),
-  });
+  DoExpectedLookup(cache, array);
+  DoRandomLookup(cache, 1000, array);
+  CheckContent(cache, array);
 }
 
 // Test setting prefix set with only 5~32 bytes prefixes
-TEST_P(UrlClassifierPrefixSetTest, VariableLengthSet) {
-  SetupPrefixesAndVerify(
-      {_Prefix("bravo"), _Prefix("charlie"), _Prefix("delta"),
-       _Prefix("EchoEchoEchoEchoEcho"), _Prefix("foxtrot"),
-       _Prefix("GolfGolfGolfGolfGolfGolfGolfGolf"), _Prefix("hotel"),
-       _Prefix("november"), _Prefix("oscar"), _Prefix("quebec"),
-       _Prefix("romeo"), _Prefix("sierrasierrasierrasierrasierra"),
-       _Prefix("Tango"), _Prefix("whiskey"), _Prefix("yankee"),
-       _Prefix("ZuluZuluZuluZulu")});
-}
+TEST(UrlClassifierVLPrefixSet, VariableLengthSet)
+{
+  RefPtr<LookupCacheV4> cache = SetupLookupCache(NS_LITERAL_CSTRING("test"));
+
+  PrefixStringMap map;
+  _PrefixArray array = {
+      _Prefix("bravo"),   _Prefix("charlie"),
+      _Prefix("delta"),   _Prefix("EchoEchoEchoEchoEcho"),
+      _Prefix("foxtrot"), _Prefix("GolfGolfGolfGolfGolfGolfGolfGolf"),
+      _Prefix("hotel"),   _Prefix("november"),
+      _Prefix("oscar"),   _Prefix("quebec"),
+      _Prefix("romeo"),   _Prefix("sierrasierrasierrasierrasierra"),
+      _Prefix("Tango"),   _Prefix("whiskey"),
+      _Prefix("yankee"),  _Prefix("ZuluZuluZuluZulu")};
 
-TEST_P(UrlClassifierPrefixSetTest, VariableLengthRandomSet) {
-  SetupRandomPrefixesAndVerify(1500, 5, 32);
+  SetupPrefixMap(array, map);
+  cache->Build(map);
+
+  DoExpectedLookup(cache, array);
+  DoRandomLookup(cache, 1000, array);
+  CheckContent(cache, array);
+
+  // Run random test
+  array.Clear();
+  map.Clear();
+
+  RandomPrefixes(1500, 5, 32, array);
+
+  SetupPrefixMap(array, map);
+  cache->Build(map);
+
+  DoExpectedLookup(cache, array);
+  DoRandomLookup(cache, 1000, array);
+  CheckContent(cache, array);
 }
 
 // Test setting prefix set with both 4-bytes prefixes and 5~32 bytes prefixes
-TEST_P(UrlClassifierPrefixSetTest, MixedPrefixSet) {
-  SetupPrefixesAndVerify(
-      {_Prefix("enus"), _Prefix("apollo"), _Prefix("mars"),
-       _Prefix("Hecatonchires cyclopes"), _Prefix("vesta"), _Prefix("neptunus"),
-       _Prefix("jupiter"), _Prefix("diana"), _Prefix("minerva"),
-       _Prefix("ceres"), _Prefix("Aidos,Adephagia,Adikia,Aletheia"),
-       _Prefix("hecatonchires"), _Prefix("alcyoneus"), _Prefix("hades"),
-       _Prefix("vulcanus"), _Prefix("juno"), _Prefix("mercury"),
-       _Prefix("Stheno, Euryale and Medusa")});
-}
+TEST(UrlClassifierVLPrefixSet, MixedPrefixSet)
+{
+  RefPtr<LookupCacheV4> cache = SetupLookupCache(NS_LITERAL_CSTRING("test"));
 
-TEST_P(UrlClassifierPrefixSetTest, MixedRandomPrefixSet) {
-  SetupRandomPrefixesAndVerify(1500, 4, 32);
+  PrefixStringMap map;
+  _PrefixArray array = {_Prefix("enus"),
+                        _Prefix("apollo"),
+                        _Prefix("mars"),
+                        _Prefix("Hecatonchires cyclopes"),
+                        _Prefix("vesta"),
+                        _Prefix("neptunus"),
+                        _Prefix("jupiter"),
+                        _Prefix("diana"),
+                        _Prefix("minerva"),
+                        _Prefix("ceres"),
+                        _Prefix("Aidos,Adephagia,Adikia,Aletheia"),
+                        _Prefix("hecatonchires"),
+                        _Prefix("alcyoneus"),
+                        _Prefix("hades"),
+                        _Prefix("vulcanus"),
+                        _Prefix("juno"),
+                        _Prefix("mercury"),
+                        _Prefix("Stheno, Euryale and Medusa")};
+
+  SetupPrefixMap(array, map);
+  cache->Build(map);
+
+  DoExpectedLookup(cache, array);
+  DoRandomLookup(cache, 1000, array);
+  CheckContent(cache, array);
+
+  // Run random test
+  array.Clear();
+  map.Clear();
+
+  RandomPrefixes(1500, 4, 32, array);
+
+  SetupPrefixMap(array, map);
+  cache->Build(map);
+
+  DoExpectedLookup(cache, array);
+  DoRandomLookup(cache, 1000, array);
+  CheckContent(cache, array);
 }
 
 // Test resetting prefix set
-TEST_P(UrlClassifierPrefixSetTest, ResetPrefix) {
-  // Base prefix set
-  _PrefixArray oldArray = {
+TEST(UrlClassifierVLPrefixSet, ResetPrefix)
+{
+  RefPtr<LookupCacheV4> cache = SetupLookupCache(NS_LITERAL_CSTRING("test"));
+
+  // First prefix set
+  _PrefixArray array1 = {
       _Prefix("Iceland"),   _Prefix("Peru"),    _Prefix("Mexico"),
       _Prefix("Australia"), _Prefix("Japan"),   _Prefix("Egypt"),
       _Prefix("America"),   _Prefix("Finland"), _Prefix("Germany"),
       _Prefix("Italy"),     _Prefix("France"),  _Prefix("Taiwan"),
   };
-  SetupPrefixesAndVerify(oldArray);
+  {
+    PrefixStringMap map;
+
+    SetupPrefixMap(array1, map);
+    cache->Build(map);
 
-  // New prefix set
-  _PrefixArray newArray = {
+    DoExpectedLookup(cache, array1);
+  }
+
+  // Second
+  _PrefixArray array2 = {
       _Prefix("Pikachu"),    _Prefix("Bulbasaur"), _Prefix("Charmander"),
       _Prefix("Blastoise"),  _Prefix("Pidgey"),    _Prefix("Mewtwo"),
       _Prefix("Jigglypuff"), _Prefix("Persian"),   _Prefix("Tentacool"),
       _Prefix("Onix"),       _Prefix("Eevee"),     _Prefix("Jynx"),
   };
-  SetupPrefixesAndVerify(newArray);
+  {
+    PrefixStringMap map;
+
+    SetupPrefixMap(array2, map);
+    cache->Build(map);
+
+    DoExpectedLookup(cache, array2);
+  }
 
   // Should not match any of the first prefix set
   uint32_t matchLength = 0;
-  for (uint32_t i = 0; i < oldArray.Length(); i++) {
+  for (uint32_t i = 0; i < array1.Length(); i++) {
     Completion complete;
-    complete.Assign(CreateFullHash(oldArray[i]));
+    complete.Assign(CreateFullHash(array1[i]));
 
     // Find match for prefix-generated full hash
     bool has, confirmed;
-    mCache->Has(complete, &has, &matchLength, &confirmed);
+    cache->Has(complete, &has, &matchLength, &confirmed);
 
     ASSERT_TRUE(matchLength == 0);
   }
 }
 
 // Test only set one 4-bytes prefix and one full-length prefix
-TEST_P(UrlClassifierPrefixSetTest, TinyPrefixSet) {
-  SetupPrefixesAndVerify({
+TEST(UrlClassifierVLPrefixSet, TinyPrefixSet)
+{
+  RefPtr<LookupCacheV4> cache = SetupLookupCache(NS_LITERAL_CSTRING("test"));
+
+  PrefixStringMap map;
+  _PrefixArray array = {
       _Prefix("AAAA"),
       _Prefix("11112222333344445555666677778888"),
-  });
+  };
+
+  SetupPrefixMap(array, map);
+  cache->Build(map);
+
+  DoExpectedLookup(cache, array);
+  DoRandomLookup(cache, 1000, array);
+  CheckContent(cache, array);
 }
 
 // Test empty prefix set and IsEmpty function
-TEST_P(UrlClassifierPrefixSetTest, EmptyFixedPrefixSet) {
-  ASSERT_TRUE(mCache->IsEmpty());
+TEST(UrlClassifierVLPrefixSet, EmptyPrefixSet)
+{
+  RefPtr<LookupCacheV4> cache = SetupLookupCache(NS_LITERAL_CSTRING("test"));
 
-  SetupPrefixesAndVerify({});
+  bool empty = cache->IsEmpty();
+  ASSERT_TRUE(empty);
+
+  PrefixStringMap map;
+  _PrefixArray array1;
+
+  // Lookup an empty array should never match
+  DoRandomLookup(cache, 100, array1);
 
   // Insert an 4-bytes prefix, then IsEmpty should return false
-  SetupPrefixesAndVerify({_Prefix("test")});
-
-  ASSERT_TRUE(!mCache->IsEmpty());
-}
+  _PrefixArray array2 = {_Prefix("test")};
+  SetupPrefixMap(array2, map);
+  cache->Build(map);
 
-TEST_P(UrlClassifierPrefixSetTest, EmptyVariableLengthPrefixSet) {
-  ASSERT_TRUE(mCache->IsEmpty());
+  empty = cache->IsEmpty();
+  ASSERT_TRUE(!empty);
 
-  SetupPrefixesAndVerify({});
+  _PrefixArray array3 = {_Prefix("test variable length")};
 
   // Insert an 5~32 bytes prefix, then IsEmpty should return false
-  SetupPrefixesAndVerify({_Prefix("test variable length")});
+  SetupPrefixMap(array3, map);
+  cache->Build(map);
 
-  ASSERT_TRUE(!mCache->IsEmpty());
+  empty = cache->IsEmpty();
+  ASSERT_TRUE(!empty);
 }
 
 // Test prefix size should only between 4~32 bytes
-TEST_P(UrlClassifierPrefixSetTest, MinMaxPrefixSet) {
-  // Test prefix set between 4-32 bytes, should success
-  SetupPrefixesAndVerify({_Prefix("1234"), _Prefix("ABCDEFGHIJKKMNOP"),
-                          _Prefix("1aaa2bbb3ccc4ddd5eee6fff7ggg8hhh")});
+TEST(UrlClassifierVLPrefixSet, MinMaxPrefixSet)
+{
+  RefPtr<LookupCacheV4> cache = SetupLookupCache(NS_LITERAL_CSTRING("test"));
+
+  PrefixStringMap map;
+  {
+    _PrefixArray array = {_Prefix("1234"), _Prefix("ABCDEFGHIJKKMNOP"),
+                          _Prefix("1aaa2bbb3ccc4ddd5eee6fff7ggg8hhh")};
+
+    SetupPrefixMap(array, map);
+    nsresult rv = cache->Build(map);
+    ASSERT_TRUE(rv == NS_OK);
+  }
 
   // Prefix size less than 4-bytes should fail
-  nsresult rv = SetupPrefixes({_Prefix("123")});
-  ASSERT_TRUE(NS_FAILED(rv));
+  {
+    _PrefixArray array = {_Prefix("123")};
+
+    SetupPrefixMap(array, map);
+    nsresult rv = cache->Build(map);
+    ASSERT_TRUE(NS_FAILED(rv));
+  }
 
   // Prefix size greater than 32-bytes should fail
-  rv = SetupPrefixes({_Prefix("1aaa2bbb3ccc4ddd5eee6fff7ggg8hhh9")});
-  ASSERT_TRUE(NS_FAILED(rv));
+  {
+    _PrefixArray array = {_Prefix("1aaa2bbb3ccc4ddd5eee6fff7ggg8hhh9")};
+
+    SetupPrefixMap(array, map);
+    nsresult rv = cache->Build(map);
+    ASSERT_TRUE(NS_FAILED(rv));
+  }
 }
 
 // Test save then load prefix set with only 4-bytes prefixes
-TEST_P(UrlClassifierPrefixSetTest, LoadSaveFixedLengthPrefixSet) {
+TEST(UrlClassifierVLPrefixSet, LoadSaveFixedLengthPrefixSet)
+{
   nsCOMPtr<nsIFile> file;
   _PrefixArray array;
   PrefixStringMap map;
 
   // Save
   {
     RefPtr<LookupCacheV4> save =
         SetupLookupCache(NS_LITERAL_CSTRING("test-save"));
@@ -362,17 +418,18 @@ TEST_P(UrlClassifierPrefixSetTest, LoadS
     DoRandomLookup(load, 1000, array);
     CheckContent(load, array);
   }
 
   file->Remove(false);
 }
 
 // Test save then load prefix set with only 5~32 bytes prefixes
-TEST_P(UrlClassifierPrefixSetTest, LoadSaveVariableLengthPrefixSet) {
+TEST(UrlClassifierVLPrefixSet, LoadSaveVariableLengthPrefixSet)
+{
   nsCOMPtr<nsIFile> file;
   _PrefixArray array;
   PrefixStringMap map;
 
   // Save
   {
     RefPtr<LookupCacheV4> save =
         SetupLookupCache(NS_LITERAL_CSTRING("test-save"));
@@ -401,17 +458,18 @@ TEST_P(UrlClassifierPrefixSetTest, LoadS
     DoRandomLookup(load, 1000, array);
     CheckContent(load, array);
   }
 
   file->Remove(false);
 }
 
 // Test save then load prefix with both 4 bytes prefixes and 5~32 bytes prefixes
-TEST_P(UrlClassifierPrefixSetTest, LoadSavePrefixSet) {
+TEST(UrlClassifierVLPrefixSet, LoadSavePrefixSet)
+{
   nsCOMPtr<nsIFile> file;
   _PrefixArray array;
   PrefixStringMap map;
 
   // Save
   {
     RefPtr<LookupCacheV4> save =
         SetupLookupCache(NS_LITERAL_CSTRING("test-save"));
@@ -442,17 +500,18 @@ TEST_P(UrlClassifierPrefixSetTest, LoadS
     DoRandomLookup(load, 1000, array);
     CheckContent(load, array);
   }
 
   file->Remove(false);
 }
 
 // This is for fixed-length prefixset
-TEST_P(UrlClassifierPrefixSetTest, LoadSaveNoDelta) {
+TEST(UrlClassifierVLPrefixSet, LoadSaveNoDelta)
+{
   nsCOMPtr<nsIFile> file;
   _PrefixArray array;
   PrefixStringMap map;
 
   for (uint32_t i = 0; i < 100; i++) {
     // construct a tree without deltas by making the distance
     // between entries larger than 16 bits
     uint32_t v = ((1 << 16) + 1) * i;
@@ -485,11 +544,8 @@ TEST_P(UrlClassifierPrefixSetTest, LoadS
 
     DoExpectedLookup(load, array);
     DoRandomLookup(load, 1000, array);
     CheckContent(load, array);
   }
 
   file->Remove(false);
 }
-
-// To run the same test for different configurations of "browser_safebrowsing_prefixset_max_array_size"
-INSTANTIATE_TEST_CASE_P(UrlClassifierPrefixSetTest, UrlClassifierPrefixSetTest, ::testing::Values(0, UINT32_MAX));