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 expandtab 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: /** michael@0: * This test ensures that when removing a folder within a transaction, undoing michael@0: * the transaction restores it with the same id (as received by the observers). michael@0: */ michael@0: michael@0: var bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"]. michael@0: getService(Ci.nsINavBookmarksService); michael@0: michael@0: function run_test() michael@0: { michael@0: const TITLE = "test folder"; michael@0: michael@0: // Create two test folders; remove the first one. This ensures that undoing michael@0: // the removal will not get the same id by chance (the insert id's can be michael@0: // reused in SQLite). michael@0: let id = bs.createFolder(bs.placesRoot, TITLE, -1); michael@0: bs.createFolder(bs.placesRoot, "test folder 2", -1); michael@0: let transaction = bs.getRemoveFolderTransaction(id); michael@0: transaction.doTransaction(); michael@0: michael@0: // Now check to make sure it gets added with the right id michael@0: bs.addObserver({ michael@0: onItemAdded: function(aItemId, aFolder, aIndex, aItemType, aURI, aTitle) michael@0: { michael@0: do_check_eq(aItemId, id); michael@0: do_check_eq(aTitle, TITLE); michael@0: } michael@0: }, false); michael@0: transaction.undoTransaction(); michael@0: }