mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 913070 - Move TelemetryPing to a jsm. r=Yoric, r=glandium
--HG-- rename : toolkit/components/telemetry/TelemetryPing.js => toolkit/components/telemetry/TelemetryPing.jsm
This commit is contained in:
parent
208013d353
commit
9191340566
File diff suppressed because it is too large
Load Diff
1102
toolkit/components/telemetry/TelemetryPing.jsm
Normal file
1102
toolkit/components/telemetry/TelemetryPing.jsm
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,2 @@
|
||||
component {55d6a5fa-130e-4ee6-a158-0133af3b86ba} TelemetryPing.js
|
||||
contract @mozilla.org/base/telemetry-ping;1 {55d6a5fa-130e-4ee6-a158-0133af3b86ba}
|
||||
category profile-after-change TelemetryPing @mozilla.org/base/telemetry-ping;1
|
||||
|
28
toolkit/components/telemetry/TelemetryStartup.js
Normal file
28
toolkit/components/telemetry/TelemetryStartup.js
Normal file
@ -0,0 +1,28 @@
|
||||
/* -*- js-indent-level: 2; indent-tabs-mode: nil -*- */
|
||||
/* 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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/TelemetryPing.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm")
|
||||
|
||||
/**
|
||||
* TelemetryStartup is needed to forward the "profile-after-change" notification
|
||||
* to TelemetryPing.jsm.
|
||||
*/
|
||||
function TelemetryStartup() {
|
||||
}
|
||||
|
||||
TelemetryStartup.prototype.classID = Components.ID("{117b219f-92fe-4bd2-a21b-95a342a9d474}");
|
||||
TelemetryStartup.prototype.QueryInterface = XPCOMUtils.generateQI([Components.interfaces.nsIObserver])
|
||||
TelemetryStartup.prototype.observe = function(aSubject, aTopic, aData){
|
||||
if (aTopic == "profile-after-change") {
|
||||
TelemetryPing.observe(null, "profile-after-change", null);
|
||||
}
|
||||
}
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TelemetryStartup]);
|
3
toolkit/components/telemetry/TelemetryStartup.manifest
Normal file
3
toolkit/components/telemetry/TelemetryStartup.manifest
Normal file
@ -0,0 +1,3 @@
|
||||
component {117b219f-92fe-4bd2-a21b-95a342a9d474} TelemetryStartup.js
|
||||
contract @mozilla.org/base/telemetry-startup;1 {117b219f-92fe-4bd2-a21b-95a342a9d474}
|
||||
category profile-after-change TelemetryStartup @mozilla.org/base/telemetry-startup;1
|
@ -24,11 +24,10 @@ SOURCES += [
|
||||
]
|
||||
|
||||
EXTRA_COMPONENTS += [
|
||||
'TelemetryPing.manifest',
|
||||
]
|
||||
|
||||
EXTRA_PP_COMPONENTS += [
|
||||
'TelemetryPing.js',
|
||||
'TelemetryPing.manifest',
|
||||
'TelemetryStartup.js',
|
||||
'TelemetryStartup.manifest'
|
||||
]
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
@ -38,6 +37,7 @@ EXTRA_JS_MODULES += [
|
||||
]
|
||||
|
||||
EXTRA_PP_JS_MODULES += [
|
||||
'TelemetryPing.jsm',
|
||||
'UITelemetry.jsm',
|
||||
]
|
||||
|
||||
|
@ -17,6 +17,7 @@ Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/LightweightThemeManager.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/TelemetryPing.jsm");
|
||||
|
||||
const IGNORE_HISTOGRAM = "test::ignore_me";
|
||||
const IGNORE_HISTOGRAM_TO_CLONE = "MEMORY_HEAP_ALLOCATED";
|
||||
@ -38,7 +39,6 @@ const NUMBER_OF_THREADS_TO_LAUNCH = 30;
|
||||
var gNumberOfThreadsLaunched = 0;
|
||||
|
||||
const Telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
|
||||
const TelemetryPing = Cc["@mozilla.org/base/telemetry-ping;1"].getService(Ci.nsITelemetryPing);
|
||||
|
||||
var httpserver = new HttpServer();
|
||||
var serverStarted = false;
|
||||
|
@ -13,13 +13,13 @@
|
||||
* -> previousBuildID in telemetry, new value set in prefs.
|
||||
*/
|
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
const Cu = Components.utils;
|
||||
|
||||
// Get the TelemetryPing definitions directly so we can test it without going through xpcom.
|
||||
Services.scriptloader.loadSubScript("resource://gre/components/TelemetryPing.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/TelemetryPing.jsm");
|
||||
|
||||
// Force the Telemetry enabled preference so that TelemetryPing.setup() doesn't exit early.
|
||||
Services.prefs.setBoolPref(PREF_ENABLED, true);
|
||||
// Force the Telemetry enabled preference so that TelemetryPing.reset() doesn't exit early.
|
||||
Services.prefs.setBoolPref(TelemetryPing.Constants.PREF_ENABLED, true);
|
||||
|
||||
// Set up our dummy AppInfo object so we can control the appBuildID.
|
||||
Cu.import("resource://testing-common/AppInfo.jsm");
|
||||
@ -28,25 +28,22 @@ updateAppInfo();
|
||||
// Check that when run with no previous build ID stored, we update the pref but do not
|
||||
// put anything into the metadata.
|
||||
function testFirstRun() {
|
||||
let ping = new TelemetryPing();
|
||||
ping.setup();
|
||||
let metadata = ping.getMetadata();
|
||||
TelemetryPing.reset();
|
||||
let metadata = TelemetryPing.getMetadata();
|
||||
do_check_false("previousBuildID" in metadata);
|
||||
let appBuildID = getAppInfo().appBuildID;
|
||||
let buildIDPref = Services.prefs.getCharPref(PREF_PREVIOUS_BUILDID);
|
||||
let buildIDPref = Services.prefs.getCharPref(TelemetryPing.Constants.PREF_PREVIOUS_BUILDID);
|
||||
do_check_eq(appBuildID, buildIDPref);
|
||||
}
|
||||
|
||||
// Check that a subsequent run with the same build ID does not put prev build ID in
|
||||
// metadata. Assumes testFirstRun() has already been called to set the previousBuildID pref.
|
||||
function testSecondRun() {
|
||||
let ping = new TelemetryPing();
|
||||
ping.setup();
|
||||
let metadata = ping.getMetadata();
|
||||
TelemetryPing.reset();
|
||||
let metadata = TelemetryPing.getMetadata();
|
||||
do_check_false("previousBuildID" in metadata);
|
||||
}
|
||||
|
||||
|
||||
// Set up telemetry with a different app build ID and check that the old build ID
|
||||
// is returned in the metadata and the pref is updated to the new build ID.
|
||||
// Assumes testFirstRun() has been called to set the previousBuildID pref.
|
||||
@ -55,11 +52,10 @@ function testNewBuild() {
|
||||
let info = getAppInfo();
|
||||
let oldBuildID = info.appBuildID;
|
||||
info.appBuildID = NEW_BUILD_ID;
|
||||
let ping = new TelemetryPing();
|
||||
ping.setup();
|
||||
let metadata = ping.getMetadata();
|
||||
TelemetryPing.reset();
|
||||
let metadata = TelemetryPing.getMetadata();
|
||||
do_check_eq(metadata.previousBuildID, oldBuildID);
|
||||
let buildIDPref = Services.prefs.getCharPref(PREF_PREVIOUS_BUILDID);
|
||||
let buildIDPref = Services.prefs.getCharPref(TelemetryPing.Constants.PREF_PREVIOUS_BUILDID);
|
||||
do_check_eq(NEW_BUILD_ID, buildIDPref);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,12 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// Check that TelemetryPing notifies correctly on idle.
|
||||
// Check that TelemetryPing notifies correctly on idle-daily.
|
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/TelemetryPing.jsm");
|
||||
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
@ -13,7 +16,5 @@ function run_test() {
|
||||
do_test_finished();
|
||||
}, "gather-telemetry", false);
|
||||
|
||||
Components.classes["@mozilla.org/base/telemetry-ping;1"]
|
||||
.getService(Components.interfaces.nsITelemetryPing)
|
||||
.observe(null, "idle-daily", null);
|
||||
TelemetryPing.observe(null, "idle-daily", null);
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/ThirdPartyCookieProbe.jsm");
|
||||
Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");
|
||||
Cu.import("resource://gre/modules/TelemetryPing.jsm");
|
||||
|
||||
let TOPIC_ACCEPTED = "third-party-cookie-accepted";
|
||||
let TOPIC_REJECTED = "third-party-cookie-rejected";
|
||||
@ -19,8 +20,6 @@ const NUMBER_OF_REJECTS = 30;
|
||||
const NUMBER_OF_ACCEPTS = 17;
|
||||
const NUMBER_OF_REPEATS = 5;
|
||||
|
||||
const TelemetryPing = Cc["@mozilla.org/base/telemetry-ping;1"].getService(Ci.nsITelemetryPing);
|
||||
|
||||
let gCookieService;
|
||||
let gThirdPartyCookieProbe;
|
||||
|
||||
|
@ -10,14 +10,13 @@ const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/TelemetryTimestamps.jsm");
|
||||
Cu.import("resource://gre/modules/TelemetryPing.jsm");
|
||||
|
||||
const Telemetry = Services.telemetry;
|
||||
const bundle = Services.strings.createBundle(
|
||||
"chrome://global/locale/aboutTelemetry.properties");
|
||||
const brandBundle = Services.strings.createBundle(
|
||||
"chrome://branding/locale/brand.properties");
|
||||
const TelemetryPing = Cc["@mozilla.org/base/telemetry-ping;1"].
|
||||
getService(Ci.nsITelemetryPing);
|
||||
|
||||
// Maximum height of a histogram bar (in em for html, in chars for text)
|
||||
const MAX_BAR_HEIGHT = 18;
|
||||
|
@ -13,10 +13,8 @@ Cu.import("resource://testing-common/AppInfo.jsm");
|
||||
updateAppInfo();
|
||||
|
||||
function getSimpleMeasurementsFromTelemetryPing() {
|
||||
const TelemetryPing = Cc["@mozilla.org/base/telemetry-ping;1"].getService(Ci.nsITelemetryPing);
|
||||
let ping = TelemetryPing.getPayload();
|
||||
|
||||
return ping.simpleMeasurements;
|
||||
return Cu.import("resource://gre/modules/TelemetryPing.jsm", {}).
|
||||
TelemetryPing.getPayload().simpleMeasurements;
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
|
@ -2254,8 +2254,7 @@ var XPIProvider = {
|
||||
}
|
||||
catch (e) { }
|
||||
|
||||
const TelemetryPing = Cc["@mozilla.org/base/telemetry-ping;1"].getService(Ci.nsITelemetryPing);
|
||||
TelemetryPing.setAddOns(data);
|
||||
Cu.import("resource://gre/modules/TelemetryPing.jsm", {}).TelemetryPing.setAddOns(data);
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user