Bug 1406181 - Test storage.local telemetry on file and indexedDB backends. draft
authorLuca Greco <lgreco@mozilla.com>
Thu, 19 Oct 2017 15:46:51 +0200
changeset 802172 528d73674d5475234f850a425c31710bc9312ac6
parent 802171 9f518bd0f02a5f9ce8ecf559a209e10a3886fb81
child 802173 f4b1666730090cdc5194482be36ef73d71f46cb7
push id111848
push userluca.greco@alcacoop.it
push dateThu, 31 May 2018 16:18:52 +0000
bugs1406181
milestone62.0a1
Bug 1406181 - Test storage.local telemetry on file and indexedDB backends. MozReview-Commit-ID: AHSPICGKdib
toolkit/components/extensions/test/xpcshell/test_ext_storage_telemetry.js
--- a/toolkit/components/extensions/test/xpcshell/test_ext_storage_telemetry.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_storage_telemetry.js
@@ -1,17 +1,19 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
+ChromeUtils.import("resource://gre/modules/ExtensionStorageIDB.jsm");
+
 const HISTOGRAM_IDS = [
   "WEBEXT_STORAGE_LOCAL_SET_MS", "WEBEXT_STORAGE_LOCAL_GET_MS",
 ];
 
-add_task(async function test_telemetry_background() {
+async function test_telemetry_background() {
   const server = createHttpServer();
   server.registerDirectory("/data/", do_get_file("data"));
 
   const BASE_URL = `http://localhost:${server.identity.primaryPort}/data`;
 
   async function contentScript() {
     await browser.storage.local.set({a: "b"});
     await browser.storage.local.get("a");
@@ -96,9 +98,19 @@ add_task(async function test_telemetry_b
   // Telemetry from extension1's content script should be recorded.
   snapshots = getSnapshots(process);
   for (let id of HISTOGRAM_IDS) {
     equal(arraySum(snapshots[id].counts), expectedCount,
           `Data recorded in content script for histogram: ${id}.`);
   }
 
   await extension1.unload();
+}
+
+add_task(function test_telemetry_background_file_backend() {
+  return runWithPrefs([[ExtensionStorageIDB.BACKEND_ENABLED_PREF, false]],
+                      test_telemetry_background);
 });
+
+add_task(function test_telemetry_background_idb_backend() {
+  return runWithPrefs([[ExtensionStorageIDB.BACKEND_ENABLED_PREF, true]],
+                      test_telemetry_background);
+});