2012-08-29 14:43:41 -07:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
2011-01-28 00:18:36 -08:00
|
|
|
_("Rewrite place: URIs.");
|
|
|
|
Cu.import("resource://services-sync/engines/bookmarks.js");
|
2012-08-29 14:43:41 -07:00
|
|
|
Cu.import("resource://services-sync/service.js");
|
2011-01-28 00:18:36 -08:00
|
|
|
Cu.import("resource://services-sync/util.js");
|
|
|
|
|
2012-08-29 14:43:41 -07:00
|
|
|
let engine = new BookmarksEngine(Service);
|
2011-01-28 00:18:36 -08:00
|
|
|
let store = engine._store;
|
|
|
|
|
|
|
|
function run_test() {
|
|
|
|
initTestLogging("Trace");
|
2011-06-13 11:42:18 -07:00
|
|
|
Log4Moz.repository.getLogger("Sync.Engine.Bookmarks").level = Log4Moz.Level.Trace;
|
|
|
|
Log4Moz.repository.getLogger("Sync.Store.Bookmarks").level = Log4Moz.Level.Trace;
|
2011-01-28 00:18:36 -08:00
|
|
|
|
|
|
|
let tagRecord = new BookmarkQuery("bookmarks", "abcdefabcdef");
|
|
|
|
let uri = "place:folder=499&type=7&queryType=1";
|
|
|
|
tagRecord.queryId = "MagicTags";
|
|
|
|
tagRecord.parentName = "Bookmarks Toolbar";
|
|
|
|
tagRecord.bmkUri = uri;
|
|
|
|
tagRecord.title = "tagtag";
|
|
|
|
tagRecord.folderName = "bar";
|
|
|
|
|
|
|
|
_("Type: " + tagRecord.type);
|
|
|
|
_("Folder name: " + tagRecord.folderName);
|
|
|
|
store.preprocessTagQuery(tagRecord);
|
2012-08-29 14:43:41 -07:00
|
|
|
|
2011-01-28 00:18:36 -08:00
|
|
|
_("Verify that the URI has been rewritten.");
|
|
|
|
do_check_neq(tagRecord.bmkUri, uri);
|
2012-08-29 14:43:41 -07:00
|
|
|
|
2011-05-19 18:08:22 -07:00
|
|
|
let tags = store._getNode(PlacesUtils.tagsFolderId);
|
2011-01-28 00:18:36 -08:00
|
|
|
tags.containerOpen = true;
|
|
|
|
let tagID;
|
|
|
|
for (let i = 0; i < tags.childCount; ++i) {
|
|
|
|
let child = tags.getChild(i);
|
|
|
|
if (child.title == "bar")
|
|
|
|
tagID = child.itemId;
|
|
|
|
}
|
2011-04-22 17:08:36 -07:00
|
|
|
tags.containerOpen = false;
|
|
|
|
|
2011-01-28 00:18:36 -08:00
|
|
|
_("Tag ID: " + tagID);
|
|
|
|
do_check_eq(tagRecord.bmkUri, uri.replace("499", tagID));
|
2012-08-29 14:43:41 -07:00
|
|
|
|
2011-01-28 00:18:36 -08:00
|
|
|
_("... but not if the type is wrong.");
|
|
|
|
let wrongTypeURI = "place:folder=499&type=2&queryType=1";
|
|
|
|
tagRecord.bmkUri = wrongTypeURI;
|
|
|
|
store.preprocessTagQuery(tagRecord);
|
|
|
|
do_check_eq(tagRecord.bmkUri, wrongTypeURI);
|
|
|
|
}
|