1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/places/tests/bookmarks/test_997030-bookmarks-html-encode.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,37 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +/** 1.9 + * Checks that we don't encodeURI twice when creating bookmarks.html. 1.10 + */ 1.11 + 1.12 +function run_test() { 1.13 + run_next_test(); 1.14 +} 1.15 + 1.16 +add_task(function() { 1.17 + let uri = NetUtil.newURI("http://bt.ktxp.com/search.php?keyword=%E5%A6%84%E6%83%B3%E5%AD%A6%E7%94%9F%E4%BC%9A"); 1.18 + let bm = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId, 1.19 + uri, 1.20 + PlacesUtils.bookmarks.DEFAULT_INDEX, 1.21 + "bookmark"); 1.22 + 1.23 + let file = OS.Path.join(OS.Constants.Path.profileDir, "bookmarks.exported.997030.html"); 1.24 + if ((yield OS.File.exists(file))) { 1.25 + yield OS.File.remove(file); 1.26 + } 1.27 + yield BookmarkHTMLUtils.exportToFile(file); 1.28 + 1.29 + // Remove the bookmarks, then restore the backup. 1.30 + PlacesUtils.bookmarks.removeItem(bm); 1.31 + yield BookmarkHTMLUtils.importFromFile(file, true); 1.32 + 1.33 + do_log_info("Checking first level"); 1.34 + let root = PlacesUtils.getFolderContents(PlacesUtils.unfiledBookmarksFolderId).root; 1.35 + let node = root.getChild(0); 1.36 + do_check_eq(node.uri, uri.spec); 1.37 + 1.38 + root.containerOpen = false; 1.39 + PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.unfiledBookmarksFolderId); 1.40 +});