summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/tests/bookmarks/test_1129529.js
blob: da1ff708fa04976288101d414ae1d099ccf7e212 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
var now = Date.now() * 1000;

// Test that importing bookmark data where a bookmark has a tag longer than 100
// chars imports everything except the tags for that bookmark.
add_task(function* () {
  let aData = {
    guid: "root________",
    index: 0,
    id: 1,
    type: "text/x-moz-place-container",
    dateAdded: now,
    lastModified: now,
    root: "placesRoot",
    children: [{
      guid: "unfiled_____",
      index: 0,
      id: 2,
      type: "text/x-moz-place-container",
      dateAdded: now,
      lastModified: now,
      root: "unfiledBookmarksFolder",
      children: [
        {
          guid: "___guid1____",
          index: 0,
          id: 3,
          charset: "UTF-8",
          tags: "tag0",
          type: "text/x-moz-place",
          dateAdded: now,
          lastModified: now,
          uri: "http://test0.com/"
        },
        {
          guid: "___guid2____",
          index: 1,
          id: 4,
          charset: "UTF-8",
          tags: "tag1," + "a" + "0123456789".repeat(10), // 101 chars
          type: "text/x-moz-place",
          dateAdded: now,
          lastModified: now,
          uri: "http://test1.com/"
        },
        {
          guid: "___guid3____",
          index: 2,
          id: 5,
          charset: "UTF-8",
          tags: "tag2",
          type: "text/x-moz-place",
          dateAdded: now,
          lastModified: now,
          uri: "http://test2.com/"
        }
      ]
    }]
  };

  let contentType = "application/json";
  let uri = "data:" + contentType + "," + JSON.stringify(aData);
  yield BookmarkJSONUtils.importFromURL(uri, false);

  let [bookmarks] = yield PlacesBackups.getBookmarksTree();
  let unsortedBookmarks = bookmarks.children[2].children;
  Assert.equal(unsortedBookmarks.length, 3);

  for (let i = 0; i < unsortedBookmarks.length; ++i) {
    let bookmark = unsortedBookmarks[i];
    Assert.equal(bookmark.charset, "UTF-8");
    Assert.equal(bookmark.dateAdded, now);
    Assert.equal(bookmark.lastModified, now);
    Assert.equal(bookmark.uri, "http://test" + i + ".com/");
    Assert.equal(bookmark.tags, "tag" + i);
  }
});