mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 753205 - Add back separators support to bookmarks HTML import.
r=dietrich --HG-- rename : browser/components/places/tests/unit/bookmarks.corrupt.html => toolkit/components/places/tests/unit/bookmarks.corrupt.html rename : browser/components/places/tests/unit/bookmarks.preplaces.html => toolkit/components/places/tests/unit/bookmarks.preplaces.html rename : browser/components/places/tests/unit/test_384370.js => toolkit/components/places/tests/unit/test_384370.js rename : browser/components/places/tests/unit/test_398914.js => toolkit/components/places/tests/unit/test_398914.js rename : browser/components/places/tests/unit/test_bookmarks_html.js => toolkit/components/places/tests/unit/test_bookmarks_html.js rename : browser/components/places/tests/unit/test_457441-import-export-corrupt-bookmarks-html.js => toolkit/components/places/tests/unit/test_bookmarks_html_corrupt.js rename : browser/components/places/tests/unit/test_bookmarksRestoreNotification.js => toolkit/components/places/tests/unit/test_bookmarks_restore_notification.js
This commit is contained in:
parent
23019e4123
commit
6f0021b7e9
@ -61,12 +61,6 @@ let (XULAppInfo = {
|
||||
XULAppInfoFactory);
|
||||
}
|
||||
|
||||
|
||||
const FILENAME_BOOKMARKS_HTML = "bookmarks.html";
|
||||
let (backup_date = new Date().toLocaleFormat("%Y-%m-%d")) {
|
||||
const FILENAME_BOOKMARKS_JSON = "bookmarks-" + backup_date + ".json";
|
||||
}
|
||||
|
||||
// Smart bookmarks constants.
|
||||
const SMART_BOOKMARKS_VERSION = 4;
|
||||
const SMART_BOOKMARKS_ON_TOOLBAR = 1;
|
||||
|
@ -2,12 +2,7 @@
|
||||
head = head_bookmarks.js
|
||||
tail =
|
||||
|
||||
[test_384370.js]
|
||||
[test_398914.js]
|
||||
[test_421483.js]
|
||||
[test_457441-import-export-corrupt-bookmarks-html.js]
|
||||
[test_bookmarksRestoreNotification.js]
|
||||
[test_bookmarks_html.js]
|
||||
[test_browserGlue_corrupt.js]
|
||||
[test_browserGlue_corrupt_nobackup.js]
|
||||
[test_browserGlue_corrupt_nobackup_default.js]
|
||||
|
@ -194,6 +194,23 @@ BookmarkImporter.prototype = {
|
||||
this._frames.push(new Frame(containerId));
|
||||
},
|
||||
|
||||
/**
|
||||
* Handles <hr> as a separator.
|
||||
*
|
||||
* @note Separators may have a title in old html files, though Places dropped
|
||||
* support for them.
|
||||
* We also don't import ADD_DATE or LAST_MODIFIED for separators because
|
||||
* pre-Places bookmarks did not support them.
|
||||
*/
|
||||
_handleSeparator: function handleSeparator(aElt) {
|
||||
let frame = this._curFrame;
|
||||
try {
|
||||
frame.previousId =
|
||||
PlacesUtils.bookmarks.insertSeparator(frame.containerId,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX);
|
||||
} catch(e) {}
|
||||
},
|
||||
|
||||
/**
|
||||
* Handles <H1>. We check for the attribute PLACES_ROOT and reset the
|
||||
* container id if it's found. Otherwise, the default bookmark menu
|
||||
@ -517,6 +534,9 @@ BookmarkImporter.prototype = {
|
||||
case "dd":
|
||||
this._curFrame.inDescription = true;
|
||||
break;
|
||||
case "hr":
|
||||
this._handleSeparator(aElt);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -405,6 +405,10 @@ function shutdownPlaces(aKeepAliveConnection)
|
||||
hs.observe(null, "profile-before-change", null);
|
||||
}
|
||||
|
||||
const FILENAME_BOOKMARKS_HTML = "bookmarks.html";
|
||||
let (backup_date = new Date().toLocaleFormat("%Y-%m-%d")) {
|
||||
const FILENAME_BOOKMARKS_JSON = "bookmarks-" + backup_date + ".json";
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a bookmarks.html file in the profile folder from a given source file.
|
||||
|
@ -14,6 +14,7 @@
|
||||
<DT><A HREF="http://en-US.www.mozilla.com/en-US/firefox/community/" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv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2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg==" ID="rdf:#$52iCK1">About Us</A>
|
||||
</DL><p>
|
||||
<HR>
|
||||
<DT><H3 ADD_DATE="1177541020" LAST_MODIFIED="1177541050" ID="rdf:#$74Gpx2">test</H3>
|
||||
<DD>folder test comment
|
||||
<DL><p>
|
@ -29,9 +29,6 @@ function run_test() {
|
||||
// import the importer
|
||||
Cu.import("resource://gre/modules/BookmarkHTMLUtils.jsm");
|
||||
|
||||
// avoid creating the places smart folder during tests
|
||||
Services.prefs.setIntPref("browser.places.smartBookmarksVersion", -1);
|
||||
|
||||
// file pointer to legacy bookmarks file
|
||||
//var bookmarksFileOld = do_get_file("bookmarks.large.html");
|
||||
var bookmarksFileOld = do_get_file("bookmarks.preplaces.html");
|
||||
@ -136,12 +133,15 @@ function testCanonicalBookmarks() {
|
||||
var rootNode = result.root;
|
||||
rootNode.containerOpen = true;
|
||||
|
||||
// 6-2: the toolbar contents are imported to the places-toolbar folder,
|
||||
// the separator above it is removed.
|
||||
do_check_eq(rootNode.childCount, DEFAULT_BOOKMARKS_ON_MENU + 1);
|
||||
// Count expected bookmarks in the menu root.
|
||||
do_check_eq(rootNode.childCount, 3);
|
||||
|
||||
// check separator
|
||||
var testSeparator = rootNode.getChild(1);
|
||||
do_check_eq(testSeparator.type, testSeparator.RESULT_TYPE_SEPARATOR);
|
||||
|
||||
// get test folder
|
||||
var testFolder = rootNode.getChild(DEFAULT_BOOKMARKS_ON_MENU);
|
||||
var testFolder = rootNode.getChild(2);
|
||||
do_check_eq(testFolder.type, testFolder.RESULT_TYPE_FOLDER);
|
||||
do_check_eq(testFolder.title, "test");
|
||||
|
@ -4,6 +4,9 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
const LOAD_IN_SIDEBAR_ANNO = "bookmarkProperties/loadInSidebar";
|
||||
const DESCRIPTION_ANNO = "bookmarkProperties/description";
|
||||
|
||||
// An object representing the contents of bookmarks.preplaces.html.
|
||||
let test_bookmarks = {
|
||||
menu: [
|
||||
@ -27,6 +30,9 @@ let test_bookmarks = {
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: Ci.nsINavHistoryResultNode.RESULT_TYPE_SEPARATOR
|
||||
},
|
||||
{ title: "test",
|
||||
description: "folder test comment",
|
||||
dateAdded: 1177541020000000,
|
||||
@ -385,12 +391,15 @@ function checkItem(aExpected, aNode)
|
||||
let id = aNode.itemId;
|
||||
for (prop in aExpected) {
|
||||
switch (prop) {
|
||||
case "type":
|
||||
do_check_eq(aNode.type, aExpected.type);
|
||||
break;
|
||||
case "title":
|
||||
do_check_eq(aNode.title, aExpected.title);
|
||||
break;
|
||||
case "description":
|
||||
do_check_eq(PlacesUtils.annotations
|
||||
.getItemAnnotation(id, PlacesUIUtils.DESCRIPTION_ANNO),
|
||||
.getItemAnnotation(id, DESCRIPTION_ANNO),
|
||||
aExpected.description);
|
||||
break;
|
||||
case "dateAdded":
|
||||
@ -423,7 +432,7 @@ function checkItem(aExpected, aNode)
|
||||
break;
|
||||
case "sidebar":
|
||||
do_check_eq(PlacesUtils.annotations
|
||||
.itemHasAnnotation(id, PlacesUIUtils.LOAD_IN_SIDEBAR_ANNO),
|
||||
.itemHasAnnotation(id, LOAD_IN_SIDEBAR_ANNO),
|
||||
aExpected.sidebar);
|
||||
break;
|
||||
case "postData":
|
@ -104,10 +104,10 @@ function database_check(aCallback) {
|
||||
var result = hs.executeQuery(query, options);
|
||||
var rootNode = result.root;
|
||||
rootNode.containerOpen = true;
|
||||
do_check_eq(rootNode.childCount, DEFAULT_BOOKMARKS_ON_MENU + 1);
|
||||
do_check_eq(rootNode.childCount, 2);
|
||||
|
||||
// get test folder
|
||||
var testFolder = rootNode.getChild(DEFAULT_BOOKMARKS_ON_MENU);
|
||||
var testFolder = rootNode.getChild(1);
|
||||
do_check_eq(testFolder.type, testFolder.RESULT_TYPE_FOLDER);
|
||||
do_check_eq(testFolder.title, "test");
|
||||
// add date
|
@ -8,9 +8,11 @@ tail =
|
||||
# Bug 676989: test hangs consistently on Android
|
||||
skip-if = os == "android"
|
||||
[test_331487.js]
|
||||
[test_384370.js]
|
||||
[test_385397.js]
|
||||
# Bug 676989: test fails consistently on Android
|
||||
fail-if = os == "android"
|
||||
[test_398914.js]
|
||||
[test_399264_query_to_string.js]
|
||||
[test_399264_string_to_query.js]
|
||||
[test_399266.js]
|
||||
@ -53,6 +55,9 @@ skip-if = os == "android"
|
||||
[test_async_history_api.js]
|
||||
[test_autocomplete_stopSearch_no_throw.js]
|
||||
[test_bookmark_catobs.js]
|
||||
[test_bookmarks_html.js]
|
||||
[test_bookmarks_html_corrupt.js]
|
||||
[test_bookmarks_restore_notification.js]
|
||||
[test_bookmarks_setNullTitle.js]
|
||||
[test_broken_folderShortcut_result.js]
|
||||
[test_browserhistory.js]
|
||||
|
Loading…
Reference in New Issue
Block a user