mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 724116 - Add additional URL types to implement channel parameter for Google search plugin. r=gavin
Based on Gavin's patch for bug 596439. --HG-- rename : browser/components/search/test/testEngine.xml => browser/components/search/test/testEngine_mozsearch.xml extra : rebase_source : c2d88610668c305a7a1710fb69a99a44d8f23bb7
This commit is contained in:
parent
2a8ace96e9
commit
e7b9ec98ac
@ -261,7 +261,8 @@
|
||||
accesskey="&keywordfield.accesskey;"
|
||||
oncommand="AddKeywordForSearchField();"/>
|
||||
<menuitem id="context-searchselect"
|
||||
oncommand="BrowserSearch.loadSearch(getBrowserSelection(), true);"/>
|
||||
oncommand="BrowserSearch.loadSearch(getBrowserSelection(), true,
|
||||
'application/x-moz-contextsearch');"/>
|
||||
<menuseparator id="frame-sep"/>
|
||||
<menu id="frame" label="&thisFrameMenu.label;" accesskey="&thisFrameMenu.accesskey;">
|
||||
<menupopup>
|
||||
|
@ -3525,8 +3525,13 @@ const BrowserSearch = {
|
||||
* @param useNewTab
|
||||
* Boolean indicating whether or not the search should load in a new
|
||||
* tab.
|
||||
*
|
||||
* @param responseType [optional]
|
||||
* The MIME type that we'd like to receive in response
|
||||
* to this submission. If null or the the response type is not supported
|
||||
* for the search engine, will fallback to "text/html".
|
||||
*/
|
||||
loadSearch: function BrowserSearch_search(searchText, useNewTab) {
|
||||
loadSearch: function BrowserSearch_search(searchText, useNewTab, responseType) {
|
||||
var engine;
|
||||
|
||||
// If the search bar is visible, use the current engine, otherwise, fall
|
||||
@ -3536,7 +3541,12 @@ const BrowserSearch = {
|
||||
else
|
||||
engine = Services.search.defaultEngine;
|
||||
|
||||
var submission = engine.getSubmission(searchText); // HTML response
|
||||
var submission = engine.getSubmission(searchText, responseType);
|
||||
|
||||
// If a response type was specified and getSubmission returned null,
|
||||
// fallback to the default response type.
|
||||
if (!submission && responseType)
|
||||
submission = engine.getSubmission(searchText);
|
||||
|
||||
// getSubmission can return null if the engine doesn't have a URL
|
||||
// with a text/html response type. This is unlikely (since
|
||||
|
@ -17,7 +17,7 @@ var pairs = [
|
||||
["1.1.1.1", "http://1.1.1.1/"],
|
||||
["ftp://example", "ftp://example/"],
|
||||
["ftp.example.bar", "ftp://ftp.example.bar/"],
|
||||
["ex ample", Services.search.originalDefaultEngine.getSubmission("ex ample").uri.spec],
|
||||
["ex ample", Services.search.originalDefaultEngine.getSubmission("ex ample", "application/x-moz-keywordsearch").uri.spec],
|
||||
];
|
||||
|
||||
function testNext() {
|
||||
|
@ -7,12 +7,12 @@ var gTests = [
|
||||
{
|
||||
name: "normal search (search service)",
|
||||
testText: "test search",
|
||||
searchURL: Services.search.originalDefaultEngine.getSubmission("test search").uri.spec
|
||||
searchURL: Services.search.originalDefaultEngine.getSubmission("test search", "application/x-moz-keywordsearch").uri.spec
|
||||
},
|
||||
{
|
||||
name: "?-prefixed search (search service)",
|
||||
testText: "? foo ",
|
||||
searchURL: Services.search.originalDefaultEngine.getSubmission("foo").uri.spec
|
||||
searchURL: Services.search.originalDefaultEngine.getSubmission("foo", "application/x-moz-keywordsearch").uri.spec
|
||||
},
|
||||
{
|
||||
name: "normal search (keyword.url)",
|
||||
|
@ -46,7 +46,9 @@ include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_BROWSER_TEST_FILES = browser_405664.js \
|
||||
browser_addEngine.js \
|
||||
browser_contextmenu.js \
|
||||
testEngine.xml \
|
||||
testEngine_mozsearch.xml \
|
||||
testEngine.src \
|
||||
browser_426329.js \
|
||||
426329.xml \
|
||||
|
@ -8,6 +8,8 @@ this._scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/Chr
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
const ENGINE_HTML_BASE = "http://mochi.test:8888/browser/browser/components/search/test/test.html";
|
||||
|
||||
var searchEntries = ["test", "More Text", "Some Text"];
|
||||
var searchBar = BrowserSearch.searchBar;
|
||||
var searchButton = document.getAnonymousElementByAttribute(searchBar,
|
||||
@ -57,6 +59,7 @@ function test() {
|
||||
is(gBrowser.tabs.length, preTabNo, "Return key did not open new tab");
|
||||
is(event.originalTarget, preSelectedBrowser.contentDocument,
|
||||
"Return key loaded results in current tab");
|
||||
is(event.originalTarget.URL, expectedURL(searchBar.value), "Check URL of search page opened");
|
||||
|
||||
testAltReturn();
|
||||
});
|
||||
@ -72,6 +75,7 @@ function test() {
|
||||
"Alt+Return key loaded results in new tab");
|
||||
is(event.originalTarget, gBrowser.contentDocument,
|
||||
"Alt+Return key loaded results in foreground tab");
|
||||
is(event.originalTarget.URL, expectedURL(searchBar.value), "Check URL of search page opened");
|
||||
|
||||
//Shift key has no effect for now, so skip it
|
||||
//testShiftAltReturn();
|
||||
@ -89,6 +93,7 @@ function test() {
|
||||
"Shift+Alt+Return key loaded results in new tab");
|
||||
isnot(event.originalTarget, gBrowser.contentDocument,
|
||||
"Shift+Alt+Return key loaded results in background tab");
|
||||
is(event.originalTarget.URL, expectedURL(searchBar.value), "Check URL of search page opened");
|
||||
|
||||
testLeftClick();
|
||||
});
|
||||
@ -102,6 +107,7 @@ function test() {
|
||||
is(gBrowser.tabs.length, preTabNo, "LeftClick did not open new tab");
|
||||
is(event.originalTarget, preSelectedBrowser.contentDocument,
|
||||
"LeftClick loaded results in current tab");
|
||||
is(event.originalTarget.URL, expectedURL(searchBar.value), "Check URL of search page opened");
|
||||
|
||||
testMiddleClick();
|
||||
});
|
||||
@ -117,6 +123,7 @@ function test() {
|
||||
"MiddleClick loaded results in new tab");
|
||||
is(event.originalTarget, gBrowser.contentDocument,
|
||||
"MiddleClick loaded results in foreground tab");
|
||||
is(event.originalTarget.URL, expectedURL(searchBar.value), "Check URL of search page opened");
|
||||
|
||||
testShiftMiddleClick();
|
||||
});
|
||||
@ -132,6 +139,7 @@ function test() {
|
||||
"Shift+MiddleClick loaded results in new tab");
|
||||
isnot(event.originalTarget, gBrowser.contentDocument,
|
||||
"Shift+MiddleClick loaded results in background tab");
|
||||
is(event.originalTarget.URL, expectedURL(searchBar.value), "Check URL of search page opened");
|
||||
|
||||
testDropText();
|
||||
});
|
||||
@ -232,6 +240,13 @@ function test() {
|
||||
aTarget.dispatchEvent(event);
|
||||
}
|
||||
|
||||
function expectedURL(aSearchTerms) {
|
||||
var textToSubURI = Cc["@mozilla.org/intl/texttosuburi;1"].
|
||||
getService(Ci.nsITextToSubURI);
|
||||
var searchArg = textToSubURI.ConvertAndEscape("utf-8", aSearchTerms);
|
||||
return ENGINE_HTML_BASE + "?test=" + searchArg;
|
||||
}
|
||||
|
||||
// modified from toolkit/components/satchel/test/test_form_autocomplete.html
|
||||
function checkMenuEntries(expectedValues) {
|
||||
var actualValues = getMenuEntries();
|
||||
|
97
browser/components/search/test/browser_contextmenu.js
Normal file
97
browser/components/search/test/browser_contextmenu.js
Normal file
@ -0,0 +1,97 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* * http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
/*
|
||||
* Test searching for the selected text using the context menu
|
||||
*/
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
const ss = Services.search;
|
||||
const ENGINE_NAME = "Foo";
|
||||
var contextMenu;
|
||||
|
||||
function observer(aSub, aTopic, aData) {
|
||||
switch (aData) {
|
||||
case "engine-added":
|
||||
var engine = ss.getEngineByName(ENGINE_NAME);
|
||||
ok(engine, "Engine was added.");
|
||||
//XXX Bug 493051
|
||||
//ss.currentEngine = engine;
|
||||
break;
|
||||
case "engine-current":
|
||||
ok(ss.currentEngine.name == ENGINE_NAME, "currentEngine set");
|
||||
startTest();
|
||||
break;
|
||||
case "engine-removed":
|
||||
Services.obs.removeObserver(observer, "browser-search-engine-modified");
|
||||
finish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Services.obs.addObserver(observer, "browser-search-engine-modified", false);
|
||||
ss.addEngine("http://mochi.test:8888/browser/browser/components/search/test/testEngine_mozsearch.xml",
|
||||
Ci.nsISearchEngine.DATA_XML, "data:image/x-icon,%00",
|
||||
false);
|
||||
|
||||
function startTest() {
|
||||
contextMenu = document.getElementById("contentAreaContextMenu");
|
||||
ok(contextMenu, "Got context menu XUL");
|
||||
|
||||
doOnloadOnce(testContextMenu);
|
||||
var tab = gBrowser.addTab("data:text/plain,test%20search");
|
||||
gBrowser.selectedTab = tab;
|
||||
}
|
||||
|
||||
function testContextMenu() {
|
||||
function rightClickOnDocument(){
|
||||
var clickTarget = content.document.body;
|
||||
var eventDetails = { type: "contextmenu", button: 2 };
|
||||
EventUtils.synthesizeMouseAtCenter(clickTarget, eventDetails, content);
|
||||
SimpleTest.executeSoon(checkContextMenu);
|
||||
}
|
||||
|
||||
// check the search menu item and then perform a search
|
||||
function checkContextMenu() {
|
||||
var searchItem = contextMenu.getElementsByAttribute("id", "context-searchselect")[0];
|
||||
ok(searchItem, "Got search context menu item");
|
||||
is(searchItem.label, 'Search ' + ENGINE_NAME + ' for "test search"', "Check context menu label");
|
||||
is(searchItem.disabled, false, "Check that search context menu item is enabled");
|
||||
searchItem.click();
|
||||
}
|
||||
|
||||
function checkSearchURL(event){
|
||||
is(event.originalTarget.URL,
|
||||
"http://mochi.test:8888/browser/browser/components/search/test/?test=test+search&ie=utf-8&client=app&channel=contextsearch",
|
||||
"Checking context menu search URL");
|
||||
finalize();
|
||||
}
|
||||
|
||||
doOnloadOnce(checkSearchURL);
|
||||
|
||||
// select the text on the page
|
||||
var selectAllItem = contextMenu.getElementsByAttribute("id", "context-selectall")[0];
|
||||
ok(selectAllItem, "Got select all context menu item");
|
||||
selectAllItem.click();
|
||||
|
||||
// wait for the selection to take effect
|
||||
SimpleTest.executeSoon(rightClickOnDocument);
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
while (gBrowser.tabs.length != 1) {
|
||||
gBrowser.removeTab(gBrowser.tabs[0]);
|
||||
}
|
||||
content.location.href = "about:blank";
|
||||
var engine = ss.getEngineByName(ENGINE_NAME);
|
||||
ss.removeEngine(engine);
|
||||
}
|
||||
|
||||
function doOnloadOnce(callback) {
|
||||
gBrowser.addEventListener("DOMContentLoaded", function handleLoad(event) {
|
||||
gBrowser.removeEventListener("DOMContentLoaded", handleLoad, true);
|
||||
callback(event);
|
||||
}, true);
|
||||
}
|
||||
}
|
25
browser/components/search/test/testEngine_mozsearch.xml
Normal file
25
browser/components/search/test/testEngine_mozsearch.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/">
|
||||
<ShortName>Foo</ShortName>
|
||||
<Description>Foo Search</Description>
|
||||
<InputEncoding>utf-8</InputEncoding>
|
||||
<Image width="16" height="16">data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABGklEQVQoz2NgGB6AnZ1dUlJSXl4eSDIyMhLW4Ovr%2B%2Fr168uXL69Zs4YoG%2BLi4i5dusTExMTGxsbNzd3f37937976%2BnpmZmagbHR09J49e5YvX66kpATVEBYW9ubNm2nTphkbG7e2tp44cQLIuHfvXm5urpaWFlDKysqqu7v73LlzECMYIiIiHj58mJCQoKKicvXq1bS0NKBgW1vbjh074uPjgeqAXE1NzSdPnvDz84M0AEUvXLgAsW379u1z5swBen3jxo2zZ892cHB4%2BvQp0KlAfwI1cHJyghQFBwfv2rULokFXV%2FfixYu7d%2B8GGqGgoMDKyrpu3br9%2B%2FcDuXl5eVA%2FAEWBfoWHAdAYoNuAYQ0XAeoUERFhGDYAAPoUaT2dfWJuAAAAAElFTkSuQmCC</Image>
|
||||
<Url type="application/x-suggestions+json" method="GET" template="http://mochi.test:8888/browser/browser/components/search/test/?suggestions&locale={moz:locale}&test={searchTerms}"/>
|
||||
<Url type="text/html" method="GET" template="http://mochi.test:8888/browser/browser/components/search/test/">
|
||||
<Param name="test" value="{searchTerms}"/>
|
||||
<Param name="ie" value="utf-8"/>
|
||||
<MozParam name="client" condition="defaultEngine" trueValue="app-default" falseValue="app"/>
|
||||
</Url>
|
||||
<Url type="application/x-moz-keywordsearch" method="GET" template="http://mochi.test:8888/browser/browser/components/search/test/">
|
||||
<Param name="test" value="{searchTerms}"/>
|
||||
<Param name="ie" value="utf-8"/>
|
||||
<MozParam name="client" condition="defaultEngine" trueValue="app-default" falseValue="app"/>
|
||||
<Param name="channel" value="keywordsearch"/>
|
||||
</Url>
|
||||
<Url type="application/x-moz-contextsearch" method="GET" template="http://mochi.test:8888/browser/browser/components/search/test/">
|
||||
<Param name="test" value="{searchTerms}"/>
|
||||
<Param name="ie" value="utf-8"/>
|
||||
<MozParam name="client" condition="defaultEngine" trueValue="app-default" falseValue="app"/>
|
||||
<Param name="channel" value="contextsearch"/>
|
||||
</Url>
|
||||
<SearchForm>http://mochi.test:8888/browser/browser/components/search/test/</SearchForm>
|
||||
</SearchPlugin>
|
15
browser/locales/en-US/searchplugins/google-params.inc
Normal file
15
browser/locales/en-US/searchplugins/google-params.inc
Normal file
@ -0,0 +1,15 @@
|
||||
<Param name="q" value="{searchTerms}"/>
|
||||
<Param name="ie" value="utf-8"/>
|
||||
<Param name="oe" value="utf-8"/>
|
||||
<Param name="aq" value="t"/>
|
||||
<!-- Dynamic parameters -->
|
||||
<Param name="rls" value="{moz:distributionID}:{moz:locale}:{moz:official}"/>
|
||||
#if MOZ_UPDATE_CHANNEL == beta
|
||||
<MozParam name="client" condition="defaultEngine" trueValue="firefox-beta" falseValue="firefox"/>
|
||||
#elif MOZ_UPDATE_CHANNEL == aurora
|
||||
<MozParam name="client" condition="defaultEngine" trueValue="firefox-aurora" falseValue="firefox"/>
|
||||
#elif MOZ_UPDATE_CHANNEL == nightly
|
||||
<MozParam name="client" condition="defaultEngine" trueValue="firefox-nightly" falseValue="firefox"/>
|
||||
#else
|
||||
<MozParam name="client" condition="defaultEngine" trueValue="firefox-a" falseValue="firefox"/>
|
||||
#endif
|
@ -5,21 +5,17 @@
|
||||
<Image width="16" height="16">data:image/png;base64,AAABAAEAEBAAAAEAGABoAwAAFgAAACgAAAAQAAAAIAAAAAEAGAAAAAAAAAAAAAA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MAAOUDAtr%2F%2F%2F%2F7%2B%2Fu2bCTIYwDPZgDBWQDSr4P%2F%2Fv%2F%2F%2FP5GRuABAPkAA%2FwBAfkDAPAAAesAAN%2F%2F%2B%2Fz%2F%2F%2F64g1C5VwDMYwK8Yg7y5tz8%2Fv%2FV1PYKDOcAAP0DAf4AAf0AAfYEAOwAAuAAAAD%2F%2FPvi28ymXyChTATRrIb8%2F%2F3v8fk6P8MAAdUCAvoAAP0CAP0AAfYAAO4AAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAQAA</Image>
|
||||
<Url type="application/x-suggestions+json" method="GET" template="http://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl={moz:locale}&q={searchTerms}"/>
|
||||
<Url type="text/html" method="GET" template="http://www.google.com/search">
|
||||
<Param name="q" value="{searchTerms}"/>
|
||||
<Param name="ie" value="utf-8"/>
|
||||
<Param name="oe" value="utf-8"/>
|
||||
<Param name="aq" value="t"/>
|
||||
<!-- Dynamic parameters -->
|
||||
<Param name="rls" value="{moz:distributionID}:{moz:locale}:{moz:official}"/>
|
||||
#if MOZ_UPDATE_CHANNEL == beta
|
||||
<MozParam name="client" condition="defaultEngine" trueValue="firefox-beta" falseValue="firefox"/>
|
||||
#elif MOZ_UPDATE_CHANNEL == aurora
|
||||
<MozParam name="client" condition="defaultEngine" trueValue="firefox-aurora" falseValue="firefox"/>
|
||||
#elif MOZ_UPDATE_CHANNEL == nightly
|
||||
<MozParam name="client" condition="defaultEngine" trueValue="firefox-nightly" falseValue="firefox"/>
|
||||
#else
|
||||
<MozParam name="client" condition="defaultEngine" trueValue="firefox-a" falseValue="firefox"/>
|
||||
#endif
|
||||
#include google-params.inc
|
||||
</Url>
|
||||
<!-- Keyword search URL is the same as the default, but with an additional parameter -->
|
||||
<Url type="application/x-moz-keywordsearch" method="GET" template="http://www.google.com/search">
|
||||
#include google-params.inc
|
||||
<Param name="channel" value="fflb"/>
|
||||
</Url>
|
||||
<!-- Context/Right-click search URL is the same as the default, but with an additional parameter -->
|
||||
<Url type="application/x-moz-contextsearch" method="GET" template="http://www.google.com/search">
|
||||
#include google-params.inc
|
||||
<Param name="channel" value="rcs"/>
|
||||
</Url>
|
||||
<SearchForm>http://www.google.com/</SearchForm>
|
||||
</SearchPlugin>
|
||||
|
Loading…
Reference in New Issue
Block a user