Bug 1262639 - Fix NS_ERROR_ILLEGAL_VALUE spam by not run getLivemark without valid node id; r?mak draft
authorgasolin <gasolin@gmail.com>
Wed, 20 Apr 2016 17:38:54 +0800
changeset 354205 8bb709d04b54ee26ce690b30b4be55c66bf8a5fc
parent 354111 8bcb31d3dfcaae0bbcdc53708a685cc3b4c5c628
child 518926 f11e5620c3e3f44899672354bf7af4206a693910
push id15993
push userbmo:gasolin@mozilla.com
push dateWed, 20 Apr 2016 09:40:20 +0000
reviewersmak
bugs1262639
milestone48.0a1
Bug 1262639 - Fix NS_ERROR_ILLEGAL_VALUE spam by not run getLivemark without valid node id; r?mak MozReview-Commit-ID: HgLHJ1vdYVi
browser/components/places/content/treeView.js
--- a/browser/components/places/content/treeView.js
+++ b/browser/components/places/content/treeView.js
@@ -877,34 +877,35 @@ PlacesTreeView.prototype = {
     this.invalidateContainer(aNode);
 
     if (PlacesUtils.nodeIsFolder(aNode) ||
         (this._flatList && aNode == this._rootNode)) {
       let queryOptions = PlacesUtils.asQuery(this._rootNode).queryOptions;
       if (queryOptions.excludeItems) {
         return;
       }
-
-      PlacesUtils.livemarks.getLivemark({ id: aNode.itemId })
-        .then(aLivemark => {
-          let shouldInvalidate =
-            !this._controller.hasCachedLivemarkInfo(aNode);
-          this._controller.cacheLivemarkInfo(aNode, aLivemark);
-          if (aNewState == Components.interfaces.nsINavHistoryContainerResultNode.STATE_OPENED) {
-            aLivemark.registerForUpdates(aNode, this);
-            // Prioritize the current livemark.
-            aLivemark.reload();
-            PlacesUtils.livemarks.reloadLivemarks();
-            if (shouldInvalidate)
-              this.invalidateContainer(aNode);
-          }
-          else {
-            aLivemark.unregisterForUpdates(aNode);
-          }
-        }, () => undefined);
+      if (aNode.itemId != -1) { // run when there's a valid node id
+        PlacesUtils.livemarks.getLivemark({ id: aNode.itemId })
+          .then(aLivemark => {
+            let shouldInvalidate =
+              !this._controller.hasCachedLivemarkInfo(aNode);
+            this._controller.cacheLivemarkInfo(aNode, aLivemark);
+            if (aNewState == Components.interfaces.nsINavHistoryContainerResultNode.STATE_OPENED) {
+              aLivemark.registerForUpdates(aNode, this);
+              // Prioritize the current livemark.
+              aLivemark.reload();
+              PlacesUtils.livemarks.reloadLivemarks();
+              if (shouldInvalidate)
+                this.invalidateContainer(aNode);
+            }
+            else {
+              aLivemark.unregisterForUpdates(aNode);
+            }
+          }, () => undefined);
+      }
     }
   },
 
   invalidateContainer: function PTV_invalidateContainer(aContainer) {
     NS_ASSERT(this._result, "Need to have a result to update");
     if (!this._tree)
       return;