Bug 1295301 - history.onVisitRemoved argument is wrong after a call to history.deleteAll, r?aswan draft
authorBob Silverberg <bsilverberg@mozilla.com>
Tue, 16 Aug 2016 09:35:37 -0400
changeset 401162 55c88b3c27bfb96d0c2010558cc8eb94d86a89c9
parent 400444 6e191a55c3d23e83e6a2e72e4e80c1dc21516493
child 528415 ec4a03c16cf8e00c0365932313de1ae13976cf0e
push id26382
push userbmo:bob.silverberg@gmail.com
push dateTue, 16 Aug 2016 13:36:07 +0000
reviewersaswan
bugs1295301
milestone51.0a1
Bug 1295301 - history.onVisitRemoved argument is wrong after a call to history.deleteAll, r?aswan MozReview-Commit-ID: 9b9PKAwcNDA
browser/components/extensions/ext-history.js
browser/components/extensions/schemas/history.json
browser/components/extensions/test/xpcshell/test_ext_history.js
--- a/browser/components/extensions/ext-history.js
+++ b/browser/components/extensions/ext-history.js
@@ -110,17 +110,17 @@ function getObserver() {
           typedCount: typed,
         };
         this.emit("visited", data);
       },
       onBeginUpdateBatch: function() {},
       onEndUpdateBatch: function() {},
       onTitleChanged: function() {},
       onClearHistory: function() {
-        this.emit("visitRemoved", {allHistory: true});
+        this.emit("visitRemoved", {allHistory: true, urls: []});
       },
       onPageChanged: function() {},
       onFrecencyChanged: function() {},
       onManyFrecenciesChanged: function() {},
       onDeleteVisits: function(uri, time, guid, reason) {
         this.emit("visitRemoved", {allHistory: false, urls: [uri.spec]});
       },
     };
--- a/browser/components/extensions/schemas/history.json
+++ b/browser/components/extensions/schemas/history.json
@@ -311,17 +311,16 @@
             "type": "object",
             "properties": {
               "allHistory": {
                 "type": "boolean",
                 "description": "True if all history was removed.  If true, then urls will be empty."
               },
               "urls": {
                 "type": "array",
-                "optional": true,
                 "items": {
                   "type": "string"
                 }
               }
             }
           }
         ]
       }
--- a/browser/components/extensions/test/xpcshell/test_ext_history.js
+++ b/browser/components/extensions/test/xpcshell/test_ext_history.js
@@ -12,16 +12,17 @@ XPCOMUtils.defineLazyModuleGetter(this, 
 add_task(function* test_delete() {
   function background() {
     let historyClearedCount = 0;
     let removedUrls = [];
 
     browser.history.onVisitRemoved.addListener(data => {
       if (data.allHistory) {
         historyClearedCount++;
+        browser.test.assertEq(0, data.urls.length, "onVisitRemoved received an empty urls array");
       } else {
         browser.test.assertEq(1, data.urls.length, "onVisitRemoved received one URL");
         removedUrls.push(data.urls[0]);
       }
     });
 
     browser.test.onMessage.addListener((msg, arg) => {
       if (msg === "delete-url") {