Bug 801450 - Can't import bookmarks from Safari-created HTML files. r=mak

This commit is contained in:
Virgil Dupras 2012-12-03 20:26:15 -05:00
parent adaf7b8ea9
commit d0943e17dd
4 changed files with 46 additions and 1 deletions

View File

@ -254,7 +254,10 @@ BookmarkImporter.prototype = {
// implicit ending of the FOO container. The output will be FOO and BAR as
// siblings. If there's another <dl> following (as in "content 2"), those
// items will be treated as further siblings of FOO and BAR
if (frame.containerNesting == 0) {
// This special frame popping business, of course, only happens when our
// frame array has more than one element so we can avoid situations where
// we don't have a frame to parse into anymore.
if (frame.containerNesting == 0 && this._frames.length > 1) {
this._frames.pop();
}

View File

@ -0,0 +1,10 @@
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<HTML>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<Title>Bookmarks</Title>
<H1>Bookmarks</H1>
<DT><H3>Subtitle</H3>
<DL><p>
<DT><A HREF="http://www.mozilla.org/">Mozilla</A>
</DL><p>
</HTML>

View File

@ -0,0 +1,31 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
// Test for bug #801450
// Get Services
Cu.import("resource://gre/modules/BookmarkHTMLUtils.jsm");
function run_test() {
do_test_pending();
let bookmarksFile = do_get_file("bookmarks_html_singleframe.html");
BookmarkHTMLUtils.importFromFile(bookmarksFile, true, after_import);
}
function after_import(success) {
do_check_true(success);
let root = PlacesUtils.getFolderContents(PlacesUtils.bookmarksMenuFolderId).root;
do_check_eq(root.childCount, 1);
let folder = root.getChild(0);
PlacesUtils.asContainer(folder).containerOpen = true;
do_check_eq(folder.title, "Subtitle");
do_check_eq(folder.childCount, 1);
let bookmark = folder.getChild(0);
do_check_eq(bookmark.uri, "http://www.mozilla.org/");
do_check_eq(bookmark.title, "Mozilla");
folder.containerOpen = false;
do_test_finished();
}

View File

@ -58,6 +58,7 @@ skip-if = os == "android"
[test_bookmark_catobs.js]
[test_bookmarks_html.js]
[test_bookmarks_html_corrupt.js]
[test_bookmarks_html_singleframe.js]
[test_bookmarks_restore_notification.js]
[test_bookmarks_setNullTitle.js]
[test_broken_folderShortcut_result.js]