mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1119281 - Fix missing telemetry client id in saved session pings. r=vladan
This commit is contained in:
parent
d84258083b
commit
d95fc78482
@ -214,6 +214,7 @@ this.TelemetryPing = Object.freeze({
|
||||
*/
|
||||
reset: function() {
|
||||
this.uninstall();
|
||||
Impl._clientID = null;
|
||||
return this.setup();
|
||||
},
|
||||
/**
|
||||
@ -222,6 +223,7 @@ this.TelemetryPing = Object.freeze({
|
||||
setup: function() {
|
||||
return Impl.setupChromeProcess(true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Used only for testing purposes.
|
||||
*/
|
||||
@ -232,6 +234,13 @@ this.TelemetryPing = Object.freeze({
|
||||
// Ignore errors
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Used only for testing purposes.
|
||||
*/
|
||||
shutdown: function() {
|
||||
return Impl.shutdown(true);
|
||||
},
|
||||
/**
|
||||
* Descriptive metadata
|
||||
*
|
||||
@ -1025,10 +1034,7 @@ let Impl = {
|
||||
AsyncShutdown.sendTelemetry.addBlocker(
|
||||
"Telemetry: shutting down",
|
||||
function condition(){
|
||||
this.uninstall();
|
||||
if (Telemetry.canSend) {
|
||||
return this.savePendingPings();
|
||||
}
|
||||
this.shutdown();
|
||||
}.bind(this));
|
||||
|
||||
Services.obs.addObserver(this, "sessionstore-windows-restored", false);
|
||||
@ -1175,7 +1181,6 @@ let Impl = {
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
Services.obs.removeObserver(this, "application-background", false);
|
||||
#endif
|
||||
this._clientID = null;
|
||||
},
|
||||
|
||||
getPayload: function getPayload() {
|
||||
@ -1308,4 +1313,16 @@ let Impl = {
|
||||
get clientID() {
|
||||
return this._clientID;
|
||||
},
|
||||
|
||||
/**
|
||||
* This tells TelemetryPing to uninitialize and save any pending pings.
|
||||
* @param testing Optional. If true, always saves the ping whether Telemetry
|
||||
* can send pings or not, which is used for testing.
|
||||
*/
|
||||
shutdown: function(testing = false) {
|
||||
this.uninstall();
|
||||
if (Telemetry.canSend || testing) {
|
||||
return this.savePendingPings();
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@ -22,6 +22,7 @@ Cu.import("resource://gre/modules/TelemetryFile.jsm", this);
|
||||
Cu.import("resource://gre/modules/Task.jsm", this);
|
||||
Cu.import("resource://gre/modules/Promise.jsm", this);
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
Cu.import("resource://gre/modules/osfile.jsm", this);
|
||||
|
||||
const IGNORE_HISTOGRAM = "test::ignore_me";
|
||||
const IGNORE_HISTOGRAM_TO_CLONE = "MEMORY_HEAP_ALLOCATED";
|
||||
@ -621,6 +622,20 @@ add_task(function* test_runOldPingFile() {
|
||||
do_check_false(histogramsFile.exists());
|
||||
});
|
||||
|
||||
add_task(function* test_savedSessionClientID() {
|
||||
// Assure that we store the ping properly when saving sessions on shutdown.
|
||||
// We make the TelemetryPings shutdown to trigger a session save.
|
||||
const dir = TelemetryFile.pingDirectoryPath;
|
||||
yield OS.File.removeDir(dir, {ignoreAbsent: true});
|
||||
yield OS.File.makeDir(dir);
|
||||
TelemetryPing.shutdown();
|
||||
|
||||
yield TelemetryFile.loadSavedPings();
|
||||
Assert.equal(TelemetryFile.pingsLoaded, 1);
|
||||
let ping = TelemetryFile.popPendingPings().next();
|
||||
Assert.equal(ping.value.payload.clientID, gDataReportingClientID);
|
||||
});
|
||||
|
||||
add_task(function* stopServer(){
|
||||
gHttpServer.stop(do_test_finished);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user