Bug 1380287 - Turn on telemetry in test_chrome_ext_contentscript_telemetry.html. r=Dexter
authorLuca Greco <lgreco@mozilla.com>
Wed, 19 Jul 2017 14:22:23 +0200
changeset 419549 2039119836eafbe19e47a9db193141e5f1da355d
parent 419548 98ea7eeab6f3ae7835e8fa47d9b42cc2a02a29a5
child 419550 58b73242f3ef211bdac77612e8cd797b49a22a35
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersDexter
bugs1380287
milestone56.0a1
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
Bug 1380287 - Turn on telemetry in test_chrome_ext_contentscript_telemetry.html. r=Dexter MozReview-Commit-ID: L4v0PDks3uH
toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_telemetry.html
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_telemetry.html
+++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_telemetry.html
@@ -11,16 +11,29 @@
 <body>
 
 <script>
 "use strict";
 
 const HISTOGRAM = "WEBEXT_CONTENT_SCRIPT_INJECTION_MS";
 
 add_task(async function test_contentscript_telemetry() {
+  // Turn on telemetry and reset it to the previous state once the test is completed.
+  // NOTE: This is only needed on Android (which does not properly support unified telemetry,
+  // while we're always recording opt-out telemetry on desktop).
+  // Switching the "toolkit.telemetry.enabled" preference
+  // (e.g. using SpecialPowers.pushPrefEnv) is unfortunately not enough,
+  // because the TelemetryController has been already initialized when this
+  // code is going to be executed.
+  const telemetryCanRecordBase = SpecialPowers.Services.telemetry.canRecordBase;
+  SpecialPowers.Services.telemetry.canRecordBase = true;
+  SimpleTest.registerCleanupFunction(() => {
+    SpecialPowers.Services.telemetry.canRecordBase = telemetryCanRecordBase;
+  });
+
   function background() {
     browser.test.onMessage.addListener(() => {
       browser.tabs.executeScript({code: 'browser.test.sendMessage("content-script-run");'});
     });
   }
 
   let extensionData = {
     manifest: {