зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1640045 - Replace PlacesSearchAutocompleteProvider with UrlbarSearchUtils, remove its parseSubmissionURL function, and init the search service on the first query. r=mak
* Replace PlacesSearchAutocompleteProvider with UrlbarSearchUtils. * Move the module from toolkit to browser. The only consumers of PlacesSearchAutocompleteProvider are urlbar and UnifiedComplete. * I'd like to add functions to UrlbarUtils instead, but PlacesSearchAutocompleteProvider adds itself as an observer for search engine changes, and it keeps some state so that alias lookups are O(1). It has an init function to set that up. That's not quite as easy to do if I just added some functions to UrlbarUtils, and I think that O(1) lookups of aliases are worth keeping (vs. O(number of installed engines)), so I kept a separate module, now called UrlbarSearchUtils. * Init the search service (via UrlbarSearchUtils) from UrlbarProvidersManager.startQuery so that every module involved in querying doesn't need to do it. * Remove PlacesSearchAutocompleteProvider.currentEngine. Previous consumers can simply use Services.search directly now that the service is initialized early (see previous point). * Remove PlacesSearchAutocompleteProvider.parseSubmissionURL. Here again consumers can use Services.search directly. Differential Revision: https://phabricator.services.mozilla.com/D79244
This commit is contained in:
Родитель
a39858820c
Коммит
7024c06712
|
@ -1356,14 +1356,8 @@ add_task(async function test_privateBrowsing_allowed_onQueryCanceled() {
|
|||
controller.cancelQuery();
|
||||
await startPromise;
|
||||
|
||||
// Check isActive and priority.
|
||||
Assert.ok(provider.isActive(context));
|
||||
Assert.equal(provider.getPriority(context), 0);
|
||||
|
||||
// The events should have been fired.
|
||||
await Promise.all(
|
||||
["onBehaviorRequested", "onQueryCanceled"].map(msg => ext.awaitMessage(msg))
|
||||
);
|
||||
// onQueryCanceled should have been fired.
|
||||
await ext.awaitMessage("onQueryCanceled");
|
||||
|
||||
await ext.unload();
|
||||
});
|
||||
|
|
|
@ -15,8 +15,7 @@ const { XPCOMUtils } = ChromeUtils.import(
|
|||
);
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
Log: "resource://gre/modules/Log.jsm",
|
||||
PlacesSearchAutocompleteProvider:
|
||||
"resource://gre/modules/PlacesSearchAutocompleteProvider.jsm",
|
||||
Services: "resource://gre/modules/Services.jsm",
|
||||
UrlbarPrefs: "resource:///modules/UrlbarPrefs.jsm",
|
||||
UrlbarMuxer: "resource:///modules/UrlbarUtils.jsm",
|
||||
UrlbarUtils: "resource:///modules/UrlbarUtils.jsm",
|
||||
|
@ -194,15 +193,7 @@ class MuxerUnifiedComplete extends UrlbarMuxer {
|
|||
result.source == UrlbarUtils.RESULT_SOURCE.HISTORY &&
|
||||
result.type == UrlbarUtils.RESULT_TYPE.URL
|
||||
) {
|
||||
let submission;
|
||||
try {
|
||||
// parseSubmissionURL throws if PlacesSearchAutocompleteProvider
|
||||
// hasn't finished initializing, so try-catch this call. There's no
|
||||
// harm if it throws, we just won't dedupe SERPs this time.
|
||||
submission = PlacesSearchAutocompleteProvider.parseSubmissionURL(
|
||||
result.payload.url
|
||||
);
|
||||
} catch (error) {}
|
||||
let submission = Services.search.parseSubmissionURL(result.payload.url);
|
||||
if (submission) {
|
||||
let resultQuery = submission.terms.toLocaleLowerCase();
|
||||
if (
|
||||
|
|
|
@ -15,13 +15,12 @@ const { XPCOMUtils } = ChromeUtils.import(
|
|||
"resource://gre/modules/XPCOMUtils.jsm"
|
||||
);
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
PlacesSearchAutocompleteProvider:
|
||||
"resource://gre/modules/PlacesSearchAutocompleteProvider.jsm",
|
||||
Services: "resource://gre/modules/Services.jsm",
|
||||
SkippableTimer: "resource:///modules/UrlbarUtils.jsm",
|
||||
UrlbarProvider: "resource:///modules/UrlbarUtils.jsm",
|
||||
UrlbarProvidersManager: "resource:///modules/UrlbarProvidersManager.jsm",
|
||||
UrlbarResult: "resource:///modules/UrlbarResult.jsm",
|
||||
UrlbarSearchUtils: "resource:///modules/UrlbarSearchUtils.jsm",
|
||||
UrlbarUtils: "resource:///modules/UrlbarUtils.jsm",
|
||||
});
|
||||
|
||||
|
@ -303,7 +302,7 @@ class UrlbarProviderExtension extends UrlbarProvider {
|
|||
engine = Services.search.getEngineByName(extResult.payload.engine);
|
||||
} else if (extResult.payload.keyword) {
|
||||
// Look up the engine by its alias.
|
||||
engine = await PlacesSearchAutocompleteProvider.engineForAlias(
|
||||
engine = await UrlbarSearchUtils.engineForAlias(
|
||||
extResult.payload.keyword
|
||||
);
|
||||
} else if (extResult.payload.url) {
|
||||
|
@ -313,9 +312,7 @@ class UrlbarProviderExtension extends UrlbarProvider {
|
|||
host = new URL(extResult.payload.url).hostname;
|
||||
} catch (err) {}
|
||||
if (host) {
|
||||
engine = await PlacesSearchAutocompleteProvider.engineForDomainPrefix(
|
||||
host
|
||||
);
|
||||
engine = await UrlbarSearchUtils.engineForDomainPrefix(host);
|
||||
}
|
||||
}
|
||||
if (!engine) {
|
||||
|
|
|
@ -15,8 +15,6 @@ const { XPCOMUtils } = ChromeUtils.import(
|
|||
);
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
Log: "resource://gre/modules/Log.jsm",
|
||||
PlacesSearchAutocompleteProvider:
|
||||
"resource://gre/modules/PlacesSearchAutocompleteProvider.jsm",
|
||||
SearchSuggestionController:
|
||||
"resource://gre/modules/SearchSuggestionController.jsm",
|
||||
Services: "resource://gre/modules/Services.jsm",
|
||||
|
@ -24,6 +22,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
UrlbarPrefs: "resource:///modules/UrlbarPrefs.jsm",
|
||||
UrlbarProvider: "resource:///modules/UrlbarUtils.jsm",
|
||||
UrlbarResult: "resource:///modules/UrlbarResult.jsm",
|
||||
UrlbarSearchUtils: "resource:///modules/UrlbarSearchUtils.jsm",
|
||||
UrlbarTokenizer: "resource:///modules/UrlbarTokenizer.jsm",
|
||||
UrlbarUtils: "resource:///modules/UrlbarUtils.jsm",
|
||||
});
|
||||
|
@ -264,15 +263,16 @@ class ProviderSearchSuggestions extends UrlbarProvider {
|
|||
let engine;
|
||||
if (aliasEngine) {
|
||||
engine = aliasEngine.engine;
|
||||
} else if (queryContext.engineName) {
|
||||
engine = Services.search.getEngineByName(queryContext.engineName);
|
||||
} else if (queryContext.isPrivate) {
|
||||
engine = Services.search.defaultPrivateEngine;
|
||||
} else {
|
||||
engine = queryContext.engineName
|
||||
? Services.search.getEngineByName(queryContext.engineName)
|
||||
: await PlacesSearchAutocompleteProvider.currentEngine(
|
||||
queryContext.isPrivate
|
||||
);
|
||||
if (!engine) {
|
||||
return;
|
||||
}
|
||||
engine = Services.search.defaultEngine;
|
||||
}
|
||||
|
||||
if (!engine) {
|
||||
return;
|
||||
}
|
||||
|
||||
let alias = (aliasEngine && aliasEngine.alias) || "";
|
||||
|
@ -503,9 +503,7 @@ class ProviderSearchSuggestions extends UrlbarProvider {
|
|||
}
|
||||
|
||||
// Check if the user entered an engine alias directly.
|
||||
let engineMatch = await PlacesSearchAutocompleteProvider.engineForAlias(
|
||||
possibleAlias
|
||||
);
|
||||
let engineMatch = await UrlbarSearchUtils.engineForAlias(possibleAlias);
|
||||
if (engineMatch) {
|
||||
return {
|
||||
engine: engineMatch,
|
||||
|
@ -518,25 +516,6 @@ class ProviderSearchSuggestions extends UrlbarProvider {
|
|||
};
|
||||
}
|
||||
|
||||
// Check if the user is matching a token alias.
|
||||
let engines = await PlacesSearchAutocompleteProvider.tokenAliasEngines();
|
||||
if (!engines || !engines.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (let { engine, tokenAliases } of engines) {
|
||||
if (tokenAliases.includes(possibleAlias)) {
|
||||
return {
|
||||
engine,
|
||||
alias: possibleAlias,
|
||||
query: UrlbarUtils.substringAfter(
|
||||
queryContext.searchString,
|
||||
possibleAlias
|
||||
).trim(),
|
||||
isTokenAlias: true,
|
||||
};
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,10 +15,9 @@ const { XPCOMUtils } = ChromeUtils.import(
|
|||
);
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
Log: "resource://gre/modules/Log.jsm",
|
||||
PlacesSearchAutocompleteProvider:
|
||||
"resource://gre/modules/PlacesSearchAutocompleteProvider.jsm",
|
||||
UrlbarProvider: "resource:///modules/UrlbarUtils.jsm",
|
||||
UrlbarResult: "resource:///modules/UrlbarResult.jsm",
|
||||
UrlbarSearchUtils: "resource:///modules/UrlbarSearchUtils.jsm",
|
||||
UrlbarUtils: "resource:///modules/UrlbarUtils.jsm",
|
||||
});
|
||||
|
||||
|
@ -68,7 +67,7 @@ class ProviderTokenAliasEngines extends UrlbarProvider {
|
|||
async isActive(queryContext) {
|
||||
this._engines = [];
|
||||
if (queryContext.searchString.trim() == "@") {
|
||||
this._engines = await PlacesSearchAutocompleteProvider.tokenAliasEngines();
|
||||
this._engines = await UrlbarSearchUtils.tokenAliasEngines();
|
||||
}
|
||||
|
||||
return this._engines.length;
|
||||
|
|
|
@ -14,13 +14,12 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
AboutNewTab: "resource:///modules/AboutNewTab.jsm",
|
||||
Log: "resource://gre/modules/Log.jsm",
|
||||
PlacesUtils: "resource://gre/modules/PlacesUtils.jsm",
|
||||
PlacesSearchAutocompleteProvider:
|
||||
"resource://gre/modules/PlacesSearchAutocompleteProvider.jsm",
|
||||
Services: "resource://gre/modules/Services.jsm",
|
||||
UrlbarPrefs: "resource:///modules/UrlbarPrefs.jsm",
|
||||
UrlbarProvider: "resource:///modules/UrlbarUtils.jsm",
|
||||
UrlbarProviderOpenTabs: "resource:///modules/UrlbarProviderOpenTabs.jsm",
|
||||
UrlbarResult: "resource:///modules/UrlbarResult.jsm",
|
||||
UrlbarSearchUtils: "resource:///modules/UrlbarSearchUtils.jsm",
|
||||
UrlbarUtils: "resource:///modules/UrlbarUtils.jsm",
|
||||
TOP_SITES_MAX_SITES_PER_ROW: "resource://activity-stream/common/Reducers.jsm",
|
||||
TOP_SITES_DEFAULT_ROWS: "resource://activity-stream/common/Reducers.jsm",
|
||||
|
@ -190,9 +189,7 @@ class ProviderTopSites extends UrlbarProvider {
|
|||
break;
|
||||
}
|
||||
case "search": {
|
||||
let engine = await PlacesSearchAutocompleteProvider.engineForAlias(
|
||||
site.title
|
||||
);
|
||||
let engine = await UrlbarSearchUtils.engineForAlias(site.title);
|
||||
|
||||
if (!engine && site.url) {
|
||||
// Look up the engine by its domain.
|
||||
|
@ -201,9 +198,7 @@ class ProviderTopSites extends UrlbarProvider {
|
|||
host = new URL(site.url).hostname;
|
||||
} catch (err) {}
|
||||
if (host) {
|
||||
engine = await PlacesSearchAutocompleteProvider.engineForDomainPrefix(
|
||||
host
|
||||
);
|
||||
engine = await UrlbarSearchUtils.engineForDomainPrefix(host);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
UrlbarMuxer: "resource:///modules/UrlbarUtils.jsm",
|
||||
UrlbarPrefs: "resource:///modules/UrlbarPrefs.jsm",
|
||||
UrlbarProvider: "resource:///modules/UrlbarUtils.jsm",
|
||||
UrlbarSearchUtils: "resource:///modules/UrlbarSearchUtils.jsm",
|
||||
UrlbarTokenizer: "resource:///modules/UrlbarTokenizer.jsm",
|
||||
UrlbarUtils: "resource:///modules/UrlbarUtils.jsm",
|
||||
});
|
||||
|
@ -196,6 +197,14 @@ class ProvidersManager {
|
|||
let query = new Query(queryContext, controller, muxer, providers);
|
||||
this.queries.set(queryContext, query);
|
||||
|
||||
// The muxer and many providers depend on the search service and our search
|
||||
// utils. Make sure they're initialized now (via UrlbarSearchUtils) so that
|
||||
// all query-related urlbar modules don't need to do it.
|
||||
await UrlbarSearchUtils.init();
|
||||
if (query.canceled) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the behavior of extension providers.
|
||||
for (let provider of this.providers) {
|
||||
if (
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
* Search service utilities for urlbar. The only reason these functions aren't
|
||||
* a part of UrlbarUtils is that we want O(1) case-insensitive lookup for search
|
||||
* aliases, and to do that we need to observe the search service, persistent
|
||||
* state, and an init method. A separate object is easier.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["UrlbarSearchUtils"];
|
||||
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const SEARCH_ENGINE_TOPIC = "browser-search-engine-modified";
|
||||
|
||||
/**
|
||||
* Search service utilities for urlbar.
|
||||
*/
|
||||
class SearchUtils {
|
||||
constructor() {
|
||||
this._refreshEnginesByAliasPromise = Promise.resolve();
|
||||
this.QueryInterface = ChromeUtils.generateQI([
|
||||
Ci.nsIObserver,
|
||||
Ci.nsISupportsWeakReference,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the instance and also Services.search.
|
||||
*/
|
||||
async init() {
|
||||
if (!this._initPromise) {
|
||||
this._initPromise = this._initInternal();
|
||||
}
|
||||
await this._initPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the engine whose domain matches a given prefix.
|
||||
*
|
||||
* @param {string} prefix
|
||||
* String containing the first part of the matching domain name.
|
||||
* @returns {nsISearchEngine}
|
||||
* The matching engine or null if there isn't one.
|
||||
*/
|
||||
async engineForDomainPrefix(prefix) {
|
||||
await this.init();
|
||||
for (let engine of await Services.search.getVisibleEngines()) {
|
||||
let domain = engine.getResultDomain();
|
||||
if (domain.startsWith(prefix) || domain.startsWith("www." + prefix)) {
|
||||
return engine;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the engine with a given alias.
|
||||
*
|
||||
* @param {string} alias
|
||||
* A search engine alias. The alias string comparison is case insensitive.
|
||||
* @returns {nsISearchEngine}
|
||||
* The matching engine or null if there isn't one.
|
||||
*/
|
||||
async engineForAlias(alias) {
|
||||
await Promise.all([this.init(), this._refreshEnginesByAliasPromise]);
|
||||
return this._enginesByAlias.get(alias.toLocaleLowerCase()) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The list of engines with token ("@") aliases.
|
||||
*
|
||||
* @returns {array}
|
||||
* Array of objects { engine, tokenAliases } for token alias engines.
|
||||
*/
|
||||
async tokenAliasEngines() {
|
||||
await this.init();
|
||||
let tokenAliasEngines = [];
|
||||
for (let engine of await Services.search.getVisibleEngines()) {
|
||||
let tokenAliases = this._engineAliases(engine).filter(a =>
|
||||
a.startsWith("@")
|
||||
);
|
||||
if (tokenAliases.length) {
|
||||
tokenAliasEngines.push({ engine, tokenAliases });
|
||||
}
|
||||
}
|
||||
return tokenAliasEngines;
|
||||
}
|
||||
|
||||
async _initInternal() {
|
||||
await Services.search.init();
|
||||
await this._refreshEnginesByAlias();
|
||||
Services.obs.addObserver(this, SEARCH_ENGINE_TOPIC, true);
|
||||
}
|
||||
|
||||
async _refreshEnginesByAlias() {
|
||||
// See the comment at the top of this file. The only reason we need this
|
||||
// class is for O(1) case-insensitive lookup for search aliases, which is
|
||||
// facilitated by _enginesByAlias.
|
||||
this._enginesByAlias = new Map();
|
||||
for (let engine of await Services.search.getVisibleEngines()) {
|
||||
if (!engine.hidden) {
|
||||
let aliases = this._engineAliases(engine);
|
||||
for (let alias of aliases) {
|
||||
this._enginesByAlias.set(alias.toLocaleLowerCase(), engine);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_engineAliases(engine) {
|
||||
let aliases = [];
|
||||
if (engine.alias) {
|
||||
aliases.push(engine.alias);
|
||||
}
|
||||
aliases.push(...engine.wrappedJSObject._internalAliases);
|
||||
return aliases;
|
||||
}
|
||||
|
||||
observe(subject, topic, data) {
|
||||
switch (data) {
|
||||
case "engine-added":
|
||||
case "engine-changed":
|
||||
case "engine-removed":
|
||||
case "engine-default":
|
||||
this._refreshEnginesByAliasPromise = this._refreshEnginesByAlias();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var UrlbarSearchUtils = new SearchUtils();
|
|
@ -23,6 +23,7 @@ EXTRA_JS_MODULES += [
|
|||
'UrlbarProviderTopSites.jsm',
|
||||
'UrlbarProviderUnifiedComplete.jsm',
|
||||
'UrlbarResult.jsm',
|
||||
'UrlbarSearchUtils.jsm',
|
||||
'UrlbarTokenizer.jsm',
|
||||
'UrlbarUtils.jsm',
|
||||
'UrlbarValueFormatter.jsm',
|
||||
|
|
|
@ -16,8 +16,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
BrowserUtils: "resource://gre/modules/BrowserUtils.jsm",
|
||||
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.jsm",
|
||||
FormHistory: "resource://gre/modules/FormHistory.jsm",
|
||||
PlacesSearchAutocompleteProvider:
|
||||
"resource://gre/modules/PlacesSearchAutocompleteProvider.jsm",
|
||||
setTimeout: "resource://gre/modules/Timer.jsm",
|
||||
TestUtils: "resource://testing-common/TestUtils.jsm",
|
||||
UrlbarController: "resource:///modules/UrlbarController.jsm",
|
||||
|
@ -388,9 +386,8 @@ var UrlbarTestUtils = {
|
|||
.getService(Ci.nsIObserver)
|
||||
.observe(null, "profile-after-change", null);
|
||||
|
||||
// These two calls are necessary because UrlbarMuxerUnifiedComplete.sort
|
||||
// calls PlacesSearchAutocompleteProvider.parseSubmissionURL, so we need
|
||||
// engines and PlacesSearchAutocompleteProvider.
|
||||
// This is necessary because UrlbarMuxerUnifiedComplete.sort calls
|
||||
// Services.search.parseSubmissionURL, so we need engines.
|
||||
try {
|
||||
await AddonTestUtils.promiseStartupManager();
|
||||
} catch (error) {
|
||||
|
@ -398,7 +395,6 @@ var UrlbarTestUtils = {
|
|||
throw error;
|
||||
}
|
||||
}
|
||||
await PlacesSearchAutocompleteProvider.ensureReady();
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
AboutNewTab: "resource:///modules/AboutNewTab.jsm",
|
||||
NewTabUtils: "resource://gre/modules/NewTabUtils.jsm",
|
||||
PlacesSearchAutocompleteProvider:
|
||||
"resource://gre/modules/PlacesSearchAutocompleteProvider.jsm",
|
||||
});
|
||||
|
||||
const EN_US_TOPSITES =
|
||||
|
|
|
@ -19,8 +19,9 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
ResetProfile: "resource://gre/modules/ResetProfile.jsm",
|
||||
TelemetryTestUtils: "resource://testing-common/TelemetryTestUtils.jsm",
|
||||
UrlbarController: "resource:///modules/UrlbarController.jsm",
|
||||
UrlbarResult: "resource:///modules/UrlbarResult.jsm",
|
||||
UrlbarQueryContext: "resource:///modules/UrlbarUtils.jsm",
|
||||
UrlbarResult: "resource:///modules/UrlbarResult.jsm",
|
||||
UrlbarSearchUtils: "resource:///modules/UrlbarSearchUtils.jsm",
|
||||
UrlbarUtils: "resource:///modules/UrlbarUtils.jsm",
|
||||
});
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
AddonTestUtils: "resource://testing-common/AddonTestUtils.jsm",
|
||||
AppConstants: "resource://gre/modules/AppConstants.jsm",
|
||||
HttpServer: "resource://testing-common/httpd.js",
|
||||
PlacesSearchAutocompleteProvider:
|
||||
"resource://gre/modules/PlacesSearchAutocompleteProvider.jsm",
|
||||
PlacesTestUtils: "resource://testing-common/PlacesTestUtils.jsm",
|
||||
PlacesUtils: "resource://gre/modules/PlacesUtils.jsm",
|
||||
PromiseUtils: "resource://gre/modules/PromiseUtils.jsm",
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
const { PlacesSearchAutocompleteProvider } = ChromeUtils.import(
|
||||
"resource://gre/modules/PlacesSearchAutocompleteProvider.jsm"
|
||||
const { UrlbarSearchUtils } = ChromeUtils.import(
|
||||
"resource:///modules/UrlbarSearchUtils.jsm"
|
||||
);
|
||||
|
||||
add_task(async function() {
|
||||
await Services.search.init();
|
||||
await UrlbarSearchUtils.init();
|
||||
// Tell the search service we are running in the US. This also has the
|
||||
// desired side-effect of preventing our geoip lookup.
|
||||
Services.prefs.setCharPref("browser.search.region", "US");
|
||||
|
@ -21,17 +21,12 @@ add_task(async function search_engine_match() {
|
|||
let engine = await Services.search.getDefault();
|
||||
let domain = engine.getResultDomain();
|
||||
let token = domain.substr(0, 1);
|
||||
let matchedEngine = await PlacesSearchAutocompleteProvider.engineForDomainPrefix(
|
||||
token
|
||||
);
|
||||
let matchedEngine = await UrlbarSearchUtils.engineForDomainPrefix(token);
|
||||
Assert.equal(matchedEngine, engine);
|
||||
});
|
||||
|
||||
add_task(async function no_match() {
|
||||
Assert.equal(
|
||||
null,
|
||||
await PlacesSearchAutocompleteProvider.engineForDomainPrefix("test")
|
||||
);
|
||||
Assert.equal(null, await UrlbarSearchUtils.engineForDomainPrefix("test"));
|
||||
});
|
||||
|
||||
add_task(async function hide_search_engine_nomatch() {
|
||||
|
@ -41,26 +36,19 @@ add_task(async function hide_search_engine_nomatch() {
|
|||
let promiseTopic = promiseSearchTopic("engine-changed");
|
||||
await Promise.all([Services.search.removeEngine(engine), promiseTopic]);
|
||||
Assert.ok(engine.hidden);
|
||||
let matchedEngine = await PlacesSearchAutocompleteProvider.engineForDomainPrefix(
|
||||
token
|
||||
);
|
||||
let matchedEngine = await UrlbarSearchUtils.engineForDomainPrefix(token);
|
||||
Assert.ok(!matchedEngine || matchedEngine.getResultDomain() != domain);
|
||||
engine.hidden = false;
|
||||
await TestUtils.waitForCondition(() =>
|
||||
PlacesSearchAutocompleteProvider.engineForDomainPrefix(token)
|
||||
);
|
||||
let matchedEngine2 = await PlacesSearchAutocompleteProvider.engineForDomainPrefix(
|
||||
token
|
||||
UrlbarSearchUtils.engineForDomainPrefix(token)
|
||||
);
|
||||
let matchedEngine2 = await UrlbarSearchUtils.engineForDomainPrefix(token);
|
||||
Assert.ok(matchedEngine2);
|
||||
});
|
||||
|
||||
add_task(async function add_search_engine_match() {
|
||||
let promiseTopic = promiseSearchTopic("engine-added");
|
||||
Assert.equal(
|
||||
null,
|
||||
await PlacesSearchAutocompleteProvider.engineForDomainPrefix("bacon")
|
||||
);
|
||||
Assert.equal(null, await UrlbarSearchUtils.engineForDomainPrefix("bacon"));
|
||||
await Promise.all([
|
||||
Services.search.addEngineWithDetails("bacon", {
|
||||
alias: "pork",
|
||||
|
@ -71,9 +59,7 @@ add_task(async function add_search_engine_match() {
|
|||
promiseTopic,
|
||||
]);
|
||||
await promiseTopic;
|
||||
let matchedEngine = await PlacesSearchAutocompleteProvider.engineForDomainPrefix(
|
||||
"bacon"
|
||||
);
|
||||
let matchedEngine = await UrlbarSearchUtils.engineForDomainPrefix("bacon");
|
||||
Assert.ok(matchedEngine);
|
||||
Assert.equal(matchedEngine.searchForm, "http://www.bacon.moz");
|
||||
Assert.equal(matchedEngine.name, "bacon");
|
||||
|
@ -81,26 +67,21 @@ add_task(async function add_search_engine_match() {
|
|||
});
|
||||
|
||||
add_task(async function test_aliased_search_engine_match() {
|
||||
Assert.equal(
|
||||
null,
|
||||
await PlacesSearchAutocompleteProvider.engineForAlias("sober")
|
||||
);
|
||||
Assert.equal(null, await UrlbarSearchUtils.engineForAlias("sober"));
|
||||
// Lower case
|
||||
let matchedEngine = await PlacesSearchAutocompleteProvider.engineForAlias(
|
||||
"pork"
|
||||
);
|
||||
let matchedEngine = await UrlbarSearchUtils.engineForAlias("pork");
|
||||
Assert.ok(matchedEngine);
|
||||
Assert.equal(matchedEngine.name, "bacon");
|
||||
Assert.equal(matchedEngine.alias, "pork");
|
||||
Assert.equal(matchedEngine.iconURI, null);
|
||||
// Upper case
|
||||
matchedEngine = await PlacesSearchAutocompleteProvider.engineForAlias("PORK");
|
||||
matchedEngine = await UrlbarSearchUtils.engineForAlias("PORK");
|
||||
Assert.ok(matchedEngine);
|
||||
Assert.equal(matchedEngine.name, "bacon");
|
||||
Assert.equal(matchedEngine.alias, "pork");
|
||||
Assert.equal(matchedEngine.iconURI, null);
|
||||
// Cap case
|
||||
matchedEngine = await PlacesSearchAutocompleteProvider.engineForAlias("Pork");
|
||||
matchedEngine = await UrlbarSearchUtils.engineForAlias("Pork");
|
||||
Assert.ok(matchedEngine);
|
||||
Assert.equal(matchedEngine.name, "bacon");
|
||||
Assert.equal(matchedEngine.alias, "pork");
|
||||
|
@ -109,10 +90,7 @@ add_task(async function test_aliased_search_engine_match() {
|
|||
|
||||
add_task(async function test_aliased_search_engine_match_upper_case_alias() {
|
||||
let promiseTopic = promiseSearchTopic("engine-added");
|
||||
Assert.equal(
|
||||
null,
|
||||
await PlacesSearchAutocompleteProvider.engineForDomainPrefix("patch")
|
||||
);
|
||||
Assert.equal(null, await UrlbarSearchUtils.engineForDomainPrefix("patch"));
|
||||
await Promise.all([
|
||||
Services.search.addEngineWithDetails("patch", {
|
||||
alias: "PR",
|
||||
|
@ -123,21 +101,19 @@ add_task(async function test_aliased_search_engine_match_upper_case_alias() {
|
|||
promiseTopic,
|
||||
]);
|
||||
// lower case
|
||||
let matchedEngine = await PlacesSearchAutocompleteProvider.engineForAlias(
|
||||
"pr"
|
||||
);
|
||||
let matchedEngine = await UrlbarSearchUtils.engineForAlias("pr");
|
||||
Assert.ok(matchedEngine);
|
||||
Assert.equal(matchedEngine.name, "patch");
|
||||
Assert.equal(matchedEngine.alias, "PR");
|
||||
Assert.equal(matchedEngine.iconURI, null);
|
||||
// Upper case
|
||||
matchedEngine = await PlacesSearchAutocompleteProvider.engineForAlias("PR");
|
||||
matchedEngine = await UrlbarSearchUtils.engineForAlias("PR");
|
||||
Assert.ok(matchedEngine);
|
||||
Assert.equal(matchedEngine.name, "patch");
|
||||
Assert.equal(matchedEngine.alias, "PR");
|
||||
Assert.equal(matchedEngine.iconURI, null);
|
||||
// Cap case
|
||||
matchedEngine = await PlacesSearchAutocompleteProvider.engineForAlias("Pr");
|
||||
matchedEngine = await UrlbarSearchUtils.engineForAlias("Pr");
|
||||
Assert.ok(matchedEngine);
|
||||
Assert.equal(matchedEngine.name, "patch");
|
||||
Assert.equal(matchedEngine.alias, "PR");
|
||||
|
@ -148,45 +124,22 @@ add_task(async function remove_search_engine_nomatch() {
|
|||
let engine = Services.search.getEngineByName("bacon");
|
||||
let promiseTopic = promiseSearchTopic("engine-removed");
|
||||
await Promise.all([Services.search.removeEngine(engine), promiseTopic]);
|
||||
Assert.equal(
|
||||
null,
|
||||
await PlacesSearchAutocompleteProvider.engineForDomainPrefix("bacon")
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function test_parseSubmissionURL_basic() {
|
||||
// Most of the logic of parseSubmissionURL is tested in the search service
|
||||
// itself, thus we only do a sanity check of the wrapper here.
|
||||
let engine = await Services.search.getDefault();
|
||||
let submissionURL = engine.getSubmission("terms").uri.spec;
|
||||
|
||||
let result = PlacesSearchAutocompleteProvider.parseSubmissionURL(
|
||||
submissionURL
|
||||
);
|
||||
Assert.equal(result.engine.name, engine.name);
|
||||
Assert.equal(result.terms, "terms");
|
||||
|
||||
result = PlacesSearchAutocompleteProvider.parseSubmissionURL(
|
||||
"http://example.org/"
|
||||
);
|
||||
Assert.equal(result, null);
|
||||
Assert.equal(null, await UrlbarSearchUtils.engineForDomainPrefix("bacon"));
|
||||
});
|
||||
|
||||
add_task(async function test_builtin_aliased_search_engine_match() {
|
||||
let engine = await PlacesSearchAutocompleteProvider.engineForAlias("@google");
|
||||
let engine = await UrlbarSearchUtils.engineForAlias("@google");
|
||||
Assert.ok(engine);
|
||||
Assert.equal(engine.name, "Google");
|
||||
let promiseTopic = promiseSearchTopic("engine-changed");
|
||||
await Promise.all([Services.search.removeEngine(engine), promiseTopic]);
|
||||
let matchedEngine = await PlacesSearchAutocompleteProvider.engineForAlias(
|
||||
"@google"
|
||||
);
|
||||
let matchedEngine = await UrlbarSearchUtils.engineForAlias("@google");
|
||||
Assert.ok(!matchedEngine);
|
||||
engine.hidden = false;
|
||||
await TestUtils.waitForCondition(() =>
|
||||
PlacesSearchAutocompleteProvider.engineForAlias("@google")
|
||||
UrlbarSearchUtils.engineForAlias("@google")
|
||||
);
|
||||
engine = await PlacesSearchAutocompleteProvider.engineForAlias("@google");
|
||||
engine = await UrlbarSearchUtils.engineForAlias("@google");
|
||||
Assert.ok(engine);
|
||||
});
|
||||
|
|
@ -24,6 +24,7 @@ support-files =
|
|||
[test_UrlbarPrefs.js]
|
||||
[test_UrlbarQueryContext.js]
|
||||
[test_UrlbarQueryContext_restrictSource.js]
|
||||
[test_UrlbarSearchUtils.jsm]
|
||||
[test_UrlbarUtils_addToUrlbarHistory.js]
|
||||
[test_UrlbarUtils_getShortcutOrURIAndPostData.js]
|
||||
[test_UrlbarUtils_getTokenMatches.js]
|
||||
|
|
|
@ -1,226 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
* Provides functions to handle search engine URLs in the browser history.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["PlacesSearchAutocompleteProvider"];
|
||||
|
||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const SEARCH_ENGINE_TOPIC = "browser-search-engine-modified";
|
||||
|
||||
const SearchAutocompleteProviderInternal = {
|
||||
/**
|
||||
* {Map<string: nsISearchEngine>} Maps from each domain to the engine with
|
||||
* that domain. If more than one engine has the same domain, the last one
|
||||
* passed to _addEngine will be the one in this map.
|
||||
*/
|
||||
enginesByDomain: new Map(),
|
||||
|
||||
/**
|
||||
* {Map<string: nsISearchEngine>} Maps from each lowercased alias to the
|
||||
* engine with that alias. If more than one engine has the same alias, the
|
||||
* last one passed to _addEngine will be the one in this map.
|
||||
*/
|
||||
enginesByAlias: new Map(),
|
||||
|
||||
/**
|
||||
* {array<{ {nsISearchEngine} engine, {array<string>} tokenAliases }>} Array
|
||||
* of engines that have "@" aliases.
|
||||
*/
|
||||
tokenAliasEngines: [],
|
||||
|
||||
async initialize() {
|
||||
try {
|
||||
await Services.search.init();
|
||||
} catch (errorCode) {
|
||||
throw new Error("Unable to initialize search service.");
|
||||
}
|
||||
|
||||
// The initial loading of the search engines must succeed.
|
||||
this._refreshedPromise = this._refresh();
|
||||
await this._refreshedPromise;
|
||||
|
||||
Services.obs.addObserver(this, SEARCH_ENGINE_TOPIC, true);
|
||||
|
||||
this.initialized = true;
|
||||
},
|
||||
|
||||
initialized: false,
|
||||
|
||||
observe(subject, topic, data) {
|
||||
switch (data) {
|
||||
case "engine-added":
|
||||
case "engine-changed":
|
||||
case "engine-removed":
|
||||
case "engine-default":
|
||||
this._refreshedPromise = this._refresh();
|
||||
}
|
||||
},
|
||||
|
||||
async _refresh() {
|
||||
this.enginesByDomain.clear();
|
||||
this.enginesByAlias.clear();
|
||||
this.tokenAliasEngines = [];
|
||||
|
||||
// The search engines will always be processed in the order returned by the
|
||||
// search service, which can be defined by the user.
|
||||
(await Services.search.getEngines()).forEach(e => this._addEngine(e));
|
||||
},
|
||||
|
||||
_addEngine(engine) {
|
||||
if (engine.hidden) {
|
||||
return;
|
||||
}
|
||||
|
||||
let domain = engine.getResultDomain();
|
||||
if (domain) {
|
||||
this.enginesByDomain.set(domain, engine);
|
||||
}
|
||||
|
||||
let aliases = [];
|
||||
if (engine.alias) {
|
||||
aliases.push(engine.alias);
|
||||
}
|
||||
aliases.push(...engine.wrappedJSObject._internalAliases);
|
||||
for (let alias of aliases) {
|
||||
this.enginesByAlias.set(alias.toLocaleLowerCase(), engine);
|
||||
}
|
||||
|
||||
let tokenAliases = aliases.filter(a => a.startsWith("@"));
|
||||
if (tokenAliases.length) {
|
||||
this.tokenAliasEngines.push({ engine, tokenAliases });
|
||||
}
|
||||
},
|
||||
|
||||
QueryInterface: ChromeUtils.generateQI([
|
||||
Ci.nsIObserver,
|
||||
Ci.nsISupportsWeakReference,
|
||||
]),
|
||||
};
|
||||
|
||||
var gInitializationPromise = null;
|
||||
|
||||
var PlacesSearchAutocompleteProvider = Object.freeze({
|
||||
/**
|
||||
* Starts initializing the component and returns a promise that is resolved or
|
||||
* rejected when initialization and updates are finished.
|
||||
*/
|
||||
ensureReady() {
|
||||
if (!gInitializationPromise) {
|
||||
gInitializationPromise = SearchAutocompleteProviderInternal.initialize();
|
||||
}
|
||||
|
||||
return Promise.all([
|
||||
gInitializationPromise,
|
||||
SearchAutocompleteProviderInternal._refreshedPromise,
|
||||
]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the engine whose domain matches a given prefix.
|
||||
*
|
||||
* @param {string} prefix
|
||||
* String containing the first part of the matching domain name.
|
||||
* @returns {nsISearchEngine} The matching engine or null if there isn't one.
|
||||
*/
|
||||
async engineForDomainPrefix(prefix) {
|
||||
await this.ensureReady();
|
||||
|
||||
// Match at the beginning for now. In the future, an "options" argument may
|
||||
// allow the matching behavior to be tuned.
|
||||
let tuples = SearchAutocompleteProviderInternal.enginesByDomain.entries();
|
||||
for (let [domain, engine] of tuples) {
|
||||
if (domain.startsWith(prefix) || domain.startsWith("www." + prefix)) {
|
||||
return engine;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the engine with a given alias.
|
||||
*
|
||||
* @param {string} alias
|
||||
* A search engine alias.
|
||||
* @returns {nsISearchEngine} The matching engine or null if there isn't one.
|
||||
*/
|
||||
async engineForAlias(alias) {
|
||||
await this.ensureReady();
|
||||
|
||||
return (
|
||||
SearchAutocompleteProviderInternal.enginesByAlias.get(
|
||||
alias.toLocaleLowerCase()
|
||||
) || null
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the list of engines with token ("@") aliases.
|
||||
*
|
||||
* @returns {array<{ {nsISearchEngine} engine, {array<string>} tokenAliases }>}
|
||||
* Array of objects { engine, tokenAliases } for token alias engines.
|
||||
*/
|
||||
async tokenAliasEngines() {
|
||||
await this.ensureReady();
|
||||
|
||||
return SearchAutocompleteProviderInternal.tokenAliasEngines.slice();
|
||||
},
|
||||
|
||||
/**
|
||||
* Use this to get the current engine rather than Services.search.defaultEngine
|
||||
* directly. This method makes sure that the service is first initialized.
|
||||
*
|
||||
* @param {boolean} inPrivateWindow
|
||||
* Set to true if this search is being run in a private window.
|
||||
* @returns {nsISearchEngine} The current search engine.
|
||||
*/
|
||||
async currentEngine(inPrivateWindow) {
|
||||
await this.ensureReady();
|
||||
|
||||
return inPrivateWindow
|
||||
? Services.search.defaultPrivateEngine
|
||||
: Services.search.defaultEngine;
|
||||
},
|
||||
|
||||
/**
|
||||
* Synchronously determines if the provided URL represents results from a
|
||||
* search engine, and provides details about the match.
|
||||
*
|
||||
* @param url
|
||||
* String containing the URL to parse.
|
||||
*
|
||||
* @return An object with the following properties, or null if the URL does
|
||||
* not represent a search result:
|
||||
* {
|
||||
* engine: The search engine, as an nsISearchEngine.
|
||||
* terms: The originally sought terms extracted from the URI.
|
||||
* termsParameterName: The engine's search-string parameter.
|
||||
* }
|
||||
*
|
||||
* @remarks The asynchronous ensureInitialized function must be called before
|
||||
* this synchronous method can be used.
|
||||
*
|
||||
* @note This API function needs to be synchronous because it is called inside
|
||||
* a row processing callback of Sqlite.jsm, in UnifiedComplete.js.
|
||||
*/
|
||||
parseSubmissionURL(url) {
|
||||
if (!SearchAutocompleteProviderInternal.initialized) {
|
||||
throw new Error("The component has not been initialized.");
|
||||
}
|
||||
|
||||
let parseUrlResult = Services.search.parseSubmissionURL(url);
|
||||
return (
|
||||
parseUrlResult.engine && {
|
||||
engine: parseUrlResult.engine,
|
||||
terms: parseUrlResult.terms,
|
||||
termsParameterName: parseUrlResult.termsParameterName,
|
||||
}
|
||||
);
|
||||
},
|
||||
});
|
|
@ -344,8 +344,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
ObjectUtils: "resource://gre/modules/ObjectUtils.jsm",
|
||||
PlacesRemoteTabsAutocompleteProvider:
|
||||
"resource://gre/modules/PlacesRemoteTabsAutocompleteProvider.jsm",
|
||||
PlacesSearchAutocompleteProvider:
|
||||
"resource://gre/modules/PlacesSearchAutocompleteProvider.jsm",
|
||||
PlacesUtils: "resource://gre/modules/PlacesUtils.jsm",
|
||||
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
|
||||
ProfileAge: "resource://gre/modules/ProfileAge.jsm",
|
||||
|
@ -354,6 +352,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
UrlbarPrefs: "resource:///modules/UrlbarPrefs.jsm",
|
||||
UrlbarProviderOpenTabs: "resource:///modules/UrlbarProviderOpenTabs.jsm",
|
||||
UrlbarProvidersManager: "resource:///modules/UrlbarProvidersManager.jsm",
|
||||
UrlbarSearchUtils: "resource:///modules/UrlbarSearchUtils.jsm",
|
||||
UrlbarTokenizer: "resource:///modules/UrlbarTokenizer.jsm",
|
||||
UrlbarUtils: "resource:///modules/UrlbarUtils.jsm",
|
||||
});
|
||||
|
@ -958,17 +957,6 @@ Search.prototype = {
|
|||
}
|
||||
};
|
||||
|
||||
if (UrlbarPrefs.get("restyleSearches")) {
|
||||
// This explicit initialization is only necessary for
|
||||
// _maybeRestyleSearchMatch, because it calls the synchronous
|
||||
// parseSubmissionURL that can't wait for async initialization of
|
||||
// PlacesSearchAutocompleteProvider.
|
||||
await PlacesSearchAutocompleteProvider.ensureReady();
|
||||
if (!this.pending) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// For any given search, we run many queries/heuristics:
|
||||
// 1) by alias (as defined in SearchService)
|
||||
// 2) inline completion from search engine resultDomains
|
||||
|
@ -996,7 +984,7 @@ Search.prototype = {
|
|||
|
||||
// If the query is simply "@" and we have tokenAliasEngines then return
|
||||
// early. UrlbarProviderTokenAliasEngines will add engine results.
|
||||
let tokenAliasEngines = await PlacesSearchAutocompleteProvider.tokenAliasEngines();
|
||||
let tokenAliasEngines = await UrlbarSearchUtils.tokenAliasEngines();
|
||||
if (this._trimmedOriginalSearchString == "@" && tokenAliasEngines.length) {
|
||||
this._autocompleteSearch.finishSearch(true);
|
||||
return;
|
||||
|
@ -1234,7 +1222,7 @@ Search.prototype = {
|
|||
}
|
||||
|
||||
// See if any engine has a token alias that starts with the heuristic token.
|
||||
let engines = await PlacesSearchAutocompleteProvider.tokenAliasEngines();
|
||||
let engines = await UrlbarSearchUtils.tokenAliasEngines();
|
||||
for (let { engine, tokenAliases } of engines) {
|
||||
for (let alias of tokenAliases) {
|
||||
if (alias.startsWith(token.toLocaleLowerCase())) {
|
||||
|
@ -1499,7 +1487,7 @@ Search.prototype = {
|
|||
return false;
|
||||
}
|
||||
|
||||
// PlacesSearchAutocompleteProvider only matches against engine domains.
|
||||
// engineForDomainPrefix only matches against engine domains.
|
||||
// Remove an eventual trailing slash from the search string (without the
|
||||
// prefix) and check if the resulting string is worth matching.
|
||||
// Later, we'll verify that the found result matches the original
|
||||
|
@ -1515,9 +1503,7 @@ Search.prototype = {
|
|||
return false;
|
||||
}
|
||||
|
||||
let engine = await PlacesSearchAutocompleteProvider.engineForDomainPrefix(
|
||||
searchStr
|
||||
);
|
||||
let engine = await UrlbarSearchUtils.engineForDomainPrefix(searchStr);
|
||||
if (!engine) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1559,7 +1545,7 @@ Search.prototype = {
|
|||
},
|
||||
|
||||
async _matchSearchEngineAlias(alias) {
|
||||
let engine = await PlacesSearchAutocompleteProvider.engineForAlias(alias);
|
||||
let engine = await UrlbarSearchUtils.engineForAlias(alias);
|
||||
if (!engine) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1578,14 +1564,19 @@ Search.prototype = {
|
|||
},
|
||||
|
||||
async _matchCurrentSearchEngine() {
|
||||
let engine = this._engineName
|
||||
? Services.search.getEngineByName(this._engineName)
|
||||
: await PlacesSearchAutocompleteProvider.currentEngine(
|
||||
this._inPrivateWindow
|
||||
);
|
||||
let engine;
|
||||
if (this._engineName) {
|
||||
engine = Services.search.getEngineByName(this._engineName);
|
||||
} else if (this._inPrivateWindow) {
|
||||
engine = Services.search.defaultPrivateEngine;
|
||||
} else {
|
||||
engine = Services.search.defaultEngine;
|
||||
}
|
||||
|
||||
if (!engine || !this.pending) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Strip a leading search restriction char, because we prepend it to text
|
||||
// when the search shortcut is used and it's not user typed. Don't strip
|
||||
// other restriction chars, so that it's possible to search for things
|
||||
|
@ -1841,9 +1832,7 @@ Search.prototype = {
|
|||
|
||||
_maybeRestyleSearchMatch(match) {
|
||||
// Return if the URL does not represent a search result.
|
||||
let parseResult = PlacesSearchAutocompleteProvider.parseSubmissionURL(
|
||||
match.value
|
||||
);
|
||||
let parseResult = Services.search.parseSubmissionURL(match.value);
|
||||
if (!parseResult) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,6 @@ if CONFIG['MOZ_PLACES']:
|
|||
'PlacesDBUtils.jsm',
|
||||
'PlacesExpiration.jsm',
|
||||
'PlacesRemoteTabsAutocompleteProvider.jsm',
|
||||
'PlacesSearchAutocompleteProvider.jsm',
|
||||
'PlacesSyncUtils.jsm',
|
||||
'PlacesTransactions.jsm',
|
||||
'PlacesUtils.jsm',
|
||||
|
|
|
@ -36,7 +36,6 @@ support-files =
|
|||
[test_keyword_search_actions.js]
|
||||
[test_keywords.js]
|
||||
[test_multi_word_search.js]
|
||||
[test_PlacesSearchAutocompleteProvider.js]
|
||||
[test_preloaded_sites.js]
|
||||
[test_query_url.js]
|
||||
[test_remote_tab_matches.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче