summaryrefslogtreecommitdiffstats
path: root/startupcache/test/TestStartupCacheTelemetry.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /startupcache/test/TestStartupCacheTelemetry.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'startupcache/test/TestStartupCacheTelemetry.js')
-rw-r--r--startupcache/test/TestStartupCacheTelemetry.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/startupcache/test/TestStartupCacheTelemetry.js b/startupcache/test/TestStartupCacheTelemetry.js
new file mode 100644
index 000000000..7a570187f
--- /dev/null
+++ b/startupcache/test/TestStartupCacheTelemetry.js
@@ -0,0 +1,60 @@
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+
+Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+
+function shouldHaveChanged(a, b)
+{
+ if (a.length != b.length) {
+ throw Error("TEST-UNEXPECTED-FAIL: telemetry count array size changed");
+ }
+
+ for (let i = 0; i < a.length; ++i) {
+ if (a[i] == b[i]) {
+ continue;
+ }
+ return; // something was different, that's all that matters
+ }
+ throw Error("TEST-UNEXPECTED-FAIL: telemetry data didn't change");
+}
+
+function TestStartupCacheTelemetry() { }
+
+TestStartupCacheTelemetry.prototype = {
+ classID: Components.ID("{73cbeffd-d6c7-42f0-aaf3-f176430dcfc8}"),
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
+
+ saveInitial: function() {
+ let t = Services.telemetry;
+ this._age = t.getHistogramById("STARTUP_CACHE_AGE_HOURS").snapshot.counts;
+ this._invalid = t.getHistogramById("STARTUP_CACHE_INVALID").snapshot.counts;
+ },
+
+ checkFinal: function() {
+ let t = Services.telemetry;
+ let newAge = t.getHistogramById("STARTUP_CACHE_AGE_HOURS").snapshot.counts;
+ shouldHaveChanged(this._age, newAge);
+
+ let newInvalid = t.getHistogramById("STARTUP_CACHE_INVALID").snapshot.counts;
+ shouldHaveChanged(this._invalid, newInvalid);
+ },
+
+ observe: function(subject, topic, data) {
+ switch (topic) {
+ case "save-initial":
+ this.saveInitial();
+ break;
+
+ case "check-final":
+ this.checkFinal();
+ break;
+
+ default:
+ throw Error("BADDOG, NO MILKBONE FOR YOU");
+ }
+ },
+};
+
+this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TestStartupCacheTelemetry]);