summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-04-22 20:58:36 +0000
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-04-22 20:58:36 +0000
commitab5f78afbdbf3b37f89c06dcd59ff9442d6ecf14 (patch)
tree55a1e7c2bf2007f88cc5518052419bee63126688 /toolkit/components/places
parent9ffed6e8bfb35c090caf5f8bca7a0f8bd4cbec94 (diff)
parent1d7664d3a1db098024c7624650b0d272a26635e0 (diff)
downloadUXP-ab5f78afbdbf3b37f89c06dcd59ff9442d6ecf14.tar
UXP-ab5f78afbdbf3b37f89c06dcd59ff9442d6ecf14.tar.gz
UXP-ab5f78afbdbf3b37f89c06dcd59ff9442d6ecf14.tar.lz
UXP-ab5f78afbdbf3b37f89c06dcd59ff9442d6ecf14.tar.xz
UXP-ab5f78afbdbf3b37f89c06dcd59ff9442d6ecf14.zip
Merge branch 'master' into Pale_Moon-release
# Conflicts: # application/palemoon/config/version.txt # old-configure.in
Diffstat (limited to 'toolkit/components/places')
-rw-r--r--toolkit/components/places/PlacesCategoriesStarter.js7
-rw-r--r--toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm6
-rw-r--r--toolkit/components/places/UnifiedComplete.js85
-rw-r--r--toolkit/components/places/mozIPlacesAutoComplete.idl8
-rw-r--r--toolkit/components/places/nsPlacesExpiration.js14
-rw-r--r--toolkit/components/places/nsPlacesTables.h4
-rw-r--r--toolkit/components/places/nsPlacesTriggers.h3
-rw-r--r--toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js8
-rw-r--r--toolkit/components/places/tests/unifiedcomplete/test_tab_matches.js53
-rw-r--r--toolkit/components/places/tests/unit/test_000_frecency.js10
10 files changed, 50 insertions, 148 deletions
diff --git a/toolkit/components/places/PlacesCategoriesStarter.js b/toolkit/components/places/PlacesCategoriesStarter.js
index 560bd486a..bab14db52 100644
--- a/toolkit/components/places/PlacesCategoriesStarter.js
+++ b/toolkit/components/places/PlacesCategoriesStarter.js
@@ -77,11 +77,8 @@ PlacesCategoriesStarter.prototype = {
break;
case "idle-daily":
// Once a week run places.sqlite maintenance tasks.
- let lastMaintenance = 0;
- try {
- lastMaintenance =
- Services.prefs.getIntPref("places.database.lastMaintenance");
- } catch (ex) {}
+ let lastMaintenance =
+ Services.prefs.getIntPref("places.database.lastMaintenance", 0);
let nowSeconds = parseInt(Date.now() / 1000);
if (lastMaintenance < nowSeconds - MAINTENANCE_INTERVAL_SECONDS) {
PlacesDBUtils.maintenanceOnIdle();
diff --git a/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm b/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm
index d23d5bc6e..c3bc501eb 100644
--- a/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm
+++ b/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm
@@ -95,11 +95,7 @@ function observe(subject, topic, data) {
case "nsPref:changed":
if (data == PREF_SHOW_REMOTE_ICONS) {
- try {
- showRemoteIcons = Services.prefs.getBoolPref(PREF_SHOW_REMOTE_ICONS);
- } catch (_) {
- showRemoteIcons = true; // no such pref - default is to show the icons.
- }
+ showRemoteIcons = Services.prefs.getBoolPref(PREF_SHOW_REMOTE_ICONS, true);
}
break;
diff --git a/toolkit/components/places/UnifiedComplete.js b/toolkit/components/places/UnifiedComplete.js
index 2efae9cbe..7b63e29bb 100644
--- a/toolkit/components/places/UnifiedComplete.js
+++ b/toolkit/components/places/UnifiedComplete.js
@@ -124,9 +124,7 @@ function defaultQuery(conditions = "") {
h.visit_count, h.typed, h.id, t.open_count, h.frecency
FROM moz_places h
LEFT JOIN moz_favicons f ON f.id = h.favicon_id
- LEFT JOIN moz_openpages_temp t
- ON t.url = h.url
- AND t.userContextId = :userContextId
+ LEFT JOIN moz_openpages_temp t ON t.url = h.url
WHERE h.frecency <> 0
AND AUTOCOMPLETE_MATCH(:searchString, h.url,
CASE WHEN bookmarked THEN
@@ -150,7 +148,6 @@ const SQL_SWITCHTAB_QUERY =
FROM moz_openpages_temp t
LEFT JOIN moz_places h ON h.url_hash = hash(t.url) AND h.url = t.url
WHERE h.id IS NULL
- AND t.userContextId = :userContextId
AND AUTOCOMPLETE_MATCH(:searchString, t.url, t.url, NULL,
NULL, NULL, NULL, t.open_count,
:matchBehavior, :searchBehavior)
@@ -170,9 +167,7 @@ const SQL_ADAPTIVE_QUERY =
) AS i
JOIN moz_places h ON h.id = i.place_id
LEFT JOIN moz_favicons f ON f.id = h.favicon_id
- LEFT JOIN moz_openpages_temp t
- ON t.url = h.url
- AND t.userContextId = :userContextId
+ LEFT JOIN moz_openpages_temp t ON t.url = h.url
WHERE AUTOCOMPLETE_MATCH(NULL, h.url,
IFNULL(btitle, h.title), tags,
h.visit_count, h.typed, bookmarked,
@@ -301,17 +296,15 @@ XPCOMUtils.defineLazyServiceGetter(this, "textURIService",
XPCOMUtils.defineLazyGetter(this, "SwitchToTabStorage", () => Object.seal({
_conn: null,
// Temporary queue used while the database connection is not available.
- _queue: new Map(),
+ _queue: new Set(),
initDatabase: Task.async(function* (conn) {
// To reduce IO use an in-memory table for switch-to-tab tracking.
// Note: this should be kept up-to-date with the definition in
// nsPlacesTables.h.
yield conn.execute(
`CREATE TEMP TABLE moz_openpages_temp (
- url TEXT,
- userContextId INTEGER,
- open_count INTEGER,
- PRIMARY KEY (url, userContextId)
+ url TEXT PRIMARY KEY,
+ open_count INTEGER
)`);
// Note: this should be kept up-to-date with the definition in
@@ -322,64 +315,44 @@ XPCOMUtils.defineLazyGetter(this, "SwitchToTabStorage", () => Object.seal({
WHEN NEW.open_count = 0
BEGIN
DELETE FROM moz_openpages_temp
- WHERE url = NEW.url
- AND userContextId = NEW.userContextId;
+ WHERE url = NEW.url;
END`);
this._conn = conn;
// Populate the table with the current cache contents...
- for (let [userContextId, uris] of this._queue) {
- for (let uri of uris) {
- this.add(uri, userContextId);
- }
- }
+ this._queue.forEach(this.add, this);
// ...then clear it to avoid double additions.
this._queue.clear();
}),
- add(uri, userContextId) {
+ add: function (uri) {
if (!this._conn) {
- if (!this._queue.has(userContextId)) {
- this._queue.set(userContextId, new Set());
- }
- this._queue.get(userContextId).add(uri);
+ this._queue.add(uri);
return;
}
this._conn.executeCached(
- `INSERT OR REPLACE INTO moz_openpages_temp (url, userContextId, open_count)
- VALUES ( :url,
- :userContextId,
- IFNULL( ( SELECT open_count + 1
- FROM moz_openpages_temp
- WHERE url = :url
- AND userContextId = :userContextId ),
- 1
- )
+ `INSERT OR REPLACE INTO moz_openpages_temp (url, open_count)
+ VALUES ( :url, IFNULL( (SELECT open_count + 1
+ FROM moz_openpages_temp
+ WHERE url = :url),
+ 1
+ )
)`
- , { url: uri.spec, userContextId });
+ , { url: uri.spec });
},
- delete(uri, userContextId) {
+ delete: function (uri) {
if (!this._conn) {
- // This should not happen.
- if (!this._queue.has(userContextId)) {
- throw new Error("Unknown userContextId!");
- }
-
- this._queue.get(userContextId).delete(uri);
- if (this._queue.get(userContextId).size == 0) {
- this._queue.delete(userContextId);
- }
+ this._queue.delete(uri);
return;
}
this._conn.executeCached(
`UPDATE moz_openpages_temp
SET open_count = open_count - 1
- WHERE url = :url
- AND userContextId = :userContextId`
- , { url: uri.spec, userContextId });
+ WHERE url = :url`
+ , { url: uri.spec });
},
shutdown: function () {
@@ -464,10 +437,7 @@ XPCOMUtils.defineLazyGetter(this, "Prefs", () => {
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.keywordEnabled = true;
- try {
- store.keywordEnabled = Services.prefs.getBoolPref("keyword.enabled");
- } catch (ex) {}
+ store.keywordEnabled = Services.prefs.getBoolPref("keyword.enabled", true);
// If history is not set, onlyTyped value should be ignored.
if (!store.suggestHistory) {
@@ -1781,7 +1751,6 @@ Search.prototype = {
// We only want to search the tokens that we are left with - not the
// original search string.
searchString: this._searchTokens.join(" "),
- userContextId: this._userContextId,
// Limit the query to the the maximum number of desired results.
// This way we can avoid doing more work than needed.
maxResults: Prefs.maxRichResults
@@ -1805,7 +1774,6 @@ Search.prototype = {
// We only want to search the tokens that we are left with - not the
// original search string.
searchString: this._searchTokens.join(" "),
- userContextId: this._userContextId,
maxResults: Prefs.maxRichResults
}
];
@@ -1825,8 +1793,7 @@ Search.prototype = {
search_string: this._searchString,
query_type: QUERYTYPE_FILTERED,
matchBehavior: this._matchBehavior,
- searchBehavior: this._behavior,
- userContextId: this._userContextId,
+ searchBehavior: this._behavior
}
];
},
@@ -2010,12 +1977,12 @@ UnifiedComplete.prototype = {
// mozIPlacesAutoComplete
- registerOpenPage(uri, userContextId) {
- SwitchToTabStorage.add(uri, userContextId);
+ registerOpenPage: function PAC_registerOpenPage(uri) {
+ SwitchToTabStorage.add(uri);
},
- unregisterOpenPage(uri, userContextId) {
- SwitchToTabStorage.delete(uri, userContextId);
+ unregisterOpenPage: function PAC_unregisterOpenPage(uri) {
+ SwitchToTabStorage.delete(uri);
},
// nsIAutoCompleteSearch
diff --git a/toolkit/components/places/mozIPlacesAutoComplete.idl b/toolkit/components/places/mozIPlacesAutoComplete.idl
index 7f3247fdc..6ff82e667 100644
--- a/toolkit/components/places/mozIPlacesAutoComplete.idl
+++ b/toolkit/components/places/mozIPlacesAutoComplete.idl
@@ -116,10 +116,8 @@ interface mozIPlacesAutoComplete : nsISupports
*
* @param aURI
* The URI to register as an open page.
- * @param aUserContextId
- * The Container Id of the tab.
*/
- void registerOpenPage(in nsIURI aURI, in uint32_t aUserContextId);
+ void registerOpenPage(in nsIURI aURI);
/**
* Mark a page as no longer being open (either by closing the window or tab,
@@ -131,8 +129,6 @@ interface mozIPlacesAutoComplete : nsISupports
*
* @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);
+ void unregisterOpenPage(in nsIURI aURI);
};
diff --git a/toolkit/components/places/nsPlacesExpiration.js b/toolkit/components/places/nsPlacesExpiration.js
index 499934362..767a4d345 100644
--- a/toolkit/components/places/nsPlacesExpiration.js
+++ b/toolkit/components/places/nsPlacesExpiration.js
@@ -812,11 +812,8 @@ nsPlacesExpiration.prototype = {
_loadPrefs: Task.async(function* () {
// Get the user's limit, if it was set.
- try {
- // We want to silently fail since getIntPref throws if it does not exist,
- // and use a default to fallback to.
- this._urisLimit = this._prefBranch.getIntPref(PREF_MAX_URIS);
- } catch (ex) { /* User limit not set */ }
+ this._urisLimit = this._prefBranch.getIntPref(PREF_MAX_URIS,
+ PREF_MAX_URIS_NOTSET);
if (this._urisLimit < 0) {
// Some testing code expects a pref change to be synchronous, so
@@ -874,11 +871,8 @@ nsPlacesExpiration.prototype = {
this._urisLimit);
// Get the expiration interval value.
- try {
- // We want to silently fail since getIntPref throws if it does not exist,
- // and use a default to fallback to.
- this._interval = this._prefBranch.getIntPref(PREF_INTERVAL_SECONDS);
- } catch (ex) { /* User interval not set */ }
+ this._interval = this._prefBranch.getIntPref(PREF_INTERVAL_SECONDS,
+ PREF_INTERVAL_SECONDS_NOTSET);
if (this._interval <= 0) {
this._interval = PREF_INTERVAL_SECONDS_NOTSET;
}
diff --git a/toolkit/components/places/nsPlacesTables.h b/toolkit/components/places/nsPlacesTables.h
index aca92735e..0b6e414fb 100644
--- a/toolkit/components/places/nsPlacesTables.h
+++ b/toolkit/components/places/nsPlacesTables.h
@@ -133,10 +133,8 @@
// nsPlacesAutoComplete.js.
#define CREATE_MOZ_OPENPAGES_TEMP NS_LITERAL_CSTRING( \
"CREATE TEMP TABLE moz_openpages_temp (" \
- " url TEXT" \
- ", userContextId INTEGER" \
+ " url TEXT PRIMARY KEY" \
", open_count INTEGER" \
- ", PRIMARY KEY (url, userContextId)" \
")" \
)
diff --git a/toolkit/components/places/nsPlacesTriggers.h b/toolkit/components/places/nsPlacesTriggers.h
index d5b45ff5e..37871a3eb 100644
--- a/toolkit/components/places/nsPlacesTriggers.h
+++ b/toolkit/components/places/nsPlacesTriggers.h
@@ -192,8 +192,7 @@
"WHEN NEW.open_count = 0 " \
"BEGIN " \
"DELETE FROM moz_openpages_temp " \
- "WHERE url = NEW.url " \
- "AND userContextId = NEW.userContextId;" \
+ "WHERE url = NEW.url;" \
"END" \
)
diff --git a/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js b/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js
index 11e917e18..bc252efe0 100644
--- a/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js
+++ b/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js
@@ -286,19 +286,19 @@ var addBookmark = Task.async(function* (aBookmarkObj) {
}
});
-function addOpenPages(aUri, aCount=1, aUserContextId=0) {
+function addOpenPages(aUri, aCount=1) {
let ac = Cc["@mozilla.org/autocomplete/search;1?name=unifiedcomplete"]
.getService(Ci.mozIPlacesAutoComplete);
for (let i = 0; i < aCount; i++) {
- ac.registerOpenPage(aUri, aUserContextId);
+ ac.registerOpenPage(aUri);
}
}
-function removeOpenPages(aUri, aCount=1, aUserContextId=0) {
+function removeOpenPages(aUri, aCount=1) {
let ac = Cc["@mozilla.org/autocomplete/search;1?name=unifiedcomplete"]
.getService(Ci.mozIPlacesAutoComplete);
for (let i = 0; i < aCount; i++) {
- ac.unregisterOpenPage(aUri, aUserContextId);
+ ac.unregisterOpenPage(aUri);
}
}
diff --git a/toolkit/components/places/tests/unifiedcomplete/test_tab_matches.js b/toolkit/components/places/tests/unifiedcomplete/test_tab_matches.js
index 740b8d8ed..646519c32 100644
--- a/toolkit/components/places/tests/unifiedcomplete/test_tab_matches.js
+++ b/toolkit/components/places/tests/unifiedcomplete/test_tab_matches.js
@@ -11,11 +11,9 @@ add_task(function* test_tab_matches() {
let uri2 = NetUtil.newURI("http://xyz.net/");
let uri3 = NetUtil.newURI("about:mozilla");
let uri4 = NetUtil.newURI("data:text/html,test");
- let uri5 = NetUtil.newURI("http://foobar.org");
yield PlacesTestUtils.addVisits([
{ uri: uri1, title: "ABC rocks" },
- { uri: uri2, title: "xyz.net - we're better than ABC" },
- { uri: uri5, title: "foobar.org - much better than ABC, definitely better than XYZ" }
+ { uri: uri2, title: "xyz.net - we're better than ABC" }
]);
addOpenPages(uri1, 1);
// Pages that cannot be registered in history.
@@ -37,8 +35,7 @@ add_task(function* test_tab_matches() {
searchParam: "enable-actions",
matches: [ makeSearchMatch("abc", { heuristic: true }),
makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }),
- { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] },
- { uri: uri5, title: "foobar.org - much better than ABC, definitely better than XYZ", style: [ "favicon" ] } ]
+ { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] } ]
});
do_print("three results, both normal results are tab matches");
@@ -48,39 +45,7 @@ add_task(function* test_tab_matches() {
searchParam: "enable-actions",
matches: [ makeSearchMatch("abc", { heuristic: true }),
makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }),
- makeSwitchToTabMatch("http://xyz.net/", { title: "xyz.net - we're better than ABC" }),
- { uri: uri5, title: "foobar.org - much better than ABC, definitely better than XYZ", style: [ "favicon" ] } ]
- });
-
- do_print("a container tab is not visible in 'switch to tab'");
- addOpenPages(uri5, 1, /* userContextId: */ 3);
- yield check_autocomplete({
- search: "abc",
- searchParam: "enable-actions",
- matches: [ makeSearchMatch("abc", { heuristic: true }),
- makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }),
- makeSwitchToTabMatch("http://xyz.net/", { title: "xyz.net - we're better than ABC" }),
- { uri: uri5, title: "foobar.org - much better than ABC, definitely better than XYZ", style: [ "favicon" ] } ]
- });
-
- do_print("a container tab should not see 'switch to tab' for other container tabs");
- yield check_autocomplete({
- search: "abc",
- searchParam: "enable-actions user-context-id:3",
- matches: [ makeSearchMatch("abc", { heuristic: true }),
- makeSwitchToTabMatch("http://foobar.org/", { title: "foobar.org - much better than ABC, definitely better than XYZ" }),
- { uri: uri1, title: "ABC rocks", style: [ "favicon" ] },
- { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] } ]
- });
-
- do_print("a different container tab should not see any 'switch to tab'");
- yield check_autocomplete({
- search: "abc",
- searchParam: "enable-actions user-context-id:2",
- matches: [ makeSearchMatch("abc", { heuristic: true }),
- { uri: uri1, title: "ABC rocks", style: [ "favicon" ] },
- { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] },
- { uri: uri5, title: "foobar.org - much better than ABC, definitely better than XYZ", style: [ "favicon" ] } ]
+ makeSwitchToTabMatch("http://xyz.net/", { title: "xyz.net - we're better than ABC" }) ]
});
do_print("three results, both normal results are tab matches, one has multiple tabs");
@@ -90,8 +55,7 @@ add_task(function* test_tab_matches() {
searchParam: "enable-actions",
matches: [ makeSearchMatch("abc", { heuristic: true }),
makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }),
- makeSwitchToTabMatch("http://xyz.net/", { title: "xyz.net - we're better than ABC" }),
- { uri: uri5, title: "foobar.org - much better than ABC, definitely better than XYZ", style: [ "favicon" ] } ]
+ makeSwitchToTabMatch("http://xyz.net/", { title: "xyz.net - we're better than ABC" }) ]
});
do_print("three results, no tab matches (disable-private-actions)");
@@ -100,8 +64,7 @@ add_task(function* test_tab_matches() {
searchParam: "enable-actions disable-private-actions",
matches: [ makeSearchMatch("abc", { heuristic: true }),
{ uri: uri1, title: "ABC rocks", style: [ "favicon" ] },
- { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] },
- { uri: uri5, title: "foobar.org - much better than ABC, definitely better than XYZ", style: [ "favicon" ] } ]
+ { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] } ]
});
do_print("two results (actions disabled)");
@@ -109,8 +72,7 @@ add_task(function* test_tab_matches() {
search: "abc",
searchParam: "",
matches: [ { uri: uri1, title: "ABC rocks", style: [ "favicon" ] },
- { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] },
- { uri: uri5, title: "foobar.org - much better than ABC, definitely better than XYZ", style: [ "favicon" ] } ]
+ { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] } ]
});
do_print("three results, no tab matches");
@@ -121,8 +83,7 @@ add_task(function* test_tab_matches() {
searchParam: "enable-actions",
matches: [ makeSearchMatch("abc", { heuristic: true }),
{ uri: uri1, title: "ABC rocks", style: [ "favicon" ] },
- { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] },
- { uri: uri5, title: "foobar.org - much better than ABC, definitely better than XYZ", style: [ "favicon" ] } ]
+ { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] } ]
});
do_print("tab match search with restriction character");
diff --git a/toolkit/components/places/tests/unit/test_000_frecency.js b/toolkit/components/places/tests/unit/test_000_frecency.js
index 0a7347a02..64ee86b59 100644
--- a/toolkit/components/places/tests/unit/test_000_frecency.js
+++ b/toolkit/components/places/tests/unit/test_000_frecency.js
@@ -56,14 +56,8 @@ var prefPrefix = "places.frecency.";
function* task_initializeBucket(bucket) {
let [cutoffName, weightName] = bucket;
// get pref values
- var weight = 0, cutoff = 0;
- try {
- weight = prefs.getIntPref(prefPrefix + weightName);
- } catch (ex) {}
- try {
- cutoff = prefs.getIntPref(prefPrefix + cutoffName);
- } catch (ex) {}
-
+ var weight = prefs.getIntPref(prefPrefix + weightName, 0);
+ var cutoff = prefs.getIntPref(prefPrefix + cutoffName, 0);
if (cutoff < 1)
return;