summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/tests/expiration/test_pref_interval.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 /toolkit/components/places/tests/expiration/test_pref_interval.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 'toolkit/components/places/tests/expiration/test_pref_interval.js')
-rw-r--r--toolkit/components/places/tests/expiration/test_pref_interval.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/toolkit/components/places/tests/expiration/test_pref_interval.js b/toolkit/components/places/tests/expiration/test_pref_interval.js
new file mode 100644
index 000000000..44c749d7a
--- /dev/null
+++ b/toolkit/components/places/tests/expiration/test_pref_interval.js
@@ -0,0 +1,61 @@
+/**
+ * What this is aimed to test:
+ *
+ * Expiration relies on an interval, that is user-preffable setting
+ * "places.history.expiration.interval_seconds".
+ * On pref change it will stop current interval timer and fire a new one,
+ * that will obey the new value.
+ * If the pref is set to a number <= 0 we will use the default value.
+ */
+
+// Default timer value for expiration in seconds. Must have same value as
+// PREF_INTERVAL_SECONDS_NOTSET in nsPlacesExpiration.
+const DEFAULT_TIMER_DELAY_SECONDS = 3 * 60;
+
+// Sync this with the const value in the component.
+const EXPIRE_AGGRESSIVITY_MULTIPLIER = 3;
+
+var tests = [
+
+ // This test should be the first, so the interval won't be influenced by
+ // status of history.
+ { desc: "Set interval to 1s.",
+ interval: 1,
+ expectedTimerDelay: 1
+ },
+
+ { desc: "Set interval to a negative value.",
+ interval: -1,
+ expectedTimerDelay: DEFAULT_TIMER_DELAY_SECONDS
+ },
+
+ { desc: "Set interval to 0.",
+ interval: 0,
+ expectedTimerDelay: DEFAULT_TIMER_DELAY_SECONDS
+ },
+
+ { desc: "Set interval to a large value.",
+ interval: 100,
+ expectedTimerDelay: 100
+ },
+
+];
+
+add_task(function* test() {
+ // The pref should not exist by default.
+ Assert.throws(() => getInterval());
+
+ // Force the component, so it will start observing preferences.
+ force_expiration_start();
+
+ for (let currentTest of tests) {
+ print(currentTest.desc);
+ let promise = promiseTopicObserved("test-interval-changed");
+ setInterval(currentTest.interval);
+ let [, data] = yield promise;
+ Assert.equal(data, currentTest.expectedTimerDelay * EXPIRE_AGGRESSIVITY_MULTIPLIER);
+ }
+
+ clearInterval();
+});
+