michael@0: /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const LOAD_IN_SIDEBAR_ANNO = "bookmarkProperties/loadInSidebar"; michael@0: const DESCRIPTION_ANNO = "bookmarkProperties/description"; michael@0: michael@0: // An object representing the contents of bookmarks.preplaces.html. michael@0: let test_bookmarks = { michael@0: menu: [ michael@0: { title: "Mozilla Firefox", michael@0: children: [ michael@0: { title: "Help and Tutorials", michael@0: url: "http://en-us.www.mozilla.com/en-US/firefox/help/", michael@0: icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg==" michael@0: }, michael@0: { title: "Customize Firefox", michael@0: url: "http://en-us.www.mozilla.com/en-US/firefox/customize/", michael@0: icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg==" michael@0: }, michael@0: { title: "Get Involved", michael@0: url: "http://en-us.www.mozilla.com/en-US/firefox/community/", michael@0: icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg==" michael@0: }, michael@0: { title: "About Us", michael@0: url: "http://en-us.www.mozilla.com/en-US/about/", michael@0: icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg==" michael@0: } michael@0: ] michael@0: }, michael@0: { michael@0: type: Ci.nsINavHistoryResultNode.RESULT_TYPE_SEPARATOR michael@0: }, michael@0: { title: "test", michael@0: description: "folder test comment", michael@0: dateAdded: 1177541020000000, michael@0: lastModified: 1177541050000000, michael@0: children: [ michael@0: { title: "test post keyword", michael@0: description: "item description", michael@0: dateAdded: 1177375336000000, michael@0: lastModified: 1177375423000000, michael@0: keyword: "test", michael@0: sidebar: true, michael@0: postData: "hidden1%3Dbar&text1%3D%25s", michael@0: charset: "ISO-8859-1" michael@0: } michael@0: ] michael@0: } michael@0: ], michael@0: toolbar: [ michael@0: { title: "Getting Started", michael@0: url: "http://en-us.www.mozilla.com/en-US/firefox/central/", michael@0: icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg==" michael@0: }, michael@0: { title: "Latest Headlines", michael@0: url: "http://en-us.fxfeeds.mozilla.com/en-US/firefox/livebookmarks/", michael@0: feedUrl: "http://en-us.fxfeeds.mozilla.com/en-US/firefox/headlines.xml" michael@0: } michael@0: ], michael@0: unfiled: [ michael@0: { title: "Example.tld", michael@0: url: "http://example.tld/" michael@0: } michael@0: ] michael@0: }; michael@0: michael@0: // Pre-Places bookmarks.html file pointer. michael@0: let gBookmarksFileOld; michael@0: // Places bookmarks.html file pointer. michael@0: let gBookmarksFileNew; michael@0: michael@0: Cu.import("resource://gre/modules/BookmarkHTMLUtils.jsm"); michael@0: michael@0: function run_test() michael@0: { michael@0: run_next_test(); michael@0: } michael@0: michael@0: add_task(function setup() { michael@0: // Avoid creating smart bookmarks during the test. michael@0: Services.prefs.setIntPref("browser.places.smartBookmarksVersion", -1); michael@0: michael@0: // File pointer to legacy bookmarks file. michael@0: gBookmarksFileOld = do_get_file("bookmarks.preplaces.html"); michael@0: michael@0: // File pointer to a new Places-exported bookmarks file. michael@0: gBookmarksFileNew = Services.dirsvc.get("ProfD", Ci.nsILocalFile); michael@0: gBookmarksFileNew.append("bookmarks.exported.html"); michael@0: if (gBookmarksFileNew.exists()) { michael@0: gBookmarksFileNew.remove(false); michael@0: } michael@0: michael@0: // This test must be the first one, since it setups the new bookmarks.html. michael@0: // Test importing a pre-Places canonical bookmarks file. michael@0: // 1. import bookmarks.preplaces.html michael@0: // 2. run the test-suite michael@0: // Note: we do not empty the db before this import to catch bugs like 380999 michael@0: yield BookmarkHTMLUtils.importFromFile(gBookmarksFileOld, true); michael@0: yield promiseAsyncUpdates(); michael@0: yield testImportedBookmarks(); michael@0: michael@0: yield BookmarkHTMLUtils.exportToFile(gBookmarksFileNew); michael@0: yield promiseAsyncUpdates(); michael@0: remove_all_bookmarks(); michael@0: }); michael@0: michael@0: add_task(function test_import_new() michael@0: { michael@0: // Test importing a Places bookmarks.html file. michael@0: // 1. import bookmarks.exported.html michael@0: // 2. run the test-suite michael@0: yield BookmarkHTMLUtils.importFromFile(gBookmarksFileNew, true); michael@0: yield promiseAsyncUpdates(); michael@0: michael@0: yield testImportedBookmarks(); michael@0: yield promiseAsyncUpdates(); michael@0: michael@0: remove_all_bookmarks(); michael@0: }); michael@0: michael@0: add_task(function test_emptytitle_export() michael@0: { michael@0: // Test exporting and importing with an empty-titled bookmark. michael@0: // 1. import bookmarks michael@0: // 2. create an empty-titled bookmark. michael@0: // 3. export to bookmarks.exported.html michael@0: // 4. empty bookmarks db michael@0: // 5. import bookmarks.exported.html michael@0: // 6. run the test-suite michael@0: // 7. remove the empty-titled bookmark michael@0: // 8. export to bookmarks.exported.html michael@0: // 9. empty bookmarks db and continue michael@0: michael@0: yield BookmarkHTMLUtils.importFromFile(gBookmarksFileNew, true); michael@0: michael@0: const NOTITLE_URL = "http://notitle.mozilla.org/"; michael@0: let id = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId, michael@0: NetUtil.newURI(NOTITLE_URL), michael@0: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: ""); michael@0: test_bookmarks.unfiled.push({ title: "", url: NOTITLE_URL }); michael@0: michael@0: yield BookmarkHTMLUtils.exportToFile(gBookmarksFileNew); michael@0: remove_all_bookmarks(); michael@0: michael@0: yield BookmarkHTMLUtils.importFromFile(gBookmarksFileNew, true); michael@0: yield promiseAsyncUpdates(); michael@0: yield testImportedBookmarks(); michael@0: michael@0: // Cleanup. michael@0: test_bookmarks.unfiled.pop(); michael@0: PlacesUtils.bookmarks.removeItem(id); michael@0: michael@0: yield BookmarkHTMLUtils.exportToFile(gBookmarksFileNew); michael@0: yield promiseAsyncUpdates(); michael@0: remove_all_bookmarks(); michael@0: }); michael@0: michael@0: add_task(function test_import_chromefavicon() michael@0: { michael@0: // Test exporting and importing with a bookmark pointing to a chrome favicon. michael@0: // 1. import bookmarks michael@0: // 2. create a bookmark pointing to a chrome favicon. michael@0: // 3. export to bookmarks.exported.html michael@0: // 4. empty bookmarks db michael@0: // 5. import bookmarks.exported.html michael@0: // 6. run the test-suite michael@0: // 7. remove the bookmark pointing to a chrome favicon. michael@0: // 8. export to bookmarks.exported.html michael@0: // 9. empty bookmarks db and continue michael@0: michael@0: const PAGE_URI = NetUtil.newURI("http://example.com/chromefavicon_page"); michael@0: const CHROME_FAVICON_URI = NetUtil.newURI("chrome://global/skin/icons/information-16.png"); michael@0: const CHROME_FAVICON_URI_2 = NetUtil.newURI("chrome://global/skin/icons/error-16.png"); michael@0: michael@0: yield BookmarkHTMLUtils.importFromFile(gBookmarksFileNew, true); michael@0: let id = PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId, michael@0: PAGE_URI, michael@0: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: "Test"); michael@0: michael@0: let deferred = Promise.defer(); michael@0: PlacesUtils.favicons.setAndFetchFaviconForPage( michael@0: PAGE_URI, CHROME_FAVICON_URI, true, michael@0: PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE, michael@0: deferred.resolve); michael@0: yield deferred.promise; michael@0: michael@0: deferred = Promise.defer(); michael@0: PlacesUtils.favicons.getFaviconDataForPage(PAGE_URI, michael@0: function (aURI, aDataLen, aData, aMimeType) deferred.resolve(aData)); michael@0: let data = yield deferred.promise; michael@0: michael@0: let base64Icon = "data:image/png;base64," + michael@0: base64EncodeString(String.fromCharCode.apply(String, data)); michael@0: michael@0: test_bookmarks.unfiled.push( michael@0: { title: "Test", url: PAGE_URI.spec, icon: base64Icon }); michael@0: michael@0: yield BookmarkHTMLUtils.exportToFile(gBookmarksFileNew); michael@0: michael@0: // Change the favicon to check it's really imported again later. michael@0: deferred = Promise.defer(); michael@0: PlacesUtils.favicons.setAndFetchFaviconForPage( michael@0: PAGE_URI, CHROME_FAVICON_URI_2, true, michael@0: PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE, michael@0: deferred.resolve); michael@0: yield deferred.promise; michael@0: michael@0: remove_all_bookmarks(); michael@0: michael@0: yield BookmarkHTMLUtils.importFromFile(gBookmarksFileNew, true); michael@0: yield promiseAsyncUpdates(); michael@0: yield testImportedBookmarks(); michael@0: michael@0: // Cleanup. michael@0: test_bookmarks.unfiled.pop(); michael@0: PlacesUtils.bookmarks.removeItem(id); michael@0: michael@0: yield BookmarkHTMLUtils.exportToFile(gBookmarksFileNew); michael@0: yield promiseAsyncUpdates(); michael@0: remove_all_bookmarks(); michael@0: }); michael@0: michael@0: add_task(function test_import_ontop() michael@0: { michael@0: // Test importing the exported bookmarks.html file *on top of* the existing michael@0: // bookmarks. michael@0: // 1. empty bookmarks db michael@0: // 2. import the exported bookmarks file michael@0: // 3. export to file michael@0: // 3. import the exported bookmarks file michael@0: // 4. run the test-suite michael@0: michael@0: yield BookmarkHTMLUtils.importFromFile(gBookmarksFileNew, true); michael@0: yield BookmarkHTMLUtils.exportToFile(gBookmarksFileNew); michael@0: yield BookmarkHTMLUtils.importFromFile(gBookmarksFileNew, true); michael@0: yield promiseAsyncUpdates(); michael@0: yield testImportedBookmarks(); michael@0: yield promiseAsyncUpdates(); michael@0: remove_all_bookmarks(); michael@0: }); michael@0: michael@0: function testImportedBookmarks() michael@0: { michael@0: for (let group in test_bookmarks) { michael@0: do_print("[testImportedBookmarks()] Checking group '" + group + "'"); michael@0: michael@0: let root; michael@0: switch (group) { michael@0: case "menu": michael@0: root = PlacesUtils.getFolderContents(PlacesUtils.bookmarksMenuFolderId).root; michael@0: break; michael@0: case "toolbar": michael@0: root = PlacesUtils.getFolderContents(PlacesUtils.toolbarFolderId).root; michael@0: break; michael@0: case "unfiled": michael@0: root = PlacesUtils.getFolderContents(PlacesUtils.unfiledBookmarksFolderId).root; michael@0: break; michael@0: } michael@0: michael@0: let items = test_bookmarks[group]; michael@0: do_check_eq(root.childCount, items.length); michael@0: michael@0: for (let key in items) { michael@0: yield checkItem(items[key], root.getChild(key)); michael@0: } michael@0: michael@0: root.containerOpen = false; michael@0: } michael@0: } michael@0: michael@0: function testImportedBookmarksToFolder(aFolder) michael@0: { michael@0: root = PlacesUtils.getFolderContents(aFolder).root; michael@0: michael@0: // Menu bookmarks are put directly into the folder, while other roots are michael@0: // imported into subfolders. michael@0: let rootFolderCount = test_bookmarks.menu.length; michael@0: michael@0: for (let i = 0; i < root.childCount; i++) { michael@0: let child = root.getChild(i); michael@0: // This check depends on all "menu" bookmarks being listed first in the imported file :-| michael@0: if (i < rootFolderCount) { michael@0: checkItem(test_bookmarks.menu[i], child); michael@0: } michael@0: else { michael@0: let container = child.QueryInterface(Ci.nsINavHistoryContainerResultNode); michael@0: let group = /Toolbar/.test(container.title) ? test_bookmarks.toolbar michael@0: : test_bookmarks.unfiled; michael@0: container.containerOpen = true; michael@0: do_print("[testImportedBookmarksToFolder()] Checking container '" + container.title + "'"); michael@0: for (let t = 0; t < container.childCount; t++) { michael@0: checkItem(group[t], container.getChild(t)); michael@0: } michael@0: container.containerOpen = false; michael@0: } michael@0: } michael@0: michael@0: root.containerOpen = false; michael@0: } michael@0: michael@0: function checkItem(aExpected, aNode) michael@0: { michael@0: let id = aNode.itemId; michael@0: michael@0: return Task.spawn(function() { michael@0: for (prop in aExpected) { michael@0: switch (prop) { michael@0: case "type": michael@0: do_check_eq(aNode.type, aExpected.type); michael@0: break; michael@0: case "title": michael@0: do_check_eq(aNode.title, aExpected.title); michael@0: break; michael@0: case "description": michael@0: do_check_eq(PlacesUtils.annotations michael@0: .getItemAnnotation(id, DESCRIPTION_ANNO), michael@0: aExpected.description); michael@0: break; michael@0: case "dateAdded": michael@0: do_check_eq(PlacesUtils.bookmarks.getItemDateAdded(id), michael@0: aExpected.dateAdded); michael@0: break; michael@0: case "lastModified": michael@0: do_check_eq(PlacesUtils.bookmarks.getItemLastModified(id), michael@0: aExpected.lastModified); michael@0: break; michael@0: case "url": michael@0: if (!("feedUrl" in aExpected)) michael@0: do_check_eq(aNode.uri, aExpected.url) michael@0: break; michael@0: case "icon": michael@0: let (deferred = Promise.defer(), data) { michael@0: PlacesUtils.favicons.getFaviconDataForPage( michael@0: NetUtil.newURI(aExpected.url), michael@0: function (aURI, aDataLen, aData, aMimeType) { michael@0: deferred.resolve(aData); michael@0: }); michael@0: data = yield deferred.promise; michael@0: let base64Icon = "data:image/png;base64," + michael@0: base64EncodeString(String.fromCharCode.apply(String, data)); michael@0: do_check_true(base64Icon == aExpected.icon); michael@0: } michael@0: break; michael@0: case "keyword": michael@0: break; michael@0: case "sidebar": michael@0: do_check_eq(PlacesUtils.annotations michael@0: .itemHasAnnotation(id, LOAD_IN_SIDEBAR_ANNO), michael@0: aExpected.sidebar); michael@0: break; michael@0: case "postData": michael@0: do_check_eq(PlacesUtils.annotations michael@0: .getItemAnnotation(id, PlacesUtils.POST_DATA_ANNO), michael@0: aExpected.postData); michael@0: break; michael@0: case "charset": michael@0: let testURI = NetUtil.newURI(aNode.uri); michael@0: do_check_eq((yield PlacesUtils.getCharsetForURI(testURI)), aExpected.charset); michael@0: break; michael@0: case "feedUrl": michael@0: let livemark = yield PlacesUtils.livemarks.getLivemark({ id: id }); michael@0: do_check_eq(livemark.siteURI.spec, aExpected.url); michael@0: do_check_eq(livemark.feedURI.spec, aExpected.feedUrl); michael@0: break; michael@0: case "children": michael@0: let folder = aNode.QueryInterface(Ci.nsINavHistoryContainerResultNode); michael@0: do_check_eq(folder.hasChildren, aExpected.children.length > 0); michael@0: folder.containerOpen = true; michael@0: do_check_eq(folder.childCount, aExpected.children.length); michael@0: michael@0: aExpected.children.forEach(function (item, index) checkItem(item, folder.getChild(index))); michael@0: michael@0: folder.containerOpen = false; michael@0: break; michael@0: default: michael@0: throw new Error("Unknown property"); michael@0: } michael@0: } michael@0: }); michael@0: }