var b1 = b[2]; 
var b1 = b[0]; 
function run_test() {  //Test creating a folder  var txn1 = ptSvc.createFolder("Testing folder", root, bmStartIndex);  txn1.doTransaction();  var folderId = bmsvc.getChildFolder(root, "Testing folder");  do_check_eq(observer._itemAddedIndex, bmStartIndex);  do_check_eq(observer._itemAddedParent, root);  do_check_eq(observer._itemAddedId, folderId);  txn1.undoTransaction();  do_check_eq(observer._itemRemovedId, folderId);  do_check_eq(observer._itemRemovedFolder, root);  do_check_eq(observer._itemRemovedIndex, bmStartIndex);  // Test creating an item  // Create to Root  var txn2 = ptSvc.createItem(uri("http://www.example.com"), root, bmStartIndex, "Testing1");  ptSvc.commitTransaction(txn2); //Also testing commitTransaction  var b = (bmsvc.getBookmarkIdsForURI(uri("http://www.example.com"), {}))[0];  do_check_eq(observer._itemAddedId, b);  do_check_eq(observer._itemAddedIndex, bmStartIndex);  do_check_true(bmsvc.isBookmarked(uri("http://www.example.com")));  txn2.undoTransaction();  do_check_eq(observer._itemRemovedId, b);  do_check_eq(observer._itemRemovedIndex, bmStartIndex);  // Create to a folder  var txn2a = ptSvc.createFolder("Folder", root, bmStartIndex);  var fldrId = bmsvc.getChildFolder(root, "Folder");  var txn2b = ptSvc.createItem(uri("http://www.example.com"), fldrId, bmStartIndex, "Testing1b");  ptSvc.commitTransaction(txn2);   var b2 = (bmsvc.getBookmarkIdsForURI(uri("http://www.example.com"), {}))[0];  do_check_eq(observer._itemAddedId, b2);  do_check_eq(observer._itemAddedIndex, bmStartIndex);  do_check_true(bmsvc.isBookmarked(uri("http://www.example.com")));  txn2.undoTransaction();  do_check_eq(observer._itemRemovedId, b2);  do_check_eq(observer._itemRemovedIndex, bmStartIndex);  // Testing moving an item  ptSvc.commitTransaction(ptSvc.createItem(uri("http://www.example.com"), root, -1, "Testing2"));  ptSvc.commitTransaction(ptSvc.createItem(uri("http://www.example.com"), root, -1, "Testing3"));     ptSvc.commitTransaction(ptSvc.createItem(uri("http://www.example.com"), fldrId, -1, "Testing4"));  var bkmkIds = bmsvc.getBookmarkIdsForURI(uri("http://www.example.com"), {});  var bkmk1Id = bkmkIds[2];  var bkmk2Id = bkmkIds[1];  var bkmk3Id = bkmkIds[0];  var txn3 = ptSvc.moveItem(bkmk1Id, root, -1);  txn3.doTransaction();  // Moving items between the same folder  do_check_eq(observer._itemMovedId, bkmk1Id);  do_check_eq(observer._itemMovedOldParent, root);  do_check_eq(observer._itemMovedOldIndex, 1);  do_check_eq(observer._itemMovedNewParent, root);  do_check_eq(observer._itemMovedNewIndex, 2);  txn3.undoTransaction();  do_check_eq(observer._itemMovedId, bkmk1Id);  do_check_eq(observer._itemMovedOldParent, root);  do_check_eq(observer._itemMovedOldIndex, 2);  do_check_eq(observer._itemMovedNewParent, root);  do_check_eq(observer._itemMovedNewIndex, 1);  // Moving items between different folders  var txn3b = ptSvc.moveItem(bkmk1Id, fldrId, -1);  txn3b.doTransaction();  do_check_eq(observer._itemMovedId, bkmk1Id);  do_check_eq(observer._itemMovedOldParent, root);  do_check_eq(observer._itemMovedOldIndex, 1);  do_check_eq(observer._itemMovedNewParent, fldrId);  do_check_eq(observer._itemMovedNewIndex, 2);  txn3.undoTransaction();  do_check_eq(observer._itemMovedId, bkmk1Id);  do_check_eq(observer._itemMovedOldParent, fldrId);  do_check_eq(observer._itemMovedOldIndex, 2);  do_check_eq(observer._itemMovedNewParent, root);  do_check_eq(observer._itemMovedNewIndex, 1);  // Test Removing a Folder  ptSvc.commitTransaction(ptSvc.createFolder("Folder2", root, -1));  var fldrId2 = bmsvc.getChildFolder(root, "Folder2");  var txn4 = ptSvc.removeItem(fldrId2);  txn4.doTransaction();  do_check_eq(observer._itemRemovedId, fldrId2);  do_check_eq(observer._itemRemovedFolder, root);  do_check_eq(observer._itemRemovedIndex, 3);  txn4.undoTransaction();  do_check_eq(observer._itemAddedId, fldrId2);  do_check_eq(observer._itemAddedParent, root);  do_check_eq(observer._itemAddedIndex, 3);  // Test removing an item  var txn5 = ptSvc.removeItem(bkmk2Id);  txn5.doTransaction();  do_check_eq(observer._itemRemovedId, bkmk2Id);  do_check_eq(observer._itemRemovedFolder, root);  do_check_eq(observer._itemRemovedIndex, 1);  txn5.undoTransaction();  do_check_eq(observer._itemAddedParent, root);  do_check_eq(observer._itemAddedIndex, 1);  // Test creating a separator  var txn6 = ptSvc.createSeparator(root, 1);  txn6.doTransaction();  var sepId = observer._itemAddedId;  do_check_eq(observer._itemAddedIndex, 1);  do_check_eq(observer._itemAddedParent, root);  txn6.undoTransaction();  do_check_eq(observer._itemRemovedId, sepId);  do_check_eq(observer._itemRemovedFolder, root);  do_check_eq(observer._itemRemovedIndex, 1);  // Test removing a separator  ptSvc.commitTransaction(ptSvc.createSeparator(root, 1));  var sepId2 = observer._itemAddedId;  var txn7 = ptSvc.removeItem(sepId2);  txn7.doTransaction();  do_check_eq(observer._itemRemovedId, sepId2);  do_check_eq(observer._itemRemovedFolder, root);  do_check_eq(observer._itemRemovedIndex, 1);  txn7.undoTransaction();  do_check_eq(observer._itemAddedId, sepId2); //New separator created  do_check_eq(observer._itemAddedParent, root);  do_check_eq(observer._itemAddedIndex, 1);  // Test editing item title  var txn8 = ptSvc.editItemTitle(bkmk1Id, "Testing2_mod");  txn8.doTransaction();  do_check_eq(observer._itemChangedId, bkmk1Id);   do_check_eq(observer._itemChangedProperty, "title");  do_check_eq(observer._itemChangedValue, "Testing2_mod");  txn8.undoTransaction();  do_check_eq(observer._itemChangedId, bkmk1Id);   do_check_eq(observer._itemChangedProperty, "title");  do_check_eq(observer._itemChangedValue, "Testing2");  // Test editing item uri  var txn9 = ptSvc.editBookmarkURI(bkmk1Id, uri("http://newuri.com"));  txn9.doTransaction();  do_check_eq(observer._itemChangedId, bkmk1Id);  do_check_eq(observer._itemChangedProperty, "uri");  do_check_eq(observer._itemChangedValue, "http://newuri.com/");  txn9.undoTransaction();  do_check_eq(observer._itemChangedId, bkmk1Id);  do_check_eq(observer._itemChangedProperty, "uri");  do_check_eq(observer._itemChangedValue, "http://www.example.com/");    // Test edit item description  var txn10 = ptSvc.editItemDescription(bkmk1Id, "Description1");  txn10.doTransaction();  do_check_eq(observer._itemChangedId, bkmk1Id);  do_check_eq(observer._itemChangedProperty, "bookmarkProperties/description");  // Testing edit keyword  var txn11 = ptSvc.editBookmarkKeyword(bkmk1Id, "kw1");  txn11.doTransaction();  do_check_eq(observer._itemChangedId, bkmk1Id);  do_check_eq(observer._itemChangedProperty, "keyword");  do_check_eq(observer._itemChangedValue, "kw1");   txn11.undoTransaction();  do_check_eq(observer._itemChangedId, bkmk1Id);  do_check_eq(observer._itemChangedProperty, "keyword");  do_check_eq(observer._itemChangedValue, "");   var txn12 = ptSvc.createLivemark(uri("http://feeduri.com"), uri("http://siteuri.com"), "Livemark1", root);  txn12.doTransaction();  // Funky stuff going on here.  // In placesCreateLivemarkTxn, livemarks.createLivemark actually returns observer._itemAddedId -1  // instead of observer._itemAddedId. Check w. someone.  do_check_true(lmsvc.isLivemark(observer._itemAddedId-1));  do_check_eq(lmsvc.getSiteURI(observer._itemAddedId-1).spec, "http://siteuri.com/");  do_check_eq(lmsvc.getFeedURI(observer._itemAddedId-1).spec, "http://feeduri.com/");  var lvmkId = observer._itemAddedId-1;  // editLivemarkSiteURI  var txn13 = ptSvc.editLivemarkSiteURI(lvmkId, uri("http://NEWsiteuri.com/"));  txn13.doTransaction();  do_check_eq(observer._itemChangedId, lvmkId);  do_check_eq(observer._itemChangedProperty, "livemark/siteURI");  txn13.undoTransaction();  do_check_eq(observer._itemChangedId, lvmkId);  do_check_eq(observer._itemChangedProperty, "livemark/siteURI");  do_check_eq(observer._itemChangedValue, "");  // editLivemarkFeedURI  var txn14 = ptSvc.editLivemarkFeedURI(lvmkId, uri("http://NEWfeeduri.com/"));  txn14.doTransaction();  do_check_eq(observer._itemChangedId, lvmkId);  do_check_eq(observer._itemChangedProperty, "livemark/feedURI");  txn14.undoTransaction();  do_check_eq(observer._itemChangedId, lvmkId);  do_check_eq(observer._itemChangedProperty, "livemark/feedURI");  do_check_eq(observer._itemChangedValue, "");  // setBookmarksToolbar  ptSvc.commitTransaction(ptSvc.createFolder("Testing toolbar folder", root, bmStartIndex));  var tmpFolderId = bmsvc.getChildFolder(root, "Testing toolbar folder");  var txn15 = ptSvc.setBookmarksToolbar(tmpFolderId);  txn15.doTransaction();  do_check_eq(observer._itemChangedId, tmpFolderId);  do_check_eq(observer._itemChangedProperty, "became_toolbar_folder");  txn15.undoTransaction();  // Test setLoadInSidebar  var txn16 = ptSvc.setLoadInSidebar(bkmk1Id, true);  txn16.doTransaction();  do_check_eq(observer._itemChangedId, bkmk1Id);  do_check_eq(observer._itemChangedProperty, "bookmarkProperties/loadInSidebar");  do_check_eq(observer._itemChanged_isAnnotationProperty, true);  txn16.undoTransaction();  do_check_eq(observer._itemChangedId, bkmk1Id);  do_check_eq(observer._itemChangedProperty, "bookmarkProperties/loadInSidebar");  do_check_eq(observer._itemChanged_isAnnotationProperty, true);  // sortFolderByName  ptSvc.commitTransaction(ptSvc.createFolder("Sorting folder", root, bmStartIndex, [], null));  var srtFldId = bmsvc.getChildFolder(root, "Sorting folder");  ptSvc.commitTransaction(ptSvc.createItem(uri("http://www.sortingtest.com"), srtFldId, -1, "c"));  ptSvc.commitTransaction(ptSvc.createItem(uri("http://www.sortingtest.com"), srtFldId, -1, "b"));     ptSvc.commitTransaction(ptSvc.createItem(uri("http://www.sortingtest.com"), srtFldId, -1, "a"));  var b = bmsvc.getBookmarkIdsForURI(uri("http://www.sortingtest.com"), {});  var b1 = b[2];  var b2 = b[1];  var b3 = b[0];  do_check_eq(0, bmsvc.getItemIndex(b1));  do_check_eq(1, bmsvc.getItemIndex(b2));  do_check_eq(2, bmsvc.getItemIndex(b3));  var txn17 = ptSvc.sortFolderByName(srtFldId, 1);  txn17.doTransaction();  do_check_eq(2, bmsvc.getItemIndex(b1));  do_check_eq(1, bmsvc.getItemIndex(b2));  do_check_eq(0, bmsvc.getItemIndex(b3));  txn17.undoTransaction();  do_check_eq(0, bmsvc.getItemIndex(b1));  do_check_eq(1, bmsvc.getItemIndex(b2));  do_check_eq(2, bmsvc.getItemIndex(b3));  // editBookmarkMicrosummary  var tmpMs = mss.createMicrosummary(uri("http://testmicro.com"),                                      uri("http://dietrich.ganx4.com/mozilla/test-microsummary.xml"));  ptSvc.commitTransaction(  ptSvc.createItem(uri("http://dietrich.ganx4.com/mozilla/test-microsummary-content.php"),                   root, -1, "micro test", null, null, null));  var bId = (bmsvc.getBookmarkIdsForURI(uri("http://dietrich.ganx4.com/mozilla/test-microsummary-content.php"),{}))[0];  do_check_true(!mss.hasMicrosummary(bId));  var txn18 = ptSvc.editBookmarkMicrosummary(bId, tmpMs);  txn18.doTransaction();  do_check_eq(observer._itemChangedId, bId);  do_check_eq(observer._itemChangedProperty, "bookmarks/generatedTitle");  do_check_true(mss.hasMicrosummary(bId));  txn18.undoTransaction();  do_check_eq(observer._itemChangedId, bId);  do_check_eq(observer._itemChangedProperty, "bookmarks/generatedTitle");  do_check_true(!mss.hasMicrosummary(bId));  // Testing edit Post Data...  // mmm.. cant figure out a good way to test this.}
5459	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/5459/dadfc4f085a5ac9ff02981b4a9662f96a754c6ed/test_placesTxn.js/clean/browser/components/places/tests/unit/test_placesTxn.js