5 var sis =
Cc[
"@mozilla.org/scriptableinputstream;1"].
8 var dataLines = sis.read(aIS.available()).split(
"\n");
11 return dataLines[dataLines.length-1];
16 this.postData = aPostData;
21 init:
function(aKeyWord, aURL, aPostData, aSearchWord) {
22 this.keyword = aKeyWord;
24 this.postData = aPostData;
25 this.searchWord = aSearchWord;
27 this.method = (this.postData ?
"POST" :
"GET");
31 function bmKeywordData(aKeyWord, aURL, aPostData, aSearchWord) {
32 this.
init(aKeyWord, aURL, aPostData, aSearchWord);
37 this.
init(aKeyWord, aURL, aPostData, aSearchWord);
42 [
new bmKeywordData(
"bmget",
"http://bmget/search=%s",
null,
"foo"),
45 [
new bmKeywordData(
"bmpost",
"http://bmpost/",
"search=%s",
"foo2"),
48 [
new bmKeywordData(
"bmpostget",
"http://bmpostget/search1=%s",
"search2=%s",
"foo3"),
49 new keywordResult(
"http://bmpostget/search1=foo3",
"search2=foo3")],
51 [
new bmKeywordData(
"bmget-nosearch",
"http://bmget-nosearch/",
null,
""),
57 [
new searchKeywordData(
"searchpost",
"http://searchpost/",
"search={searchTerms}",
"foo5"),
60 [
new searchKeywordData(
"searchpostget",
"http://searchpostget/?search1={searchTerms}",
"search2={searchTerms}",
"foo6"),
61 new keywordResult(
"http://searchpostget/?search1=foo6",
"search2=foo6")],
65 [
new bmKeywordData(
"bmget-noparam",
"http://bmget-noparam/",
null,
"foo7"),
67 [
new bmKeywordData(
"bmpost-noparam",
"http://bmpost-noparam/",
"not_a=param",
"foo8"),
72 [
new bmKeywordData(
"bmget-escaping",
"http://bmget/?esc=%s&raw=%S",
null,
"foé ),
new keywordResult("http://bmget/?esc=fo%C3%A9&raw=foé", null)],
// Explicitly-defined ISO-8859-1
[new bmKeywordData("bmget-escaping2", "http://bmget/?esc=%s&raw=%S&mozcharset=ISO-8859-1", null, "foé"),
new keywordResult("http://bmget/?esc=fo%E9&raw=foé", null)],
];
function test() {
setupKeywords();
for each (var item in testData) {
var [data, result] = item;
var postData = {};
var query = data.keyword;
if (data.searchWord)
query += " " + data.searchWord;
var url = getShortcutOrURI(query, postData);
// null result.url means we should expect the same query we sent in
var expected = result.url || query;
is(url, expected, "got correct URL for " + data.keyword);
is(getPostDataString(postData.value), result.postData, "got correct postData for " + data.keyword);
}
cleanupKeywords();
}
var gBMFolder = null;
var gAddedEngines = [];
function setupKeywords() {
var searchService = Cc["@mozilla.org/browser/search-service;1"].
getService(Ci.nsIBrowserSearchService);
gBMFolder = Application.bookmarks.menu.addFolder("keyword-test");
for each (var item in testData) {
var data = item[0];
if (data instanceof bmKeywordData) {
var bm = gBMFolder.addBookmark(data.keyword, data.uri);
bm.keyword = data.keyword;
if (data.postData)
bm.annotations.set("bookmarkProperties/POSTData", data.postData, Ci.nsIAnnotationService.EXPIRE_SESSION);
}
if (data instanceof searchKeywordData) {
searchService.addEngineWithDetails(data.keyword, "", data.keyword, "", data.method, data.uri.spec);
var addedEngine = searchService.getEngineByName(data.keyword);
if (data.postData) {
var [paramName, paramValue] = data.postData.split("=");
addedEngine.addParam(paramName, paramValue, null);
}
gAddedEngines.push(addedEngine);
}
}
}
function cleanupKeywords() {
var searchService = Cc["@mozilla.org/browser/search-service;1"].
getService(Ci.nsIBrowserSearchService);
gBMFolder.remove();
gAddedEngines.map(searchService.removeEngine);
}
"),
73 new keywordResult(
"http://bmget/?esc=fo%C3%A9&raw=foé , null)],
// Explicitly-defined ISO-8859-1
[new bmKeywordData("bmget-escaping2", "http://bmget/?esc=%s&raw=%S&mozcharset=ISO-8859-1", null, "foé"),
new keywordResult("http://bmget/?esc=fo%E9&raw=foé", null)],
];
function test() {
setupKeywords();
for each (var item in testData) {
var [data, result] = item;
var postData = {};
var query = data.keyword;
if (data.searchWord)
query += " " + data.searchWord;
var url = getShortcutOrURI(query, postData);
// null result.url means we should expect the same query we sent in
var expected = result.url || query;
is(url, expected, "got correct URL for " + data.keyword);
is(getPostDataString(postData.value), result.postData, "got correct postData for " + data.keyword);
}
cleanupKeywords();
}
var gBMFolder = null;
var gAddedEngines = [];
function setupKeywords() {
var searchService = Cc["@mozilla.org/browser/search-service;1"].
getService(Ci.nsIBrowserSearchService);
gBMFolder = Application.bookmarks.menu.addFolder("keyword-test");
for each (var item in testData) {
var data = item[0];
if (data instanceof bmKeywordData) {
var bm = gBMFolder.addBookmark(data.keyword, data.uri);
bm.keyword = data.keyword;
if (data.postData)
bm.annotations.set("bookmarkProperties/POSTData", data.postData, Ci.nsIAnnotationService.EXPIRE_SESSION);
}
if (data instanceof searchKeywordData) {
searchService.addEngineWithDetails(data.keyword, "", data.keyword, "", data.method, data.uri.spec);
var addedEngine = searchService.getEngineByName(data.keyword);
if (data.postData) {
var [paramName, paramValue] = data.postData.split("=");
addedEngine.addParam(paramName, paramValue, null);
}
gAddedEngines.push(addedEngine);
}
}
}
function cleanupKeywords() {
var searchService = Cc["@mozilla.org/browser/search-service;1"].
getService(Ci.nsIBrowserSearchService);
gBMFolder.remove();
gAddedEngines.map(searchService.removeEngine);
}
",
null)],
75 [
new bmKeywordData(
"bmget-escaping2",
"http://bmget/?esc=%s&raw=%S&mozcharset=ISO-8859-1",
null,
"foé ),
new keywordResult("http://bmget/?esc=fo%E9&raw=foé", null)],
];
function test() {
setupKeywords();
for each (var item in testData) {
var [data, result] = item;
var postData = {};
var query = data.keyword;
if (data.searchWord)
query += " " + data.searchWord;
var url = getShortcutOrURI(query, postData);
// null result.url means we should expect the same query we sent in
var expected = result.url || query;
is(url, expected, "got correct URL for " + data.keyword);
is(getPostDataString(postData.value), result.postData, "got correct postData for " + data.keyword);
}
cleanupKeywords();
}
var gBMFolder = null;
var gAddedEngines = [];
function setupKeywords() {
var searchService = Cc["@mozilla.org/browser/search-service;1"].
getService(Ci.nsIBrowserSearchService);
gBMFolder = Application.bookmarks.menu.addFolder("keyword-test");
for each (var item in testData) {
var data = item[0];
if (data instanceof bmKeywordData) {
var bm = gBMFolder.addBookmark(data.keyword, data.uri);
bm.keyword = data.keyword;
if (data.postData)
bm.annotations.set("bookmarkProperties/POSTData", data.postData, Ci.nsIAnnotationService.EXPIRE_SESSION);
}
if (data instanceof searchKeywordData) {
searchService.addEngineWithDetails(data.keyword, "", data.keyword, "", data.method, data.uri.spec);
var addedEngine = searchService.getEngineByName(data.keyword);
if (data.postData) {
var [paramName, paramValue] = data.postData.split("=");
addedEngine.addParam(paramName, paramValue, null);
}
gAddedEngines.push(addedEngine);
}
}
}
function cleanupKeywords() {
var searchService = Cc["@mozilla.org/browser/search-service;1"].
getService(Ci.nsIBrowserSearchService);
gBMFolder.remove();
gAddedEngines.map(searchService.removeEngine);
}
"),
76 new keywordResult(
"http://bmget/?esc=fo%E9&raw=foé , null)],
];
function test() {
setupKeywords();
for each (var item in testData) {
var [data, result] = item;
var postData = {};
var query = data.keyword;
if (data.searchWord)
query += " " + data.searchWord;
var url = getShortcutOrURI(query, postData);
// null result.url means we should expect the same query we sent in
var expected = result.url || query;
is(url, expected, "got correct URL for " + data.keyword);
is(getPostDataString(postData.value), result.postData, "got correct postData for " + data.keyword);
}
cleanupKeywords();
}
var gBMFolder = null;
var gAddedEngines = [];
function setupKeywords() {
var searchService = Cc["@mozilla.org/browser/search-service;1"].
getService(Ci.nsIBrowserSearchService);
gBMFolder = Application.bookmarks.menu.addFolder("keyword-test");
for each (var item in testData) {
var data = item[0];
if (data instanceof bmKeywordData) {
var bm = gBMFolder.addBookmark(data.keyword, data.uri);
bm.keyword = data.keyword;
if (data.postData)
bm.annotations.set("bookmarkProperties/POSTData", data.postData, Ci.nsIAnnotationService.EXPIRE_SESSION);
}
if (data instanceof searchKeywordData) {
searchService.addEngineWithDetails(data.keyword, "", data.keyword, "", data.method, data.uri.spec);
var addedEngine = searchService.getEngineByName(data.keyword);
if (data.postData) {
var [paramName, paramValue] = data.postData.split("=");
addedEngine.addParam(paramName, paramValue, null);
}
gAddedEngines.push(addedEngine);
}
}
}
function cleanupKeywords() {
var searchService = Cc["@mozilla.org/browser/search-service;1"].
getService(Ci.nsIBrowserSearchService);
gBMFolder.remove();
gAddedEngines.map(searchService.removeEngine);
}
",
null)],
83 var [
data, result] = item;
86 var query = data.keyword;
88 query +=
" " + data.searchWord;
93 is(url, expected,
"got correct URL for " + data.keyword);
94 is(
getPostDataString(postData.value), result.postData,
"got correct postData for " + data.keyword);
103 var searchService =
Cc[
"@mozilla.org/browser/search-service;1"].
108 if (data instanceof bmKeywordData) {
109 var bm =
gBMFolder.addBookmark(data.keyword, data.uri);
110 bm.keyword = data.keyword;
112 bm.annotations.set(
"bookmarkProperties/POSTData", data.postData,
Ci.nsIAnnotationService.EXPIRE_SESSION);
116 searchService.addEngineWithDetails(data.keyword,
"", data.keyword,
"", data.method, data.uri.spec);
117 var addedEngine = searchService.getEngineByName(data.keyword);
119 var [paramName, paramValue] = data.postData.split(
"=");
120 addedEngine.addParam(paramName, paramValue,
null);
129 var searchService =
Cc[
"@mozilla.org/browser/search-service;1"].
function searchKeywordData(aKeyWord, aURL, aPostData, aSearchWord)
function getShortcutOrURI(aURL, aPostDataRef)
function cleanupKeywords()
getService(Ci.sbIFaceplateManager)
function makeURI(aURLSpec, aCharset)
function getPostDataString(aIS)
function keywordResult(aURL, aPostData)