mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-09 04:39:03 +02:00
Differential Revision: https://phabricator.services.mozilla.com/D64685 --HG-- extra : moz-landing-system : lando
40 lines
1.3 KiB
JavaScript
40 lines
1.3 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
"use strict";
|
|
|
|
add_task(function test() {
|
|
Assert.throws(
|
|
() => UrlbarPrefs.get("browser.migration.version"),
|
|
/Trying to access an unknown pref/,
|
|
"Should throw when passing an untracked pref"
|
|
);
|
|
|
|
Assert.throws(
|
|
() => UrlbarPrefs.set("browser.migration.version", 100),
|
|
/Trying to access an unknown pref/,
|
|
"Should throw when passing an untracked pref"
|
|
);
|
|
Assert.throws(
|
|
() => UrlbarPrefs.set("maxRichResults", "10"),
|
|
/Invalid value/,
|
|
"Should throw when passing an invalid value type"
|
|
);
|
|
|
|
Assert.deepEqual(UrlbarPrefs.get("formatting.enabled"), true);
|
|
UrlbarPrefs.set("formatting.enabled", false);
|
|
Assert.deepEqual(UrlbarPrefs.get("formatting.enabled"), false);
|
|
|
|
Assert.deepEqual(UrlbarPrefs.get("maxRichResults"), 10);
|
|
UrlbarPrefs.set("maxRichResults", 6);
|
|
Assert.deepEqual(UrlbarPrefs.get("maxRichResults"), 6);
|
|
|
|
Assert.deepEqual(UrlbarPrefs.get("autoFill.stddevMultiplier"), 0.0);
|
|
UrlbarPrefs.set("autoFill.stddevMultiplier", 0.01);
|
|
// Due to rounding errors, floats are slightly imprecise, so we can't
|
|
// directly compare what we set to what we retrieve.
|
|
Assert.deepEqual(
|
|
parseFloat(UrlbarPrefs.get("autoFill.stddevMultiplier").toFixed(2)),
|
|
0.01
|
|
);
|
|
});
|