Commit 070b3c82 authored by YUKI "Piro" Hiroshi's avatar YUKI "Piro" Hiroshi
Browse files

Bug 1463680 - Allow to install search engine with POST method via Policy Engine r=Felipe

Differential Revision: https://phabricator.services.mozilla.com/D19467

--HG--
extra : moz-landing-system : lando
parent 96db4141
......@@ -856,6 +856,7 @@ var Policies = {
alias: newEngine.Alias,
description: newEngine.Description,
method: newEngine.Method,
postData: newEngine.PostData,
suggestURL: newEngine.SuggestURLTemplate,
extensionID: "set-via-policy",
queryCharset: "UTF-8",
......
......@@ -638,6 +638,9 @@
"URLTemplate": {
"type": "string"
},
"PostData": {
"type": "string"
},
"SuggestURLTemplate": {
"type": "string"
}
......
......@@ -245,3 +245,48 @@ add_task(async function test_install_and_remove() {
EnterprisePolicyTesting.resetRunOnceState();
});
add_task(async function test_install_post_method_engine() {
is(Services.search.getEngineByName("Post"), null,
"Engine \"Post\" should not be present when test starts");
await setupPolicyEngineWithJson({
"policies": {
"SearchEngines": {
"Add": [
{
"Name": "Post",
"Method": "POST",
"PostData": "q={searchTerms}&anotherParam=yes",
"URLTemplate": "http://example.com/",
},
],
},
},
});
// Get in line, because the Search policy callbacks are async.
await TestUtils.waitForTick();
let engine = Services.search.getEngineByName("Post");
isnot(engine, null, "Specified search engine should be installed");
is(engine.wrappedJSObject._urls[0].method, "POST", "Method should be POST");
let submission = engine.getSubmission("term", "text/html");
isnot(submission.postData, null, "Post data should not be null");
let scriptableInputStream = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(Ci.nsIScriptableInputStream);
scriptableInputStream.init(submission.postData);
is(scriptableInputStream.read(scriptableInputStream.available()),
"q=term&anotherParam=yes",
"Post data should be present");
await setupPolicyEngineWithJson({
"policies": {
"SearchEngines": {
"Remove": ["Post"],
},
},
});
EnterprisePolicyTesting.resetRunOnceState();
});
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