summaryrefslogtreecommitdiffstats
path: root/toolkit/components/terminator/tests/xpcshell
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-02-25 15:07:00 -0500
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 12:55:19 +0200
commiteb70e6e3d0bff11c25f14b1196025791bf2308fb (patch)
tree5ef4ce17db83c74d7b05ec12c8f59e095a6dd5bd /toolkit/components/terminator/tests/xpcshell
parent32ead795290b3399d56b4708fc75b77d296f6a1a (diff)
downloadUXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.gz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.lz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.xz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.zip
Issue #439 - Remove tests from toolkit/
Diffstat (limited to 'toolkit/components/terminator/tests/xpcshell')
-rw-r--r--toolkit/components/terminator/tests/xpcshell/.eslintrc.js7
-rw-r--r--toolkit/components/terminator/tests/xpcshell/test_terminator_record.js108
-rw-r--r--toolkit/components/terminator/tests/xpcshell/test_terminator_reload.js85
-rw-r--r--toolkit/components/terminator/tests/xpcshell/xpcshell.ini8
4 files changed, 0 insertions, 208 deletions
diff --git a/toolkit/components/terminator/tests/xpcshell/.eslintrc.js b/toolkit/components/terminator/tests/xpcshell/.eslintrc.js
deleted file mode 100644
index d35787cd2..000000000
--- a/toolkit/components/terminator/tests/xpcshell/.eslintrc.js
+++ /dev/null
@@ -1,7 +0,0 @@
-"use strict";
-
-module.exports = {
- "extends": [
- "../../../../../testing/xpcshell/xpcshell.eslintrc.js"
- ]
-};
diff --git a/toolkit/components/terminator/tests/xpcshell/test_terminator_record.js b/toolkit/components/terminator/tests/xpcshell/test_terminator_record.js
deleted file mode 100644
index 248ead9ce..000000000
--- a/toolkit/components/terminator/tests/xpcshell/test_terminator_record.js
+++ /dev/null
@@ -1,108 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-
-// Test that the Shutdown Terminator records durations correctly
-
-var Cu = Components.utils;
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-
-Cu.import("resource://gre/modules/Services.jsm", this);
-Cu.import("resource://gre/modules/osfile.jsm", this);
-Cu.import("resource://gre/modules/Timer.jsm", this);
-Cu.import("resource://gre/modules/Task.jsm", this);
-
-var {Path, File, Constants} = OS;
-
-var PATH;
-var PATH_TMP;
-var terminator;
-
-add_task(function* init() {
- do_get_profile();
- PATH = Path.join(Constants.Path.localProfileDir, "ShutdownDuration.json");
- PATH_TMP = PATH + ".tmp";
-
- // Initialize the terminator
- // (normally, this is done through the manifest file, but xpcshell
- // doesn't take them into account).
- do_print("Initializing the Terminator");
- terminator = Cc["@mozilla.org/toolkit/shutdown-terminator;1"].
- createInstance(Ci.nsIObserver);
- terminator.observe(null, "profile-after-change", null);
-});
-
-var promiseShutdownDurationData = Task.async(function*() {
- // Wait until PATH exists.
- // Timeout if it is never created.
- do_print("Waiting for file creation: " + PATH);
- while (true) {
- if ((yield OS.File.exists(PATH))) {
- break;
- }
-
- do_print("The file does not exist yet. Waiting 1 second.");
- yield new Promise(resolve => setTimeout(resolve, 1000));
- }
-
- do_print("The file has been created");
- let raw = yield OS.File.read(PATH, { encoding: "utf-8"} );
- do_print(raw);
- return JSON.parse(raw);
-});
-
-add_task(function* test_record() {
- let PHASE0 = "profile-change-teardown";
- let PHASE1 = "profile-before-change";
- let PHASE2 = "xpcom-will-shutdown";
- let t0 = Date.now();
-
- do_print("Starting shutdown");
- terminator.observe(null, "profile-change-teardown", null);
-
- do_print("Moving to next phase");
- terminator.observe(null, PHASE1, null);
-
- let data = yield promiseShutdownDurationData();
-
- let t1 = Date.now();
-
- Assert.ok(PHASE0 in data, "The file contains the expected key");
- let duration = data[PHASE0];
- Assert.equal(typeof duration, "number");
- Assert.ok(duration >= 0, "Duration is a non-negative number");
- Assert.ok(duration <= Math.ceil((t1 - t0) / 1000) + 1,
- "Duration is reasonable");
-
- Assert.equal(Object.keys(data).length, 1, "Data does not contain other durations");
-
- do_print("Cleaning up and moving to next phase");
- yield File.remove(PATH);
- yield File.remove(PATH_TMP);
-
- do_print("Waiting at least one tick");
- let WAIT_MS = 2000;
- yield new Promise(resolve => setTimeout(resolve, WAIT_MS));
-
- terminator.observe(null, PHASE2, null);
- data = yield promiseShutdownDurationData();
-
- let t2 = Date.now();
-
- Assert.equal(Object.keys(data).sort().join(", "),
- [PHASE0, PHASE1].sort().join(", "),
- "The file contains the expected keys");
- Assert.equal(data[PHASE0], duration, "Duration of phase 0 hasn't changed");
- let duration2 = data[PHASE1];
- Assert.equal(typeof duration2, "number");
- Assert.ok(duration2 >= WAIT_MS / 2000, "We have waited at least " + (WAIT_MS / 2000) + " ticks");
- Assert.ok(duration2 <= Math.ceil((t2 - t1) / 1000) + 1,
- "Duration is reasonable");
-});
-
-function run_test() {
- run_next_test();
-}
diff --git a/toolkit/components/terminator/tests/xpcshell/test_terminator_reload.js b/toolkit/components/terminator/tests/xpcshell/test_terminator_reload.js
deleted file mode 100644
index 1c16395b3..000000000
--- a/toolkit/components/terminator/tests/xpcshell/test_terminator_reload.js
+++ /dev/null
@@ -1,85 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-
-// Test that the Shutdown Terminator reloads durations correctly
-
-var Cu = Components.utils;
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-
-Cu.import("resource://gre/modules/Services.jsm", this);
-Cu.import("resource://gre/modules/osfile.jsm", this);
-Cu.import("resource://gre/modules/Timer.jsm", this);
-Cu.import("resource://gre/modules/Task.jsm", this);
-
-var {Path, File, Constants} = OS;
-
-var PATH;
-
-var HISTOGRAMS = {
- "quit-application": "SHUTDOWN_PHASE_DURATION_TICKS_QUIT_APPLICATION",
- "profile-change-teardown": "SHUTDOWN_PHASE_DURATION_TICKS_PROFILE_CHANGE_TEARDOWN",
- "profile-before-change": "SHUTDOWN_PHASE_DURATION_TICKS_PROFILE_BEFORE_CHANGE",
- "xpcom-will-shutdown": "SHUTDOWN_PHASE_DURATION_TICKS_XPCOM_WILL_SHUTDOWN",
-};
-
-add_task(function* init() {
- do_get_profile();
- PATH = Path.join(Constants.Path.localProfileDir, "ShutdownDuration.json");
-});
-
-add_task(function* test_reload() {
- do_print("Forging data");
- let data = {};
- let telemetrySnapshots = Services.telemetry.histogramSnapshots;
- let i = 0;
- for (let k of Object.keys(HISTOGRAMS)) {
- let id = HISTOGRAMS[k];
- data[k] = i++;
- Assert.equal(telemetrySnapshots[id] || undefined, undefined, "Histogram " + id + " is empty");
- }
-
-
- yield OS.File.writeAtomic(PATH, JSON.stringify(data));
-
- const TOPIC = "shutdown-terminator-telemetry-updated";
-
- let wait = new Promise(resolve =>
- Services.obs.addObserver(
- function observer() {
- do_print("Telemetry has been updated");
- Services.obs.removeObserver(observer, TOPIC);
- resolve();
- },
- TOPIC,
- false));
-
- do_print("Starting nsTerminatorTelemetry");
- let tt = Cc["@mozilla.org/toolkit/shutdown-terminator-telemetry;1"].
- createInstance(Ci.nsIObserver);
- tt.observe(null, "profile-after-change", "");
-
- do_print("Waiting until telemetry is updated");
- // Now wait until Telemetry is updated
- yield wait;
-
- telemetrySnapshots = Services.telemetry.histogramSnapshots;
- for (let k of Object.keys(HISTOGRAMS)) {
- let id = HISTOGRAMS[k];
- do_print("Testing histogram " + id);
- let snapshot = telemetrySnapshots[id];
- let count = 0;
- for (let x of snapshot.counts) {
- count += x;
- }
- Assert.equal(count, 1, "We have added one item");
- }
-
-});
-
-function run_test() {
- run_next_test();
-}
diff --git a/toolkit/components/terminator/tests/xpcshell/xpcshell.ini b/toolkit/components/terminator/tests/xpcshell/xpcshell.ini
deleted file mode 100644
index 7f77938aa..000000000
--- a/toolkit/components/terminator/tests/xpcshell/xpcshell.ini
+++ /dev/null
@@ -1,8 +0,0 @@
-[DEFAULT]
-head=
-tail=
-
-[test_terminator_record.js]
-skip-if = debug # Disabled by bug 1242084, bug 1255484 will enable it again.
-[test_terminator_reload.js]
-skip-if = os == "android"