diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /services/cloudsync/tests/xpcshell/test_bookmarks.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'services/cloudsync/tests/xpcshell/test_bookmarks.js')
-rw-r--r-- | services/cloudsync/tests/xpcshell/test_bookmarks.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/services/cloudsync/tests/xpcshell/test_bookmarks.js b/services/cloudsync/tests/xpcshell/test_bookmarks.js new file mode 100644 index 000000000..d4e1d2b75 --- /dev/null +++ b/services/cloudsync/tests/xpcshell/test_bookmarks.js @@ -0,0 +1,73 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +Cu.import("resource://gre/modules/CloudSync.jsm"); + +function run_test () { + run_next_test(); +} + +function cleanup () { + +} + +add_task(function* test_merge_bookmarks_flat () { + try { + let rootFolder = yield CloudSync().bookmarks.getRootFolder("TEST"); + ok(rootFolder.id, "root folder id is ok"); + + let items = [ + {"id":"G_UL4ZhOyX8m","type":rootFolder.BOOKMARK,"title":"reddit: the front page of the internet 1","uri":"http://www.reddit.com",index:2}, + {"id":"G_UL4ZhOyX8n","type":rootFolder.BOOKMARK,"title":"reddit: the front page of the internet 2","uri":"http://www.reddit.com?1",index:1}, + ]; + yield rootFolder.mergeRemoteItems(items); + + let localItems = yield rootFolder.getLocalItems(); + equal(Object.keys(localItems).length, items.length, "found merged items"); + } finally { + yield CloudSync().bookmarks.deleteRootFolder("TEST"); + } +}); + +add_task(function* test_merge_bookmarks_in_folders () { + try { + let rootFolder = yield CloudSync().bookmarks.getRootFolder("TEST"); + ok(rootFolder.id, "root folder id is ok"); + + let items = [ + {"id":"G_UL4ZhOyX8m","type":rootFolder.BOOKMARK,"title":"reddit: the front page of the internet 1","uri":"http://www.reddit.com",index:2}, + {"id":"G_UL4ZhOyX8n","type":rootFolder.BOOKMARK,parent:"G_UL4ZhOyX8x","title":"reddit: the front page of the internet 2","uri":"http://www.reddit.com/?a=å%20ä%20ö",index:1}, + {"id":"G_UL4ZhOyX8x","type":rootFolder.FOLDER}, + ]; + yield rootFolder.mergeRemoteItems(items); + + let localItems = yield rootFolder.getLocalItems(); + equal(localItems.length, items.length, "found merged items"); + + localItems.forEach(function(item) { + ok(item.id == "G_UL4ZhOyX8m" || + item.id == "G_UL4ZhOyX8n" || + item.id == "G_UL4ZhOyX8x"); + if (item.id == "G_UL4ZhOyX8n") { + equal(item.parent, "G_UL4ZhOyX8x") + } else { + equal(item.parent, rootFolder.id); + } + }); + + let folder = (yield rootFolder.getLocalItemsById(["G_UL4ZhOyX8x"]))[0]; + equal(folder.id, "G_UL4ZhOyX8x"); + equal(folder.type, rootFolder.FOLDER); + + let bookmark = (yield rootFolder.getLocalItemsById(["G_UL4ZhOyX8n"]))[0]; + equal(bookmark.id, "G_UL4ZhOyX8n"); + equal(bookmark.parent, "G_UL4ZhOyX8x"); + equal(bookmark.title, "reddit: the front page of the internet 2"); + equal(bookmark.index, 0); + equal(bookmark.uri, "http://www.reddit.com/?a=%C3%A5%20%C3%A4%20%C3%B6"); + } finally { + yield CloudSync().bookmarks.deleteRootFolder("TEST"); + } +});
\ No newline at end of file |