--- a/browser/modules/BrowserUsageTelemetry.jsm
+++ b/browser/modules/BrowserUsageTelemetry.jsm
@@ -60,16 +60,17 @@ const URLBAR_SELECTED_RESULT_TYPES = {
keyword: 3,
searchengine: 4,
searchsuggestion: 5,
switchtab: 6,
tag: 7,
visiturl: 8,
remotetab: 9,
extension: 10,
+ "preloaded-top-site": 11,
};
function getOpenTabsAndWinsCounts() {
let tabCount = 0;
let winCount = 0;
let browserEnum = Services.wm.getEnumerator("navigator:browser");
while (browserEnum.hasMoreElements()) {
@@ -245,17 +246,17 @@ let urlbarListener = {
if (action) {
actionType =
action.type == "searchengine" && action.params.searchSuggestion ?
"searchsuggestion" :
action.type;
}
if (!actionType) {
let styles = new Set(controller.getStyleAt(idx).split(/\s+/));
- let style = ["autofill", "tag", "bookmark"].find(s => styles.has(s));
+ let style = ["preloaded-top-site", "autofill", "tag", "bookmark"].find(s => styles.has(s));
actionType = style || "history";
}
Services.telemetry
.getHistogramById("FX_URLBAR_SELECTED_RESULT_INDEX")
.add(idx);
// Ideally this would be a keyed histogram and we'd just add(actionType),
--- a/toolkit/components/places/UnifiedComplete.js
+++ b/toolkit/components/places/UnifiedComplete.js
@@ -44,18 +44,18 @@ const PREF_MATCH_URL = [ "m
const PREF_SUGGEST_HISTORY = [ "suggest.history", true ];
const PREF_SUGGEST_BOOKMARK = [ "suggest.bookmark", true ];
const PREF_SUGGEST_OPENPAGE = [ "suggest.openpage", true ];
const PREF_SUGGEST_HISTORY_ONLYTYPED = [ "suggest.history.onlyTyped", false ];
const PREF_SUGGEST_SEARCHES = [ "suggest.searches", false ];
const PREF_MAX_CHARS_FOR_SUGGEST = [ "maxCharsForSearchSuggestions", 20];
-const PREF_PREFILL_SITES_ENABLED = [ "usepreloadedtopurls.enabled", true ];
-const PREF_PREFILL_SITES_EXPIRE_DAYS = [ "usepreloadedtopurls.expire_days", 14 ];
+const PREF_PRELOADED_SITES_ENABLED = [ "usepreloadedtopurls.enabled", true ];
+const PREF_PRELOADED_SITES_EXPIRE_DAYS = [ "usepreloadedtopurls.expire_days", 14 ];
// AutoComplete query type constants.
// Describes the various types of queries that we can process rows for.
const QUERYTYPE_FILTERED = 0;
const QUERYTYPE_AUTOFILL_HOST = 1;
const QUERYTYPE_AUTOFILL_URL = 2;
// This separator is used as an RTL-friendly way to split the title and tags.
@@ -470,18 +470,18 @@ XPCOMUtils.defineLazyGetter(this, "Prefs
store.matchTitleToken = prefs.get(...PREF_MATCH_TITLE);
store.matchURLToken = prefs.get(...PREF_MATCH_URL);
store.suggestHistory = prefs.get(...PREF_SUGGEST_HISTORY);
store.suggestBookmark = prefs.get(...PREF_SUGGEST_BOOKMARK);
store.suggestOpenpage = prefs.get(...PREF_SUGGEST_OPENPAGE);
store.suggestTyped = prefs.get(...PREF_SUGGEST_HISTORY_ONLYTYPED);
store.suggestSearches = prefs.get(...PREF_SUGGEST_SEARCHES);
store.maxCharsForSearchSuggestions = prefs.get(...PREF_MAX_CHARS_FOR_SUGGEST);
- store.prefillSitesEnabled = prefs.get(...PREF_PREFILL_SITES_ENABLED);
- store.prefillSitesExpireDays = prefs.get(...PREF_PREFILL_SITES_EXPIRE_DAYS);
+ store.preloadedSitesEnabled = prefs.get(...PREF_PRELOADED_SITES_ENABLED);
+ store.preloadedSitesExpireDays = prefs.get(...PREF_PRELOADED_SITES_EXPIRE_DAYS);
store.keywordEnabled = Services.prefs.getBoolPref("keyword.enabled", true);
// If history is not set, onlyTyped value should be ignored.
if (!store.suggestHistory) {
store.suggestTyped = false;
}
store.defaultBehavior = types.concat("Typed").reduce((memo, type) => {
let prefValue = store["suggest" + type];
@@ -542,38 +542,38 @@ XPCOMUtils.defineLazyGetter(this, "Prefs
loadPrefs();
Services.prefs.addObserver(PREF_BRANCH, store, false);
Services.prefs.addObserver("keyword.enabled", store, true);
return Object.seal(store);
});
-// Prefill Sites related
+// Preloaded Sites related
-function PrefillSite(url, title) {
+function PreloadedSite(url, title) {
this.uri = NetUtil.newURI(url);
this.title = title;
this._matchTitle = title.toLowerCase();
this._hasWWW = this.uri.host.startsWith("www.");
this._hostWithoutWWW = this._hasWWW ? this.uri.host.slice(4)
: this.uri.host;
}
/**
- * Storage object for Prefill Sites.
+ * Storage object for Preloaded Sites.
* add(url, title): adds a site to storage
* populate(sites) : populates the storage with array of [url,title]
- * sites[]: resulting array of sites (PrefillSite objects)
+ * sites[]: resulting array of sites (PreloadedSite objects)
*/
-XPCOMUtils.defineLazyGetter(this, "PrefillSiteStorage", () => Object.seal({
+XPCOMUtils.defineLazyGetter(this, "PreloadedSiteStorage", () => Object.seal({
sites: [],
add(url, title) {
- let site = new PrefillSite(url, title);
+ let site = new PreloadedSite(url, title);
this.sites.push(site);
},
populate(sites) {
for (let site of sites) {
this.add(site[0], site[1]);
}
},
@@ -969,18 +969,18 @@ Search.prototype = {
// "openpage" behavior is supported by the default query.
// _switchToTabQuery instead returns only pages not supported by history.
if (this.hasBehavior("openpage")) {
queries.push(this._switchToTabQuery);
}
queries.push(this._searchQuery);
- // Check for Prefill Sites Expiry before Autofill
- yield this._checkPrefillSitesExpiry();
+ // Check for Preloaded Sites Expiry before Autofill
+ yield this._checkPreloadedSitesExpiry();
// Add the first heuristic result, if any. Set _addingHeuristicFirstMatch
// to true so that when the result is added, "heuristic" can be included in
// its style.
this._addingHeuristicFirstMatch = true;
let hasHeuristic = yield this._matchFirstHeuristicResult(conn);
this._addingHeuristicFirstMatch = false;
if (!this.pending)
@@ -1035,72 +1035,72 @@ Search.prototype = {
this._originalSearchString.length > this._searchTokens[0].length) {
yield this._matchExtensionSuggestions();
if (!this.pending)
return;
} else if (ExtensionSearchHandler.hasActiveInputSession()) {
ExtensionSearchHandler.handleInputCancelled();
}
- this._matchPrefillSites();
+ this._matchPreloadedSites();
// Ensure to fill any remaining space. Suggestions which come from extensions are
// inserted at the beginning, so any suggestions
yield Promise.all(this._remoteMatchesPromises);
}),
- *_checkPrefillSitesExpiry() {
- if (!Prefs.prefillSitesEnabled)
+ *_checkPreloadedSitesExpiry() {
+ if (!Prefs.preloadedSitesEnabled)
return;
let profileCreationDate = yield ProfileAgeCreatedPromise;
let daysSinceProfileCreation = (Date.now() - profileCreationDate) / MS_PER_DAY;
- if (daysSinceProfileCreation > Prefs.prefillSitesExpireDays)
+ if (daysSinceProfileCreation > Prefs.preloadedSitesExpireDays)
Services.prefs.setBoolPref("browser.urlbar.usepreloadedtopurls.enabled", false);
},
- _matchPrefillSites() {
- if (!Prefs.prefillSitesEnabled)
+ _matchPreloadedSites() {
+ if (!Prefs.preloadedSitesEnabled)
return;
// In case user typed just "https://" or "www." or "https://www."
// - we do not put out the whole lot of sites
if (!this._searchString)
return;
if (!(this._searchStringScheme === "" ||
this._searchStringScheme === "https" ||
this._searchStringScheme === "http"))
return;
let strictMatches = [];
let looseMatches = [];
- for (let site of PrefillSiteStorage.sites) {
+ for (let site of PreloadedSiteStorage.sites) {
if (this._searchStringScheme && this._searchStringScheme !== site.uri.scheme)
continue;
let match = {
value: site.uri.spec,
comment: site.title,
- style: "prefill-site",
+ style: "preloaded-top-site",
frecency: FRECENCY_DEFAULT - 1,
};
if (site.uri.host.includes(this._searchStringFromWWW) ||
site._matchTitle.includes(this._searchStringFromWWW)) {
strictMatches.push(match);
} else if (site.uri.host.includes(this._searchString) ||
site._matchTitle.includes(this._searchString)) {
looseMatches.push(match);
}
}
[...strictMatches, ...looseMatches].forEach(this._addMatch, this);
},
- _matchPrefillSiteForAutofill() {
- if (!Prefs.prefillSitesEnabled)
+ _matchPreloadedSiteForAutofill() {
+ if (!Prefs.preloadedSitesEnabled)
return false;
if (!(this._searchStringScheme === "" ||
this._searchStringScheme === "https" ||
this._searchStringScheme === "http"))
return false;
let searchStringSchemePrefix = this._searchStringScheme
@@ -1114,43 +1114,43 @@ Search.prototype = {
}
// First we try to strict-match
// If search string has "www."- we try to strict-match it along with "www."
function matchStrict(site) {
return site.uri.host.startsWith(this._searchStringFromWWW)
&& matchScheme(site, this);
}
- let site = PrefillSiteStorage.sites.find(matchStrict, this)
+ let site = PreloadedSiteStorage.sites.find(matchStrict, this)
if (site) {
let match = {
// We keep showing prefix that user typed, then what we match on
value: searchStringSchemePrefix + site.uri.host + "/",
- style: "autofill",
+ style: "autofill preloaded-top-site",
finalCompleteValue: site.uri.spec,
frecency: FRECENCY_DEFAULT,
};
this._result.setDefaultIndex(0);
this._addMatch(match);
return true;
}
// If no strict result found - we try loose match
- // regardless of "www." in prefill-sites or search string
+ // regardless of "www." in Preloaded-sites or search string
function matchLoose(site) {
return site._hostWithoutWWW.startsWith(this._searchString)
&& matchScheme(site, this);
}
- site = PrefillSiteStorage.sites.find(matchLoose, this);
+ site = PreloadedSiteStorage.sites.find(matchLoose, this);
if (site) {
let match = {
// We keep showing prefix that user typed, then what we match on
value: searchStringSchemePrefix + this._searchStringWWW +
site._hostWithoutWWW + "/",
- style: "autofill",
+ style: "autofill preloaded-top-site",
// On loose match, result should always have "www."
finalCompleteValue: site.uri.scheme + "://www." +
site._hostWithoutWWW + "/",
frecency: FRECENCY_DEFAULT,
};
this._result.setDefaultIndex(0);
this._addMatch(match);
return true;
@@ -1202,17 +1202,17 @@ Search.prototype = {
// Or it may look like a URL we know about from search engines.
let matched = yield this._matchSearchEngineUrl();
if (matched) {
return true;
}
}
if (this.pending && shouldAutofill) {
- let matched = this._matchPrefillSiteForAutofill();
+ let matched = this._matchPreloadedSiteForAutofill();
if (matched) {
return true;
}
}
if (this.pending && hasSearchTerms && this._enableActions) {
// If we don't have a result that matches what we know about, then
// we use a fallback for things we don't know about.
@@ -2148,25 +2148,25 @@ Search.prototype = {
function UnifiedComplete() {
// Make sure the preferences are initialized as soon as possible.
// If the value of browser.urlbar.autocomplete.enabled is set to false,
// then all the other suggest preferences for history, bookmarks and
// open pages should be set to false.
Prefs;
- if (Prefs.prefillSitesEnabled) {
+ if (Prefs.preloadedSitesEnabled) {
// force initializing the profile age check
// to ensure the off-main-thread-IO happens ASAP
// and we don't have to wait for it when doing an autocomplete lookup
ProfileAgeCreatedPromise;
fetch("chrome://global/content/unifiedcomplete-top-urls.json")
.then(response => response.json())
- .then(sites => PrefillSiteStorage.populate(sites))
+ .then(sites => PreloadedSiteStorage.populate(sites))
.catch(ex => Cu.reportError(ex));
}
}
UnifiedComplete.prototype = {
// Database handling
/**
@@ -2224,18 +2224,18 @@ UnifiedComplete.prototype = {
registerOpenPage(uri, userContextId) {
SwitchToTabStorage.add(uri, userContextId);
},
unregisterOpenPage(uri, userContextId) {
SwitchToTabStorage.delete(uri, userContextId);
},
- populatePrefillSiteStorage(json) {
- PrefillSiteStorage.populate(json);
+ populatePreloadedSiteStorage(json) {
+ PreloadedSiteStorage.populate(json);
},
// nsIAutoCompleteSearch
startSearch(searchString, searchParam, previousResult, listener) {
// Stop the search in case the controller has not taken care of it.
if (this._currentSearch) {
this.stopSearch();
--- a/toolkit/components/places/mozIPlacesAutoComplete.idl
+++ b/toolkit/components/places/mozIPlacesAutoComplete.idl
@@ -132,15 +132,15 @@ interface mozIPlacesAutoComplete : nsISu
* @param aURI
* The URI to unregister as an open page.
* @param aUserContextId
* The Container Id of the tab.
*/
void unregisterOpenPage(in nsIURI aURI, in uint32_t aUserContextId);
/**
- * Populate list of Prefill Sites from JSON.
+ * Populate list of Preloaded Sites from JSON.
*
* @param sites
* Array of [url,title] to populate from.
*/
- void populatePrefillSiteStorage(in jsval sites);
+ void populatePreloadedSiteStorage(in jsval sites);
};
rename from toolkit/components/places/tests/unifiedcomplete/test_prefill_sites.js
rename to toolkit/components/places/tests/unifiedcomplete/test_preloaded_sites.js
--- a/toolkit/components/places/tests/unifiedcomplete/test_prefill_sites.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_preloaded_sites.js
@@ -1,38 +1,38 @@
/**
- * Test for bug 1211726 - prefill list of top web sites for better
+ * Test for bug 1211726 - preload list of top web sites for better
* autocompletion on empty profiles.
*/
const PREF_FEATURE_ENABLED = "browser.urlbar.usepreloadedtopurls.enabled";
const PREF_FEATURE_EXPIRE_DAYS = "browser.urlbar.usepreloadedtopurls.expire_days";
const autocompleteObject = Cc["@mozilla.org/autocomplete/search;1?name=unifiedcomplete"]
.getService(Ci.mozIPlacesAutoComplete);
Cu.importGlobalProperties(["fetch"]);
// With or without trailing slash - no matter. URI.spec does have it always.
// Then, check_autocomplete() doesn't cut it off (uses stripPrefix()).
let yahoooURI = NetUtil.newURI("https://yahooo.com/");
let gooogleURI = NetUtil.newURI("https://gooogle.com/");
-autocompleteObject.populatePrefillSiteStorage([
+autocompleteObject.populatePreloadedSiteStorage([
[yahoooURI.spec, "Yahooo"],
[gooogleURI.spec, "Gooogle"],
]);
function *assert_feature_works(condition) {
do_print("List Results do appear " + condition);
yield check_autocomplete({
search: "ooo",
matches: [
- { uri: yahoooURI, title: "Yahooo", style: ["prefill-site"] },
- { uri: gooogleURI, title: "Gooogle", style: ["prefill-site"] },
+ { uri: yahoooURI, title: "Yahooo", style: ["preloaded-top-site"] },
+ { uri: gooogleURI, title: "Gooogle", style: ["preloaded-top-site"] },
],
});
do_print("Autofill does appear " + condition);
yield check_autocomplete({
search: "gooo",
autofilled: "gooogle.com/", // Will fail without trailing slash
completed: "https://gooogle.com/",
@@ -46,17 +46,17 @@ function *assert_feature_does_not_appear
matches: [],
});
do_print("Autofill doesn't appear " + condition);
// "search" is what you type,
// "autofilled" is what you get in response in the url bar,
// "completed" is what you get there when you hit enter.
// So if they are all equal - it's the proof there was no autofill
- // (knowing we have a suitable prefill site).
+ // (knowing we have a suitable preloaded top site).
yield check_autocomplete({
search: "gooo",
autofilled: "gooo",
completed: "gooo",
});
}
add_task(function* test_it_works() {
@@ -78,45 +78,45 @@ add_task(function* test_it_works() {
add_task(function* test_sorting_against_bookmark() {
let boookmarkURI = NetUtil.newURI("https://boookmark.com");
yield addBookmark( { uri: boookmarkURI, title: "Boookmark" } );
Services.prefs.setBoolPref(PREF_FEATURE_ENABLED, true);
Services.prefs.setIntPref(PREF_FEATURE_EXPIRE_DAYS, 14);
- do_print("Prefill Sites are placed lower than Bookmarks");
+ do_print("Preloaded Top Sites are placed lower than Bookmarks");
yield check_autocomplete({
checkSorting: true,
search: "ooo",
matches: [
{ uri: boookmarkURI, title: "Boookmark", style: ["bookmark"] },
- { uri: yahoooURI, title: "Yahooo", style: ["prefill-site"] },
- { uri: gooogleURI, title: "Gooogle", style: ["prefill-site"] },
+ { uri: yahoooURI, title: "Yahooo", style: ["preloaded-top-site"] },
+ { uri: gooogleURI, title: "Gooogle", style: ["preloaded-top-site"] },
],
});
yield cleanup();
});
add_task(function* test_sorting_against_history() {
let histoooryURI = NetUtil.newURI("https://histooory.com");
yield PlacesTestUtils.addVisits( { uri: histoooryURI, title: "Histooory" } );
Services.prefs.setBoolPref(PREF_FEATURE_ENABLED, true);
Services.prefs.setIntPref(PREF_FEATURE_EXPIRE_DAYS, 14);
- do_print("Prefill Sites are placed lower than History entries");
+ do_print("Preloaded Top Sites are placed lower than History entries");
yield check_autocomplete({
checkSorting: true,
search: "ooo",
matches: [
{ uri: histoooryURI, title: "Histooory" },
- { uri: yahoooURI, title: "Yahooo", style: ["prefill-site"] },
- { uri: gooogleURI, title: "Gooogle", style: ["prefill-site"] },
+ { uri: yahoooURI, title: "Yahooo", style: ["preloaded-top-site"] },
+ { uri: gooogleURI, title: "Gooogle", style: ["preloaded-top-site"] },
],
});
yield cleanup();
});
add_task(function* test_scheme_and_www() {
// Order is important to check sorting
@@ -126,17 +126,17 @@ add_task(function* test_scheme_and_www()
["HTTP://ooops-HTTP.com/", "Ooops"],
["HTTP://www.ooops-HTTP-www.com/", "Ooops"],
["https://foo.com/", "Title with www"],
["https://www.bar.com/", "Tile"],
];
let titlesMap = new Map(sites)
- autocompleteObject.populatePrefillSiteStorage(sites);
+ autocompleteObject.populatePreloadedSiteStorage(sites);
let tests =
[
// User typed,
// Inline autofill,
// Substitute after enter is pressed,
// [List matches, with sorting]
// not tested if omitted
@@ -172,17 +172,17 @@ add_task(function* test_scheme_and_www()
[// Edge case: no "www." in search string, autofill and list entries with "www."
"ww",
"www.ooops-https-www.com/",
"https://www.ooops-https-www.com/", // 2nd in list, but has priority as strict
[
["https://www.ooops-https-www.com/", "https://www.ooops-https-www.com"],
"HTTP://www.ooops-HTTP-www.com/",
- ["https://foo.com/", "Title with www", ["prefill-site"]],
+ ["https://foo.com/", "Title with www", ["preloaded-top-site"]],
"https://www.bar.com/",
]
],
[// Strict match, no "www."
"ooops",
"ooops-https.com/",
"https://ooops-https.com/", // 2nd in list, but has priority as strict
@@ -217,17 +217,17 @@ add_task(function* test_scheme_and_www()
],
[// Loose match: search "www.", no-www site gets "www."
"www.ooops-https.",
"www.ooops-https.com/",
"https://www.ooops-https.com/",
[// Only autofill entry gets "www."
["https://www.ooops-https.com/", "https://www.ooops-https.com"],
- "https://ooops-https.com/", // List entry with prefilled URl for match site
+ "https://ooops-https.com/", // List entry with preloaded top URL for match site
]
],
[// Explicit protocol, no "www."
"https://ooops",
"https://ooops-https.com/",
"https://ooops-https.com/",
[
@@ -264,23 +264,23 @@ add_task(function* test_scheme_and_www()
],
];
function toMatch(entry, index) {
if (Array.isArray(entry)) {
return {
uri: NetUtil.newURI(entry[0]),
title: entry[1],
- style: entry[2] || ["autofill", "heuristic"],
+ style: entry[2] || ["autofill", "heuristic", "preloaded-top-site"],
};
}
return {
uri: NetUtil.newURI(entry),
title: titlesMap.get(entry),
- style: ["prefill-site"],
+ style: ["preloaded-top-site"],
};
}
for (let test of tests) {
let matches = test[3] ? test[3].map(toMatch) : null;
do_print("User types: " + test[0]);
yield check_autocomplete({
checkSorting: true,
@@ -299,17 +299,17 @@ add_task(function* test_data_file() {
do_print("Source file is supplied and fetched OK");
Assert.ok(response.ok);
do_print("The JSON is parsed");
let sites = yield response.json();
do_print("Storage is populated");
- autocompleteObject.populatePrefillSiteStorage(sites);
+ autocompleteObject.populatePreloadedSiteStorage(sites);
let lastSite = sites.pop();
let uri = NetUtil.newURI(lastSite[0]);
do_print("Storage is populated from JSON correctly");
yield check_autocomplete({
search: uri.host,
autofilled: uri.host + "/",
--- a/toolkit/components/places/tests/unifiedcomplete/xpcshell.ini
+++ b/toolkit/components/places/tests/unifiedcomplete/xpcshell.ini
@@ -26,17 +26,17 @@ support-files =
[test_escape_self.js]
[test_extension_matches.js]
[test_ignore_protocol.js]
[test_keyword_search.js]
[test_keyword_search_actions.js]
[test_keywords.js]
[test_match_beginning.js]
[test_multi_word_search.js]
-[test_prefill_sites.js]
+[test_preloaded_sites.js]
[test_query_url.js]
[test_remote_tab_matches.js]
skip-if = !sync
[test_search_engine_alias.js]
[test_search_engine_current.js]
[test_search_engine_host.js]
[test_search_engine_restyle.js]
[test_search_suggestions.js]