--- a/browser/components/places/content/browserPlacesViews.js
+++ b/browser/components/places/content/browserPlacesViews.js
@@ -50,21 +50,18 @@ PlacesViewBase.prototype = {
return this._place;
},
set place(val) {
this._place = val;
let history = PlacesUtils.history;
let queries = { }, options = { };
history.queryStringToQueries(val, queries, { }, options);
- if (!queries.value.length)
- queries.value = [history.getNewQuery()];
-
- let result = history.executeQueries(queries.value, queries.value.length,
- options.value);
+ let query = queries.value.length ? queries.value[0] : history.getNewQuery();
+ let result = history.executeQuery(query, options.value);
result.addObserver(this);
return val;
},
_result: null,
get result() {
return this._result;
},
--- a/browser/components/places/content/history-panel.js
+++ b/browser/components/places/content/history-panel.js
@@ -81,16 +81,16 @@ function searchHistory(aInput) {
options.includeHidden = !!aInput;
if (gHistoryGrouping == "lastvisited")
this.TelemetryStopwatch.start("HISTORY_LASTVISITED_TREE_QUERY_TIME_MS");
// call load() on the tree manually
// instead of setting the place attribute in history-panel.xul
// otherwise, we will end up calling load() twice
- gHistoryTree.load([query], options);
+ gHistoryTree.load(query, options);
if (gHistoryGrouping == "lastvisited")
this.TelemetryStopwatch.finish("HISTORY_LASTVISITED_TREE_QUERY_TIME_MS");
}
window.addEventListener("SidebarFocused",
() => gSearchBox.focus());
--- a/browser/components/places/content/tree.xml
+++ b/browser/components/places/content/tree.xml
@@ -93,27 +93,26 @@
if (folderRestrict) {
query.setFolders(folderRestrict, folderRestrict.length);
options.queryType = options.QUERY_TYPE_BOOKMARKS;
}
options.includeHidden = !!includeHidden;
- this.load([query], options);
+ this.load(query, options);
]]></body>
</method>
<method name="load">
- <parameter name="queries"/>
+ <parameter name="query"/>
<parameter name="options"/>
<body><![CDATA[
let result = PlacesUtils.history
- .executeQueries(queries, queries.length,
- options);
+ .executeQuery(query, options);
let callback;
if (this.flatList) {
let onOpenFlatContainer = this.onOpenFlatContainer;
if (onOpenFlatContainer)
callback = new Function("aContainer", onOpenFlatContainer);
}
if (!this._controller) {
@@ -287,22 +286,21 @@
]]></getter>
<setter><![CDATA[
this.setAttribute("place", val);
var queriesRef = { };
var queryCountRef = { };
var optionsRef = { };
PlacesUtils.history.queryStringToQueries(val, queriesRef, queryCountRef, optionsRef);
- if (queryCountRef.value == 0)
- queriesRef.value = [PlacesUtils.history.getNewQuery()];
if (!optionsRef.value)
optionsRef.value = PlacesUtils.history.getNewQueryOptions();
+ let query = queriesRef.value.length ? queriesRef.value[0] : PlacesUtils.history.getNewQuery();
- this.load(queriesRef.value, optionsRef.value);
+ this.load(query, optionsRef.value);
return val;
]]></setter>
</property>
<!-- nsIPlacesView -->
<property name="hasSelection">
<getter><![CDATA[
--- a/toolkit/components/downloads/DownloadHistory.jsm
+++ b/toolkit/components/downloads/DownloadHistory.jsm
@@ -416,23 +416,19 @@ var DownloadHistoryList = function(publi
this._slots = [];
this._slotsForUrl = new Map();
this._slotForDownload = new WeakMap();
// Start the asynchronous queries to retrieve history and session downloads.
publicList.addView(this).catch(Cu.reportError);
let queries = {}, options = {};
PlacesUtils.history.queryStringToQueries(place, queries, {}, options);
- if (!queries.value.length) {
- queries.value = [PlacesUtils.history.getNewQuery()];
- }
+ let query = queries.value.length ? queries.value[0] : PlacesUtils.history.getNewQuery();
- let result = PlacesUtils.history.executeQueries(queries.value,
- queries.value.length,
- options.value);
+ let result = PlacesUtils.history.executeQuery(query, options.value);
result.addObserver(this);
};
this.DownloadHistoryList.prototype = {
__proto__: DownloadList.prototype,
/**
* This is set when executing the Places query.
--- a/toolkit/components/places/PlacesUtils.jsm
+++ b/toolkit/components/places/PlacesUtils.jsm
@@ -1309,19 +1309,17 @@ var PlacesUtils = {
if (excludeItems == aExcludeItems && expandQueries == aExpandQueries)
return aNode;
// Otherwise, get contents manually.
var queries = {}, options = {};
this.history.queryStringToQueries(aNode.uri, queries, {}, options);
options.value.excludeItems = aExcludeItems;
options.value.expandQueries = aExpandQueries;
- return this.history.executeQueries(queries.value,
- queries.value.length,
- options.value).root;
+ return this.history.executeQuery(queries.value[0], options.value).root;
},
/**
* Returns true if a container has uri nodes in its first level.
* Has better performance than (getURLsForContainerNode(node).length > 0).
* @param aNode
* The container node to search through.
* @returns true if the node contains uri nodes, false otherwise.
--- a/toolkit/components/places/nsINavHistoryService.idl
+++ b/toolkit/components/places/nsINavHistoryService.idl
@@ -936,19 +936,16 @@ interface nsINavHistoryQuery : nsISuppor
readonly attribute boolean hasAnnotation;
/**
* Limit results to items that are tagged with all of the given tags. This
* attribute must be set to an array of strings. When called as a getter it
* will return an array of strings sorted ascending in lexicographical order.
* The array may be empty in either case. Duplicate tags may be specified
* when setting the attribute, but the getter returns only unique tags.
- *
- * To search for items that are tagged with any given tags rather than all,
- * multiple queries may be passed to nsINavHistoryService.executeQueries().
*/
attribute nsIVariant tags;
/**
* If 'tagsAreNot' is true, the results are instead limited to items that
* are not tagged with any of the given tags. This attribute is used in
* conjunction with the 'tags' attribute.
*/
@@ -1338,28 +1335,18 @@ interface nsINavHistoryService : nsISupp
/**
* Executes a single query.
*/
nsINavHistoryResult executeQuery(in nsINavHistoryQuery aQuery,
in nsINavHistoryQueryOptions options);
/**
- * Executes an array of queries. All of the query objects are ORed
- * together. Within a query, all the terms are ANDed together as in
- * executeQuery. See executeQuery()
- */
- nsINavHistoryResult executeQueries(
- [array,size_is(aQueryCount)] in nsINavHistoryQuery aQueries,
- in unsigned long aQueryCount,
- in nsINavHistoryQueryOptions options);
-
- /**
- * Converts a query URI-like string to an array of actual query objects for
- * use to executeQueries(). The output query array may be empty if there is
+ * Converts a query URI-like string to an array of actual query objects.
+ * The output query array may be empty if there is
* no information. However, there will always be an options structure returned
* (if nothing is defined, it will just have the default values).
*/
void queryStringToQueries(in AUTF8String aQueryString,
[array, size_is(aResultCount)] out nsINavHistoryQuery aQueries,
out unsigned long aResultCount,
out nsINavHistoryQueryOptions options);
--- a/toolkit/components/places/nsNavHistory.cpp
+++ b/toolkit/components/places/nsNavHistory.cpp
@@ -28,16 +28,17 @@
#include "nsString.h"
#include "nsUnicharUtils.h"
#include "prsystem.h"
#include "prtime.h"
#include "nsEscape.h"
#include "nsIEffectiveTLDService.h"
#include "nsIClassInfoImpl.h"
#include "nsIIDNService.h"
+#include "nsQueryObject.h"
#include "nsThreadUtils.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsMathUtils.h"
#include "mozilla/storage.h"
#include "mozilla/Preferences.h"
#include <algorithm>
#ifdef MOZ_XUL
@@ -187,19 +188,18 @@ NS_INTERFACE_MAP_END
// We don't care about flattening everything
NS_IMPL_CI_INTERFACE_GETTER(nsNavHistory,
nsINavHistoryService,
nsIBrowserHistory)
namespace {
-static int64_t GetSimpleBookmarksQueryFolder(
- const nsCOMArray<nsNavHistoryQuery>& aQueries,
- nsNavHistoryQueryOptions* aOptions);
+static int64_t GetSimpleBookmarksQueryFolder(nsNavHistoryQuery* aQuery,
+ nsNavHistoryQueryOptions* aOptions);
static void ParseSearchTermsFromQueries(const nsCOMArray<nsNavHistoryQuery>& aQueries,
nsTArray<nsTArray<nsString>*>* aTerms);
void GetTagsSqlFragment(int64_t aTagsFolder,
const nsACString& aRelation,
bool aHasSearchTerms,
nsACString& _sqlFragment) {
if (!aHasSearchTerms)
@@ -1228,71 +1228,42 @@ nsNavHistory::GetNewQueryOptions(nsINavH
NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
NS_ENSURE_ARG_POINTER(_retval);
RefPtr<nsNavHistoryQueryOptions> queryOptions = new nsNavHistoryQueryOptions();
queryOptions.forget(_retval);
return NS_OK;
}
-// nsNavHistory::ExecuteQuery
-//
NS_IMETHODIMP
-nsNavHistory::ExecuteQuery(nsINavHistoryQuery *aQuery, nsINavHistoryQueryOptions *aOptions,
+nsNavHistory::ExecuteQuery(nsINavHistoryQuery *aQuery,
+ nsINavHistoryQueryOptions *aOptions,
nsINavHistoryResult** _retval)
{
NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
NS_ENSURE_ARG(aQuery);
NS_ENSURE_ARG(aOptions);
NS_ENSURE_ARG_POINTER(_retval);
- return ExecuteQueries(&aQuery, 1, aOptions, _retval);
-}
-
-
-// nsNavHistory::ExecuteQueries
-//
-// This function is actually very simple, we just create the proper root node (either
-// a bookmark folder or a complex query node) and assign it to the result. The node
-// will then populate itself accordingly.
-//
-// Quick overview of query operation: When you call this function, we will construct
-// the correct container node and set the options you give it. This node will then
-// fill itself. Folder nodes will call nsNavBookmarks::QueryFolderChildren, and
-// all other queries will call GetQueryResults. If these results contain other
-// queries, those will be populated when the container is opened.
-
-NS_IMETHODIMP
-nsNavHistory::ExecuteQueries(nsINavHistoryQuery** aQueries, uint32_t aQueryCount,
- nsINavHistoryQueryOptions *aOptions,
- nsINavHistoryResult** _retval)
-{
- NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
- NS_ENSURE_ARG(aQueries);
- NS_ENSURE_ARG(aOptions);
- NS_ENSURE_ARG(aQueryCount);
- NS_ENSURE_ARG_POINTER(_retval);
-
nsresult rv;
// concrete options
nsCOMPtr<nsNavHistoryQueryOptions> options = do_QueryInterface(aOptions);
NS_ENSURE_TRUE(options, NS_ERROR_INVALID_ARG);
// concrete queries array
nsCOMArray<nsNavHistoryQuery> queries;
- for (uint32_t i = 0; i < aQueryCount; i ++) {
- nsCOMPtr<nsNavHistoryQuery> query = do_QueryInterface(aQueries[i], &rv);
- NS_ENSURE_SUCCESS(rv, rv);
- queries.AppendElement(query.forget());
- }
+ RefPtr<nsNavHistoryQuery> query = do_QueryObject(aQuery);
+ NS_ENSURE_STATE(query);
+ queries.AppendObject(query);
// Create the root node.
RefPtr<nsNavHistoryContainerResultNode> rootNode;
- int64_t folderId = GetSimpleBookmarksQueryFolder(queries, options);
+
+ int64_t folderId = GetSimpleBookmarksQueryFolder(query, options);
if (folderId) {
// In the simple case where we're just querying children of a single
// bookmark folder, we can more efficiently generate results.
nsNavBookmarks* bookmarks = nsNavBookmarks::GetBookmarksService();
NS_ENSURE_TRUE(bookmarks, NS_ERROR_OUT_OF_MEMORY);
RefPtr<nsNavHistoryResultNode> tempRootNode;
rv = bookmarks->ResultNodeForContainer(folderId, options,
getter_AddRefs(tempRootNode));
@@ -1310,17 +1281,17 @@ nsNavHistory::ExecuteQueries(nsINavHisto
// Either this is not a folder shortcut, or is a broken one. In both cases
// just generate a query node.
rootNode = new nsNavHistoryQueryResultNode(EmptyCString(),
queries, options);
}
// Create the result that will hold nodes. Inject batching status into it.
RefPtr<nsNavHistoryResult> result;
- rv = nsNavHistoryResult::NewHistoryResult(aQueries, aQueryCount, options,
+ rv = nsNavHistoryResult::NewHistoryResult(queries, 1, options,
rootNode, isBatching(),
getter_AddRefs(result));
NS_ENSURE_SUCCESS(rv, rv);
result.forget(_retval);
return NS_OK;
}
@@ -4007,17 +3978,19 @@ nsNavHistory::QueryRowToResult(int64_t i
nsresult rv = QueryStringToQueryArray(aURI, &queries,
getter_AddRefs(options));
RefPtr<nsNavHistoryResultNode> resultNode;
// If this failed the query does not parse correctly, let the error pass and
// handle it later.
if (NS_SUCCEEDED(rv)) {
// Check if this is a folder shortcut, so we can take a faster path.
- int64_t targetFolderId = GetSimpleBookmarksQueryFolder(queries, options);
+ RefPtr<nsNavHistoryQuery> query = do_QueryObject(queries[0]);
+ NS_ENSURE_STATE(query);
+ int64_t targetFolderId = GetSimpleBookmarksQueryFolder(query, options);
if (targetFolderId) {
nsNavBookmarks *bookmarks = nsNavBookmarks::GetBookmarksService();
NS_ENSURE_TRUE(bookmarks, NS_ERROR_OUT_OF_MEMORY);
rv = bookmarks->ResultNodeForContainer(targetFolderId, options,
getter_AddRefs(resultNode));
// If this failed the shortcut is pointing to nowhere, let the error pass
// and handle it later.
@@ -4306,65 +4279,61 @@ nsNavHistory::GetMonthYear(const PRExplo
CopyUTF16toUTF8(monthYear, aResult);
}
namespace {
// GetSimpleBookmarksQueryFolder
//
-// Determines if this set of queries is a simple bookmarks query for a
+// Determines if this is a simple bookmarks query for a
// folder with no other constraints. In these common cases, we can more
// efficiently compute the results.
//
// A simple bookmarks query will result in a hierarchical tree of
// bookmark items, folders and separators.
//
// Returns the folder ID if it is a simple folder query, 0 if not.
static int64_t
-GetSimpleBookmarksQueryFolder(const nsCOMArray<nsNavHistoryQuery>& aQueries,
+GetSimpleBookmarksQueryFolder(nsNavHistoryQuery* aQuery,
nsNavHistoryQueryOptions* aOptions)
{
- if (aQueries.Count() != 1)
- return 0;
-
- nsNavHistoryQuery* query = aQueries[0];
- if (query->Folders().Length() != 1)
+ if (aQuery->Folders().Length() != 1)
return 0;
bool hasIt;
- query->GetHasBeginTime(&hasIt);
+ aQuery->GetHasBeginTime(&hasIt);
if (hasIt)
return 0;
- query->GetHasEndTime(&hasIt);
+ aQuery->GetHasEndTime(&hasIt);
if (hasIt)
return 0;
- query->GetHasDomain(&hasIt);
+ aQuery->GetHasDomain(&hasIt);
if (hasIt)
return 0;
- query->GetHasUri(&hasIt);
+ aQuery->GetHasUri(&hasIt);
if (hasIt)
return 0;
- (void)query->GetHasSearchTerms(&hasIt);
+ (void)aQuery->GetHasSearchTerms(&hasIt);
if (hasIt)
return 0;
- if (query->Tags().Length() > 0)
+ if (aQuery->Tags().Length() > 0)
return 0;
if (aOptions->MaxResults() > 0)
return 0;
// RESULTS_AS_TAG_CONTENTS is quite similar to a folder shortcut, but it must
// not be treated like that, since it needs all query options.
if(aOptions->ResultType() == nsINavHistoryQueryOptions::RESULTS_AS_TAG_CONTENTS)
return 0;
// Don't care about onlyBookmarked flag, since specifying a bookmark
// folder is inferring onlyBookmarked.
- return query->Folders()[0];
+ return aQuery->Folders()[0];
}
// ParseSearchTermsFromQueries
//
// Construct a matrix of search terms from the given queries array.
// All of the query objects are ORed together. Within a query, all the terms
// are ANDed together. See nsINavHistoryService.idl.
--- a/toolkit/components/places/nsNavHistoryResult.cpp
+++ b/toolkit/components/places/nsNavHistoryResult.cpp
@@ -4078,23 +4078,23 @@ nsNavHistoryResult::StopObserving()
}
}
/**
* @note you must call AddRef before this, since we may do things like
* register ourselves.
*/
nsresult
-nsNavHistoryResult::Init(nsINavHistoryQuery** aQueries,
+nsNavHistoryResult::Init(nsCOMArray<nsNavHistoryQuery>& aQueries,
uint32_t aQueryCount,
nsNavHistoryQueryOptions *aOptions)
{
nsresult rv;
NS_ASSERTION(aOptions, "Must have valid options");
- NS_ASSERTION(aQueries && aQueryCount > 0, "Must have >1 query in result");
+ NS_ASSERTION(aQueries.Count() == aQueryCount && aQueryCount > 0, "Must have >1 query in result");
// Fill saved source queries with copies of the original (the caller might
// change their original objects, and we always want to reflect the source
// parameters).
for (uint32_t i = 0; i < aQueryCount; ++i) {
nsCOMPtr<nsINavHistoryQuery> queryClone;
rv = aQueries[i]->Clone(getter_AddRefs(queryClone));
NS_ENSURE_SUCCESS(rv, rv);
@@ -4114,17 +4114,17 @@ nsNavHistoryResult::Init(nsINavHistoryQu
return NS_OK;
}
/**
* Constructs a new history result object.
*/
nsresult // static
-nsNavHistoryResult::NewHistoryResult(nsINavHistoryQuery** aQueries,
+nsNavHistoryResult::NewHistoryResult(nsCOMArray<nsNavHistoryQuery>& aQueries,
uint32_t aQueryCount,
nsNavHistoryQueryOptions* aOptions,
nsNavHistoryContainerResultNode* aRoot,
bool aBatchInProgress,
nsNavHistoryResult** result)
{
*result = new nsNavHistoryResult(aRoot);
if (!*result)
--- a/toolkit/components/places/nsNavHistoryResult.h
+++ b/toolkit/components/places/nsNavHistoryResult.h
@@ -96,17 +96,17 @@ private:
{ 0x455d1d40, 0x1b9b, 0x40e6, { 0xa6, 0x41, 0x8b, 0xb7, 0xe8, 0x82, 0x23, 0x87 } }
class nsNavHistoryResult final : public nsSupportsWeakReference,
public nsINavHistoryResult,
public nsINavBookmarkObserver,
public nsINavHistoryObserver
{
public:
- static nsresult NewHistoryResult(nsINavHistoryQuery** aQueries,
+ static nsresult NewHistoryResult(nsCOMArray<nsNavHistoryQuery>& aQueries,
uint32_t aQueryCount,
nsNavHistoryQueryOptions* aOptions,
nsNavHistoryContainerResultNode* aRoot,
bool aBatchInProgress,
nsNavHistoryResult** result);
NS_DECLARE_STATIC_IID_ACCESSOR(NS_NAVHISTORYRESULT_IID)
@@ -130,17 +130,17 @@ public:
nsresult OnVisit(nsIURI* aURI, int64_t aVisitId, PRTime aTime,
uint32_t aTransitionType, const nsACString& aGUID,
bool aHidden, uint32_t aVisitCount,
const nsAString& aLastKnownTitle);
public:
// two-stage init, use NewHistoryResult to construct
explicit nsNavHistoryResult(nsNavHistoryContainerResultNode* mRoot);
- nsresult Init(nsINavHistoryQuery** aQueries,
+ nsresult Init(nsCOMArray<nsNavHistoryQuery>& aQueries,
uint32_t aQueryCount,
nsNavHistoryQueryOptions *aOptions);
RefPtr<nsNavHistoryContainerResultNode> mRootNode;
nsCOMArray<nsINavHistoryQuery> mQueries;
nsCOMPtr<nsNavHistoryQueryOptions> mOptions;
deleted file mode 100644
--- a/toolkit/components/places/tests/bookmarks/test_395593.js
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
-/* 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/. */
-
-
-function check_queries_results(aQueries, aOptions, aExpectedBookmarks) {
- var result = PlacesUtils.history.executeQueries(aQueries, aQueries.length, aOptions);
- var root = result.root;
- root.containerOpen = true;
-
- // Dump found nodes.
- for (let i = 0; i < root.childCount; i++) {
- dump("nodes[" + i + "]: " + root.getChild(0).title + "\n");
- }
-
- Assert.equal(root.childCount, aExpectedBookmarks.length);
- for (let i = 0; i < root.childCount; i++) {
- Assert.equal(root.getChild(i).bookmarkGuid, aExpectedBookmarks[i].guid);
- }
-
- root.containerOpen = false;
-}
-
-// main
-add_task(async function run_test() {
- let bookmarks = await PlacesUtils.bookmarks.insertTree({
- guid: PlacesUtils.bookmarks.menuGuid,
- children: [{
- title: "123 0",
- url: "http://foo.tld",
- }, {
- title: "456",
- url: "http://foo.tld",
- }, {
- title: "123 456",
- url: "http://foo.tld",
- }, {
- title: "789 456",
- url: "http://foo.tld",
- }]
- });
-
- /**
- * All of the query objects are ORed together. Within a query, all the terms
- * are ANDed together. See nsINavHistory.idl.
- */
- var queries = [];
- queries.push(PlacesUtils.history.getNewQuery());
- queries.push(PlacesUtils.history.getNewQuery());
- var options = PlacesUtils.history.getNewQueryOptions();
- options.queryType = Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS;
-
- // Test 1
- dump("Test searching for 123 OR 789\n");
- queries[0].searchTerms = "123";
- queries[1].searchTerms = "789";
- check_queries_results(queries, options, [
- bookmarks[0],
- bookmarks[2],
- bookmarks[3]
- ]);
-
- // Test 2
- dump("Test searching for 123 OR 456\n");
- queries[0].searchTerms = "123";
- queries[1].searchTerms = "456";
- check_queries_results(queries, options, bookmarks);
-
- // Test 3
- dump("Test searching for 00 OR 789\n");
- queries[0].searchTerms = "00";
- queries[1].searchTerms = "789";
- check_queries_results(queries, options, [bookmarks[3]]);
-});
--- a/toolkit/components/places/tests/bookmarks/xpcshell.ini
+++ b/toolkit/components/places/tests/bookmarks/xpcshell.ini
@@ -3,17 +3,16 @@ head = head_bookmarks.js
skip-if = toolkit == 'android'
[test_1016953-renaming-uncompressed.js]
[test_1017502-bookmarks_foreign_count.js]
[test_384228.js]
[test_385829.js]
[test_388695.js]
[test_393498.js]
-[test_395593.js]
[test_405938_restore_queries.js]
[test_424958-json-quoted-folders.js]
[test_448584.js]
[test_458683.js]
[test_466303-json-remove-backups.js]
[test_477583_json-backup-in-future.js]
[test_818584-discard-duplicate-backups.js]
[test_818587_compress-bookmarks-backups.js]
--- a/toolkit/components/places/tests/queries/test_tags.js
+++ b/toolkit/components/places/tests/queries/test_tags.js
@@ -464,55 +464,16 @@ add_task(async function ORed_queries() {
info("Add visits and tag the URIs");
for (let [pURI, tags] of Object.entries(urisAndTags)) {
let nsiuri = uri(pURI);
await PlacesTestUtils.addVisits(nsiuri);
if (tags)
PlacesUtils.tagging.tagURI(nsiuri, tags);
}
- info("Query for /1 OR query for /2 should match both /1 and /2");
- var [query1, opts] = makeQuery(urisAndTags["http://example.com/1"]);
- var [query2] = makeQuery(urisAndTags["http://example.com/2"]);
- var root = PlacesUtils.history.executeQueries([query1, query2], 2, opts).root;
- queryResultsAre(root, ["http://example.com/1", "http://example.com/2"]);
-
- info("Query for /1 OR query on bogus tag should match only /1");
- [query1, opts] = makeQuery(urisAndTags["http://example.com/1"]);
- [query2] = makeQuery(["bogus"]);
- root = PlacesUtils.history.executeQueries([query1, query2], 2, opts).root;
- queryResultsAre(root, ["http://example.com/1"]);
-
- info("Query for /1 OR query for /1 should match only /1");
- [query1, opts] = makeQuery(urisAndTags["http://example.com/1"]);
- [query2] = makeQuery(urisAndTags["http://example.com/1"]);
- root = PlacesUtils.history.executeQueries([query1, query2], 2, opts).root;
- queryResultsAre(root, ["http://example.com/1"]);
-
- info("Query for /1 with tagsAreNot OR query for /2 with tagsAreNot " +
- "should match both /1 and /2");
- [query1, opts] = makeQuery(urisAndTags["http://example.com/1"], true);
- [query2] = makeQuery(urisAndTags["http://example.com/2"], true);
- root = PlacesUtils.history.executeQueries([query1, query2], 2, opts).root;
- queryResultsAre(root, ["http://example.com/1", "http://example.com/2"]);
-
- info("Query for /1 OR query for /2 with tagsAreNot should match " +
- "only /1");
- [query1, opts] = makeQuery(urisAndTags["http://example.com/1"]);
- [query2] = makeQuery(urisAndTags["http://example.com/2"], true);
- root = PlacesUtils.history.executeQueries([query1, query2], 2, opts).root;
- queryResultsAre(root, ["http://example.com/1"]);
-
- info("Query for /1 OR query for /1 with tagsAreNot should match " +
- "both URIs");
- [query1, opts] = makeQuery(urisAndTags["http://example.com/1"]);
- [query2] = makeQuery(urisAndTags["http://example.com/1"], true);
- root = PlacesUtils.history.executeQueries([query1, query2], 2, opts).root;
- queryResultsAre(root, ["http://example.com/1", "http://example.com/2"]);
-
// Clean up.
for (let [pURI, tags] of Object.entries(urisAndTags)) {
let nsiuri = uri(pURI);
if (tags)
PlacesUtils.tagging.untagURI(nsiuri, tags);
}
await task_cleanDatabase();
});
--- a/toolkit/components/places/tests/unit/test_399264_string_to_query.js
+++ b/toolkit/components/places/tests/unit/test_399264_string_to_query.js
@@ -7,25 +7,22 @@
/**
* Obtains the id of the folder obtained from the query.
*
* @param aQuery
* The query to obtain the folder id from.
* @returns the folder id of the folder of the root node of the query.
*/
function folder_id(aQuery) {
- var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
- getService(Ci.nsINavHistoryService);
-
- dump("Checking query '" + aQuery + "'\n");
+ info("Checking query '" + aQuery + "'\n");
var options = { };
var queries = { };
var size = { };
- hs.queryStringToQueries(aQuery, queries, size, options);
- var result = hs.executeQueries(queries.value, size.value, options.value);
+ PlacesUtils.history.queryStringToQueries(aQuery, queries, size, options);
+ var result = PlacesUtils.history.executeQuery(queries.value, options.value);
var root = result.root;
root.containerOpen = true;
Assert.ok(root.hasChildren);
var folderID = root.getChild(0).parent.itemId;
root.containerOpen = false;
return folderID;
}
@@ -48,32 +45,29 @@ add_task(async function test_history_str
// add something in the bookmarks menu folder so a query to it returns results
await PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.menuGuid,
title: "bmf",
url: "http://example.com/bmf/",
});
// add something to the tags folder
- var ts = Cc["@mozilla.org/browser/tagging-service;1"].
- getService(Ci.nsITaggingService);
- ts.tagURI(uri("http://www.example.com/"), ["tag"]);
+ PlacesUtils.tagging.tagURI(uri("http://www.example.com/"), ["tag"]);
// add something to the unfiled bookmarks folder
await PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
title: "ubf",
url: "http://example.com/ubf/",
});
// add something to the toolbar folder
await PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.toolbarGuid,
title: "tf",
url: "http://example.com/tf/",
});
- for (var i = 0; i < QUERIES.length; i++) {
- var result = folder_id(QUERIES[i]);
- dump("expected " + FOLDER_IDS[i] + ", got " + result + "\n");
+ for (let i = 0; i < QUERIES.length; i++) {
+ let result = folder_id(QUERIES[i]);
Assert.equal(FOLDER_IDS[i], result);
}
});
--- a/toolkit/components/places/tests/unit/test_bookmarks_restore_notification.js
+++ b/toolkit/components/places/tests/unit/test_bookmarks_restore_notification.js
@@ -31,38 +31,18 @@ var uris = [
/**
* Adds some bookmarks for the URIs in |uris|.
*/
async function addBookmarks() {
for (let url of uris) {
await PlacesUtils.bookmarks.insert({
url, parentGuid: PlacesUtils.bookmarks.menuGuid
});
+ Assert.ok(await PlacesUtils.bookmarks.fetch({ url }), "Url is bookmarked");
}
- checkBookmarksExist();
-}
-
-/**
- * Checks that all of the bookmarks created for |uris| exist. It works by
- * creating one query per URI and then ORing all the queries. The number of
- * results returned should be uris.length.
- */
-function checkBookmarksExist() {
- let hs = PlacesUtils.history;
- let queries = uris.map(function(u) {
- let q = hs.getNewQuery();
- q.uri = uri(u);
- return q;
- });
- let options = hs.getNewQueryOptions();
- options.queryType = options.QUERY_TYPE_BOOKMARKS;
- let root = hs.executeQueries(queries, uris.length, options).root;
- root.containerOpen = true;
- Assert.equal(root.childCount, uris.length);
- root.containerOpen = false;
}
/**
* Creates an file in the profile directory.
*
* @param aBasename
* e.g., "foo.txt" in the path /some/long/path/foo.txt
* @return {Promise}
deleted file mode 100644
--- a/toolkit/components/places/tests/unit/test_multi_queries.js
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
-/* 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/. */
-
-/**
- * Adds a test URI visit to history.
- *
- * @param aURI
- * The URI to add a visit for.
- * @param aReferrer
- * The referring URI for the given URI. This can be null.
- */
-async function add_visit(aURI, aDayOffset, aTransition) {
- await PlacesTestUtils.addVisits({
- uri: aURI,
- transition: aTransition,
- visitDate: (Date.now() + aDayOffset * 86400000) * 1000
- });
-}
-
-add_task(async function test_execute() {
- await add_visit(uri("http://mirror1.mozilla.com/a"), -1, TRANSITION_LINK);
- await add_visit(uri("http://mirror2.mozilla.com/b"), -2, TRANSITION_LINK);
- await add_visit(uri("http://mirror3.mozilla.com/c"), -4, TRANSITION_FRAMED_LINK);
- await add_visit(uri("http://mirror1.google.com/b"), -1, TRANSITION_EMBED);
- await add_visit(uri("http://mirror2.google.com/a"), -2, TRANSITION_LINK);
- await add_visit(uri("http://mirror1.apache.org/b"), -3, TRANSITION_LINK);
- await add_visit(uri("http://mirror2.apache.org/a"), -4, TRANSITION_FRAMED_LINK);
-
- let queries = [
- PlacesUtils.history.getNewQuery(),
- PlacesUtils.history.getNewQuery()
- ];
- queries[0].domain = "mozilla.com";
- queries[1].domain = "google.com";
-
- let root = PlacesUtils.history.executeQueries(
- queries, queries.length, PlacesUtils.history.getNewQueryOptions()
- ).root;
- root.containerOpen = true;
- let childCount = root.childCount;
- root.containerOpen = false;
-
- Assert.equal(childCount, 3);
-});
--- a/toolkit/components/places/tests/unit/xpcshell.ini
+++ b/toolkit/components/places/tests/unit/xpcshell.ini
@@ -87,17 +87,16 @@ skip-if = (os == 'win' && ccov) # Bug 14
[test_isPageInDB.js]
[test_isURIVisited.js]
[test_isvisited.js]
[test_keywords.js]
[test_lastModified.js]
[test_markpageas.js]
[test_metadata.js]
[test_mozIAsyncLivemarks.js]
-[test_multi_queries.js]
[test_multi_word_tags.js]
[test_nsINavHistoryViewer.js]
# Bug 902248: intermittent timeouts on all platforms
skip-if = true
[test_null_interfaces.js]
[test_onItemChanged_tags.js]
[test_pageGuid_bookmarkGuid.js]
[test_frecency_observers.js]