зеркало из https://github.com/mozilla/gecko-dev.git
Bug 989083 - Stop leaking aCallback and remove aScope from asyncGetBookmarkIds r=mak
This commit is contained in:
Родитель
a7de85d2e8
Коммит
856a1d7394
|
@ -1322,7 +1322,7 @@ let BookmarkingUI = {
|
|||
return;
|
||||
}
|
||||
|
||||
this._pendingStmt = PlacesUtils.asyncGetBookmarkIds(this._uri, function (aItemIds, aURI) {
|
||||
this._pendingStmt = PlacesUtils.asyncGetBookmarkIds(this._uri, (aItemIds, aURI) => {
|
||||
// Safety check that the bookmarked URI equals the tracked one.
|
||||
if (!aURI.equals(this._uri)) {
|
||||
Components.utils.reportError("BookmarkingUI did not receive current URI");
|
||||
|
@ -1349,7 +1349,7 @@ let BookmarkingUI = {
|
|||
}
|
||||
|
||||
delete this._pendingStmt;
|
||||
}, this);
|
||||
});
|
||||
},
|
||||
|
||||
_updateStar: function BUI__updateStar() {
|
||||
|
|
|
@ -89,7 +89,6 @@ skip-if = true # Bug 921984, hopefully fixed by bug 930202
|
|||
[browser_tabview_bug626791.js]
|
||||
[browser_tabview_bug627736.js]
|
||||
[browser_tabview_bug628061.js]
|
||||
skip-if = os == 'linux'&&debug # bug 989083
|
||||
[browser_tabview_bug628165.js]
|
||||
[browser_tabview_bug628270.js]
|
||||
[browser_tabview_bug628887.js]
|
||||
|
@ -112,7 +111,6 @@ skip-if = true # Bug 922422
|
|||
[browser_tabview_bug641802.js]
|
||||
[browser_tabview_bug642793.js]
|
||||
[browser_tabview_bug643392.js]
|
||||
skip-if = os == 'linux'&&debug # bug 989083
|
||||
[browser_tabview_bug644097.js]
|
||||
[browser_tabview_bug648882.js]
|
||||
skip-if = true # Bug 752862
|
||||
|
@ -120,7 +118,6 @@ skip-if = true # Bug 752862
|
|||
[browser_tabview_bug649307.js]
|
||||
[browser_tabview_bug649319.js]
|
||||
[browser_tabview_bug650280_perwindowpb.js]
|
||||
skip-if = os == 'linux'&&debug # bug 989083
|
||||
[browser_tabview_bug650573.js]
|
||||
[browser_tabview_bug651311.js]
|
||||
[browser_tabview_bug654295.js]
|
||||
|
|
|
@ -48,9 +48,9 @@ var Bookmarks = {
|
|||
isURIBookmarked: function bh_isURIBookmarked(aURI, callback) {
|
||||
if (!callback)
|
||||
return;
|
||||
PlacesUtils.asyncGetBookmarkIds(aURI, function(aItemIds) {
|
||||
PlacesUtils.asyncGetBookmarkIds(aURI, aItemIds => {
|
||||
callback(aItemIds && aItemIds.length > 0 && aItemIds.some(this._isMetroBookmark));
|
||||
}, this);
|
||||
});
|
||||
},
|
||||
|
||||
removeForURI: function bh_removeForURI(aURI, callback) {
|
||||
|
|
|
@ -1306,15 +1306,13 @@ this.PlacesUtils = {
|
|||
* Function to be called when done.
|
||||
* The function will receive an array of itemIds associated to aURI and
|
||||
* aURI itself.
|
||||
* @param aScope
|
||||
* Scope for the callback.
|
||||
*
|
||||
* @return A object with a .cancel() method allowing to cancel the request.
|
||||
*
|
||||
* @note Children of live bookmarks folders are excluded. The callback function is
|
||||
* not invoked if the request is cancelled or hits an error.
|
||||
*/
|
||||
asyncGetBookmarkIds: function PU_asyncGetBookmarkIds(aURI, aCallback, aScope)
|
||||
asyncGetBookmarkIds: function PU_asyncGetBookmarkIds(aURI, aCallback)
|
||||
{
|
||||
if (!this._asyncGetBookmarksStmt) {
|
||||
let db = this.history.DBConnection;
|
||||
|
@ -1336,6 +1334,7 @@ this.PlacesUtils = {
|
|||
// will cause a REASON_CANCELED. Thus we wrap the statement.
|
||||
let stmt = new AsyncStatementCancelWrapper(this._asyncGetBookmarksStmt);
|
||||
return stmt.executeAsync({
|
||||
_callback: aCallback,
|
||||
_itemIds: [],
|
||||
handleResult: function(aResultSet) {
|
||||
for (let row; (row = aResultSet.getNextRow());) {
|
||||
|
@ -1345,7 +1344,7 @@ this.PlacesUtils = {
|
|||
handleCompletion: function(aReason)
|
||||
{
|
||||
if (aReason == Ci.mozIStorageStatementCallback.REASON_FINISHED) {
|
||||
aCallback.apply(aScope, [this._itemIds, aURI]);
|
||||
this._callback(this._itemIds, aURI);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -10,11 +10,11 @@ const TEST_URL = "http://www.example.com/";
|
|||
[
|
||||
|
||||
function test_no_bookmark() {
|
||||
PlacesUtils.asyncGetBookmarkIds(TEST_URL, function (aItemIds, aURI) {
|
||||
PlacesUtils.asyncGetBookmarkIds(TEST_URL, (aItemIds, aURI) => {
|
||||
do_check_eq(aItemIds.length, 0);
|
||||
do_check_eq(aURI, TEST_URL);
|
||||
run_next_test();
|
||||
}, this);
|
||||
});
|
||||
},
|
||||
|
||||
function test_one_bookmark_nsIURI() {
|
||||
|
@ -23,13 +23,13 @@ const TEST_URL = "http://www.example.com/";
|
|||
PlacesUtils.unfiledBookmarksFolderId, uri, "test",
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX
|
||||
);
|
||||
PlacesUtils.asyncGetBookmarkIds(uri, function (aItemIds, aURI) {
|
||||
PlacesUtils.asyncGetBookmarkIds(uri, (aItemIds, aURI) => {
|
||||
do_check_eq(aItemIds.length, 1);
|
||||
do_check_eq(aItemIds[0], itemId);
|
||||
do_check_true(aURI.equals(uri));
|
||||
PlacesUtils.bookmarks.removeItem(itemId);
|
||||
run_next_test();
|
||||
}, this);
|
||||
});
|
||||
},
|
||||
|
||||
function test_one_bookmark_spec() {
|
||||
|
@ -38,13 +38,13 @@ const TEST_URL = "http://www.example.com/";
|
|||
PlacesUtils.unfiledBookmarksFolderId, uri, "test",
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX
|
||||
);
|
||||
PlacesUtils.asyncGetBookmarkIds(TEST_URL, function (aItemIds, aURI) {
|
||||
PlacesUtils.asyncGetBookmarkIds(TEST_URL, (aItemIds, aURI) => {
|
||||
do_check_eq(aItemIds.length, 1);
|
||||
do_check_eq(aItemIds[0], itemId);
|
||||
do_check_eq(aURI, TEST_URL);
|
||||
PlacesUtils.bookmarks.removeItem(itemId);
|
||||
run_next_test();
|
||||
}, this);
|
||||
});
|
||||
},
|
||||
|
||||
function test_multiple_bookmarks() {
|
||||
|
@ -58,25 +58,25 @@ const TEST_URL = "http://www.example.com/";
|
|||
PlacesUtils.unfiledBookmarksFolderId, uri, "test",
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX
|
||||
));
|
||||
PlacesUtils.asyncGetBookmarkIds(uri, function (aItemIds, aURI) {
|
||||
PlacesUtils.asyncGetBookmarkIds(uri, (aItemIds, aURI) => {
|
||||
do_check_eq(aItemIds.length, 2);
|
||||
do_check_true(do_compare_arrays(itemIds, aItemIds));
|
||||
do_check_true(aURI.equals(uri));
|
||||
itemIds.forEach(PlacesUtils.bookmarks.removeItem);
|
||||
run_next_test();
|
||||
}, this);
|
||||
});
|
||||
},
|
||||
|
||||
function test_cancel() {
|
||||
let pending = PlacesUtils.asyncGetBookmarkIds(TEST_URL, function (aItemIds, aURI) {
|
||||
let pending = PlacesUtils.asyncGetBookmarkIds(TEST_URL, (aItemIds, aURI) => {
|
||||
do_throw("A canceled pending statement should not be invoked");
|
||||
}, this);
|
||||
});
|
||||
pending.cancel();
|
||||
PlacesUtils.asyncGetBookmarkIds(TEST_URL, function (aItemIds, aURI) {
|
||||
PlacesUtils.asyncGetBookmarkIds(TEST_URL, (aItemIds, aURI) => {
|
||||
do_check_eq(aItemIds.length, 0);
|
||||
do_check_eq(aURI, TEST_URL);
|
||||
run_next_test();
|
||||
}, this);
|
||||
});
|
||||
},
|
||||
|
||||
].forEach(add_test);
|
||||
|
|
Загрузка…
Ссылка в новой задаче