summaryrefslogtreecommitdiffstats
path: root/browser/components/places/tests/browser/browser_library_left_pane_select_hierarchy.js
blob: 6caaf5a9d4908aadea864e816d2583dbae262ccb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/
 */

add_task(async function () {
  let hierarchy = ["AllBookmarks", "BookmarksMenu"];

  let items = await PlacesUtils.bookmarks.insertTree({
    guid: PlacesUtils.bookmarks.menuGuid,
    children: [
      {
        title: "Folder 1",
        type: PlacesUtils.bookmarks.TYPE_FOLDER,
        children: [
          {
            title: "Folder 2",
            type: PlacesUtils.bookmarks.TYPE_FOLDER,
            children: [
              {
                title: "Bookmark",
                url: "http://example.com",
              },
            ],
          },
        ],
      },
    ],
  });

  hierarchy.push(items[0].guid, items[1].guid);

  let library = await promiseLibrary();

  registerCleanupFunction(async function () {
    await PlacesUtils.bookmarks.remove(items[0]);
    await promiseLibraryClosed(library);
  });

  library.PlacesOrganizer.selectLeftPaneContainerByHierarchy(hierarchy);

  Assert.equal(
    library.PlacesOrganizer._places.selectedNode.bookmarkGuid,
    items[1].guid,
    "Found the expected left pane selected node"
  );

  Assert.equal(
    library.ContentTree.view.view.nodeForTreeIndex(0).bookmarkGuid,
    items[2].guid,
    "Found the expected right pane contents"
  );
});