Bug 1343182 - Added updatePlaces's ignoreErrors, ignoreResults and aGroupNotifications to insertMany API in History.jsm. r=mak
☠☠ backed out by 1aa2b156d8f4 ☠ ☠
authorGanesh Chaitanya Kale <ganesh2583@gmail.com>
Sat, 01 Apr 2017 13:10:04 +0530
changeset 351761 38bbf2279a94
parent 351760 57b19b8018c7
child 351762 1d1403165215
push id40293
push userryanvm@gmail.com
push dateFri, 07 Apr 2017 12:33:32 +0000
treeherderautoland@38bbf2279a94 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1343182
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1343182 - Added updatePlaces's ignoreErrors, ignoreResults and aGroupNotifications to insertMany API in History.jsm. r=mak MozReview-Commit-ID: 45VbtBu25cP
toolkit/components/places/History.jsm
toolkit/components/places/tests/history/test_insertMany.js
--- a/toolkit/components/places/History.jsm
+++ b/toolkit/components/places/History.jsm
@@ -1030,20 +1030,22 @@ var insertMany = Task.async(function*(db
       handleError: (resultCode, result) => {
         let pageInfo = mergeUpdateInfoIntoPageInfo(result);
         onErrorData.push(pageInfo);
       },
       handleResult: result => {
         let pageInfo = mergeUpdateInfoIntoPageInfo(result);
         onResultData.push(pageInfo);
       },
-      handleCompletion: () => {
+      ignoreErrors: !onError,
+      ignoreResults: !onResult,
+      handleCompletion: (updatedCount) => {
         notifyOnResult(onResultData, onResult);
         notifyOnResult(onErrorData, onError);
-        if (onResultData.length) {
+        if (updatedCount > 0) {
           resolve();
         } else {
           reject({message: "No items were added to history."})
         }
       }
-    });
+    }, true);
   });
 });
--- a/toolkit/components/places/tests/history/test_insertMany.js
+++ b/toolkit/components/places/tests/history/test_insertMany.js
@@ -48,16 +48,31 @@ add_task(function* test_insertMany() {
 
       pageInfo.url = yield filter(uri);
       pageInfos.push(pageInfo);
     }
     return pageInfos;
   });
 
   let inserter = Task.async(function*(name, filter, useCallbacks) {
+    function promiseManyFrecenciesChanged() {
+      return new Promise((resolve, reject) => {
+        let obs = new NavHistoryObserver();
+        obs.onManyFrecenciesChanged = () => {
+          PlacesUtils.history.removeObserver(obs);
+          resolve();
+        };
+        obs.onFrecencyChanged = () => {
+          PlacesUtils.history.removeObserver(obs);
+          reject();
+        };
+        PlacesUtils.history.addObserver(obs, false);
+      });
+    }
+
     do_print(name);
     do_print(`filter: ${filter}`);
     do_print(`useCallbacks: ${useCallbacks}`);
     yield PlacesTestUtils.clearHistory();
 
     let result;
     let allUrls = GOOD_URLS.concat(BAD_URLS);
     let pageInfos = yield makePageInfos(allUrls, filter);
@@ -76,17 +91,19 @@ add_task(function* test_insertMany() {
         Assert.ok(BAD_URLS.includes(url), "onError callback called for correct uri");
         onErrorUrls.push(url);
         Assert.equal(undefined, pageInfo.title, "onError callback provides the correct title");
         Assert.equal(undefined, pageInfo.guid, "onError callback provides the expected guid");
       });
       Assert.equal(GOOD_URLS.sort().toString(), onResultUrls.sort().toString(), "onResult callback was called for each good url");
       Assert.equal(BAD_URLS.sort().toString(), onErrorUrls.sort().toString(), "onError callback was called for each bad url");
     } else {
+      let promiseManyFrecencies = promiseManyFrecenciesChanged();
       result = yield PlacesUtils.history.insertMany(pageInfos);
+      yield promiseManyFrecencies;
     }
 
     Assert.equal(undefined, result, "insertMany returned undefined");
 
     for (let url of allUrls) {
       let expected = GOOD_URLS.includes(url);
       Assert.equal(expected, yield PlacesTestUtils.isPageInDB(url), `isPageInDB for ${url} is ${expected}`);
       Assert.equal(expected, yield PlacesTestUtils.visitsInDB(url), `visitsInDB for ${url} is ${expected}`);