Backed out changeset ca779a5aa93f (bug 1383728) for failing the xpcshell tests test_ext_storage_telemetry.js and test_ext_extension_content_telemetry.js on Android. r=backout on a CLOSED TREE
authorSebastian Hengst <archaeopteryx@coole-files.de>
Thu, 27 Jul 2017 14:18:42 +0200
changeset 422535 eeb8b3ad1b548d635b63bc0af9cb805af192604b
parent 422534 a5e025d29c794fde8d3556ecd92ba3e9a2104d4f
child 422536 64c75441ef16f13e26067151237ce2e9f6b92ee3
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1383728
milestone56.0a1
backs outca779a5aa93fecf65a56647492208f3a17fd215c
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 changeset ca779a5aa93f (bug 1383728) for failing the xpcshell tests test_ext_storage_telemetry.js and test_ext_extension_content_telemetry.js on Android. r=backout on a CLOSED TREE
toolkit/components/extensions/test/xpcshell/head_telemetry.js
toolkit/components/extensions/test/xpcshell/test_ext_extension_content_telemetry.js
toolkit/components/extensions/test/xpcshell/test_ext_storage_telemetry.js
toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
toolkit/components/extensions/test/xpcshell/xpcshell-remote.ini
toolkit/components/extensions/test/xpcshell/xpcshell.ini
deleted file mode 100644
--- a/toolkit/components/extensions/test/xpcshell/head_telemetry.js
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set sts=2 sw=2 et tw=80: */
-"use strict";
-
-/* exported IS_OOP, arraySum, clearHistograms, getSnapshots, promiseTelemetryRecorded */
-
-XPCOMUtils.defineLazyModuleGetter(this, "ContentTaskUtils",
-                                  "resource://testing-common/ContentTaskUtils.jsm");
-
-const IS_OOP = Services.prefs.getBoolPref("extensions.webextensions.remote");
-
-function arraySum(arr) {
-  return arr.reduce((a, b) => a + b, 0);
-}
-
-function clearHistograms() {
-  Services.telemetry.snapshotSubsessionHistograms(true);
-}
-
-function getSnapshots(process) {
-  return Services.telemetry.snapshotSubsessionHistograms()[process];
-}
-
-// There is no good way to make sure that the parent received the histogram
-// entries from the extension and content processes.
-// Let's stick to the ugly, spinning the event loop until we have a good
-// approach (Bug 1357509).
-function promiseTelemetryRecorded(id, process, expectedCount) {
-  let condition = () => {
-    let snapshot = Services.telemetry.snapshotSubsessionHistograms()[process][id];
-    return snapshot && arraySum(snapshot.counts) >= expectedCount;
-  };
-  return ContentTaskUtils.waitForCondition(condition);
-}
--- a/toolkit/components/extensions/test/xpcshell/test_ext_extension_content_telemetry.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_extension_content_telemetry.js
@@ -36,41 +36,38 @@ add_task(async function test_telemetry()
       }],
     },
 
     files: {
       "content_script.js": contentScript,
     },
   });
 
-  clearHistograms();
-
-  let process = IS_OOP ? "content" : "parent";
-  ok(!(HISTOGRAM in getSnapshots(process)), `No data recorded for histogram: ${HISTOGRAM}.`);
+  let histogram = Services.telemetry.getHistogramById(HISTOGRAM);
+  histogram.clear();
+  equal(histogram.snapshot().sum, 0,
+        `No data recorded for histogram: ${HISTOGRAM}.`);
 
   await extension1.startup();
-  ok(!(HISTOGRAM in getSnapshots(process)),
-     `No data recorded for histogram after startup: ${HISTOGRAM}.`);
+  equal(histogram.snapshot().sum, 0,
+        `No data recorded for histogram after startup: ${HISTOGRAM}.`);
 
   let contentPage = await ExtensionTestUtils.loadContentPage(`${BASE_URL}/file_sample.html`);
   await extension1.awaitMessage("content-script-run");
-  await promiseTelemetryRecorded(HISTOGRAM, process, 1);
-
-  equal(arraySum(getSnapshots(process)[HISTOGRAM].counts), 1,
-        `Data recorded for histogram: ${HISTOGRAM}.`);
+  let histogramSum = histogram.snapshot().sum;
+  ok(histogramSum > 0,
+     `Data recorded for first extension for histogram: ${HISTOGRAM}.`);
 
   await contentPage.close();
   await extension1.unload();
 
   await extension2.startup();
-  equal(arraySum(getSnapshots(process)[HISTOGRAM].counts), 1,
+  equal(histogram.snapshot().sum, histogramSum,
         `No data recorded for histogram after startup: ${HISTOGRAM}.`);
 
   contentPage = await ExtensionTestUtils.loadContentPage(`${BASE_URL}/file_sample.html`);
   await extension2.awaitMessage("content-script-run");
-  await promiseTelemetryRecorded(HISTOGRAM, process, 2);
-
-  equal(arraySum(getSnapshots(process)[HISTOGRAM].counts), 2,
-        `Data recorded for histogram: ${HISTOGRAM}.`);
+  ok(histogram.snapshot().sum > histogramSum,
+     `Data recorded for second extension for histogram: ${HISTOGRAM}.`);
 
   await contentPage.close();
   await extension2.unload();
 });
--- a/toolkit/components/extensions/test/xpcshell/test_ext_storage_telemetry.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_storage_telemetry.js
@@ -1,16 +1,20 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 const HISTOGRAM_IDS = [
   "WEBEXT_STORAGE_LOCAL_SET_MS", "WEBEXT_STORAGE_LOCAL_GET_MS",
 ];
 
+function arraySum(arr) {
+  return arr.reduce((a, b) => a + b, 0);
+}
+
 add_task(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"});
@@ -40,65 +44,51 @@ add_task(async function test_telemetry_b
     files: {
       "content_script.js": contentScript,
     },
   };
 
   let extension1 = ExtensionTestUtils.loadExtension(extInfo);
   let extension2 = ExtensionTestUtils.loadExtension(extInfo);
 
-  clearHistograms();
-
-  let process = IS_OOP ? "extension" : "parent";
-  let snapshots = getSnapshots(process);
+  // Initialize and clear histograms.
+  let histograms = {};
   for (let id of HISTOGRAM_IDS) {
-    ok(!(id in snapshots), `No data recorded for histogram: ${id}.`);
+    histograms[id] = Services.telemetry.getHistogramById(id);
+    histograms[id].clear();
+    equal(arraySum(histograms[id].snapshot().counts), 0,
+          `No data recorded for histogram: ${id}.`);
   }
 
   await extension1.startup();
   await extension1.awaitMessage("backgroundDone");
-  for (let id of HISTOGRAM_IDS) {
-    await promiseTelemetryRecorded(id, process, 1);
-  }
 
   // Telemetry from extension1's background page should be recorded.
-  snapshots = getSnapshots(process);
-  for (let id of HISTOGRAM_IDS) {
-    equal(arraySum(snapshots[id].counts), 1,
+  for (let id in histograms) {
+    equal(arraySum(histograms[id].snapshot().counts), 1,
           `Data recorded for histogram: ${id}.`);
   }
 
   await extension2.startup();
   await extension2.awaitMessage("backgroundDone");
-  for (let id of HISTOGRAM_IDS) {
-    await promiseTelemetryRecorded(id, process, 2);
-  }
 
   // Telemetry from extension2's background page should be recorded.
-  snapshots = getSnapshots(process);
-  for (let id of HISTOGRAM_IDS) {
-    equal(arraySum(snapshots[id].counts), 2,
+  for (let id in histograms) {
+    equal(arraySum(histograms[id].snapshot().counts), 2,
           `Additional data recorded for histogram: ${id}.`);
   }
 
   await extension2.unload();
 
   // Run a content script.
-  process = IS_OOP ? "content" : "parent";
-  let expectedCount = IS_OOP ? 1 : 3;
   let contentScriptPromise = extension1.awaitMessage("contentDone");
   let contentPage = await ExtensionTestUtils.loadContentPage(`${BASE_URL}/file_sample.html`);
   await contentScriptPromise;
   await contentPage.close();
 
-  for (let id of HISTOGRAM_IDS) {
-    await promiseTelemetryRecorded(id, process, expectedCount);
-  }
-
   // Telemetry from extension1's content script should be recorded.
-  snapshots = getSnapshots(process);
-  for (let id of HISTOGRAM_IDS) {
-    equal(arraySum(snapshots[id].counts), expectedCount,
+  for (let id in histograms) {
+    equal(arraySum(histograms[id].snapshot().counts), 3,
           `Data recorded in content script for histogram: ${id}.`);
   }
 
   await extension1.unload();
 });
--- a/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
@@ -8,32 +8,30 @@
 [test_ext_background_global_history.js]
 skip-if = os == "android" # Android does not use Places for history.
 [test_ext_background_private_browsing.js]
 [test_ext_background_runtime_connect_params.js]
 [test_ext_background_sub_windows.js]
 [test_ext_background_telemetry.js]
 [test_ext_background_window_properties.js]
 skip-if = os == "android"
-[test_ext_browserSettings.js]
 [test_ext_contextual_identities.js]
 skip-if = os == "android" # Containers are not exposed to android.
 [test_ext_debugging_utils.js]
 [test_ext_downloads.js]
 [test_ext_downloads_download.js]
 skip-if = os == "android"
 [test_ext_downloads_misc.js]
 skip-if = os == "android" || (os=='linux' && bits==32) # linux32: bug 1324870
 [test_ext_downloads_search.js]
 skip-if = os == "android"
 [test_ext_experiments.js]
 [test_ext_extension.js]
 [test_ext_extensionPreferencesManager.js]
 [test_ext_extensionSettingsStore.js]
-[test_ext_extension_content_telemetry.js]
 [test_ext_extension_startup_telemetry.js]
 [test_ext_idle.js]
 [test_ext_legacy_extension_context.js]
 [test_ext_legacy_extension_embedding.js]
 [test_ext_localStorage.js]
 [test_ext_management.js]
 [test_ext_management_uninstall_self.js]
 [test_ext_onmessage_removelistener.js]
@@ -53,13 +51,12 @@ skip-if = true # This test no longer tes
 [test_ext_simple.js]
 [test_ext_startup_cache.js]
 [test_ext_storage.js]
 [test_ext_storage_sync.js]
 head = head.js head_sync.js
 skip-if = os == "android"
 [test_ext_storage_sync_crypto.js]
 skip-if = os == "android"
-[test_ext_storage_telemetry.js]
 [test_ext_topSites.js]
 skip-if = os == "android"
 [test_native_messaging.js]
 skip-if = os == "android"
--- a/toolkit/components/extensions/test/xpcshell/xpcshell-remote.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell-remote.ini
@@ -1,10 +1,10 @@
 [DEFAULT]
-head = head.js head_remote.js head_e10s.js head_telemetry.js
+head = head.js head_remote.js head_e10s.js
 tail =
 firefox-appdir = browser
 skip-if = appname == "thunderbird" || os == "android"
 dupe-manifest =
 support-files =
   data/**
   xpcshell-content.ini
 tags = webextensions remote-webextensions
--- a/toolkit/components/extensions/test/xpcshell/xpcshell.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell.ini
@@ -1,10 +1,10 @@
 [DEFAULT]
-head = head.js head_telemetry.js
+head = head.js
 firefox-appdir = browser
 skip-if = appname == "thunderbird"
 dupe-manifest =
 support-files =
   data/**
   head_sync.js
   xpcshell-content.ini
 tags = webextensions in-process-webextensions