This is keyed on the settings redesign preference. This seemed to be the simplest way to ensure the old setting was respected at the right time. The tests are not testing the results of the settings redesign, so we force the preference to false there as that's simplest. There will be a separate clean-up stage where we'll remove support for the old setting. Differential Revision: https://phabricator.services.mozilla.com/D304748
53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
/*
|
|
* Test the SearchEngine.hideOneOffButton property.
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
add_setup(async function () {
|
|
SearchTestUtils.setRemoteSettingsConfig([
|
|
{ identifier: "enterprise-a" },
|
|
{ identifier: "enterprise-b" },
|
|
]);
|
|
|
|
const result = await SearchService.init();
|
|
Assert.ok(
|
|
Components.isSuccessCode(result),
|
|
"Should have initialized the service"
|
|
);
|
|
|
|
// Disable settings-redesign to begin with.
|
|
Services.prefs.setBoolPref("browser.settings-redesign.enabled", false);
|
|
});
|
|
|
|
add_task(async function test_hideOneOffButton() {
|
|
let engine = SearchService.getEngineById("enterprise-b");
|
|
|
|
Assert.ok(!engine.hideOneOffButton, "Should be false at initial creation");
|
|
|
|
engine.hideOneOffButton = true;
|
|
|
|
Assert.ok(
|
|
engine.hideOneOffButton,
|
|
"Should be set when setting it and the redesign preference is false"
|
|
);
|
|
|
|
Services.prefs.setBoolPref("browser.settings-redesign.enabled", true);
|
|
|
|
Assert.ok(
|
|
!engine.hideOneOffButton,
|
|
"Should be false when the setting is set, but the redesign preference is true"
|
|
);
|
|
|
|
Services.prefs.setBoolPref("browser.settings-redesign.enabled", false);
|
|
engine.hideOneOffButton = false;
|
|
|
|
Assert.ok(
|
|
!engine.hideOneOffButton,
|
|
"Should still be false when value is reset"
|
|
);
|
|
});
|