mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
45d3f90cf3
Engines now maintain a reference to the service they belong to. This allows them to obtain references to other engine instances belonging to that service and that service only. Stores and trackers now maintain a reference to the engine they belong to. Engine managers now maintain a reference back to a service. The clients singleton has been removed. It now exists as an instance variable on Service. Parts of ClientsEngine do behave as singletons (e.g. commands). This will be addressed in future refactoring.
51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
/* Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
_("Rewrite place: URIs.");
|
|
Cu.import("resource://services-sync/engines/bookmarks.js");
|
|
Cu.import("resource://services-sync/service.js");
|
|
Cu.import("resource://services-sync/util.js");
|
|
|
|
let engine = new BookmarksEngine(Service);
|
|
let store = engine._store;
|
|
|
|
function run_test() {
|
|
initTestLogging("Trace");
|
|
Log4Moz.repository.getLogger("Sync.Engine.Bookmarks").level = Log4Moz.Level.Trace;
|
|
Log4Moz.repository.getLogger("Sync.Store.Bookmarks").level = Log4Moz.Level.Trace;
|
|
|
|
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);
|
|
|
|
_("Verify that the URI has been rewritten.");
|
|
do_check_neq(tagRecord.bmkUri, uri);
|
|
|
|
let tags = store._getNode(PlacesUtils.tagsFolderId);
|
|
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;
|
|
}
|
|
tags.containerOpen = false;
|
|
|
|
_("Tag ID: " + 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";
|
|
tagRecord.bmkUri = wrongTypeURI;
|
|
store.preprocessTagQuery(tagRecord);
|
|
do_check_eq(tagRecord.bmkUri, wrongTypeURI);
|
|
}
|