mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1129529 - Bookmark backup may not be restorable. r=mak
This commit is contained in:
parent
6b86c2ac37
commit
280cc13b2a
@ -462,9 +462,16 @@ BookmarkImporter.prototype = {
|
||||
this._importPromises.push(kwPromise);
|
||||
}
|
||||
if (aData.tags) {
|
||||
let tags = aData.tags.split(",");
|
||||
if (tags.length)
|
||||
PlacesUtils.tagging.tagURI(NetUtil.newURI(aData.uri), tags);
|
||||
let tags = aData.tags.split(",").filter(aTag =>
|
||||
aTag.length <= Ci.nsITaggingService.MAX_TAG_LENGTH);
|
||||
if (tags.length) {
|
||||
try {
|
||||
PlacesUtils.tagging.tagURI(NetUtil.newURI(aData.uri), tags);
|
||||
} catch (ex) {
|
||||
// Invalid tag child, skip it.
|
||||
Cu.reportError(`Unable to set tags "${tags.join(", ")}" for ${aData.uri}: ${ex}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aData.charset) {
|
||||
PlacesUtils.annotations.setPageAnnotation(
|
||||
|
76
toolkit/components/places/tests/bookmarks/test_1129529.js
Normal file
76
toolkit/components/places/tests/bookmarks/test_1129529.js
Normal file
@ -0,0 +1,76 @@
|
||||
let 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, count] = 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);
|
||||
}
|
||||
});
|
@ -1,6 +1,6 @@
|
||||
[DEFAULT]
|
||||
head = head_bookmarks.js
|
||||
tail =
|
||||
tail =
|
||||
skip-if = toolkit == 'android' || toolkit == 'gonk'
|
||||
|
||||
[test_1016953-renaming-uncompressed.js]
|
||||
@ -26,6 +26,7 @@ skip-if = toolkit == 'android' || toolkit == 'gonk'
|
||||
[test_818593-store-backup-metadata.js]
|
||||
[test_992901-backup-unsorted-hierarchy.js]
|
||||
[test_997030-bookmarks-html-encode.js]
|
||||
[test_1129529.js]
|
||||
[test_async_observers.js]
|
||||
[test_bmindex.js]
|
||||
[test_bookmarks.js]
|
||||
|
Loading…
Reference in New Issue
Block a user