Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim:set ts=2 sw=2 sts=2 expandtab
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /**
8 * This test ensures that when removing a folder within a transaction, undoing
9 * the transaction restores it with the same id (as received by the observers).
10 */
12 var bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
13 getService(Ci.nsINavBookmarksService);
15 function run_test()
16 {
17 const TITLE = "test folder";
19 // Create two test folders; remove the first one. This ensures that undoing
20 // the removal will not get the same id by chance (the insert id's can be
21 // reused in SQLite).
22 let id = bs.createFolder(bs.placesRoot, TITLE, -1);
23 bs.createFolder(bs.placesRoot, "test folder 2", -1);
24 let transaction = bs.getRemoveFolderTransaction(id);
25 transaction.doTransaction();
27 // Now check to make sure it gets added with the right id
28 bs.addObserver({
29 onItemAdded: function(aItemId, aFolder, aIndex, aItemType, aURI, aTitle)
30 {
31 do_check_eq(aItemId, id);
32 do_check_eq(aTitle, TITLE);
33 }
34 }, false);
35 transaction.undoTransaction();
36 }