Commit aa16d5c0 authored by Kirk Steuber's avatar Kirk Steuber
Browse files

Bug 1449681 - Fix bug where opensearch API is not always successfully blocked by policy r=Felipe

MozReview-Commit-ID: 7ZrmiMop9IB

--HG--
extra : rebase_source : a6477d659cc3567411f0ba9911e5667f3c0b4607
parent 9458999c
......@@ -411,6 +411,11 @@ var Policies = {
},
"SearchEngines": {
onBeforeUIStartup(manager, param) {
if (param.PreventInstalls) {
manager.disallowFeature("installSearchEngine", true);
}
},
onAllWindowsRestored(manager, param) {
Services.search.init(() => {
if (param.Add) {
......@@ -460,9 +465,6 @@ var Policies = {
}
});
}
if (param.PreventInstalls) {
manager.disallowFeature("installSearchEngine");
}
});
}
}
......
......@@ -72,9 +72,46 @@ add_task(async function test_install_and_set_default() {
// Clean up
Services.search.removeEngine(Services.search.currentEngine);
EnterprisePolicyTesting.resetRunOnceState();
});
// Same as the last test, but with "PreventInstalls" set to true to make sure
// it does not prevent search engines from being installed properly
add_task(async function test_install_and_set_default_prevent_installs() {
isnot(Services.search.currentEngine.name, "MozSearch",
"Default search engine should not be MozSearch when test starts");
is(Services.search.getEngineByName("Foo"), null,
"Engine \"Foo\" should not be present when test starts");
await setupPolicyEngineWithJson({
"policies": {
"SearchEngines": {
"Add": [
{
"Name": "MozSearch",
"URLTemplate": "http://example.com/?q={searchTerms}"
}
],
"Default": "MozSearch",
"PreventInstalls": true
}
}
});
is(Services.search.currentEngine.name, "MozSearch",
"Specified search engine should be the default");
// Clean up
Services.search.removeEngine(Services.search.currentEngine);
EnterprisePolicyTesting.resetRunOnceState();
});
add_task(async function test_opensearch_works() {
// Clear out policies so we can test with no policies applied
await setupPolicyEngineWithJson({
"policies": {
}
});
// Ensure that opensearch works before we make sure that it can be properly
// disabled
await test_opensearch(true);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment