зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1518545 - Remove the superfluous 'engine-current' Search Service observer topic in favour of 'engine-default'. r=daleharvey
Differential Revision: https://phabricator.services.mozilla.com/D27857 --HG-- rename : toolkit/components/places/tests/unifiedcomplete/test_search_engine_current.js => toolkit/components/places/tests/unifiedcomplete/test_search_engine_default.js extra : moz-landing-system : lando
This commit is contained in:
Родитель
c3de4ebcfa
Коммит
5d842c0354
|
@ -4015,7 +4015,7 @@ const BrowserSearch = {
|
|||
// browser's offered engines.
|
||||
this._removeMaybeOfferedEngine(engineName);
|
||||
break;
|
||||
case "engine-current":
|
||||
case "engine-default":
|
||||
if (this._searchInitComplete) {
|
||||
this._updateURLBarPlaceholder(engineName);
|
||||
}
|
||||
|
|
|
@ -392,7 +392,7 @@ add_task(async function cycleEngines() {
|
|||
let promiseEngineChange = function(newEngineName) {
|
||||
return new Promise(resolve => {
|
||||
Services.obs.addObserver(function resolver(subj, topic, data) {
|
||||
if (data != "engine-current") {
|
||||
if (data != "engine-default") {
|
||||
return;
|
||||
}
|
||||
subj.QueryInterface(Ci.nsISearchEngine);
|
||||
|
|
|
@ -87,7 +87,7 @@ this.TopSitesFeed = class TopSitesFeed {
|
|||
observe(subj, topic, data) {
|
||||
// We should update the current top sites if the search engine has been changed since
|
||||
// the search engine that gets filtered out of top sites has changed.
|
||||
if (topic === "browser-search-engine-modified" && data === "engine-current" && this.store.getState().Prefs.values[NO_DEFAULT_SEARCH_TILE_EXP_PREF]) {
|
||||
if (topic === "browser-search-engine-modified" && data === "engine-default" && this.store.getState().Prefs.values[NO_DEFAULT_SEARCH_TILE_EXP_PREF]) {
|
||||
delete this._currentSearchHostname;
|
||||
this._currentSearchHostname = getShortURLForCurrentSearch();
|
||||
this.refresh({broadcast: true});
|
||||
|
|
|
@ -1164,7 +1164,7 @@ describe("Top Sites Feed", () => {
|
|||
it("should call refresh and set ._currentSearchHostname to the new engine hostname when the the default search engine has been set", () => {
|
||||
sinon.stub(feed, "refresh");
|
||||
sandbox.stub(global.Services.search, "defaultEngine").value({identifier: "ddg", searchForm: "duckduckgo.com"});
|
||||
feed.observe(null, "browser-search-engine-modified", "engine-current");
|
||||
feed.observe(null, "browser-search-engine-modified", "engine-default");
|
||||
assert.equal(feed._currentSearchHostname, "duckduckgo");
|
||||
assert.calledOnce(feed.refresh);
|
||||
});
|
||||
|
|
|
@ -260,18 +260,15 @@ var gSearchPane = {
|
|||
case "engine-removed":
|
||||
gSearchPane.remove(aEngine);
|
||||
break;
|
||||
case "engine-current":
|
||||
case "engine-default":
|
||||
// If the user is going through the drop down using up/down keys, the
|
||||
// dropdown may still be open (eg. on Windows) when engine-current is
|
||||
// dropdown may still be open (eg. on Windows) when engine-default is
|
||||
// fired, so rebuilding the list unconditionally would get in the way.
|
||||
let selectedEngine =
|
||||
document.getElementById("defaultEngine").selectedItem.engine;
|
||||
if (selectedEngine.name != aEngine.name)
|
||||
gSearchPane.buildDefaultEngineDropDown();
|
||||
break;
|
||||
case "engine-default":
|
||||
// Not relevant
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -67,7 +67,7 @@ function promiseSetEngine() {
|
|||
ok(engine, "Engine was added.");
|
||||
ss.defaultEngine = engine;
|
||||
break;
|
||||
case "engine-current":
|
||||
case "engine-default":
|
||||
ok(ss.defaultEngine.name == "Bug 426329", "defaultEngine set");
|
||||
searchBar = BrowserSearch.searchBar;
|
||||
searchButton = searchBar.querySelector(".search-go-button");
|
||||
|
|
|
@ -17,7 +17,7 @@ function observer(aSubject, aTopic, aData) {
|
|||
if (gCurrentTest.added)
|
||||
method = "added";
|
||||
break;
|
||||
case "engine-current":
|
||||
case "engine-default":
|
||||
if (gCurrentTest.current)
|
||||
method = "current";
|
||||
break;
|
||||
|
|
|
@ -59,7 +59,7 @@ function test() {
|
|||
Services.search.defaultEngine = engine;
|
||||
break;
|
||||
|
||||
case "engine-current":
|
||||
case "engine-default":
|
||||
// We may be called again when resetting the engine at the end.
|
||||
if (!calledTestTelemetry) {
|
||||
is(Services.search.defaultEngine.name, "Foo", "Current engine is Foo");
|
||||
|
|
|
@ -112,7 +112,7 @@ add_task(async function test_urlBarChangeEngine() {
|
|||
function promisedefaultEngineChanged() {
|
||||
return new Promise(resolve => {
|
||||
function observer(aSub, aTopic, aData) {
|
||||
if (aData == "engine-current") {
|
||||
if (aData == "engine-default") {
|
||||
Assert.equal(Services.search.defaultEngine.name, TEST_ENGINE_NAME, "defaultEngine set");
|
||||
Services.obs.removeObserver(observer, "browser-search-engine-modified");
|
||||
resolve();
|
||||
|
|
|
@ -377,7 +377,7 @@ var tests = [
|
|||
await new Promise(resolve => {
|
||||
let observe = function(subject, topic, verb) {
|
||||
info("browser-search-engine-modified: " + verb);
|
||||
if (verb == "engine-current") {
|
||||
if (verb == "engine-default") {
|
||||
is(Services.search.defaultEngine.identifier, someOtherEngineID, "correct engine was switched to");
|
||||
done();
|
||||
}
|
||||
|
|
|
@ -461,12 +461,10 @@ var ContentSearch = {
|
|||
},
|
||||
|
||||
async _onObserve(data) {
|
||||
if (data === "engine-current") {
|
||||
if (data === "engine-default") {
|
||||
let engine = await this._currentEngineObj();
|
||||
this._broadcast("CurrentEngine", engine);
|
||||
} else if (data !== "engine-default") {
|
||||
// engine-default is always sent with engine-current and isn't otherwise
|
||||
// relevant to content searches.
|
||||
} else {
|
||||
let state = await this.currentStateObj();
|
||||
this._broadcast("CurrentState", state);
|
||||
}
|
||||
|
|
|
@ -77,14 +77,14 @@ add_task(async function SetDefaultEngine() {
|
|||
let deferred = PromiseUtils.defer();
|
||||
Services.obs.addObserver(function obs(subj, topic, data) {
|
||||
info("Test observed " + data);
|
||||
if (data == "engine-current") {
|
||||
ok(true, "Test observed engine-current");
|
||||
if (data == "engine-default") {
|
||||
ok(true, "Test observed engine-default");
|
||||
Services.obs.removeObserver(obs, "browser-search-engine-modified");
|
||||
deferred.resolve();
|
||||
}
|
||||
}, "browser-search-engine-modified");
|
||||
let searchPromise = waitForTestMsg(mm, "CurrentEngine");
|
||||
info("Waiting for test to observe engine-current...");
|
||||
info("Waiting for test to observe engine-default...");
|
||||
await deferred.promise;
|
||||
let msg = await searchPromise;
|
||||
checkMsg(msg, {
|
||||
|
|
|
@ -60,7 +60,7 @@ const SearchAutocompleteProviderInternal = {
|
|||
case "engine-added":
|
||||
case "engine-changed":
|
||||
case "engine-removed":
|
||||
case "engine-current":
|
||||
case "engine-default":
|
||||
this._refresh();
|
||||
}
|
||||
},
|
||||
|
|
|
@ -47,7 +47,7 @@ skip-if = appname == "thunderbird"
|
|||
[test_remote_tab_matches.js]
|
||||
skip-if = !sync
|
||||
[test_search_engine_alias.js]
|
||||
[test_search_engine_current.js]
|
||||
[test_search_engine_default.js]
|
||||
[test_search_engine_host.js]
|
||||
[test_search_engine_restyle.js]
|
||||
[test_search_suggestions.js]
|
||||
|
|
|
@ -65,7 +65,6 @@ const SEARCH_ENGINE_REMOVED = "engine-removed";
|
|||
const SEARCH_ENGINE_ADDED = "engine-added";
|
||||
const SEARCH_ENGINE_CHANGED = "engine-changed";
|
||||
const SEARCH_ENGINE_LOADED = "engine-loaded";
|
||||
const SEARCH_ENGINE_CURRENT = "engine-current";
|
||||
const SEARCH_ENGINE_DEFAULT = "engine-default";
|
||||
|
||||
// The following constants are left undocumented in nsISearchService.idl
|
||||
|
@ -2963,7 +2962,6 @@ SearchService.prototype = {
|
|||
// dispatch the appropriate notifications.
|
||||
if (prevCurrentEngine && this.defaultEngine !== prevCurrentEngine) {
|
||||
notifyAction(this._currentEngine, SEARCH_ENGINE_DEFAULT);
|
||||
notifyAction(this._currentEngine, SEARCH_ENGINE_CURRENT);
|
||||
}
|
||||
Services.obs.notifyObservers(null, SEARCH_SERVICE_TOPIC, "engines-reloaded");
|
||||
},
|
||||
|
@ -4169,7 +4167,6 @@ SearchService.prototype = {
|
|||
this.setGlobalAttr("hash", getVerificationHash(newName));
|
||||
|
||||
notifyAction(this._currentEngine, SEARCH_ENGINE_DEFAULT);
|
||||
notifyAction(this._currentEngine, SEARCH_ENGINE_CURRENT);
|
||||
},
|
||||
|
||||
async getDefault() {
|
||||
|
|
|
@ -533,11 +533,6 @@ interface nsISearchService : nsISupports
|
|||
*/
|
||||
#define SEARCH_ENGINE_LOADED "engine-loaded"
|
||||
|
||||
/**
|
||||
* Sent when the "current" engine is changed.
|
||||
*/
|
||||
#define SEARCH_ENGINE_CURRENT "engine-current";
|
||||
|
||||
/**
|
||||
* Sent when the "default" engine is changed.
|
||||
*/
|
||||
|
|
|
@ -10,7 +10,7 @@ var gTestLog = [];
|
|||
* - engine-changed (while we're installing the engine, we modify it, which notifies - bug 606886)
|
||||
* - engine-added (engine was added to the store by the search service)
|
||||
* -> our search observer is called, which sets:
|
||||
* - .defaultEngine, triggering engine-default and engine-current (after bug
|
||||
* - .defaultEngine, triggering engine-default and engine-default (after bug
|
||||
* 493051 - for now the search service sets this after engine-added)
|
||||
* ...and then schedules a removal
|
||||
* - engine-loaded (the search service's observer is garanteed to fire first, which is what causes engine-added to fire)
|
||||
|
@ -20,7 +20,6 @@ var expectedLog = [
|
|||
"engine-changed", // XXX bug 606886
|
||||
"engine-added",
|
||||
"engine-default",
|
||||
"engine-current",
|
||||
"engine-loaded",
|
||||
"engine-removed",
|
||||
];
|
||||
|
|
|
@ -1222,7 +1222,7 @@ EnvironmentCache.prototype = {
|
|||
this._log.trace("observe - aTopic: " + aTopic + ", aData: " + aData);
|
||||
switch (aTopic) {
|
||||
case SEARCH_ENGINE_MODIFIED_TOPIC:
|
||||
if (aData != "engine-current") {
|
||||
if (aData != "engine-default") {
|
||||
return;
|
||||
}
|
||||
// Record the new default search choice and send the change notification.
|
||||
|
|
|
@ -1563,10 +1563,10 @@ add_task(async function test_defaultSearchEngine() {
|
|||
for (let engine of await Services.search.getEngines()) {
|
||||
await Services.search.removeEngine(engine);
|
||||
}
|
||||
// The search service does not notify "engine-current" when removing a default engine.
|
||||
// The search service does not notify "engine-default" when removing a default engine.
|
||||
// Manually force the notification.
|
||||
// TODO: remove this when bug 1165341 is resolved.
|
||||
Services.obs.notifyObservers(null, "browser-search-engine-modified", "engine-current");
|
||||
Services.obs.notifyObservers(null, "browser-search-engine-modified", "engine-default");
|
||||
await promiseNextTick();
|
||||
|
||||
// Then check that no default engine is reported if none is available.
|
||||
|
@ -1635,7 +1635,7 @@ add_task(async function test_defaultSearchEngine() {
|
|||
TelemetryEnvironment.registerChangeListener("testWatch_SearchDefault", resolve);
|
||||
});
|
||||
engine.wrappedJSObject.setAttr("loadPathHash", "broken");
|
||||
Services.obs.notifyObservers(null, "browser-search-engine-modified", "engine-current");
|
||||
Services.obs.notifyObservers(null, "browser-search-engine-modified", "engine-default");
|
||||
await promise;
|
||||
TelemetryEnvironment.unregisterChangeListener("testWatch_SearchDefault");
|
||||
data = TelemetryEnvironment.currentEnvironment;
|
||||
|
|
Загрузка…
Ссылка в новой задаче