diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:44:51 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:44:51 +0000 |
commit | 9e3c08db40b8916968b9f30096c7be3f00ce9647 (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /toolkit/components/places/tests/bookmarks/test_untitled.js | |
parent | Initial commit. (diff) | |
download | thunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.tar.xz thunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/places/tests/bookmarks/test_untitled.js')
-rw-r--r-- | toolkit/components/places/tests/bookmarks/test_untitled.js | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/toolkit/components/places/tests/bookmarks/test_untitled.js b/toolkit/components/places/tests/bookmarks/test_untitled.js new file mode 100644 index 0000000000..6e756d79a6 --- /dev/null +++ b/toolkit/components/places/tests/bookmarks/test_untitled.js @@ -0,0 +1,114 @@ +add_task(async function test_untitled_visited_bookmark() { + let fxURI = uri("http://getfirefox.com"); + + await PlacesUtils.history.insert({ + url: fxURI, + title: "Get Firefox!", + visits: [ + { + date: new Date(), + transition: PlacesUtils.history.TRANSITIONS.TYPED, + }, + ], + }); + + let { root: node } = PlacesUtils.getFolderContents( + PlacesUtils.bookmarks.toolbarGuid + ); + + try { + let fxBmk = await PlacesUtils.bookmarks.insert({ + parentGuid: PlacesUtils.bookmarks.toolbarGuid, + url: fxURI, + }); + strictEqual(fxBmk.title, "", "Visited bookmark should not have title"); + + await PlacesTestUtils.promiseAsyncUpdates(); + + let fxBmkId = await PlacesUtils.promiseItemId(fxBmk.guid); + strictEqual( + PlacesUtils.bookmarks.getItemTitle(fxBmkId), + "", + "Should return empty string for untitled visited bookmark" + ); + + let fxBmkNode = node.getChild(0); + equal(fxBmkNode.itemId, fxBmkId, "Visited bookmark ID should match"); + strictEqual( + fxBmkNode.title, + "", + "Visited bookmark node should not have title" + ); + } finally { + node.containerOpen = false; + } + + await PlacesUtils.bookmarks.eraseEverything(); +}); + +add_task(async function test_untitled_unvisited_bookmark() { + let tbURI = uri("http://getthunderbird.com"); + + let { root: node } = PlacesUtils.getFolderContents( + PlacesUtils.bookmarks.toolbarGuid + ); + + try { + let tbBmk = await PlacesUtils.bookmarks.insert({ + parentGuid: PlacesUtils.bookmarks.toolbarGuid, + url: tbURI, + }); + strictEqual(tbBmk.title, "", "Unvisited bookmark should not have title"); + + await PlacesTestUtils.promiseAsyncUpdates(); + + let tbBmkId = await PlacesUtils.promiseItemId(tbBmk.guid); + strictEqual( + PlacesUtils.bookmarks.getItemTitle(tbBmkId), + "", + "Should return empty string for untitled unvisited bookmark" + ); + + let tbBmkNode = node.getChild(0); + equal(tbBmkNode.itemId, tbBmkId, "Unvisited bookmark ID should match"); + strictEqual( + tbBmkNode.title, + "", + "Unvisited bookmark node should not have title" + ); + } finally { + node.containerOpen = false; + } + + await PlacesUtils.bookmarks.eraseEverything(); +}); + +add_task(async function test_untitled_folder() { + let { root: node } = PlacesUtils.getFolderContents( + PlacesUtils.bookmarks.toolbarGuid + ); + + try { + let folder = await PlacesUtils.bookmarks.insert({ + parentGuid: PlacesUtils.bookmarks.toolbarGuid, + type: PlacesUtils.bookmarks.TYPE_FOLDER, + }); + + await PlacesTestUtils.promiseAsyncUpdates(); + + let folderId = await PlacesUtils.promiseItemId(folder.guid); + strictEqual( + PlacesUtils.bookmarks.getItemTitle(folderId), + "", + "Should return empty string for untitled folder" + ); + + let folderNode = node.getChild(0); + equal(folderNode.itemId, folderId, "Folder ID should match"); + strictEqual(folderNode.title, "", "Folder node should not have title"); + } finally { + node.containerOpen = false; + } + + await PlacesUtils.bookmarks.eraseEverything(); +}); |