--- a/addon-sdk/source/lib/sdk/places/host/host-query.js
+++ b/addon-sdk/source/lib/sdk/places/host/host-query.js
@@ -42,28 +42,42 @@ const MANUAL_QUERY_PROPERTIES = [
const PLACES_PROPERTIES = [
'uri', 'title', 'accessCount', 'time'
];
function execute (queries, options) {
return new Promise(resolve => {
let root = historyService
.executeQueries(queries, queries.length, options).root;
- resolve(collect([], root));
+ // Let's extract an eventual uri wildcard, if both domain and uri are set.
+ // See utils.js::urlQueryParser() for more details.
+ // In case of multiple queries, we only retain the first found wildcard.
+ let uriWildcard = queries.reduce((prev, query) => {
+ if (query.uri && query.domain) {
+ if (!prev)
+ prev = query.uri.spec;
+ query.uri = null;
+ }
+ return prev;
+ }, "");
+ resolve(collect([], root, uriWildcard));
});
}
-function collect (acc, node) {
+function collect (acc, node, uriWildcard) {
node.containerOpen = true;
for (let i = 0; i < node.childCount; i++) {
let child = node.getChild(i);
- acc.push(child);
+
+ if (!uriWildcard || child.uri.startsWith(uriWildcard)) {
+ acc.push(child);
+ }
if (child.type === child.RESULT_TYPE_FOLDER) {
let container = child.QueryInterface(Ci.nsINavHistoryContainerResultNode);
- collect(acc, container);
+ collect(acc, container, uriWildcard);
}
}
node.containerOpen = false;
return acc;
}
function query (queries, options) {
return new Promise((resolve, reject) => {
--- a/addon-sdk/source/lib/sdk/places/utils.js
+++ b/addon-sdk/source/lib/sdk/places/utils.js
@@ -7,26 +7,28 @@
module.metadata = {
"stability": "experimental",
"engines": {
"Firefox": "*",
"SeaMonkey": "*"
}
};
-const { Cc, Ci } = require('chrome');
+const { Cc, Ci, Cu } = require('chrome');
const { Class } = require('../core/heritage');
const { method } = require('../lang/functional');
const { defer, promised, all } = require('../core/promise');
const { send } = require('../addon/events');
const { EventTarget } = require('../event/target');
const { merge } = require('../util/object');
const bmsrv = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
+Cu.importGlobalProperties(["URL"]);
+
/*
* TreeNodes are used to construct dependency trees
* for BookmarkItems
*/
var TreeNode = Class({
initialize: function (value) {
this.value = value;
this.children = [];
@@ -123,29 +125,42 @@ exports.isRootGroup = isRootGroup;
/*
* Merges appropriate options into query based off of url
* 4 scenarios:
*
* 'moz.com' // domain: moz.com, domainIsHost: true
* --> 'http://moz.com', 'http://moz.com/thunderbird'
* '*.moz.com' // domain: moz.com, domainIsHost: false
* --> 'http://moz.com', 'http://moz.com/index', 'http://ff.moz.com/test'
- * 'http://moz.com' // url: http://moz.com/, urlIsPrefix: false
+ * 'http://moz.com' // uri: http://moz.com/
* --> 'http://moz.com/'
- * 'http://moz.com/*' // url: http://moz.com/, urlIsPrefix: true
+ * 'http://moz.com/*' // uri: http://moz.com/, domain: moz.com, domainIsHost: true
* --> 'http://moz.com/', 'http://moz.com/thunderbird'
*/
function urlQueryParser (query, url) {
if (!url) return;
if (/^https?:\/\//.test(url)) {
query.uri = url.charAt(url.length - 1) === '/' ? url : url + '/';
if (/\*$/.test(url)) {
- query.uri = url.replace(/\*$/, '');
- query.uriIsPrefix = true;
+ // Wildcard searches on URIs are not supported, so try to extract a
+ // domain and filter the data later.
+ url = url.replace(/\*$/, '');
+ try {
+ query.domain = new URL(url).hostname;
+ query.domainIsHost = true;
+ // Unfortunately here we cannot use an expando to store the wildcard,
+ // cause the query is a wrapped native XPCOM object, so we reuse uri.
+ // We clearly don't want to query for both uri and domain, thus we'll
+ // have to handle this in host-query.js::execute()
+ query.uri = url;
+ } catch (ex) {
+ // Cannot extract an host cause it's not a valid uri, the query will
+ // just return nothing.
+ }
}
} else {
if (/^\*/.test(url)) {
query.domain = url.replace(/^\*\./, '');
query.domainIsHost = false;
} else {
query.domain = url;
query.domainIsHost = true;
--- a/toolkit/components/places/nsINavHistoryService.idl
+++ b/toolkit/components/places/nsINavHistoryService.idl
@@ -899,26 +899,18 @@ interface nsINavHistoryQuery : nsISuppor
* is a real query and will match any URI that has no host name (local files
* and such). Set this to NULL (in C++ use SetIsVoid) if you don't want
* domain matching.
*/
attribute AUTF8String domain;
readonly attribute boolean hasDomain;
/**
- * Controls the interpretation of 'uri'. When unset (default), the URI will
- * request an exact match of the specified URI. When set, any history entry
- * beginning in 'uri' will match. For example "http://bar.com/foo" will match
- * "http://bar.com/foo" as well as "http://bar.com/foo/baz.gif".
- */
- attribute boolean uriIsPrefix;
-
- /**
* This is a URI to match, to, for example, find out every time you visited
- * a given URI. Use uriIsPrefix to control whether this is an exact match.
+ * a given URI. This is an exact match.
*/
attribute nsIURI uri;
readonly attribute boolean hasUri;
/**
* Test for existence or non-existence of a given annotation. We don't
* currently support >1 annotation name per query. If 'annotationIsNot' is
* true, we test for the non-existence of the specified annotation.
--- a/toolkit/components/places/nsNavHistory.cpp
+++ b/toolkit/components/places/nsNavHistory.cpp
@@ -890,37 +890,22 @@ nsNavHistory::EvaluateQueryForNode(const
}
// --- URI matching ---
if (query->Uri()) {
if (! nodeUri) { // lazy creation of nodeUri
if (NS_FAILED(NS_NewURI(getter_AddRefs(nodeUri), aNode->mURI)))
continue;
}
- if (! query->UriIsPrefix()) {
- // easy case: the URI is an exact match
- bool equals;
- nsresult rv = query->Uri()->Equals(nodeUri, &equals);
- NS_ENSURE_SUCCESS(rv, false);
- if (! equals)
- continue;
- } else {
- // harder case: match prefix, note that we need to get the ASCII string
- // from the node's parsed URI instead of using the node's mUrl string,
- // because that might not be normalized
- nsAutoCString nodeUriString;
- nodeUri->GetAsciiSpec(nodeUriString);
- nsAutoCString queryUriString;
- query->Uri()->GetAsciiSpec(queryUriString);
- if (queryUriString.Length() > nodeUriString.Length())
- continue; // not long enough to match as prefix
- nodeUriString.SetLength(queryUriString.Length());
- if (! nodeUriString.Equals(queryUriString))
- continue; // prefixes don't match
- }
+
+ bool equals;
+ nsresult rv = query->Uri()->Equals(nodeUri, &equals);
+ NS_ENSURE_SUCCESS(rv, false);
+ if (! equals)
+ continue;
}
// Transitions matching.
const nsTArray<uint32_t>& transitions = query->Transitions();
if (aNode->mTransitionType > 0 &&
transitions.Length() &&
!transitions.Contains(aNode->mTransitionType)) {
continue; // transition doesn't match.
@@ -1319,19 +1304,16 @@ bool IsOptimizableHistoryQuery(const nsC
return false;
if (aQuery->DomainIsHost() || !aQuery->Domain().IsEmpty())
return false;
if (aQuery->AnnotationIsNot() || !aQuery->Annotation().IsEmpty())
return false;
- if (aQuery->UriIsPrefix() || aQuery->Uri())
- return false;
-
if (aQuery->Folders().Length() > 0)
return false;
if (aQuery->Tags().Length() > 0)
return false;
if (aQuery->Transitions().Length() > 0)
return false;
@@ -3364,22 +3346,17 @@ nsNavHistory::QueryToSelectClause(nsNavH
else
// see domain setting in BindQueryClauseParameters for why we do this
clause.Condition("h.rev_host >=").Param(":domain_lower")
.Condition("h.rev_host <").Param(":domain_upper");
}
// URI
if (NS_SUCCEEDED(aQuery->GetHasUri(&hasIt)) && hasIt) {
- if (aQuery->UriIsPrefix()) {
- clause.Condition("h.url >= ").Param(":uri")
- .Condition("h.url <= ").Param(":uri_upper");
- }
- else
- clause.Condition("h.url =").Param(":uri");
+ clause.Condition("h.url =").Param(":uri");
}
// annotation
aQuery->GetHasAnnotation(&hasIt);
if (hasIt) {
clause.Condition("");
if (aQuery->AnnotationIsNot())
clause.Str("NOT");
@@ -3563,25 +3540,16 @@ nsNavHistory::BindQueryClauseParameters(
}
// URI
if (aQuery->Uri()) {
rv = URIBinder::Bind(
statement, NS_LITERAL_CSTRING("uri") + qIndex, aQuery->Uri()
);
NS_ENSURE_SUCCESS(rv, rv);
- if (aQuery->UriIsPrefix()) {
- nsAutoCString uriString;
- aQuery->Uri()->GetSpec(uriString);
- uriString.Append(char(0x7F)); // MAX_UTF8
- rv = URIBinder::Bind(
- statement, NS_LITERAL_CSTRING("uri_upper") + qIndex, uriString
- );
- NS_ENSURE_SUCCESS(rv, rv);
- }
}
// annotation
if (!aQuery->Annotation().IsEmpty()) {
rv = statement->BindUTF8StringByName(
NS_LITERAL_CSTRING("anno") + qIndex, aQuery->Annotation()
);
NS_ENSURE_SUCCESS(rv, rv);
--- a/toolkit/components/places/nsNavHistoryQuery.cpp
+++ b/toolkit/components/places/nsNavHistoryQuery.cpp
@@ -121,17 +121,16 @@ static void SetOptionsKeyUint32(const ns
#define QUERYKEY_MAX_VISITS "maxVisits"
#define QUERYKEY_ONLY_BOOKMARKED "onlyBookmarked"
#define QUERYKEY_DOMAIN_IS_HOST "domainIsHost"
#define QUERYKEY_DOMAIN "domain"
#define QUERYKEY_FOLDER "folder"
#define QUERYKEY_NOTANNOTATION "!annotation"
#define QUERYKEY_ANNOTATION "annotation"
#define QUERYKEY_URI "uri"
-#define QUERYKEY_URIISPREFIX "uriIsPrefix"
#define QUERYKEY_SEPARATOR "OR"
#define QUERYKEY_GROUP "group"
#define QUERYKEY_SORT "sort"
#define QUERYKEY_SORTING_ANNOTATION "sortingAnnotation"
#define QUERYKEY_RESULT_TYPE "type"
#define QUERYKEY_EXCLUDE_ITEMS "excludeItems"
#define QUERYKEY_EXCLUDE_QUERIES "excludeQueries"
#define QUERYKEY_EXCLUDE_READ_ONLY_FOLDERS "excludeReadOnlyFolders"
@@ -421,19 +420,16 @@ nsNavHistory::QueriesToQueryString(nsINa
AppendAmpersandIfNonempty(queryString);
queryString.AppendLiteral(QUERYKEY_DOMAIN "=");
queryString.Append(escapedDomain);
}
// uri
query->GetHasUri(&hasIt);
if (hasIt) {
- AppendBoolKeyValueIfTrue(aQueryString,
- NS_LITERAL_CSTRING(QUERYKEY_URIISPREFIX),
- query, &nsINavHistoryQuery::GetUriIsPrefix);
nsCOMPtr<nsIURI> uri;
query->GetUri(getter_AddRefs(uri));
NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE); // hasURI should tell is if invalid
nsAutoCString uriSpec;
nsresult rv = uri->GetSpec(uriSpec);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString escaped;
bool success = NS_Escape(uriSpec, escaped, url_XAlphas);
@@ -720,20 +716,16 @@ nsNavHistory::TokensToQueries(const nsTA
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), unescapedUri);
if (NS_FAILED(rv)) {
NS_WARNING("Unable to parse URI");
}
rv = query->SetUri(uri);
NS_ENSURE_SUCCESS(rv, rv);
- // URI is prefix
- } else if (kvp.key.EqualsLiteral(QUERYKEY_URIISPREFIX)) {
- SetQueryKeyBool(kvp.value, query, &nsINavHistoryQuery::SetUriIsPrefix);
-
// not annotation
} else if (kvp.key.EqualsLiteral(QUERYKEY_NOTANNOTATION)) {
nsAutoCString unescaped(kvp.value);
NS_UnescapeURL(unescaped); // modifies input
query->SetAnnotationIsNot(true);
query->SetAnnotation(unescaped);
// annotation
@@ -896,32 +888,32 @@ NS_IMPL_ISUPPORTS(nsNavHistoryQuery, nsN
// all history to be returned if this query is used. Then the caller can
// just set the things it's interested in.
nsNavHistoryQuery::nsNavHistoryQuery()
: mMinVisits(-1), mMaxVisits(-1), mBeginTime(0),
mBeginTimeReference(TIME_RELATIVE_EPOCH),
mEndTime(0), mEndTimeReference(TIME_RELATIVE_EPOCH),
mOnlyBookmarked(false),
- mDomainIsHost(false), mUriIsPrefix(false),
+ mDomainIsHost(false),
mAnnotationIsNot(false),
mTagsAreNot(false)
{
// differentiate not set (IsVoid) from empty string (local files)
mDomain.SetIsVoid(true);
}
nsNavHistoryQuery::nsNavHistoryQuery(const nsNavHistoryQuery& aOther)
: mMinVisits(aOther.mMinVisits), mMaxVisits(aOther.mMaxVisits),
mBeginTime(aOther.mBeginTime),
mBeginTimeReference(aOther.mBeginTimeReference),
mEndTime(aOther.mEndTime), mEndTimeReference(aOther.mEndTimeReference),
mSearchTerms(aOther.mSearchTerms), mOnlyBookmarked(aOther.mOnlyBookmarked),
mDomainIsHost(aOther.mDomainIsHost), mDomain(aOther.mDomain),
- mUriIsPrefix(aOther.mUriIsPrefix), mUri(aOther.mUri),
+ mUri(aOther.mUri),
mAnnotationIsNot(aOther.mAnnotationIsNot),
mAnnotation(aOther.mAnnotation), mTags(aOther.mTags),
mTagsAreNot(aOther.mTagsAreNot), mTransitions(aOther.mTransitions)
{}
NS_IMETHODIMP nsNavHistoryQuery::GetBeginTime(PRTime *aBeginTime)
{
*aBeginTime = mBeginTime;
@@ -1068,27 +1060,16 @@ NS_IMETHODIMP nsNavHistoryQuery::SetDoma
}
NS_IMETHODIMP nsNavHistoryQuery::GetHasDomain(bool* _retval)
{
// note that empty but not void is still a valid query (local files)
*_retval = (! mDomain.IsVoid());
return NS_OK;
}
-NS_IMETHODIMP nsNavHistoryQuery::GetUriIsPrefix(bool* aIsPrefix)
-{
- *aIsPrefix = mUriIsPrefix;
- return NS_OK;
-}
-NS_IMETHODIMP nsNavHistoryQuery::SetUriIsPrefix(bool aIsPrefix)
-{
- mUriIsPrefix = aIsPrefix;
- return NS_OK;
-}
-
NS_IMETHODIMP nsNavHistoryQuery::GetUri(nsIURI** aUri)
{
NS_IF_ADDREF(*aUri = mUri);
return NS_OK;
}
NS_IMETHODIMP nsNavHistoryQuery::SetUri(nsIURI* aUri)
{
mUri = aUri;
--- a/toolkit/components/places/nsNavHistoryQuery.h
+++ b/toolkit/components/places/nsNavHistoryQuery.h
@@ -37,17 +37,16 @@ public:
PRTime BeginTime() { return mBeginTime; }
uint32_t BeginTimeReference() { return mBeginTimeReference; }
PRTime EndTime() { return mEndTime; }
uint32_t EndTimeReference() { return mEndTimeReference; }
const nsString& SearchTerms() { return mSearchTerms; }
bool OnlyBookmarked() { return mOnlyBookmarked; }
bool DomainIsHost() { return mDomainIsHost; }
const nsCString& Domain() { return mDomain; }
- bool UriIsPrefix() { return mUriIsPrefix; }
nsIURI* Uri() { return mUri; } // NOT AddRef-ed!
bool AnnotationIsNot() { return mAnnotationIsNot; }
const nsCString& Annotation() { return mAnnotation; }
const nsTArray<int64_t>& Folders() const { return mFolders; }
const nsTArray<nsString>& Tags() const { return mTags; }
nsresult SetTags(const nsTArray<nsString>& aTags)
{
if (!mTags.ReplaceElementsAt(0, mTags.Length(), aTags))
@@ -77,17 +76,16 @@ protected:
PRTime mBeginTime;
uint32_t mBeginTimeReference;
PRTime mEndTime;
uint32_t mEndTimeReference;
nsString mSearchTerms;
bool mOnlyBookmarked;
bool mDomainIsHost;
nsCString mDomain; // Default is IsVoid, empty string is valid query
- bool mUriIsPrefix;
nsCOMPtr<nsIURI> mUri;
bool mAnnotationIsNot;
nsCString mAnnotation;
nsTArray<int64_t> mFolders;
nsTArray<nsString> mTags;
bool mTagsAreNot;
nsTArray<uint32_t> mTransitions;
};
--- a/toolkit/components/places/tests/queries/test_abstime-annotation-uri.js
+++ b/toolkit/components/places/tests/queries/test_abstime-annotation-uri.js
@@ -48,34 +48,16 @@ var badAnnoName = "text/foo";
// see compareArrayToResult in head_queries.js for more info.
var testData = [
// Test flat domain with annotation
{isInQuery: true, isVisit: true, isDetails: true, isPageAnnotation: true,
uri: "http://foo.com/", annoName: goodAnnoName, annoVal: val,
lastVisit: jan14_2130, title: "moz"},
- // Test begin edge of time
- {isInQuery: true, isVisit: true, isDetails: true, title: "moz mozilla",
- uri: "http://foo.com/begin.html", lastVisit: beginTime},
-
- // Test end edge of time
- {isInQuery: true, isVisit: true, isDetails: true, title: "moz mozilla",
- uri: "http://foo.com/end.html", lastVisit: endTime},
-
- // Test uri included with isRedirect=true, different transtype
- {isInQuery: true, isVisit: true, isDetails: true, title: "moz",
- isRedirect: true, uri: "http://foo.com/redirect", lastVisit: jan11_800,
- transType: PlacesUtils.history.TRANSITION_LINK},
-
- // Test leading time edge with tag string is included
- {isInQuery: true, isVisit: true, isDetails: true, title: "taggariffic",
- uri: "http://foo.com/tagging/test.html", lastVisit: beginTime, isTag: true,
- tagArray: ["moz"] },
-
// Begin the invalid queries:
// Test www. style URI is not included, with an annotation
{isInQuery: false, isVisit: true, isDetails: true, isPageAnnotation: true,
uri: "http://www.foo.com/yiihah", annoName: goodAnnoName, annoVal: val,
lastVisit: jan7_800, title: "moz"},
// Test subdomain not inclued at the leading time edge
{isInQuery: false, isVisit: true, isDetails: true,
@@ -131,17 +113,16 @@ add_task(function* test_abstime_annotati
// Query
var query = PlacesUtils.history.getNewQuery();
query.beginTime = beginTime;
query.endTime = endTime;
query.beginTimeReference = PlacesUtils.history.TIME_RELATIVE_EPOCH;
query.endTimeReference = PlacesUtils.history.TIME_RELATIVE_EPOCH;
query.searchTerms = "moz";
query.uri = uri("http://foo.com");
- query.uriIsPrefix = true;
query.annotation = "text/foo";
query.annotationIsNot = true;
// Options
var options = PlacesUtils.history.getNewQueryOptions();
options.sortingMode = options.SORT_BY_URI_ASCENDING;
options.resultType = options.RESULTS_AS_URI;
// The next two options should be ignored
@@ -151,58 +132,31 @@ add_task(function* test_abstime_annotati
// Results
var result = PlacesUtils.history.executeQuery(query, options);
var root = result.root;
root.containerOpen = true;
// Ensure the result set is correct
compareArrayToResult(testData, root);
- // Make some changes to the result set
- // Let's add something first
- var addItem = [{isInQuery: true, isVisit: true, isDetails: true, title: "moz",
- uri: "http://foo.com/i-am-added.html", lastVisit: jan11_800}];
- yield task_populateDB(addItem);
- do_print("Adding item foo.com/i-am-added.html");
- do_check_eq(isInResult(addItem, root), true);
-
- // Let's update something by title
- var change1 = [{isDetails: true, uri: "http://foo.com/changeme1",
- lastVisit: jan12_1730, title: "moz moz mozzie"}];
+ // live update.
+ do_print("change title");
+ var change1 = [{isDetails: true, uri:"http://foo.com/",
+ title: "mo"},];
yield task_populateDB(change1);
- do_print("LiveUpdate by changing title");
- do_check_eq(isInResult(change1, root), true);
+ do_check_false(isInResult({uri: "http://foo.com/"}, root));
- // Let's update something by annotation
- // Updating a page by removing an annotation does not cause it to join this
- // query set. I tend to think that it should cause that page to join this
- // query set, because this visit fits all theother specified criteria once the
- // annotation is removed. Uncommenting this will fail the test.
- // This is bug 424050 - appears to happen for both domain and URI queries
- /*var change2 = [{isPageAnnotation: true, uri: "http://foo.com/badannotaion.html",
- annoName: "text/mozilla", annoVal: "test"}];
+ var change2 = [{isDetails: true, uri:"http://foo.com/",
+ title: "moz", lastvisit: endTime},];
yield task_populateDB(change2);
- do_print("LiveUpdate by removing annotation");
- do_check_eq(isInResult(change2, root), true);*/
-
- // Let's update by adding a visit in the time range for an existing URI
- var change3 = [{isDetails: true, uri: "http://foo.com/changeme3.htm",
- title: "moz", lastVisit: jan15_2045}];
- yield task_populateDB(change3);
- do_print("LiveUpdate by adding visit within timerange");
- do_check_eq(isInResult(change3, root), true);
+ dump_table("moz_places");
+ do_check_false(isInResult({uri: "http://foo.com/"}, root));
- // And delete something from the result set - using annotation
- // Once more, bug 424050
- /*var change4 = [{isPageAnnotation: true, uri: "http://foo.com/",
- annoVal: "test", annoName: badAnnoName}];
- yield task_populateDB(change4);
- do_print("LiveUpdate by deleting item from set by adding annotation");
- do_check_eq(isInResult(change4, root), false);*/
-
- // Delete something by changing the title
- var change5 = [{isDetails: true, uri: "http://foo.com/end.html", title: "deleted"}];
- yield task_populateDB(change5);
- do_print("LiveUpdate by deleting item by changing title");
- do_check_eq(isInResult(change5, root), false);
+ // Let's delete something from the result set - using annotation
+ var change3 = [{isPageAnnotation: true,
+ uri: "http://foo.com/",
+ annoName: badAnnoName, annoVal: "test"}];
+ yield task_populateDB(change3);
+ do_print("LiveUpdate by removing annotation");
+ do_check_false(isInResult({uri: "http://foo.com/"}, root));
root.containerOpen = false;
});
--- a/toolkit/components/places/tests/queries/test_querySerialization.js
+++ b/toolkit/components/places/tests/queries/test_querySerialization.js
@@ -160,28 +160,23 @@ const querySwitches = [
function (aQuery, aQueryOptions) {
aQuery.domain = "";
}
]
},
// hasUri
{
flag: "hasUri",
- subswitches: ["uri", "uriIsPrefix"],
+ subswitches: ["uri"],
desc: "nsINavHistoryQuery.hasUri",
matches: flagSwitchMatches,
runs: [
function (aQuery, aQueryOptions) {
aQuery.uri = uri("http://mozilla.com");
- aQuery.uriIsPrefix = false;
},
- function (aQuery, aQueryOptions) {
- aQuery.uri = uri("http://mozilla.com");
- aQuery.uriIsPrefix = true;
- }
]
},
// hasAnnotation
{
flag: "hasAnnotation",
subswitches: ["annotation", "annotationIsNot"],
desc: "nsINavHistoryQuery.hasAnnotation",
matches: flagSwitchMatches,
--- a/toolkit/components/places/tests/queries/test_searchterms-uri.js
+++ b/toolkit/components/places/tests/queries/test_searchterms-uri.js
@@ -8,26 +8,16 @@
// will be returned by the query (the isInQuery: true objects) is IMPORTANT.
// see compareArrayToResult in head_queries.js for more info.
var testData = [
// Test flat domain with annotation, search term in sentence
{isInQuery: true, isVisit: true, isDetails: true, isPageAnnotation: true,
uri: "http://foo.com/", annoName: "moz/test", annoVal: "val",
lastVisit: lastweek, title: "you know, moz is cool"},
- // Test subdomain included with isRedirect=true, different transtype
- {isInQuery: true, isVisit: true, isDetails: true, title: "amozzie",
- isRedirect: true, uri: "http://foo.com/redirect", lastVisit: old,
- referrer: "http://myreferrer.com", transType: PlacesUtils.history.TRANSITION_LINK},
-
- // Test www. style URI is included, with a tag
- {isInQuery: true, isVisit: true, isDetails: true, isTag: true,
- uri: "http://foo.com/yiihah", tagArray: ["moz"], lastVisit: yesterday,
- title: "foo"},
-
// Test https protocol
{isInQuery: false, isVisit: true, isDetails: true, title: "moz",
uri: "https://foo.com/", lastVisit: today},
// Begin the invalid queries: wrong search term
{isInQuery: false, isVisit:true, isDetails: true, title: "m o z",
uri: "http://foo.com/wrongsearch.php", lastVisit: today},
@@ -57,17 +47,16 @@ function run_test()
}
add_task(function* test_searchterms_uri()
{
yield task_populateDB(testData);
var query = PlacesUtils.history.getNewQuery();
query.searchTerms = "moz";
query.uri = uri("http://foo.com");
- query.uriIsPrefix = true;
// Options
var options = PlacesUtils.history.getNewQueryOptions();
options.sortingMode = options.SORT_BY_DATE_ASCENDING;
options.resultType = options.RESULTS_AS_URI;
// Results
var result = PlacesUtils.history.executeQuery(query, options);
@@ -77,46 +66,22 @@ add_task(function* test_searchterms_uri(
do_print("Number of items in result set: " + root.childCount);
for(var i=0; i < root.childCount; ++i) {
do_print("result: " + root.getChild(i).uri + " Title: " + root.getChild(i).title);
}
// Check our inital result set
compareArrayToResult(testData, root);
- // If that passes, check liveupdate
- // Add to the query set
- do_print("Adding item to query");
- var change1 = [{isVisit: true, isDetails: true, uri: "http://foo.com/added.htm",
- title: "moz", transType: PlacesUtils.history.TRANSITION_LINK}];
+ // live update.
+ do_print("change title");
+ var change1 = [{isDetails: true, uri:"http://foo.com/",
+ title: "mo"},];
yield task_populateDB(change1);
- do_check_true(isInResult(change1, root));
-
- // Update an existing URI
- do_print("Updating Item");
- var change2 = [{isDetails: true, uri: "http://foo.com/changeme1.htm",
- title: "moz" }];
- yield task_populateDB(change2);
- do_check_true(isInResult(change2, root));
- // Add one and take one out of query set, and simply change one so that it
- // still applies to the query.
- do_print("Updating More Items");
- var change3 = [{isDetails: true, uri:"http://foo.com/changeme2.htm",
- title: "moz"},
- {isDetails: true, uri: "http://foo.com/yiihah",
- title: "moz now updated"},
- {isDetails: true, uri: "http://foo.com/redirect",
- title: "gone"}];
- yield task_populateDB(change3);
- do_check_true(isInResult({uri: "http://foo.com/changeme2.htm"}, root));
- do_check_true(isInResult({uri: "http://foo.com/yiihah"}, root));
- do_check_false(isInResult({uri: "http://foo.com/redirect"}, root));
-
- // And now, delete one
- do_print("Deleting items");
- var change4 = [{isDetails: true, uri: "http://foo.com/",
- title: "mo,z"}];
- yield task_populateDB(change4);
- do_check_false(isInResult(change4, root));
+ do_check_false(isInResult({uri: "http://foo.com/"}, root));
+ var change2 = [{isDetails: true, uri:"http://foo.com/",
+ title: "moz"},];
+ yield task_populateDB(change2);
+ do_check_true(isInResult({uri: "http://foo.com/"}, root));
root.containerOpen = false;
});