diff --git a/toolkit/components/places/tests/unit/test_421180.js b/toolkit/components/places/tests/unit/test_421180.js index 92cdfc979de..7fa93e91578 100644 --- a/toolkit/components/places/tests/unit/test_421180.js +++ b/toolkit/components/places/tests/unit/test_421180.js @@ -56,8 +56,7 @@ catch(ex) { do_throw("Could not get database connection\n"); } -// main -function run_test() { +add_test(function test_keywordRemovedOnUniqueItemRemoval() { var bookmarkedURI = uri("http://foo.bar"); var keyword = "testkeyword"; @@ -74,12 +73,22 @@ function run_test() { // remove bookmark bmsvc.removeItem(bookmarkId); - // check that keyword has been removed - var sql = "SELECT id FROM moz_keywords WHERE keyword = ?1"; - var stmt = mDBConn.createStatement(sql); - stmt.bindByIndex(0, keyword); - do_check_false(stmt.executeStep()); - stmt.finalize(); + waitForAsyncUpdates(function() { + // Check that keyword has been removed from the database. + // The removal is asynchronous. + var sql = "SELECT id FROM moz_keywords WHERE keyword = ?1"; + var stmt = mDBConn.createStatement(sql); + stmt.bindByIndex(0, keyword); + do_check_false(stmt.executeStep()); + stmt.finalize(); + + run_next_test(); + }); +}); + +add_test(function test_keywordNotRemovedOnNonUniqueItemRemoval() { + var bookmarkedURI = uri("http://foo.bar"); + var keyword = "testkeyword"; // TEST 2 // 1. add 2 bookmarks @@ -101,10 +110,18 @@ function run_test() { // remove first bookmark bmsvc.removeItem(bookmarkId1); - // check that keyword is still there - var sql = "SELECT id FROM moz_keywords WHERE keyword = ?1"; - var stmt = mDBConn.createStatement(sql); - stmt.bindByIndex(0, keyword); - do_check_true(stmt.executeStep()); - stmt.finalize(); + waitForAsyncUpdates(function() { + // check that keyword is still there + var sql = "SELECT id FROM moz_keywords WHERE keyword = ?1"; + var stmt = mDBConn.createStatement(sql); + stmt.bindByIndex(0, keyword); + do_check_true(stmt.executeStep()); + stmt.finalize(); + + run_next_test(); + }); +}); + +function run_test() { + run_next_test(); }