Bug 1071357 - Need yield against checkItem and promiseAsyncUpdates after each importFromFile/exportToFile in test_bookmarks_json.js. r=mak, a=test-only
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Mon, 22 Dec 2014 02:53:00 +0100
changeset 242590 8a4a3e9e1fd757814231e353d7c1ac7c1e7e170a
parent 242589 2f714060ef558fe6d9296024c7e730cfdc8a3884
child 242591 6fd67401ddeedc35d68824db4017e475bbde8c0f
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak, test-only
bugs1071357
milestone36.0a2
Bug 1071357 - Need yield against checkItem and promiseAsyncUpdates after each importFromFile/exportToFile in test_bookmarks_json.js. r=mak, a=test-only
toolkit/components/places/tests/unit/test_bookmarks_json.js
--- a/toolkit/components/places/tests/unit/test_bookmarks_json.js
+++ b/toolkit/components/places/tests/unit/test_bookmarks_json.js
@@ -73,36 +73,42 @@ let test_bookmarks = {
 
 // Exported bookmarks file pointer.
 let bookmarksExportedFile;
 
 add_task(function test_import_bookmarks() {
   let bookmarksFile = OS.Path.join(do_get_cwd().path, "bookmarks.json");
 
   yield BookmarkJSONUtils.importFromFile(bookmarksFile, true);
+  yield promiseAsyncUpdates();
   yield testImportedBookmarks();
 });
 
 add_task(function test_export_bookmarks() {
   bookmarksExportedFile = OS.Path.join(OS.Constants.Path.profileDir,
                                        "bookmarks.exported.json");
   yield BookmarkJSONUtils.exportToFile(bookmarksExportedFile);
+  yield promiseAsyncUpdates();
 });
 
 add_task(function test_import_exported_bookmarks() {
   remove_all_bookmarks();
   yield BookmarkJSONUtils.importFromFile(bookmarksExportedFile, true);
+  yield promiseAsyncUpdates();
   yield testImportedBookmarks();
 });
 
 add_task(function test_import_ontop() {
   remove_all_bookmarks();
   yield BookmarkJSONUtils.importFromFile(bookmarksExportedFile, true);
+  yield promiseAsyncUpdates();
   yield BookmarkJSONUtils.exportToFile(bookmarksExportedFile);
+  yield promiseAsyncUpdates();
   yield BookmarkJSONUtils.importFromFile(bookmarksExportedFile, true);
+  yield promiseAsyncUpdates();
   yield testImportedBookmarks();
 });
 
 add_task(function test_clean() {
   remove_all_bookmarks();
 });
 
 function testImportedBookmarks() {
@@ -197,17 +203,19 @@ function checkItem(aExpected, aNode) {
           do_check_eq(livemark.feedURI.spec, aExpected.feedUrl);
           break;
         case "children":
           let folder = aNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
           do_check_eq(folder.hasChildren, aExpected.children.length > 0);
           folder.containerOpen = true;
           do_check_eq(folder.childCount, aExpected.children.length);
 
-          aExpected.children.forEach(function (item, index) checkItem(item, folder.getChild(index)));
+          for (let index = 0; index < aExpected.children.length; index++) {
+            yield checkItem(aExpected.children[index], folder.getChild(index));
+          }
 
           folder.containerOpen = false;
           break;
         default:
           throw new Error("Unknown property");
       }
     }
   });