summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/tests/unit/test_1085291.js
blob: 3159ff8bc79e04fda89db8824fad6ae6dfd4550f (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
add_task(function* () {
  // test that nodes inserted by incremental update for bookmarks of all types
  // have the extra bookmark properties (bookmarkGuid, dateAdded, lastModified).

  // getFolderContents opens the root node.
  let root = PlacesUtils.getFolderContents(PlacesUtils.toolbarFolderId).root;

  function* insertAndTest(bmInfo) {
    bmInfo = yield PlacesUtils.bookmarks.insert(bmInfo);
    let node = root.getChild(root.childCount - 1);
    Assert.equal(node.bookmarkGuid, bmInfo.guid);
    Assert.equal(node.dateAdded, bmInfo.dateAdded * 1000);
    Assert.equal(node.lastModified, bmInfo.lastModified * 1000);
  }

  // Normal bookmark.
  yield insertAndTest({ parentGuid: root.bookmarkGuid
                      , type: PlacesUtils.bookmarks.TYPE_BOOKMARK
                      , title: "Test Bookmark"
                      , url: "http://test.url.tld" });

  // place: query
  yield insertAndTest({ parentGuid: root.bookmarkGuid
                      , type: PlacesUtils.bookmarks.TYPE_BOOKMARK
                      , title: "Test Query"
                      , url: "place:folder=BOOKMARKS_MENU" });

  // folder
  yield insertAndTest({ parentGuid: root.bookmarkGuid
                      , type: PlacesUtils.bookmarks.TYPE_FOLDER
                      , title: "Test Folder" });

  // separator
  yield insertAndTest({ parentGuid: root.bookmarkGuid
                      , type: PlacesUtils.bookmarks.TYPE_SEPARATOR });

  root.containerOpen = false;
});

function run_test() {
  run_next_test();
}