Bug 886054 - Intermittent test_bookmarks_json.js | Test timed out. r=mak
authorRaymond Lee <raymond@appcoast.com>
Tue, 28 Jan 2014 17:26:14 -0500
changeset 165630 d3f107710885743fb96afe07b9bf5ab145207c5d
parent 165629 52b83e4b3f8b6f5c549e287296f3af8396d947a8
child 165631 afed99fd2c9f6ade5ff025723108cf4c2f301172
push id4624
push userryanvm@gmail.com
push dateTue, 28 Jan 2014 23:09:06 +0000
treeherderfx-team@ea49291871ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs886054
milestone29.0a1
Bug 886054 - Intermittent test_bookmarks_json.js | Test timed out. r=mak
toolkit/components/places/tests/unit/test_bookmarks_html.js
toolkit/components/places/tests/unit/test_bookmarks_json.js
--- a/toolkit/components/places/tests/unit/test_bookmarks_html.js
+++ b/toolkit/components/places/tests/unit/test_bookmarks_html.js
@@ -325,41 +325,31 @@ function checkItem(aExpected, aNode)
           do_check_eq(PlacesUtils.bookmarks.getItemDateAdded(id),
                       aExpected.dateAdded);
           break;
         case "lastModified":
           do_check_eq(PlacesUtils.bookmarks.getItemLastModified(id),
                       aExpected.lastModified);
           break;
         case "url":
-          yield function() {
-            let deferred = Promise.defer();
-            PlacesUtils.livemarks.getLivemark(
-              { id: id },
-              function (aStatus, aLivemark) {
-                if (!Components.isSuccessCode(aStatus)) {
-                  do_check_eq(aNode.uri, aExpected.url);
-                }
-                deferred.resolve();
-              }
-            );
-          return deferred.promise; }();
+          if (!("feedUrl" in aExpected))
+            do_check_eq(aNode.uri, aExpected.url)
           break;
         case "icon":
-          yield function() {
-            let deferred = Promise.defer();
+          let (deferred = Promise.defer(), data) {
             PlacesUtils.favicons.getFaviconDataForPage(
               NetUtil.newURI(aExpected.url),
               function (aURI, aDataLen, aData, aMimeType) {
-                let base64Icon = "data:image/png;base64," +
-                  base64EncodeString(String.fromCharCode.apply(String, aData));
-                do_check_true(base64Icon == aExpected.icon);
-                deferred.resolve();
-            });
-            return deferred.promise; }();
+                deferred.resolve(aData);
+              });
+            data = yield deferred.promise;
+            let base64Icon = "data:image/png;base64," +
+                             base64EncodeString(String.fromCharCode.apply(String, data));
+            do_check_true(base64Icon == aExpected.icon);
+          }
           break;
         case "keyword":
           break;
         case "sidebar":
           do_check_eq(PlacesUtils.annotations
                                  .itemHasAnnotation(id, LOAD_IN_SIDEBAR_ANNO),
                       aExpected.sidebar);
           break;
@@ -368,28 +358,23 @@ function checkItem(aExpected, aNode)
                                  .getItemAnnotation(id, PlacesUtils.POST_DATA_ANNO),
                       aExpected.postData);
           break;
         case "charset":
           let testURI = NetUtil.newURI(aNode.uri);
           do_check_eq((yield PlacesUtils.getCharsetForURI(testURI)), aExpected.charset);
           break;
         case "feedUrl":
-          yield function() {
-            let deferred = Promise.defer();
-            PlacesUtils.livemarks.getLivemark(
-              { id: id },
-              function (aStatus, aLivemark) {
-                do_check_true(Components.isSuccessCode(aStatus));
-                do_check_eq(aLivemark.siteURI.spec, aExpected.url);
-                do_check_eq(aLivemark.feedURI.spec, aExpected.feedUrl);
-                deferred.resolve();
-              }
-            );
-          return deferred.promise; }();
+          yield PlacesUtils.livemarks.getLivemark(
+            { id: id },
+            (aStatus, aLivemark) => {
+              do_check_true(Components.isSuccessCode(aStatus));
+              do_check_eq(aLivemark.siteURI.spec, aExpected.url);
+              do_check_eq(aLivemark.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)));
--- a/toolkit/components/places/tests/unit/test_bookmarks_json.js
+++ b/toolkit/components/places/tests/unit/test_bookmarks_json.js
@@ -156,67 +156,54 @@ function checkItem(aExpected, aNode) {
           do_check_eq(PlacesUtils.bookmarks.getItemDateAdded(id),
                       aExpected.dateAdded);
           break;
         case "lastModified":
           do_check_eq(PlacesUtils.bookmarks.getItemLastModified(id),
                       aExpected.lastModified);
           break;
         case "url":
-          yield function() {
-            let deferred = Promise.defer();
-            PlacesUtils.livemarks.getLivemark(
-              { id: id },
-              function (aStatus, aLivemark) {
-                if (!Components.isSuccessCode(aStatus)) {
-                  do_check_eq(aNode.uri, aExpected.url);
-                }
-                deferred.resolve();
-              });
-            return deferred.promise; }();
+          if (!("feedUrl" in aExpected))
+            do_check_eq(aNode.uri, aExpected.url);
           break;
         case "icon":
-          yield function() {
-            let deferred = Promise.defer();
+          let (deferred = Promise.defer(), data) {
             PlacesUtils.favicons.getFaviconDataForPage(
               NetUtil.newURI(aExpected.url),
               function (aURI, aDataLen, aData, aMimeType) {
-                let base64Icon = "data:image/png;base64," +
-                      base64EncodeString(String.fromCharCode.apply(String, aData));
-                do_check_true(base64Icon == aExpected.icon);
-                deferred.resolve();
+                deferred.resolve(aData);
               });
-            return deferred.promise; }();
+            data = yield deferred.promise;
+            let base64Icon = "data:image/png;base64," +
+                             base64EncodeString(String.fromCharCode.apply(String, data));
+            do_check_true(base64Icon == aExpected.icon);
+          }
           break;
         case "keyword":
           break;
         case "sidebar":
           do_check_eq(PlacesUtils.annotations.itemHasAnnotation(
                       id, LOAD_IN_SIDEBAR_ANNO), aExpected.sidebar);
           break;
         case "postData":
           do_check_eq(PlacesUtils.annotations.getItemAnnotation(
                       id, PlacesUtils.POST_DATA_ANNO), aExpected.postData);
           break;
         case "charset":
           let testURI = NetUtil.newURI(aNode.uri);
           do_check_eq((yield PlacesUtils.getCharsetForURI(testURI)), aExpected.charset);
           break;
         case "feedUrl":
-          yield function() {
-            let deferred = Promise.defer();
-            PlacesUtils.livemarks.getLivemark(
-              { id: id },
-              function (aStatus, aLivemark) {
-                do_check_true(Components.isSuccessCode(aStatus));
-                do_check_eq(aLivemark.siteURI.spec, aExpected.url);
-                do_check_eq(aLivemark.feedURI.spec, aExpected.feedUrl);
-                deferred.resolve();
-              });
-            return deferred.promise; }();
+          yield PlacesUtils.livemarks.getLivemark(
+            { id: id },
+            (aStatus, aLivemark) => {
+              do_check_true(Components.isSuccessCode(aStatus));
+              do_check_eq(aLivemark.siteURI.spec, aExpected.url);
+              do_check_eq(aLivemark.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)));