Bug 1378711 - Ensure that current places transactions have completed before clearing batch processing mode to avoid messing up the undo queue. r=mak

MozReview-Commit-ID: 7k0sgZIaUyB

--HG--
extra : rebase_source : 36a599395a13374550644dd5a2c63f8938de8d6d
This commit is contained in:
Mark Banner 2017-07-06 11:57:44 +01:00
Родитель 1f28dba52c
Коммит 9651d46673
2 изменённых файлов: 7 добавлений и 12 удалений

Просмотреть файл

@ -317,14 +317,6 @@ gTests.push({
let bookmark = await PlacesUtils.bookmarks.fetch({url: TEST_URL});
self._bookmarkGuid = bookmark.guid;
// TODO: Bug 1378711. We shouldn't need to wait for onItemChanged here,
// however we are working around an async bug in the PlacesTransactions
// manager and ensuring that async functions have completed before moving
// on.
let promiseItemChanged = PlacesTestUtils.waitForNotification("onItemChanged",
(itemId, property, isAnnotationProperty, newValue, lastModified, itemType) =>
itemType === PlacesUtils.bookmarks.TYPE_FOLDER && isAnnotationProperty);
// Create a new folder.
var newFolderButton = self.window.document.getElementById("editBMPanel_newFolderButton");
newFolderButton.doCommand();
@ -337,7 +329,7 @@ gTests.push({
EventUtils.synthesizeKey("VK_ESCAPE", {}, self.window);
Assert.ok(!folderTree.hasAttribute("editing"),
"We have finished editing folder name in folder tree");
await promiseItemChanged;
self._cleanShutdown = true;
self._removeObserver = PlacesTestUtils.waitForNotification("onItemRemoved",
(itemId, parentId, index, type, uri, guid) => guid == self._bookmarkGuid);

Просмотреть файл

@ -563,11 +563,14 @@ var TransactionsManager = {
this._createdBatchEntry = false;
let rv;
try {
// We should return here, but bug 958949 makes that impossible.
rv = await task();
} finally {
this._batching = false;
this._createdBatchEntry = false;
// We must enqueue clearing batching mode to ensure that any existing
// transactions have completed before we clear the batching mode.
this._mainEnqueuer.enqueue(async () => {
this._batching = false;
this._createdBatchEntry = false;
});
}
return rv;
});