mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-19 14:57:32 +09:00
Import Tycho weave client
This commit is contained in:
parent
e4ac0e17f8
commit
c53787dfdb
183 changed files with 7272 additions and 16759 deletions
|
|
@ -7,54 +7,45 @@ Cu.import("resource://services-sync/engines/bookmarks.js");
|
|||
Cu.import("resource://services-sync/service.js");
|
||||
Cu.import("resource://services-sync/util.js");
|
||||
|
||||
var engine = new BookmarksEngine(Service);
|
||||
var store = engine._store;
|
||||
|
||||
function makeTagRecord(id, uri) {
|
||||
let tagRecord = new BookmarkQuery("bookmarks", id);
|
||||
tagRecord.queryId = "MagicTags";
|
||||
tagRecord.parentName = "Bookmarks Toolbar";
|
||||
tagRecord.bmkUri = uri;
|
||||
tagRecord.title = "tagtag";
|
||||
tagRecord.folderName = "bar";
|
||||
tagRecord.parentid = PlacesUtils.bookmarks.toolbarGuid;
|
||||
return tagRecord;
|
||||
}
|
||||
let engine = new BookmarksEngine(Service);
|
||||
let store = engine._store;
|
||||
|
||||
function run_test() {
|
||||
initTestLogging("Trace");
|
||||
Log.repository.getLogger("Sync.Engine.Bookmarks").level = Log.Level.Trace;
|
||||
Log.repository.getLogger("Sync.Store.Bookmarks").level = Log.Level.Trace;
|
||||
|
||||
let tagRecord = new BookmarkQuery("bookmarks", "abcdefabcdef");
|
||||
let uri = "place:folder=499&type=7&queryType=1";
|
||||
let tagRecord = makeTagRecord("abcdefabcdef", uri);
|
||||
tagRecord.queryId = "MagicTags";
|
||||
tagRecord.parentName = "Bookmarks Toolbar";
|
||||
tagRecord.bmkUri = uri;
|
||||
tagRecord.title = "tagtag";
|
||||
tagRecord.folderName = "bar";
|
||||
|
||||
_("Type: " + tagRecord.type);
|
||||
_("Folder name: " + tagRecord.folderName);
|
||||
store.applyIncoming(tagRecord);
|
||||
store.preprocessTagQuery(tagRecord);
|
||||
|
||||
let tags = PlacesUtils.getFolderContents(PlacesUtils.tagsFolderId).root;
|
||||
_("Verify that the URI has been rewritten.");
|
||||
do_check_neq(tagRecord.bmkUri, uri);
|
||||
|
||||
let tags = store._getNode(PlacesUtils.tagsFolderId);
|
||||
tags.containerOpen = true;
|
||||
let tagID;
|
||||
try {
|
||||
for (let i = 0; i < tags.childCount; ++i) {
|
||||
let child = tags.getChild(i);
|
||||
if (child.title == "bar") {
|
||||
tagID = child.itemId;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
tags.containerOpen = false;
|
||||
for (let i = 0; i < tags.childCount; ++i) {
|
||||
let child = tags.getChild(i);
|
||||
if (child.title == "bar")
|
||||
tagID = child.itemId;
|
||||
}
|
||||
tags.containerOpen = false;
|
||||
|
||||
_("Tag ID: " + tagID);
|
||||
let insertedRecord = store.createRecord("abcdefabcdef", "bookmarks");
|
||||
do_check_eq(insertedRecord.bmkUri, uri.replace("499", tagID));
|
||||
do_check_eq(tagRecord.bmkUri, uri.replace("499", tagID));
|
||||
|
||||
_("... but not if the type is wrong.");
|
||||
let wrongTypeURI = "place:folder=499&type=2&queryType=1";
|
||||
let wrongTypeRecord = makeTagRecord("fedcbafedcba", wrongTypeURI);
|
||||
store.applyIncoming(wrongTypeRecord);
|
||||
|
||||
insertedRecord = store.createRecord("fedcbafedcba", "bookmarks");
|
||||
do_check_eq(insertedRecord.bmkUri, wrongTypeURI);
|
||||
tagRecord.bmkUri = wrongTypeURI;
|
||||
store.preprocessTagQuery(tagRecord);
|
||||
do_check_eq(tagRecord.bmkUri, wrongTypeURI);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue