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/queries/test_results-as-left-pane.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/queries/test_results-as-left-pane.js')
-rw-r--r-- | toolkit/components/places/tests/queries/test_results-as-left-pane.js | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/toolkit/components/places/tests/queries/test_results-as-left-pane.js b/toolkit/components/places/tests/queries/test_results-as-left-pane.js new file mode 100644 index 0000000000..6cec733758 --- /dev/null +++ b/toolkit/components/places/tests/queries/test_results-as-left-pane.js @@ -0,0 +1,83 @@ +"use strict"; + +const expectedRoots = [ + { + title: "OrganizerQueryHistory", + uri: `place:sort=${Ci.nsINavHistoryQueryOptions.SORT_BY_DATE_DESCENDING}&type=${Ci.nsINavHistoryQueryOptions.RESULTS_AS_DATE_QUERY}`, + guid: "history____v", + }, + { + title: "OrganizerQueryDownloads", + uri: `place:transition=${Ci.nsINavHistoryService.TRANSITION_DOWNLOAD}&sort=${Ci.nsINavHistoryQueryOptions.SORT_BY_DATE_DESCENDING}`, + guid: "downloads__v", + }, + { + title: "TagsFolderTitle", + uri: `place:sort=${Ci.nsINavHistoryQueryOptions.SORT_BY_TITLE_ASCENDING}&type=${Ci.nsINavHistoryQueryOptions.RESULTS_AS_TAGS_ROOT}`, + guid: "tags_______v", + }, + { + title: "OrganizerQueryAllBookmarks", + uri: `place:type=${Ci.nsINavHistoryQueryOptions.RESULTS_AS_ROOTS_QUERY}`, + guid: "allbms_____v", + }, +]; + +const placesStrings = Services.strings.createBundle( + "chrome://places/locale/places.properties" +); + +function getLeftPaneQuery() { + var query = PlacesUtils.history.getNewQuery(); + + // Options + var options = PlacesUtils.history.getNewQueryOptions(); + options.resultType = options.RESULTS_AS_LEFT_PANE_QUERY; + + // Results + var result = PlacesUtils.history.executeQuery(query, options); + return result.root; +} + +function assertExpectedChildren(root, expectedChildren) { + Assert.equal( + root.childCount, + expectedChildren.length, + "Should have the expected number of children." + ); + + for (let i = 0; i < root.childCount; i++) { + Assert.ok( + PlacesTestUtils.ComparePlacesURIs( + root.getChild(i).uri, + expectedChildren[i].uri + ), + "Should have the correct uri for root ${i}" + ); + Assert.equal( + root.getChild(i).title, + placesStrings.GetStringFromName(expectedChildren[i].title), + "Should have the correct title for root ${i}" + ); + Assert.equal(root.getChild(i).bookmarkGuid, expectedChildren[i].guid); + } +} + +/** + * This test will test the basic RESULTS_AS_ROOTS_QUERY, that simply returns, + * the existing bookmark roots. + */ +add_task(async function test_results_as_root() { + let root = getLeftPaneQuery(); + root.containerOpen = true; + + Assert.equal( + PlacesUtils.asQuery(root).queryOptions.queryType, + Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS, + "Should have a query type of QUERY_TYPE_BOOKMARKS" + ); + + assertExpectedChildren(root, expectedRoots); + + root.containerOpen = false; +}); |