зеркало из https://github.com/mozilla/gecko-dev.git
Bug 969318 - Mute "A promise chain failed to handle a rejection" error from the livemarks service. r=mano
This commit is contained in:
Родитель
ca3d47fa75
Коммит
784031cd19
|
@ -167,7 +167,7 @@ DistributionCustomizer.prototype = {
|
|||
, index: index
|
||||
, feedURI: this._makeURI(items[iid]["feedLink"])
|
||||
, siteURI: this._makeURI(items[iid]["siteLink"])
|
||||
});
|
||||
}).then(null, Cu.reportError);
|
||||
break;
|
||||
|
||||
case "bookmark":
|
||||
|
|
|
@ -251,24 +251,20 @@ var BookmarkPropertiesPanel = {
|
|||
|
||||
case "folder":
|
||||
this._itemType = BOOKMARK_FOLDER;
|
||||
PlacesUtils.livemarks.getLivemark(
|
||||
{ id: this._itemId },
|
||||
(function (aStatus, aLivemark) {
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
this._itemType = LIVEMARK_CONTAINER;
|
||||
this._feedURI = aLivemark.feedURI;
|
||||
this._siteURI = aLivemark.siteURI;
|
||||
this._fillEditProperties();
|
||||
PlacesUtils.livemarks.getLivemark({ id: this._itemId })
|
||||
.then(aLivemark => {
|
||||
this._itemType = LIVEMARK_CONTAINER;
|
||||
this._feedURI = aLivemark.feedURI;
|
||||
this._siteURI = aLivemark.siteURI;
|
||||
this._fillEditProperties();
|
||||
|
||||
let acceptButton = document.documentElement.getButton("accept");
|
||||
acceptButton.disabled = !this._inputIsValid();
|
||||
let acceptButton = document.documentElement.getButton("accept");
|
||||
acceptButton.disabled = !this._inputIsValid();
|
||||
|
||||
let newHeight = window.outerHeight +
|
||||
this._element("descriptionField").boxObject.height;
|
||||
window.resizeTo(window.outerWidth, newHeight);
|
||||
}
|
||||
}).bind(this)
|
||||
);
|
||||
let newHeight = window.outerHeight +
|
||||
this._element("descriptionField").boxObject.height;
|
||||
window.resizeTo(window.outerWidth, newHeight);
|
||||
}, () => undefined);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -317,21 +317,17 @@ PlacesViewBase.prototype = {
|
|||
element.setAttribute("hostContainer", "true");
|
||||
}
|
||||
else if (itemId != -1) {
|
||||
PlacesUtils.livemarks.getLivemark(
|
||||
{ id: itemId },
|
||||
function (aStatus, aLivemark) {
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
element.setAttribute("livemark", "true");
|
||||
PlacesUtils.livemarks.getLivemark({ id: itemId })
|
||||
.then(aLivemark => {
|
||||
element.setAttribute("livemark", "true");
|
||||
#ifdef XP_MACOSX
|
||||
// OS X native menubar doesn't track list-style-images since
|
||||
// it doesn't have a frame (bug 733415). Thus enforce updating.
|
||||
element.setAttribute("image", "");
|
||||
element.removeAttribute("image");
|
||||
// OS X native menubar doesn't track list-style-images since
|
||||
// it doesn't have a frame (bug 733415). Thus enforce updating.
|
||||
element.setAttribute("image", "");
|
||||
element.removeAttribute("image");
|
||||
#endif
|
||||
this.controller.cacheLivemarkInfo(aPlacesNode, aLivemark);
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
this.controller.cacheLivemarkInfo(aPlacesNode, aLivemark);
|
||||
}, () => undefined);
|
||||
}
|
||||
|
||||
let popup = document.createElement("menupopup");
|
||||
|
@ -509,16 +505,12 @@ PlacesViewBase.prototype = {
|
|||
#endif
|
||||
}
|
||||
|
||||
PlacesUtils.livemarks.getLivemark(
|
||||
{ id: aPlacesNode.itemId },
|
||||
function (aStatus, aLivemark) {
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
// Controller will use this to build the meta data for the node.
|
||||
this.controller.cacheLivemarkInfo(aPlacesNode, aLivemark);
|
||||
this.invalidateContainer(aPlacesNode);
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
PlacesUtils.livemarks.getLivemark({ id: aPlacesNode.itemId })
|
||||
.then(aLivemark => {
|
||||
// Controller will use this to build the meta data for the node.
|
||||
this.controller.cacheLivemarkInfo(aPlacesNode, aLivemark);
|
||||
this.invalidateContainer(aPlacesNode);
|
||||
}, () => undefined);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -647,26 +639,23 @@ PlacesViewBase.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
PlacesUtils.livemarks.getLivemark({ id: aPlacesNode.itemId },
|
||||
function (aStatus, aLivemark) {
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
let shouldInvalidate =
|
||||
!this.controller.hasCachedLivemarkInfo(aPlacesNode);
|
||||
this.controller.cacheLivemarkInfo(aPlacesNode, aLivemark);
|
||||
if (aNewState == Ci.nsINavHistoryContainerResultNode.STATE_OPENED) {
|
||||
aLivemark.registerForUpdates(aPlacesNode, this);
|
||||
// Prioritize the current livemark.
|
||||
aLivemark.reload();
|
||||
PlacesUtils.livemarks.reloadLivemarks();
|
||||
if (shouldInvalidate)
|
||||
this.invalidateContainer(aPlacesNode);
|
||||
}
|
||||
else {
|
||||
aLivemark.unregisterForUpdates(aPlacesNode);
|
||||
}
|
||||
PlacesUtils.livemarks.getLivemark({ id: aPlacesNode.itemId })
|
||||
.then(aLivemark => {
|
||||
let shouldInvalidate =
|
||||
!this.controller.hasCachedLivemarkInfo(aPlacesNode);
|
||||
this.controller.cacheLivemarkInfo(aPlacesNode, aLivemark);
|
||||
if (aNewState == Ci.nsINavHistoryContainerResultNode.STATE_OPENED) {
|
||||
aLivemark.registerForUpdates(aPlacesNode, this);
|
||||
// Prioritize the current livemark.
|
||||
aLivemark.reload();
|
||||
PlacesUtils.livemarks.reloadLivemarks();
|
||||
if (shouldInvalidate)
|
||||
this.invalidateContainer(aPlacesNode);
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
else {
|
||||
aLivemark.unregisterForUpdates(aPlacesNode);
|
||||
}
|
||||
}, () => undefined);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -678,10 +667,10 @@ PlacesViewBase.prototype = {
|
|||
if (aPopup._startMarker.nextSibling == aPopup._endMarker)
|
||||
this._setLivemarkStatusMenuItem(aPopup, Ci.mozILivemark.STATUS_LOADING);
|
||||
|
||||
PlacesUtils.livemarks.getLivemark({ id: aPopup._placesNode.itemId },
|
||||
function (aStatus, aLivemark) {
|
||||
PlacesUtils.livemarks.getLivemark({ id: aPopup._placesNode.itemId })
|
||||
.then(aLivemark => {
|
||||
let placesNode = aPopup._placesNode;
|
||||
if (!Components.isSuccessCode(aStatus) || !placesNode.containerOpen)
|
||||
if (!placesNode.containerOpen)
|
||||
return;
|
||||
|
||||
if (aLivemark.status != Ci.mozILivemark.STATUS_LOADING)
|
||||
|
@ -698,8 +687,7 @@ PlacesViewBase.prototype = {
|
|||
else
|
||||
this._getDOMNodeForPlacesNode(child).removeAttribute("visited");
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
}, Components.utils.reportError);
|
||||
},
|
||||
|
||||
invalidateContainer: function PVB_invalidateContainer(aPlacesNode) {
|
||||
|
@ -1008,15 +996,11 @@ PlacesToolbar.prototype = {
|
|||
button.setAttribute("tagContainer", "true");
|
||||
}
|
||||
else if (PlacesUtils.nodeIsFolder(aChild)) {
|
||||
PlacesUtils.livemarks.getLivemark(
|
||||
{ id: aChild.itemId },
|
||||
function (aStatus, aLivemark) {
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
button.setAttribute("livemark", "true");
|
||||
this.controller.cacheLivemarkInfo(aChild, aLivemark);
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
PlacesUtils.livemarks.getLivemark({ id: aChild.itemId })
|
||||
.then(aLivemark => {
|
||||
button.setAttribute("livemark", "true");
|
||||
this.controller.cacheLivemarkInfo(aChild, aLivemark);
|
||||
}, () => undefined);
|
||||
}
|
||||
|
||||
let popup = document.createElement("menupopup");
|
||||
|
@ -1268,15 +1252,11 @@ PlacesToolbar.prototype = {
|
|||
if (aAnno == PlacesUtils.LMANNO_FEEDURI) {
|
||||
elt.setAttribute("livemark", true);
|
||||
|
||||
PlacesUtils.livemarks.getLivemark(
|
||||
{ id: aPlacesNode.itemId },
|
||||
function (aStatus, aLivemark) {
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
this.controller.cacheLivemarkInfo(aPlacesNode, aLivemark);
|
||||
this.invalidateContainer(aPlacesNode);
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
PlacesUtils.livemarks.getLivemark({ id: aPlacesNode.itemId })
|
||||
.then(aLivemark => {
|
||||
this.controller.cacheLivemarkInfo(aPlacesNode, aLivemark);
|
||||
this.invalidateContainer(aPlacesNode);
|
||||
}, Components.utils.reportError);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1840,15 +1820,11 @@ PlacesPanelMenuView.prototype = {
|
|||
button.setAttribute("tagContainer", "true");
|
||||
}
|
||||
else if (PlacesUtils.nodeIsFolder(aChild)) {
|
||||
PlacesUtils.livemarks.getLivemark(
|
||||
{ id: aChild.itemId },
|
||||
function (aStatus, aLivemark) {
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
button.setAttribute("livemark", "true");
|
||||
this.controller.cacheLivemarkInfo(aChild, aLivemark);
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
PlacesUtils.livemarks.getLivemark({ id: aChild.itemId })
|
||||
.then(aLivemark => {
|
||||
button.setAttribute("livemark", "true");
|
||||
this.controller.cacheLivemarkInfo(aChild, aLivemark);
|
||||
}, () => undefined);
|
||||
}
|
||||
}
|
||||
else if (PlacesUtils.nodeIsURI(aChild)) {
|
||||
|
@ -1912,15 +1888,11 @@ PlacesPanelMenuView.prototype = {
|
|||
if (aAnno == PlacesUtils.LMANNO_FEEDURI) {
|
||||
elt.setAttribute("livemark", true);
|
||||
|
||||
PlacesUtils.livemarks.getLivemark(
|
||||
{ id: aPlacesNode.itemId },
|
||||
function (aStatus, aLivemark) {
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
this.controller.cacheLivemarkInfo(aPlacesNode, aLivemark);
|
||||
this.invalidateContainer(aPlacesNode);
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
PlacesUtils.livemarks.getLivemark({ id: aPlacesNode.itemId })
|
||||
.then(aLivemark => {
|
||||
this.controller.cacheLivemarkInfo(aPlacesNode, aLivemark);
|
||||
this.invalidateContainer(aPlacesNode);
|
||||
}, Components.utils.reportError);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -694,14 +694,10 @@ PlacesController.prototype = {
|
|||
var selectedNode = this._view.selectedNode;
|
||||
if (selectedNode) {
|
||||
let itemId = selectedNode.itemId;
|
||||
PlacesUtils.livemarks.getLivemark(
|
||||
{ id: itemId },
|
||||
(function(aStatus, aLivemark) {
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
aLivemark.reload(true);
|
||||
}
|
||||
}).bind(this)
|
||||
);
|
||||
PlacesUtils.livemarks.getLivemark({ id: itemId })
|
||||
.then(aLivemark => {
|
||||
aLivemark.reload(true);
|
||||
}, Components.utils.reportError);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -147,17 +147,13 @@ var gEditItemOverlay = {
|
|||
else {
|
||||
this._uri = null;
|
||||
this._isLivemark = false;
|
||||
PlacesUtils.livemarks.getLivemark(
|
||||
{id: this._itemId },
|
||||
(function (aStatus, aLivemark) {
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
this._isLivemark = true;
|
||||
this._initTextField("feedLocationField", aLivemark.feedURI.spec, true);
|
||||
this._initTextField("siteLocationField", aLivemark.siteURI ? aLivemark.siteURI.spec : "", true);
|
||||
this._showHideRows();
|
||||
}
|
||||
}).bind(this)
|
||||
);
|
||||
PlacesUtils.livemarks.getLivemark({id: this._itemId })
|
||||
.then(aLivemark => {
|
||||
this._isLivemark = true;
|
||||
this._initTextField("feedLocationField", aLivemark.feedURI.spec, true);
|
||||
this._initTextField("siteLocationField", aLivemark.siteURI ? aLivemark.siteURI.spec : "", true);
|
||||
this._showHideRows();
|
||||
}, () => undefined);
|
||||
}
|
||||
|
||||
// folder picker
|
||||
|
|
|
@ -786,11 +786,11 @@ PlacesTreeView.prototype = {
|
|||
},
|
||||
|
||||
_populateLivemarkContainer: function PTV__populateLivemarkContainer(aNode) {
|
||||
PlacesUtils.livemarks.getLivemark({ id: aNode.itemId },
|
||||
function (aStatus, aLivemark) {
|
||||
PlacesUtils.livemarks.getLivemark({ id: aNode.itemId })
|
||||
.then(aLivemark => {
|
||||
let placesNode = aNode;
|
||||
// Need to check containerOpen since getLivemark is async.
|
||||
if (!Components.isSuccessCode(aStatus) || !placesNode.containerOpen)
|
||||
if (!placesNode.containerOpen)
|
||||
return;
|
||||
|
||||
let children = aLivemark.getNodesForContainer(placesNode);
|
||||
|
@ -798,7 +798,7 @@ PlacesTreeView.prototype = {
|
|||
let child = children[i];
|
||||
this.nodeInserted(placesNode, child, i);
|
||||
}
|
||||
}.bind(this));
|
||||
}, Components.utils.reportError);
|
||||
},
|
||||
|
||||
nodeTitleChanged: function PTV_nodeTitleChanged(aNode, aNewTitle) {
|
||||
|
@ -847,19 +847,15 @@ PlacesTreeView.prototype = {
|
|||
this._invalidateCellValue(aNode, this.COLUMN_TYPE_DESCRIPTION);
|
||||
}
|
||||
else if (aAnno == PlacesUtils.LMANNO_FEEDURI) {
|
||||
PlacesUtils.livemarks.getLivemark(
|
||||
{ id: aNode.itemId },
|
||||
function (aStatus, aLivemark) {
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
this._controller.cacheLivemarkInfo(aNode, aLivemark);
|
||||
let properties = this._cellProperties.get(aNode);
|
||||
this._cellProperties.set(aNode, properties += " livemark ");
|
||||
PlacesUtils.livemarks.getLivemark({ id: aNode.itemId })
|
||||
.then(aLivemark => {
|
||||
this._controller.cacheLivemarkInfo(aNode, aLivemark);
|
||||
let properties = this._cellProperties.get(aNode);
|
||||
this._cellProperties.set(aNode, properties += " livemark ");
|
||||
|
||||
// The livemark attribute is set as a cell property on the title cell.
|
||||
this._invalidateCellValue(aNode, this.COLUMN_TYPE_TITLE);
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
// The livemark attribute is set as a cell property on the title cell.
|
||||
this._invalidateCellValue(aNode, this.COLUMN_TYPE_TITLE);
|
||||
}, Components.utils.reportError);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -883,26 +879,23 @@ PlacesTreeView.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
PlacesUtils.livemarks.getLivemark({ id: aNode.itemId },
|
||||
function (aStatus, aLivemark) {
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
else {
|
||||
aLivemark.unregisterForUpdates(aNode);
|
||||
}
|
||||
}, () => undefined);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1174,17 +1167,13 @@ PlacesTreeView.prototype = {
|
|||
properties += " livemark";
|
||||
}
|
||||
else {
|
||||
PlacesUtils.livemarks.getLivemark(
|
||||
{ id: node.itemId },
|
||||
function (aStatus, aLivemark) {
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
this._controller.cacheLivemarkInfo(node, aLivemark);
|
||||
properties += " livemark";
|
||||
// The livemark attribute is set as a cell property on the title cell.
|
||||
this._invalidateCellValue(node, this.COLUMN_TYPE_TITLE);
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
PlacesUtils.livemarks.getLivemark({ id: node.itemId })
|
||||
.then(aLivemark => {
|
||||
this._controller.cacheLivemarkInfo(node, aLivemark);
|
||||
properties += " livemark";
|
||||
// The livemark attribute is set as a cell property on the title cell.
|
||||
this._invalidateCellValue(node, this.COLUMN_TYPE_TITLE);
|
||||
}, () => undefined);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -731,10 +731,10 @@ BookmarksStore.prototype = {
|
|||
feedURI: Utils.makeURI(record.feedUri),
|
||||
siteURI: siteURI,
|
||||
guid: record.id};
|
||||
PlacesUtils.livemarks.addLivemark(livemarkObj,
|
||||
function (aStatus, aLivemark) {
|
||||
spinningCb(null, [aStatus, aLivemark]);
|
||||
});
|
||||
PlacesUtils.livemarks.addLivemark(livemarkObj).then(
|
||||
aLivemark => { spinningCb(null, [Components.results.NS_OK, aLivemark]) },
|
||||
() => { spinningCb(null, [Components.results.NS_ERROR_UNEXPECTED, aLivemark]) }
|
||||
);
|
||||
|
||||
let [status, livemark] = spinningCb.wait();
|
||||
if (!Components.isSuccessCode(status)) {
|
||||
|
|
|
@ -784,10 +784,10 @@ Livemark.prototype = {
|
|||
// Until this can handle asynchronous creation, we need to spin.
|
||||
let spinningCb = Async.makeSpinningCallback();
|
||||
|
||||
PlacesUtils.livemarks.addLivemark(livemarkObj,
|
||||
function (aStatus, aLivemark) {
|
||||
spinningCb(null, [aStatus, aLivemark]);
|
||||
});
|
||||
PlacesUtils.livemarks.addLivemark(livemarkObj).then(
|
||||
aLivemark => { spinningCb(null, [Components.results.NS_OK, aLivemark]) },
|
||||
() => { spinningCb(null, [Components.results.NS_ERROR_UNEXPECTED, aLivemark]) }
|
||||
);
|
||||
|
||||
let [status, livemark] = spinningCb.wait();
|
||||
if (!Components.isSuccessCode(status)) {
|
||||
|
|
|
@ -669,7 +669,7 @@ BookmarkImporter.prototype = {
|
|||
"index": PlacesUtils.bookmarks.DEFAULT_INDEX,
|
||||
"feedURI": frame.previousFeed,
|
||||
"siteURI": frame.previousLink,
|
||||
});
|
||||
}).then(null, Cu.reportError);
|
||||
} else if (frame.previousLink) {
|
||||
// This is a common bookmark.
|
||||
PlacesUtils.bookmarks.setItemTitle(frame.previousId,
|
||||
|
|
|
@ -386,15 +386,13 @@ BookmarkImporter.prototype = {
|
|||
index: aIndex,
|
||||
lastModified: aData.lastModified,
|
||||
siteURI: siteURI
|
||||
}, function(aStatus, aLivemark) {
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
let id = aLivemark.id;
|
||||
if (aData.dateAdded)
|
||||
PlacesUtils.bookmarks.setItemDateAdded(id, aData.dateAdded);
|
||||
if (aData.annos && aData.annos.length)
|
||||
PlacesUtils.setAnnotationsForItem(id, aData.annos);
|
||||
}
|
||||
});
|
||||
}).then(function (aLivemark) {
|
||||
let id = aLivemark.id;
|
||||
if (aData.dateAdded)
|
||||
PlacesUtils.bookmarks.setItemDateAdded(id, aData.dateAdded);
|
||||
if (aData.annos && aData.annos.length)
|
||||
PlacesUtils.setAnnotationsForItem(id, aData.annos);
|
||||
}, Cu.reportError);
|
||||
}
|
||||
} else {
|
||||
id = PlacesUtils.bookmarks.createFolder(
|
||||
|
|
|
@ -2195,29 +2195,23 @@ PlacesCreateLivemarkTransaction.prototype = {
|
|||
, parentId: this.item.parentId
|
||||
, index: this.item.index
|
||||
, siteURI: this.item.siteURI
|
||||
},
|
||||
(function(aStatus, aLivemark) {
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
this.item.id = aLivemark.id;
|
||||
if (this.item.annotations && this.item.annotations.length > 0) {
|
||||
PlacesUtils.setAnnotationsForItem(this.item.id,
|
||||
this.item.annotations);
|
||||
}
|
||||
}).then(aLivemark => {
|
||||
this.item.id = aLivemark.id;
|
||||
if (this.item.annotations && this.item.annotations.length > 0) {
|
||||
PlacesUtils.setAnnotationsForItem(this.item.id,
|
||||
this.item.annotations);
|
||||
}
|
||||
}).bind(this)
|
||||
);
|
||||
}, Cu.reportError);
|
||||
},
|
||||
|
||||
undoTransaction: function CLTXN_undoTransaction()
|
||||
{
|
||||
// The getLivemark callback is expected to receive a failure status but it
|
||||
// is used just to serialize, so doesn't matter.
|
||||
PlacesUtils.livemarks.getLivemark(
|
||||
{ id: this.item.id },
|
||||
(function (aStatus, aLivemark) {
|
||||
PlacesUtils.livemarks.getLivemark({ id: this.item.id })
|
||||
.then(null, () => {
|
||||
PlacesUtils.bookmarks.removeItem(this.item.id);
|
||||
}).bind(this)
|
||||
);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2255,17 +2249,12 @@ PlacesRemoveLivemarkTransaction.prototype = {
|
|||
|
||||
doTransaction: function RLTXN_doTransaction()
|
||||
{
|
||||
PlacesUtils.livemarks.getLivemark(
|
||||
{ id: this.item.id },
|
||||
(function (aStatus, aLivemark) {
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
this.item.feedURI = aLivemark.feedURI;
|
||||
this.item.siteURI = aLivemark.siteURI;
|
||||
|
||||
PlacesUtils.bookmarks.removeItem(this.item.id);
|
||||
}
|
||||
}).bind(this)
|
||||
);
|
||||
PlacesUtils.livemarks.getLivemark({ id: this.item.id })
|
||||
.then(aLivemark => {
|
||||
this.item.feedURI = aLivemark.feedURI;
|
||||
this.item.siteURI = aLivemark.siteURI;
|
||||
PlacesUtils.bookmarks.removeItem(this.item.id);
|
||||
}, Cu.reportError);
|
||||
},
|
||||
|
||||
undoTransaction: function RLTXN_undoTransaction()
|
||||
|
@ -2274,26 +2263,21 @@ PlacesRemoveLivemarkTransaction.prototype = {
|
|||
// feedURI and siteURI of the livemark.
|
||||
// The getLivemark callback is expected to receive a failure status but it
|
||||
// is used just to serialize, so doesn't matter.
|
||||
PlacesUtils.livemarks.getLivemark(
|
||||
{ id: this.item.id },
|
||||
(function () {
|
||||
let addLivemarkCallback = (function(aStatus, aLivemark) {
|
||||
if (Components.isSuccessCode(aStatus)) {
|
||||
let itemId = aLivemark.id;
|
||||
PlacesUtils.bookmarks.setItemDateAdded(itemId, this.item.dateAdded);
|
||||
PlacesUtils.setAnnotationsForItem(itemId, this.item.annotations);
|
||||
}
|
||||
}).bind(this);
|
||||
PlacesUtils.livemarks.getLivemark({ id: this.item.id })
|
||||
.then(null, () => {
|
||||
PlacesUtils.livemarks.addLivemark({ parentId: this.item.parentId
|
||||
, title: this.item.title
|
||||
, siteURI: this.item.siteURI
|
||||
, feedURI: this.item.feedURI
|
||||
, index: this.item.index
|
||||
, lastModified: this.item.lastModified
|
||||
},
|
||||
addLivemarkCallback);
|
||||
}).bind(this)
|
||||
);
|
||||
}).then(
|
||||
aLivemark => {
|
||||
let itemId = aLivemark.id;
|
||||
PlacesUtils.bookmarks.setItemDateAdded(itemId, this.item.dateAdded);
|
||||
PlacesUtils.setAnnotationsForItem(itemId, this.item.annotations);
|
||||
}, Cu.reportError);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -27,6 +27,9 @@ interface mozIAsyncLivemarks : nsISupports
|
|||
* @return {Promise}
|
||||
* @throws NS_ERROR_INVALID_ARG if the supplied information is insufficient
|
||||
* for the creation.
|
||||
* @deprecated passing a callback is deprecated. Moreover, for backwards
|
||||
* compatibility reasons, when a callback is provided this method
|
||||
* won't return a promise.
|
||||
*/
|
||||
jsval addLivemark(in jsval aLivemarkInfo,
|
||||
[optional] in mozILivemarkCallback aCallback);
|
||||
|
@ -43,6 +46,9 @@ interface mozIAsyncLivemarks : nsISupports
|
|||
*
|
||||
* @return {Promise}
|
||||
* @throws NS_ERROR_INVALID_ARG if the id/guid is invalid.
|
||||
* @deprecated passing a callback is deprecated. Moreover, for backwards
|
||||
* compatibility reasons, when a callback is provided this method
|
||||
* won't return a promise.
|
||||
*/
|
||||
jsval removeLivemark(in jsval aLivemarkInfo,
|
||||
[optional] in mozILivemarkCallback aCallback);
|
||||
|
@ -60,6 +66,9 @@ interface mozIAsyncLivemarks : nsISupports
|
|||
* @return {Promise}
|
||||
* @throws NS_ERROR_INVALID_ARG if the id/guid is invalid or an invalid
|
||||
* callback is provided.
|
||||
* @deprecated passing a callback is deprecated. Moreover, for backwards
|
||||
* compatibility reasons, when a callback is provided this method
|
||||
* won't return a promise.
|
||||
*/
|
||||
jsval getLivemark(in jsval aLivemarkInfo,
|
||||
[optional] in mozILivemarkCallback aCallback);
|
||||
|
|
|
@ -18,6 +18,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
|
|||
"resource://gre/modules/NetUtil.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
|
||||
"resource://gre/modules/Promise.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Deprecated",
|
||||
"resource://gre/modules/Deprecated.jsm");
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// Services
|
||||
|
@ -212,6 +214,12 @@ LivemarkService.prototype = {
|
|||
throw Cr.NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (aLivemarkCallback) {
|
||||
Deprecated.warning("Passing a callback to Livermarks methods is deprecated. " +
|
||||
"Please use the returned promise instead.",
|
||||
"https://developer.mozilla.org/docs/Mozilla/JavaScript_code_modules/Promise.jsm");
|
||||
}
|
||||
|
||||
// The addition is done synchronously due to the fact importExport service
|
||||
// and JSON backups require that. The notification is async though.
|
||||
// Once bookmarks are async, this may be properly fixed.
|
||||
|
@ -258,8 +266,9 @@ LivemarkService.prototype = {
|
|||
aLivemarkCallback.onCompletion(addLivemarkEx.result, livemark);
|
||||
}
|
||||
catch(ex2) { }
|
||||
} else {
|
||||
deferred.reject(addLivemarkEx);
|
||||
}
|
||||
deferred.reject(addLivemarkEx);
|
||||
}
|
||||
else {
|
||||
if (aLivemarkCallback) {
|
||||
|
@ -267,13 +276,14 @@ LivemarkService.prototype = {
|
|||
aLivemarkCallback.onCompletion(Cr.NS_OK, livemark);
|
||||
}
|
||||
catch(ex2) { }
|
||||
} else {
|
||||
deferred.resolve(livemark);
|
||||
}
|
||||
deferred.resolve(livemark);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
return aLivemarkCallback ? null : deferred.promise;
|
||||
},
|
||||
|
||||
removeLivemark: function LS_removeLivemark(aLivemarkInfo, aLivemarkCallback)
|
||||
|
@ -290,6 +300,12 @@ LivemarkService.prototype = {
|
|||
throw Cr.NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (aLivemarkCallback) {
|
||||
Deprecated.warning("Passing a callback to Livermarks methods is deprecated. " +
|
||||
"Please use the returned promise instead.",
|
||||
"https://developer.mozilla.org/docs/Mozilla/JavaScript_code_modules/Promise.jsm");
|
||||
}
|
||||
|
||||
// Convert the guid to an id.
|
||||
if (id in this._guids) {
|
||||
id = this._guids[id];
|
||||
|
@ -314,8 +330,9 @@ LivemarkService.prototype = {
|
|||
aLivemarkCallback.onCompletion(removeLivemarkEx.result, null);
|
||||
}
|
||||
catch(ex2) { }
|
||||
} else {
|
||||
deferred.reject(removeLivemarkEx);
|
||||
}
|
||||
deferred.reject(removeLivemarkEx);
|
||||
}
|
||||
else {
|
||||
if (aLivemarkCallback) {
|
||||
|
@ -323,13 +340,14 @@ LivemarkService.prototype = {
|
|||
aLivemarkCallback.onCompletion(Cr.NS_OK, null);
|
||||
}
|
||||
catch(ex2) { }
|
||||
} else {
|
||||
deferred.resolve();
|
||||
}
|
||||
deferred.resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
return aLivemarkCallback ? null : deferred.promise;
|
||||
},
|
||||
|
||||
_reloaded: [],
|
||||
|
@ -380,6 +398,12 @@ LivemarkService.prototype = {
|
|||
throw Cr.NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (aLivemarkCallback) {
|
||||
Deprecated.warning("Passing a callback to Livermarks methods is deprecated. " +
|
||||
"Please use the returned promise instead.",
|
||||
"https://developer.mozilla.org/docs/Mozilla/JavaScript_code_modules/Promise.jsm");
|
||||
}
|
||||
|
||||
let deferred = Promise.defer();
|
||||
this._onCacheReady( () => {
|
||||
// Convert the guid to an id.
|
||||
|
@ -391,20 +415,22 @@ LivemarkService.prototype = {
|
|||
try {
|
||||
aLivemarkCallback.onCompletion(Cr.NS_OK, this._livemarks[id]);
|
||||
} catch (ex) {}
|
||||
} else {
|
||||
deferred.resolve(this._livemarks[id]);
|
||||
}
|
||||
deferred.resolve(this._livemarks[id]);
|
||||
}
|
||||
else {
|
||||
if (aLivemarkCallback) {
|
||||
try {
|
||||
aLivemarkCallback.onCompletion(Cr.NS_ERROR_INVALID_ARG, null);
|
||||
} catch (ex) { }
|
||||
} else {
|
||||
deferred.reject(Components.Exception("", Cr.NS_ERROR_INVALID_ARG));
|
||||
}
|
||||
deferred.reject(Components.Exception("", Cr.NS_ERROR_INVALID_ARG));
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
return aLivemarkCallback ? null : deferred.promise;
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -55,10 +55,8 @@ function runTest()
|
|||
, index: PlacesUtils.bookmarks.DEFAULT_INDEX
|
||||
, feedURI: aLivemarkData.feedURI
|
||||
, siteURI: aLivemarkData.siteURI
|
||||
},
|
||||
function (aStatus, aLivemark) {
|
||||
ok(Components.isSuccessCode(aStatus), "Get livemark");
|
||||
|
||||
})
|
||||
.then(function (aLivemark) {
|
||||
is (aLivemark.feedURI.spec, aLivemarkData.feedURI.spec,
|
||||
"Get correct feedURI");
|
||||
if (aLivemarkData.siteURI) {
|
||||
|
@ -84,8 +82,10 @@ function runTest()
|
|||
SimpleTest.finish();
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
is(true, false, "Should not fail adding a livemark");
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
LIVEMARKS.forEach(testLivemark);
|
||||
|
|
|
@ -37,9 +37,8 @@ function runTest() {
|
|||
, index: PlacesUtils.bookmarks.DEFAULT_INDEX
|
||||
, feedURI: NetUtil.newURI(FEEDSPEC)
|
||||
, siteURI: NetUtil.newURI(INITIALSITESPEC)
|
||||
},
|
||||
function (aStatus, aLivemark) {
|
||||
ok(Components.isSuccessCode(aStatus), "Get livemark");
|
||||
})
|
||||
.then(function (aLivemark) {
|
||||
is(aLivemark.siteURI.spec, INITIALSITESPEC,
|
||||
"Has correct initial livemark site URI");
|
||||
|
||||
|
@ -50,6 +49,8 @@ function runTest() {
|
|||
PlacesUtils.bookmarks.removeItem(aLivemark.id);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}, function () {
|
||||
is(true, false, "Should not fail adding a livemark");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -35,9 +35,8 @@ function runTest() {
|
|||
, parentId: PlacesUtils.toolbarFolderId
|
||||
, index: PlacesUtils.bookmarks.DEFAULT_INDEX
|
||||
, feedURI: NetUtil.newURI(FEEDSPEC)
|
||||
},
|
||||
function (aStatus, aLivemark) {
|
||||
ok(Components.isSuccessCode(aStatus), "Get livemark");
|
||||
})
|
||||
.then(function (aLivemark) {
|
||||
is(aLivemark.siteURI, null, "Has null livemark site URI");
|
||||
|
||||
waitForLivemarkLoad(aLivemark, function (aLivemark) {
|
||||
|
@ -47,6 +46,8 @@ function runTest() {
|
|||
PlacesUtils.bookmarks.removeItem(aLivemark.id);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}, function () {
|
||||
is(true, false, "Should not fail adding a livemark");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -36,10 +36,8 @@ function runTest() {
|
|||
, index: PlacesUtils.bookmarks.DEFAULT_INDEX
|
||||
, feedURI: NetUtil.newURI(FEEDSPEC)
|
||||
, siteURI: NetUtil.newURI("http:/mochi.test/")
|
||||
},
|
||||
function (aStatus, aLivemark) {
|
||||
ok(Components.isSuccessCode(aStatus), "Get livemark");
|
||||
|
||||
})
|
||||
.then(function (aLivemark) {
|
||||
waitForLivemarkLoad(aLivemark, function (aLivemark) {
|
||||
let nodes = aLivemark.getNodesForContainer({});
|
||||
|
||||
|
@ -52,6 +50,8 @@ function runTest() {
|
|||
PlacesUtils.bookmarks.removeItem(aLivemark.id);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}, function () {
|
||||
is(true, false, "Should not fail adding a livemark");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -35,13 +35,10 @@ function runTest() {
|
|||
, index: PlacesUtils.bookmarks.DEFAULT_INDEX
|
||||
, feedURI: NetUtil.newURI(FEEDSPEC)
|
||||
, siteURI: NetUtil.newURI("http:/mochi.test/")
|
||||
},
|
||||
function (aStatus, aLivemark) {
|
||||
ok(Components.isSuccessCode(aStatus), "Get livemark");
|
||||
|
||||
})
|
||||
.then(function (aLivemark) {
|
||||
waitForLivemarkLoad(aLivemark, function (aLivemark) {
|
||||
let nodes = aLivemark.getNodesForContainer({});
|
||||
ok(Components.isSuccessCode(aStatus), "Get livemark entries");
|
||||
|
||||
is(nodes[0].title, "The First Title",
|
||||
"livemark site URI set to value in feed");
|
||||
|
@ -49,6 +46,9 @@ function runTest() {
|
|||
PlacesUtils.bookmarks.removeItem(aLivemark.id);
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}, function () {
|
||||
is(true, false, "Should not fail adding a livemark");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -57,15 +57,18 @@ function addLivemarks(aCallback) {
|
|||
info("Adding livemarks");
|
||||
let count = gLivemarks.length;
|
||||
gLivemarks.forEach(function(aLivemarkData) {
|
||||
PlacesUtils.livemarks.addLivemark(aLivemarkData,
|
||||
function (aStatus, aLivemark) {
|
||||
ok(Components.isSuccessCode(aStatus), "Add livemark should succeed");
|
||||
PlacesUtils.livemarks.addLivemark(aLivemarkData)
|
||||
.then(function (aLivemark) {
|
||||
ok(aLivemark.feedURI.equals(aLivemarkData.feedURI), "Livemark added");
|
||||
aLivemarkData.id = aLivemark.id;
|
||||
if (--count == 0) {
|
||||
aCallback();
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
function () {
|
||||
is(true, false, "Should not fail adding a livemark.");
|
||||
aCallback();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -73,9 +76,9 @@ function reloadLivemarks(aForceUpdate, aCallback) {
|
|||
info("Reloading livemarks with forceUpdate: " + aForceUpdate);
|
||||
let count = gLivemarks.length;
|
||||
gLivemarks.forEach(function(aLivemarkData) {
|
||||
PlacesUtils.livemarks.getLivemark(aLivemarkData,
|
||||
function (aStatus, aLivemark) {
|
||||
ok(Components.isSuccessCode(aStatus), "Get livemark should succeed");
|
||||
PlacesUtils.livemarks.getLivemark(aLivemarkData)
|
||||
.then(aLivemark => {
|
||||
ok(aLivemark.feedURI.equals(aLivemarkData.feedURI), "Livemark found");
|
||||
aLivemarkData._observer = new resultObserver(aLivemark, function() {
|
||||
if (++count == gLivemarks.length) {
|
||||
aCallback();
|
||||
|
@ -84,6 +87,10 @@ function reloadLivemarks(aForceUpdate, aCallback) {
|
|||
if (--count == 0) {
|
||||
PlacesUtils.livemarks.reloadLivemarks(aForceUpdate);
|
||||
}
|
||||
},
|
||||
function() {
|
||||
is(true, false, "Should not fail getting a livemark.");
|
||||
aCallback();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -93,12 +100,15 @@ function removeLivemarks(aCallback) {
|
|||
info("Removing livemarks");
|
||||
let count = gLivemarks.length;
|
||||
gLivemarks.forEach(function(aLivemarkData) {
|
||||
PlacesUtils.livemarks.removeLivemark(aLivemarkData,
|
||||
function (aStatus, aLivemark) {
|
||||
ok(Components.isSuccessCode(aStatus), "Remove livemark should succeed");
|
||||
PlacesUtils.livemarks.removeLivemark(aLivemarkData).then(
|
||||
function (aLivemark) {
|
||||
if (--count == 0) {
|
||||
aCallback();
|
||||
}
|
||||
},
|
||||
function() {
|
||||
is(true, false, "Should not fail adding a livemark.");
|
||||
aCallback();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
@ -162,7 +162,7 @@ function task_populateDB(aArray)
|
|||
, index: qdata.index
|
||||
, feedURI: uri(qdata.feedURI)
|
||||
, siteURI: uri(qdata.uri)
|
||||
});
|
||||
}).then(null, do_throw);
|
||||
}
|
||||
|
||||
if (qdata.isBookmark) {
|
||||
|
|
|
@ -113,7 +113,7 @@ function populate() {
|
|||
|
||||
function validate() {
|
||||
yield testCanonicalBookmarks();
|
||||
testToolbarFolder();
|
||||
yield testToolbarFolder();
|
||||
testUnfiledBookmarks();
|
||||
testTags();
|
||||
}
|
||||
|
@ -217,16 +217,11 @@ function testToolbarFolder() {
|
|||
// title
|
||||
do_check_eq("Latest Headlines", livemark.title);
|
||||
|
||||
PlacesUtils.livemarks.getLivemark(
|
||||
{ id: livemark.itemId },
|
||||
function (aStatus, aLivemark) {
|
||||
do_check_true(Components.isSuccessCode(aStatus));
|
||||
do_check_eq("http://en-us.fxfeeds.mozilla.com/en-US/firefox/livebookmarks/",
|
||||
aLivemark.siteURI.spec);
|
||||
do_check_eq("http://en-us.fxfeeds.mozilla.com/en-US/firefox/headlines.xml",
|
||||
aLivemark.feedURI.spec);
|
||||
}
|
||||
);
|
||||
let foundLivemark = yield PlacesUtils.livemarks.getLivemark({ id: livemark.itemId });
|
||||
do_check_eq("http://en-us.fxfeeds.mozilla.com/en-US/firefox/livebookmarks/",
|
||||
foundLivemark.siteURI.spec);
|
||||
do_check_eq("http://en-us.fxfeeds.mozilla.com/en-US/firefox/headlines.xml",
|
||||
foundLivemark.feedURI.spec);
|
||||
|
||||
// test added bookmark data
|
||||
var child = toolbar.getChild(2);
|
||||
|
|
|
@ -363,13 +363,9 @@ function checkItem(aExpected, aNode)
|
|||
do_check_eq((yield PlacesUtils.getCharsetForURI(testURI)), aExpected.charset);
|
||||
break;
|
||||
case "feedUrl":
|
||||
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);
|
||||
});
|
||||
let livemark = yield PlacesUtils.livemarks.getLivemark({ id: id });
|
||||
do_check_eq(livemark.siteURI.spec, aExpected.url);
|
||||
do_check_eq(livemark.feedURI.spec, aExpected.feedUrl);
|
||||
break;
|
||||
case "children":
|
||||
let folder = aNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
|
||||
|
|
|
@ -154,19 +154,11 @@ function database_check() {
|
|||
// title
|
||||
do_check_eq("Latest Headlines", livemark.title);
|
||||
|
||||
let deferGetLivemark = Promise.defer();
|
||||
PlacesUtils.livemarks.getLivemark(
|
||||
{ id: livemark.itemId },
|
||||
function (aStatus, aLivemark) {
|
||||
do_check_true(Components.isSuccessCode(aStatus));
|
||||
do_check_eq("http://en-us.fxfeeds.mozilla.com/en-US/firefox/livebookmarks/",
|
||||
aLivemark.siteURI.spec);
|
||||
do_check_eq("http://en-us.fxfeeds.mozilla.com/en-US/firefox/headlines.xml",
|
||||
aLivemark.feedURI.spec);
|
||||
deferGetLivemark.resolve();
|
||||
}
|
||||
);
|
||||
yield deferGetLivemark.promise;
|
||||
let foundLivemark = yield PlacesUtils.livemarks.getLivemark({ id: livemark.itemId });
|
||||
do_check_eq("http://en-us.fxfeeds.mozilla.com/en-US/firefox/livebookmarks/",
|
||||
foundLivemark.siteURI.spec);
|
||||
do_check_eq("http://en-us.fxfeeds.mozilla.com/en-US/firefox/headlines.xml",
|
||||
foundLivemark.feedURI.spec);
|
||||
|
||||
// cleanup
|
||||
toolbar.containerOpen = false;
|
||||
|
|
|
@ -192,13 +192,9 @@ function checkItem(aExpected, aNode) {
|
|||
do_check_eq((yield PlacesUtils.getCharsetForURI(testURI)), aExpected.charset);
|
||||
break;
|
||||
case "feedUrl":
|
||||
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);
|
||||
});
|
||||
let livemark = yield PlacesUtils.livemarks.getLivemark({ id: id });
|
||||
do_check_eq(livemark.siteURI.spec, aExpected.url);
|
||||
do_check_eq(livemark.feedURI.spec, aExpected.feedUrl);
|
||||
break;
|
||||
case "children":
|
||||
let folder = aNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
|
||||
|
|
|
@ -13,14 +13,11 @@ function run_test()
|
|||
{
|
||||
if (aAnnotationName == PlacesUtils.LMANNO_FEEDURI) {
|
||||
PlacesUtils.annotations.removeObserver(this);
|
||||
PlacesUtils.livemarks.getLivemark(
|
||||
{ id: aItemId },
|
||||
function (aStatus, aLivemark) {
|
||||
do_check_true(Components.isSuccessCode(aStatus));
|
||||
PlacesUtils.livemarks.getLivemark({ id: aItemId })
|
||||
.then(aLivemark => {
|
||||
PlacesUtils.bookmarks.removeItem(aItemId);
|
||||
do_test_finished();
|
||||
}
|
||||
);
|
||||
}, do_throw);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -39,5 +36,5 @@ function run_test()
|
|||
, siteURI: uri("http://example.com/")
|
||||
, feedURI: uri("http://example.com/rdf")
|
||||
}
|
||||
);
|
||||
).then(null, do_throw);
|
||||
}
|
||||
|
|
|
@ -178,82 +178,52 @@ add_task(function test_addLivemark_noCallback_succeeds()
|
|||
});
|
||||
|
||||
|
||||
add_task(function test_addLivemark_noSiteURI_callback_succeeds()
|
||||
add_task(function test_addLivemark_noSiteURI_succeeds()
|
||||
{
|
||||
let checkLivemark = aLivemark => {
|
||||
do_check_true(aLivemark.id > 0);
|
||||
do_check_valid_places_guid(aLivemark.guid);
|
||||
do_check_eq(aLivemark.title, "test");
|
||||
do_check_eq(aLivemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
|
||||
do_check_eq(aLivemark.index, PlacesUtils.bookmarks.getItemIndex(aLivemark.id));
|
||||
do_check_eq(aLivemark.lastModified, PlacesUtils.bookmarks.getItemLastModified(aLivemark.id));
|
||||
do_check_true(aLivemark.feedURI.equals(FEED_URI));
|
||||
do_check_eq(aLivemark.siteURI, null);
|
||||
};
|
||||
|
||||
// The deprecated callback is called before resolving the promise.
|
||||
let callbackCalled = false;
|
||||
let livemark = yield PlacesUtils.livemarks.addLivemark(
|
||||
{ title: "test"
|
||||
, parentId: PlacesUtils.unfiledBookmarksFolderId
|
||||
, index: PlacesUtils.bookmarks.DEFAULT_INDEX
|
||||
, feedURI: FEED_URI
|
||||
},
|
||||
(aStatus, aLivemark) => {
|
||||
callbackCalled = true;
|
||||
do_check_true(Components.isSuccessCode(aStatus));
|
||||
checkLivemark(aLivemark);
|
||||
} );
|
||||
do_check_true(callbackCalled);
|
||||
checkLivemark(livemark);
|
||||
});
|
||||
do_check_true(livemark.id > 0);
|
||||
do_check_valid_places_guid(livemark.guid);
|
||||
do_check_eq(livemark.title, "test");
|
||||
do_check_eq(livemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
|
||||
do_check_eq(livemark.index, PlacesUtils.bookmarks.getItemIndex(livemark.id));
|
||||
do_check_eq(livemark.lastModified, PlacesUtils.bookmarks.getItemLastModified(livemark.id));
|
||||
do_check_true(livemark.feedURI.equals(FEED_URI));
|
||||
do_check_eq(livemark.siteURI, null);
|
||||
});
|
||||
|
||||
add_task(function test_addLivemark_callback_succeeds()
|
||||
add_task(function test_addLivemark_succeeds()
|
||||
{
|
||||
let checkLivemark = aLivemark => {
|
||||
do_check_true(aLivemark.id > 0);
|
||||
do_check_valid_places_guid(aLivemark.guid);
|
||||
do_check_eq(aLivemark.title, "test");
|
||||
do_check_eq(aLivemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
|
||||
do_check_eq(aLivemark.index, PlacesUtils.bookmarks.getItemIndex(aLivemark.id));
|
||||
do_check_eq(aLivemark.lastModified, PlacesUtils.bookmarks.getItemLastModified(aLivemark.id));
|
||||
do_check_true(aLivemark.feedURI.equals(FEED_URI));
|
||||
do_check_true(aLivemark.siteURI.equals(SITE_URI));
|
||||
do_check_true(PlacesUtils.annotations
|
||||
.itemHasAnnotation(aLivemark.id,
|
||||
PlacesUtils.LMANNO_FEEDURI));
|
||||
do_check_true(PlacesUtils.annotations
|
||||
.itemHasAnnotation(aLivemark.id,
|
||||
PlacesUtils.LMANNO_SITEURI));
|
||||
};
|
||||
|
||||
// The deprecated callback is called before resolving the promise.
|
||||
let callbackCalled = false;
|
||||
let livemark = yield PlacesUtils.livemarks.addLivemark(
|
||||
{ title: "test"
|
||||
, parentId: PlacesUtils.unfiledBookmarksFolderId
|
||||
, index: PlacesUtils.bookmarks.DEFAULT_INDEX
|
||||
, feedURI: FEED_URI
|
||||
, siteURI: SITE_URI
|
||||
},
|
||||
(aStatus, aLivemark) => {
|
||||
callbackCalled = true;
|
||||
do_check_true(Components.isSuccessCode(aStatus));
|
||||
checkLivemark(aLivemark);
|
||||
} );
|
||||
do_check_true(callbackCalled);
|
||||
checkLivemark(livemark);
|
||||
});
|
||||
|
||||
do_check_true(livemark.id > 0);
|
||||
do_check_valid_places_guid(livemark.guid);
|
||||
do_check_eq(livemark.title, "test");
|
||||
do_check_eq(livemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
|
||||
do_check_eq(livemark.index, PlacesUtils.bookmarks.getItemIndex(livemark.id));
|
||||
do_check_eq(livemark.lastModified, PlacesUtils.bookmarks.getItemLastModified(livemark.id));
|
||||
do_check_true(livemark.feedURI.equals(FEED_URI));
|
||||
do_check_true(livemark.siteURI.equals(SITE_URI));
|
||||
do_check_true(PlacesUtils.annotations
|
||||
.itemHasAnnotation(livemark.id,
|
||||
PlacesUtils.LMANNO_FEEDURI));
|
||||
do_check_true(PlacesUtils.annotations
|
||||
.itemHasAnnotation(livemark.id,
|
||||
PlacesUtils.LMANNO_SITEURI));
|
||||
});
|
||||
|
||||
add_task(function test_addLivemark_bogusid_callback_succeeds()
|
||||
add_task(function test_addLivemark_bogusid_succeeds()
|
||||
{
|
||||
let checkLivemark = aLivemark => {
|
||||
do_check_true(aLivemark.id > 0);
|
||||
do_check_neq(aLivemark.id, 100);
|
||||
};
|
||||
|
||||
// The deprecated callback is called before resolving the promise.
|
||||
let callbackCalled = false;
|
||||
let livemark = yield PlacesUtils.livemarks.addLivemark(
|
||||
{ id: 100 // Should be ignored.
|
||||
, title: "test"
|
||||
|
@ -261,118 +231,72 @@ add_task(function test_addLivemark_bogusid_callback_succeeds()
|
|||
, index: PlacesUtils.bookmarks.DEFAULT_INDEX
|
||||
, feedURI: FEED_URI
|
||||
, siteURI: SITE_URI
|
||||
},
|
||||
(aStatus, aLivemark) => {
|
||||
callbackCalled = true;
|
||||
do_check_true(Components.isSuccessCode(aStatus));
|
||||
checkLivemark(aLivemark);
|
||||
} );
|
||||
do_check_true(callbackCalled);
|
||||
checkLivemark(livemark);
|
||||
});
|
||||
do_check_true(livemark.id > 0);
|
||||
do_check_neq(livemark.id, 100);
|
||||
});
|
||||
|
||||
add_task(function test_addLivemark_bogusParent_callback_fails()
|
||||
add_task(function test_addLivemark_bogusParent_fails()
|
||||
{
|
||||
// The deprecated callback is called before resolving the promise.
|
||||
let callbackCalled = false;
|
||||
try {
|
||||
yield PlacesUtils.livemarks.addLivemark(
|
||||
{ title: "test"
|
||||
, parentId: 187
|
||||
, index: PlacesUtils.bookmarks.DEFAULT_INDEX
|
||||
, feedURI: FEED_URI
|
||||
},
|
||||
(aStatus, aLivemark) => {
|
||||
callbackCalled = true;
|
||||
do_check_false(Components.isSuccessCode(aStatus));
|
||||
do_check_eq(aLivemark, null);
|
||||
} );
|
||||
});
|
||||
do_throw("Adding a livemark with a bogus parent should fail");
|
||||
}
|
||||
catch(ex) {
|
||||
do_check_true(callbackCalled);
|
||||
}
|
||||
} catch(ex) {}
|
||||
});
|
||||
|
||||
add_task(function test_addLivemark_intoLivemark_callback_fails()
|
||||
add_task(function test_addLivemark_intoLivemark_fails()
|
||||
{
|
||||
// The deprecated callback is called before resolving the promise.
|
||||
let callbackCalled = false;
|
||||
let livemark = yield PlacesUtils.livemarks.addLivemark(
|
||||
{ title: "test"
|
||||
, parentId: PlacesUtils.unfiledBookmarksFolderId
|
||||
, index: PlacesUtils.bookmarks.DEFAULT_INDEX
|
||||
, feedURI: FEED_URI
|
||||
},
|
||||
(aStatus, aLivemark) => {
|
||||
callbackCalled = true;
|
||||
do_check_true(Components.isSuccessCode(aStatus));
|
||||
} );
|
||||
do_check_true(callbackCalled);
|
||||
});
|
||||
do_check_true(Boolean(livemark));
|
||||
|
||||
callbackCalled = false;
|
||||
try {
|
||||
yield PlacesUtils.livemarks.addLivemark(
|
||||
{ title: "test"
|
||||
, parentId: livemark.id
|
||||
, index: PlacesUtils.bookmarks.DEFAULT_INDEX
|
||||
, feedURI: FEED_URI
|
||||
},
|
||||
(aStatus, aLivemark) => {
|
||||
callbackCalled = true;
|
||||
do_check_false(Components.isSuccessCode(aStatus));
|
||||
do_check_eq(aLivemark, null);
|
||||
} );
|
||||
});
|
||||
do_throw("Adding a livemark into a livemark should fail");
|
||||
}
|
||||
catch(ex) {
|
||||
do_check_true(callbackCalled);
|
||||
}
|
||||
} catch(ex) {}
|
||||
});
|
||||
|
||||
add_task(function test_addLivemark_forceGuid_callback_succeeds()
|
||||
add_task(function test_addLivemark_forceGuid_succeeds()
|
||||
{
|
||||
let checkLivemark = aLivemark => {
|
||||
do_check_eq(aLivemark.guid, "1234567890AB");
|
||||
do_check_guid_for_bookmark(aLivemark.id, "1234567890AB");
|
||||
};
|
||||
|
||||
// The deprecated callback is called before resolving the promise.
|
||||
let callbackCalled = false;
|
||||
let livemark = yield PlacesUtils.livemarks.addLivemark(
|
||||
{ title: "test"
|
||||
, parentId: PlacesUtils.unfiledBookmarksFolderId
|
||||
, index: PlacesUtils.bookmarks.DEFAULT_INDEX
|
||||
, feedURI: FEED_URI
|
||||
, guid: "1234567890AB"
|
||||
},
|
||||
(aStatus, aLivemark) => {
|
||||
callbackCalled = true;
|
||||
do_check_true(Components.isSuccessCode(aStatus));
|
||||
checkLivemark(aLivemark);
|
||||
} );
|
||||
do_check_true(callbackCalled);
|
||||
});
|
||||
checkLivemark(livemark);
|
||||
});
|
||||
|
||||
add_task(function test_addLivemark_lastModified_callback_succeeds()
|
||||
add_task(function test_addLivemark_lastModified_succeeds()
|
||||
{
|
||||
let now = Date.now() * 1000;
|
||||
let callbackCalled = false;
|
||||
let livemark = yield PlacesUtils.livemarks.addLivemark(
|
||||
{ title: "test"
|
||||
, parentId: PlacesUtils.unfiledBookmarksFolderId
|
||||
, index: PlacesUtils.bookmarks.DEFAULT_INDEX
|
||||
, feedURI: FEED_URI
|
||||
, lastModified: now
|
||||
},
|
||||
(aStatus, aLivemark) => {
|
||||
callbackCalled = true;
|
||||
do_check_true(Components.isSuccessCode(aStatus));
|
||||
do_check_eq(aLivemark.lastModified, now);
|
||||
} );
|
||||
do_check_true(callbackCalled);
|
||||
});
|
||||
do_check_eq(livemark.lastModified, now);
|
||||
});
|
||||
|
||||
|
@ -398,19 +322,11 @@ add_task(function test_removeLivemark_noValidId_throws()
|
|||
|
||||
add_task(function test_removeLivemark_nonExistent_fails()
|
||||
{
|
||||
let callbackCalled = false;
|
||||
try {
|
||||
yield PlacesUtils.livemarks.removeLivemark(
|
||||
{ id: 1337 },
|
||||
(aStatus, aLivemark) => {
|
||||
callbackCalled = true;
|
||||
do_check_false(Components.isSuccessCode(aStatus));
|
||||
do_check_eq(aLivemark, null);
|
||||
} );
|
||||
yield PlacesUtils.livemarks.removeLivemark({ id: 1337 });
|
||||
do_throw("Removing a non-existent livemark should fail");
|
||||
}
|
||||
catch(ex) {
|
||||
do_check_true(callbackCalled);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -469,36 +385,20 @@ add_task(function test_getLivemark_noValidId_throws()
|
|||
|
||||
add_task(function test_getLivemark_nonExistentId_fails()
|
||||
{
|
||||
let callbackCalled = false;
|
||||
try {
|
||||
yield PlacesUtils.livemarks.getLivemark({ id: 1234 },
|
||||
(aStatus, aLivemark) => {
|
||||
callbackCalled = true;
|
||||
do_check_false(Components.isSuccessCode(aStatus));
|
||||
do_check_eq(aLivemark, null);
|
||||
} );
|
||||
yield PlacesUtils.livemarks.getLivemark({ id: 1234 });
|
||||
do_throw("getLivemark for a non existent id should fail");
|
||||
}
|
||||
catch(ex) {
|
||||
do_check_true(callbackCalled);
|
||||
}
|
||||
catch(ex) {}
|
||||
});
|
||||
|
||||
add_task(function test_getLivemark_nonExistentGUID_fails()
|
||||
{
|
||||
let callbackCalled = false;
|
||||
try {
|
||||
yield PlacesUtils.livemarks.getLivemark({ guid: "34567890ABCD" },
|
||||
(aStatus, aLivemark) => {
|
||||
callbackCalled = true;
|
||||
do_check_false(Components.isSuccessCode(aStatus));
|
||||
do_check_eq(aLivemark, null);
|
||||
} );
|
||||
yield PlacesUtils.livemarks.getLivemark({ guid: "34567890ABCD" });
|
||||
do_throw("getLivemark for a non-existent guid should fail");
|
||||
}
|
||||
catch(ex) {
|
||||
do_check_true(callbackCalled);
|
||||
}
|
||||
catch(ex) {}
|
||||
});
|
||||
|
||||
add_task(function test_getLivemark_guid_succeeds()
|
||||
|
@ -510,26 +410,16 @@ add_task(function test_getLivemark_guid_succeeds()
|
|||
, feedURI: FEED_URI
|
||||
, guid: "34567890ABCD" });
|
||||
|
||||
let checkLivemark = aLivemark => {
|
||||
do_check_eq(aLivemark.title, "test");
|
||||
do_check_eq(aLivemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
|
||||
do_check_eq(aLivemark.index, PlacesUtils.bookmarks.getItemIndex(aLivemark.id));
|
||||
do_check_true(aLivemark.feedURI.equals(FEED_URI));
|
||||
do_check_eq(aLivemark.siteURI, null);
|
||||
do_check_eq(aLivemark.guid, "34567890ABCD");
|
||||
};
|
||||
|
||||
// invalid id to check the guid wins.
|
||||
let livemark =
|
||||
yield PlacesUtils.livemarks.getLivemark({ id: 789, guid: "34567890ABCD" },
|
||||
(aStatus, aLivemark) => {
|
||||
callbackCalled = true;
|
||||
do_check_true(Components.isSuccessCode(aStatus));
|
||||
checkLivemark(aLivemark)
|
||||
} );
|
||||
yield PlacesUtils.livemarks.getLivemark({ id: 789, guid: "34567890ABCD" });
|
||||
|
||||
do_check_true(callbackCalled);
|
||||
checkLivemark(livemark);
|
||||
do_check_eq(livemark.title, "test");
|
||||
do_check_eq(livemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
|
||||
do_check_eq(livemark.index, PlacesUtils.bookmarks.getItemIndex(livemark.id));
|
||||
do_check_true(livemark.feedURI.equals(FEED_URI));
|
||||
do_check_eq(livemark.siteURI, null);
|
||||
do_check_eq(livemark.guid, "34567890ABCD");
|
||||
});
|
||||
|
||||
add_task(function test_getLivemark_id_succeeds()
|
||||
|
@ -541,26 +431,14 @@ add_task(function test_getLivemark_id_succeeds()
|
|||
, feedURI: FEED_URI
|
||||
});
|
||||
|
||||
let checkLivemark = aLivemark => {
|
||||
do_check_eq(aLivemark.title, "test");
|
||||
do_check_eq(aLivemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
|
||||
do_check_eq(aLivemark.index, PlacesUtils.bookmarks.getItemIndex(aLivemark.id));
|
||||
do_check_true(aLivemark.feedURI.equals(FEED_URI));
|
||||
do_check_eq(aLivemark.siteURI, null);
|
||||
do_check_guid_for_bookmark(aLivemark.id, aLivemark.guid);
|
||||
};
|
||||
livemark = yield PlacesUtils.livemarks.getLivemark({ id: livemark.id });
|
||||
|
||||
let callbackCalled = false;
|
||||
livemark = yield PlacesUtils.livemarks.getLivemark(
|
||||
{ id: livemark.id },
|
||||
(aStatus, aLivemark) => {
|
||||
callbackCalled = true;
|
||||
do_check_true(Components.isSuccessCode(aStatus));
|
||||
checkLivemark(aLivemark);
|
||||
} );
|
||||
|
||||
do_check_true(callbackCalled);
|
||||
checkLivemark(livemark);
|
||||
do_check_eq(livemark.title, "test");
|
||||
do_check_eq(livemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
|
||||
do_check_eq(livemark.index, PlacesUtils.bookmarks.getItemIndex(livemark.id));
|
||||
do_check_true(livemark.feedURI.equals(FEED_URI));
|
||||
do_check_eq(livemark.siteURI, null);
|
||||
do_check_guid_for_bookmark(livemark.id, livemark.guid);
|
||||
});
|
||||
|
||||
add_task(function test_getLivemark_removeItem_contention()
|
||||
|
@ -579,26 +457,14 @@ add_task(function test_getLivemark_removeItem_contention()
|
|||
let id = PlacesUtils.bookmarks.getIdForItemAt(PlacesUtils.unfiledBookmarksFolderId,
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX);
|
||||
|
||||
let checkLivemark = (aLivemark) => {
|
||||
do_check_eq(aLivemark.title, "test");
|
||||
do_check_eq(aLivemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
|
||||
do_check_eq(aLivemark.index, PlacesUtils.bookmarks.getItemIndex(aLivemark.id));
|
||||
do_check_true(aLivemark.feedURI.equals(FEED_URI));
|
||||
do_check_eq(aLivemark.siteURI, null);
|
||||
do_check_guid_for_bookmark(aLivemark.id, aLivemark.guid);
|
||||
};
|
||||
let livemark = yield PlacesUtils.livemarks.getLivemark({ id: id });
|
||||
|
||||
let callbackCalled = false;
|
||||
let livemark = yield PlacesUtils.livemarks.getLivemark(
|
||||
{ id: id },
|
||||
(aStatus, aLivemark) => {
|
||||
callbackCalled = true;
|
||||
do_check_true(Components.isSuccessCode(aStatus));
|
||||
checkLivemark(aLivemark);
|
||||
} );
|
||||
|
||||
do_check_true(callbackCalled);
|
||||
checkLivemark(livemark);
|
||||
do_check_eq(livemark.title, "test");
|
||||
do_check_eq(livemark.parentId, PlacesUtils.unfiledBookmarksFolderId);
|
||||
do_check_eq(livemark.index, PlacesUtils.bookmarks.getItemIndex(livemark.id));
|
||||
do_check_true(livemark.feedURI.equals(FEED_URI));
|
||||
do_check_eq(livemark.siteURI, null);
|
||||
do_check_guid_for_bookmark(livemark.id, livemark.guid);
|
||||
});
|
||||
|
||||
add_task(function test_title_change()
|
||||
|
|
Загрузка…
Ссылка в новой задаче