From 7eb562e2387bcb4a5fc6bcd43bf025f1c342cabf Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Thu, 10 Dec 2015 06:46:49 -0500 Subject: [PATCH] Bug 1230471 - Basic eslint fixes in places. r=mconley --HG-- extra : commitid : 3qDaDd3cKSc extra : rebase_source : 8dc99f1b7dc0bb7bb7b9059ff4d8527685a50291 --- .eslintignore | 2 - .../components/places/content/controller.js | 26 +-- .../places/content/editBookmarkOverlay.js | 4 +- browser/components/places/content/places.js | 32 ++-- browser/components/places/content/tree.xml | 8 +- .../browser/browser_435851_copy_query.js | 4 +- .../browser/browser_bookmarklet_windowOpen.js | 2 +- .../tests/browser/browser_library_infoBox.js | 2 +- .../browser_toolbarbutton_menu_context.js | 2 +- .../components/places/BookmarkHTMLUtils.jsm | 21 ++- toolkit/components/places/PlacesBackups.jsm | 5 +- toolkit/components/places/nsTaggingService.js | 5 +- .../tests/autocomplete/head_autocomplete.js | 4 +- .../places/tests/browser/browser_bug248970.js | 2 +- .../tests/expiration/test_debug_expiration.js | 4 +- .../tests/migration/test_current_from_v19.js | 2 +- .../tests/migration/test_current_from_v24.js | 2 +- .../places/tests/queries/head_queries.js | 2 +- .../test_history_queries_titles_liveUpdate.js | 20 +- .../tests/queries/test_queryMultipleFolder.js | 2 +- .../queries/test_sort-date-site-grouping.js | 4 +- .../places/tests/queries/test_sorting.js | 28 +-- .../unifiedcomplete/head_autocomplete.js | 2 +- .../test_autoFill_default_behavior.js | 2 +- .../places/tests/unit/test_420331_wyciwyg.js | 5 +- .../places/tests/unit/test_425563.js | 8 +- .../unit/test_486978_sort_by_date_queries.js | 3 +- .../tests/unit/test_async_history_api.js | 10 +- .../tests/unit/test_async_transactions.js | 2 +- .../places/tests/unit/test_bookmarks_html.js | 2 +- .../places/tests/unit/test_bookmarks_json.js | 2 +- .../test_bookmarks_restore_notification.js | 172 ++++++++---------- .../places/tests/unit/test_frecency.js | 2 +- .../tests/unit/test_history_observer.js | 8 +- .../places/tests/unit/test_hosts_triggers.js | 2 +- .../places/tests/unit/test_isvisited.js | 5 +- .../places/tests/unit/test_null_interfaces.js | 32 ++-- .../tests/unit/test_preventive_maintenance.js | 4 +- .../tests/unit/test_promiseBookmarksTree.js | 16 +- .../unit/test_removeVisitsByTimeframe.js | 20 +- 40 files changed, 237 insertions(+), 243 deletions(-) diff --git a/.eslintignore b/.eslintignore index 1cd188cdaf00..5f57e358e209 100644 --- a/.eslintignore +++ b/.eslintignore @@ -73,7 +73,6 @@ browser/components/downloads/** browser/components/feeds/** browser/components/migration/** browser/components/*.js -browser/components/places/** browser/components/pocket/** browser/components/preferences/** browser/components/privatebrowsing/** @@ -162,7 +161,6 @@ toolkit/modules/tests/xpcshell/test_task.js # Not yet updated toolkit/components/osfile/** toolkit/components/passwordmgr/** -toolkit/components/places/** # Uses preprocessing toolkit/content/contentAreaUtils.js diff --git a/browser/components/places/content/controller.js b/browser/components/places/content/controller.js index 66798c98e8f5..ce13c65fbd10 100644 --- a/browser/components/places/content/controller.js +++ b/browser/components/places/content/controller.js @@ -188,20 +188,23 @@ PlacesController.prototype = { !PlacesUtils.asQuery(this._view.result.root).queryOptions.excludeItems && this._view.result.sortingMode == Ci.nsINavHistoryQueryOptions.SORT_BY_NONE; - case "placesCmd_show:info": - var selectedNode = this._view.selectedNode; + case "placesCmd_show:info": { + let selectedNode = this._view.selectedNode; return selectedNode && PlacesUtils.getConcreteItemId(selectedNode) != -1 - case "placesCmd_reload": + } + case "placesCmd_reload": { // Livemark containers - var selectedNode = this._view.selectedNode; + let selectedNode = this._view.selectedNode; return selectedNode && this.hasCachedLivemarkInfo(selectedNode); - case "placesCmd_sortBy:name": - var selectedNode = this._view.selectedNode; + } + case "placesCmd_sortBy:name": { + let selectedNode = this._view.selectedNode; return selectedNode && PlacesUtils.nodeIsFolder(selectedNode) && !PlacesUIUtils.isContentsReadOnly(selectedNode) && this._view.result.sortingMode == Ci.nsINavHistoryQueryOptions.SORT_BY_NONE; + } case "placesCmd_createBookmark": var node = this._view.selectedNode; return node && PlacesUtils.nodeIsURI(node) && node.itemId == -1; @@ -963,16 +966,13 @@ PlacesController.prototype = { } // Do removal in chunks to give some breath to main-thread. - function pagesChunkGenerator(aURIs) { + function* pagesChunkGenerator(aURIs) { while (aURIs.length) { let URIslice = aURIs.splice(0, REMOVE_PAGES_CHUNKLEN); PlacesUtils.bhistory.removePages(URIslice, URIslice.length); - Services.tm.mainThread.dispatch(function() { - try { - gen.next(); - } catch (ex if ex instanceof StopIteration) {} - }, Ci.nsIThread.DISPATCH_NORMAL); - yield undefined; + Services.tm.mainThread.dispatch(() => gen.next(), + Ci.nsIThread.DISPATCH_NORMAL); + yield unefined; } } let gen = pagesChunkGenerator(URIs); diff --git a/browser/components/places/content/editBookmarkOverlay.js b/browser/components/places/content/editBookmarkOverlay.js index cdbcd1e23099..e2b6b1b61f4a 100644 --- a/browser/components/places/content/editBookmarkOverlay.js +++ b/browser/components/places/content/editBookmarkOverlay.js @@ -366,7 +366,7 @@ var gEditItemOverlay = { * set. Then we sort it descendingly based on the time field. */ this._recentFolders = []; - for (var i = 0; i < folderIds.length; i++) { + for (let i = 0; i < folderIds.length; i++) { var lastUsed = annos.getItemAnnotation(folderIds[i], LAST_USED_ANNO); this._recentFolders.push({ folderId: folderIds[i], lastUsed: lastUsed }); } @@ -380,7 +380,7 @@ var gEditItemOverlay = { var numberOfItems = Math.min(MAX_FOLDER_ITEM_IN_MENU_LIST, this._recentFolders.length); - for (var i = 0; i < numberOfItems; i++) { + for (let i = 0; i < numberOfItems; i++) { this._appendFolderItemToMenupopup(menupopup, this._recentFolders[i].folderId); } diff --git a/browser/components/places/content/places.js b/browser/components/places/content/places.js index 162178a03e1e..43e6f83631bc 100644 --- a/browser/components/places/content/places.js +++ b/browser/components/places/content/places.js @@ -418,7 +418,7 @@ var PlacesOrganizer = { while (restorePopup.childNodes.length > 1) restorePopup.removeChild(restorePopup.firstChild); - Task.spawn(function() { + Task.spawn(function* () { let backupFiles = yield PlacesBackups.getBackupFiles(); if (backupFiles.length == 0) return; @@ -465,18 +465,16 @@ var PlacesOrganizer = { /** * Called when a menuitem is selected from the restore menu. */ - onRestoreMenuItemClick: function PO_onRestoreMenuItemClick(aMenuItem) { - Task.spawn(function() { - let backupName = aMenuItem.getAttribute("value"); - let backupFilePaths = yield PlacesBackups.getBackupFiles(); - for (let backupFilePath of backupFilePaths) { - if (OS.Path.basename(backupFilePath) == backupName) { - PlacesOrganizer.restoreBookmarksFromFile(backupFilePath); - break; - } + onRestoreMenuItemClick: Task.async(function* (aMenuItem) { + let backupName = aMenuItem.getAttribute("value"); + let backupFilePaths = yield PlacesBackups.getBackupFiles(); + for (let backupFilePath of backupFilePaths) { + if (OS.Path.basename(backupFilePath) == backupName) { + PlacesOrganizer.restoreBookmarksFromFile(backupFilePath); + break; } - }); - }, + } + }), /** * Called when 'Choose File...' is selected from the restore menu. @@ -521,7 +519,7 @@ var PlacesOrganizer = { PlacesUIUtils.getString("bookmarksRestoreAlert"))) return; - Task.spawn(function() { + Task.spawn(function* () { try { yield BookmarkJSONUtils.importFromFile(aFilePath, true); } catch(ex) { @@ -633,7 +631,7 @@ var PlacesOrganizer = { // don't update the panel if we are already editing this node unless we're // in multi-edit mode if (selectedNode) { - var concreteId = PlacesUtils.getConcreteItemId(selectedNode); + let concreteId = PlacesUtils.getConcreteItemId(selectedNode); var nodeIsSame = gEditItemOverlay.itemId == selectedNode.itemId || gEditItemOverlay.itemId == concreteId || (selectedNode.itemId == -1 && gEditItemOverlay.uri && @@ -653,7 +651,7 @@ var PlacesOrganizer = { // does allow setting properties for folder shortcuts as well, but since // the UI does not distinct between the couple, we better just show // the concrete item properties for shortcuts to root nodes. - var concreteId = PlacesUtils.getConcreteItemId(selectedNode); + let concreteId = PlacesUtils.getConcreteItemId(selectedNode); var isRootItem = concreteId != -1 && PlacesUtils.isRootItem(concreteId); var readOnly = isRootItem || selectedNode.parent.itemId == PlacesUIUtils.leftPaneFolderId; @@ -1206,13 +1204,13 @@ var ViewMenu = { if (aColumn) { columnId = aColumn.getAttribute("anonid"); if (!aDirection) { - var sortColumn = this._getSortColumn(); + let sortColumn = this._getSortColumn(); if (sortColumn) aDirection = sortColumn.getAttribute("sortDirection"); } } else { - var sortColumn = this._getSortColumn(); + let sortColumn = this._getSortColumn(); columnId = sortColumn ? sortColumn.getAttribute("anonid") : "title"; } diff --git a/browser/components/places/content/tree.xml b/browser/components/places/content/tree.xml index b13266502b84..7549fbeb37b5 100644 --- a/browser/components/places/content/tree.xml +++ b/browser/components/places/content/tree.xml @@ -239,7 +239,7 @@ // Walk the list backwards (opening from the root of the hierarchy) // opening each folder as we go. for (var i = parents.length - 1; i >= 0; --i) { - var index = view.treeIndexForNode(parents[i]); + let index = view.treeIndexForNode(parents[i]); if (index != Ci.nsINavHistoryResultTreeViewer.INDEX_INVISIBLE && view.isContainer(index) && !view.isContainerOpen(index)) view.toggleOpenState(index); @@ -247,7 +247,7 @@ // Select the specified node... } - var index = view.treeIndexForNode(node); + let index = view.treeIndexForNode(node); if (index == Ci.nsINavHistoryResultTreeViewer.INDEX_INVISIBLE) return; @@ -659,10 +659,10 @@ selection.selectEventsSuppressed = true; selection.clearSelection(); // Open nodes containing found items - for (var i = 0; i < nodesToOpen.length; i++) { + for (let i = 0; i < nodesToOpen.length; i++) { nodesToOpen[i].containerOpen = true; } - for (var i = 0; i < nodes.length; i++) { + for (let i = 0; i < nodes.length; i++) { var index = resultview.treeIndexForNode(nodes[i]); if (index == Ci.nsINavHistoryResultTreeViewer.INDEX_INVISIBLE) continue; diff --git a/browser/components/places/tests/browser/browser_435851_copy_query.js b/browser/components/places/tests/browser/browser_435851_copy_query.js index 73f3ebdb1d7c..92f818b41b7f 100644 --- a/browser/components/places/tests/browser/browser_435851_copy_query.js +++ b/browser/components/places/tests/browser/browser_435851_copy_query.js @@ -7,7 +7,7 @@ const SHORTCUT_URL = "place:folder=2"; const QUERY_URL = "place:sort=8&maxResults=10"; -add_task(function copy_toolbar_shortcut() { +add_task(function* copy_toolbar_shortcut() { let library = yield promiseLibrary(); registerCleanupFunction(function () { @@ -35,7 +35,7 @@ add_task(function copy_toolbar_shortcut() { "original is still a folder shortcut"); }); -add_task(function copy_history_query() { +add_task(function* copy_history_query() { let library = yield promiseLibrary(); library.PlacesOrganizer.selectLeftPaneQuery("History"); diff --git a/browser/components/places/tests/browser/browser_bookmarklet_windowOpen.js b/browser/components/places/tests/browser/browser_bookmarklet_windowOpen.js index 54199944b35a..85ce25311c4c 100644 --- a/browser/components/places/tests/browser/browser_bookmarklet_windowOpen.js +++ b/browser/components/places/tests/browser/browser_bookmarklet_windowOpen.js @@ -13,7 +13,7 @@ function makeBookmarkFor(url, keyword) { } -add_task(function openKeywordBookmarkWithWindowOpen() { +add_task(function* openKeywordBookmarkWithWindowOpen() { // This is the current default, but let's not assume that... yield new Promise((resolve, reject) => { SpecialPowers.pushPrefEnv({ 'set': [[ 'browser.link.open_newwindow', 3 ], diff --git a/browser/components/places/tests/browser/browser_library_infoBox.js b/browser/components/places/tests/browser/browser_library_infoBox.js index baa4590c1a72..459874ff5434 100644 --- a/browser/components/places/tests/browser/browser_library_infoBox.js +++ b/browser/components/places/tests/browser/browser_library_infoBox.js @@ -97,7 +97,7 @@ gTests.push({ checkAddInfoFieldsNotCollapsed(PO); // open first bookmark - var view = ContentTree.view.view; + view = ContentTree.view.view; ok(view.rowCount > 0, "Bookmark item exists."); view.selection.select(0); checkInfoBoxSelected(PO); diff --git a/browser/components/places/tests/browser/browser_toolbarbutton_menu_context.js b/browser/components/places/tests/browser/browser_toolbarbutton_menu_context.js index 217410688798..7a0eec22f111 100644 --- a/browser/components/places/tests/browser/browser_toolbarbutton_menu_context.js +++ b/browser/components/places/tests/browser/browser_toolbarbutton_menu_context.js @@ -5,7 +5,7 @@ var contextMenu = document.getElementById("placesContext"); var newBookmarkItem = document.getElementById("placesContext_new:bookmark"); waitForExplicitFinish(); -add_task(function testPopup() { +add_task(function* testPopup() { info("Checking popup context menu before moving the bookmarks button"); yield checkPopupContextMenu(); let pos = CustomizableUI.getPlacementOfWidget("bookmarks-menu-button").position; diff --git a/toolkit/components/places/BookmarkHTMLUtils.jsm b/toolkit/components/places/BookmarkHTMLUtils.jsm index e2bab644f4a0..276777d90e9a 100644 --- a/toolkit/components/places/BookmarkHTMLUtils.jsm +++ b/toolkit/components/places/BookmarkHTMLUtils.jsm @@ -1045,7 +1045,7 @@ BookmarkExporter.prototype = { this._writeLine("Bookmarks"); }, - _writeContainer: function (aItem, aIndent = "") { + *_writeContainer(aItem, aIndent = "") { if (aItem == this._root) { this._writeLine("

" + escapeHtmlEntities(this._root.title) + "

"); this._writeLine(""); @@ -1072,18 +1072,19 @@ BookmarkExporter.prototype = { this._writeLine(aIndent + "

"); }, - _writeContainerContents: function (aItem, aIndent) { + *_writeContainerContents(aItem, aIndent) { let localIndent = aIndent + EXPORT_INDENT; for (let child of aItem.children) { - if (child.annos && child.annos.some(anno => anno.name == PlacesUtils.LMANNO_FEEDURI)) - this._writeLivemark(child, localIndent); - else if (child.type == PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER) - yield this._writeContainer(child, localIndent); - else if (child.type == PlacesUtils.TYPE_X_MOZ_PLACE_SEPARATOR) + if (child.annos && child.annos.some(anno => anno.name == PlacesUtils.LMANNO_FEEDURI)) { + this._writeLivemark(child, localIndent); + } else if (child.type == PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER) { + yield this._writeContainer(child, localIndent); + } else if (child.type == PlacesUtils.TYPE_X_MOZ_PLACE_SEPARATOR) { this._writeSeparator(child, localIndent); - else + } else { yield this._writeItem(child, localIndent); + } } }, @@ -1106,7 +1107,7 @@ BookmarkExporter.prototype = { this._writeDescription(aItem, aIndent); }, - _writeItem: function (aItem, aIndent) { + *_writeItem(aItem, aIndent) { let uri = null; try { uri = NetUtil.newURI(aItem.uri); @@ -1145,7 +1146,7 @@ BookmarkExporter.prototype = { Math.floor(aItem.lastModified / MICROSEC_PER_SEC)); }, - _writeFaviconAttribute: function (aItem) { + *_writeFaviconAttribute(aItem) { if (!aItem.iconuri) return; let favicon; diff --git a/toolkit/components/places/PlacesBackups.jsm b/toolkit/components/places/PlacesBackups.jsm index a7ff98b5ea8b..78360d434794 100644 --- a/toolkit/components/places/PlacesBackups.jsm +++ b/toolkit/components/places/PlacesBackups.jsm @@ -453,7 +453,10 @@ this.PlacesBackups = { newFilenameWithMetaData = appendMetaDataToFilename(newBackupFilename, { count: nodeCount, hash: hash }); - } catch (ex if ex.becauseSameHash) { + } catch (ex) { + if (!ex.becauseSameHash) { + throw ex; + } // The last backup already contained up-to-date information, just // rename it as if it was today's backup. this._backupFiles.shift(); diff --git a/toolkit/components/places/nsTaggingService.js b/toolkit/components/places/nsTaggingService.js index af6c795e5984..d0445961b9cc 100644 --- a/toolkit/components/places/nsTaggingService.js +++ b/toolkit/components/places/nsTaggingService.js @@ -636,7 +636,7 @@ TagAutoCompleteSearch.prototype = { var self = this; // generator: if yields true, not done - function doSearch() { + function* doSearch() { var i = 0; while (i < searchResults.length) { if (self._stopped) @@ -682,8 +682,7 @@ TagAutoCompleteSearch.prototype = { // chunk the search results via the generator var gen = doSearch(); - while (gen.next()); - gen.close(); + while (gen.next().value); }, /** diff --git a/toolkit/components/places/tests/autocomplete/head_autocomplete.js b/toolkit/components/places/tests/autocomplete/head_autocomplete.js index 8fdefecba47c..0909a0969cc4 100644 --- a/toolkit/components/places/tests/autocomplete/head_autocomplete.js +++ b/toolkit/components/places/tests/autocomplete/head_autocomplete.js @@ -266,7 +266,7 @@ function run_test() { if (func) func(); - Task.spawn(function () { + Task.spawn(function* () { // Iterate over all tasks and execute them for (let [, [fn, args]] in Iterator(gNextTestSetupTasks)) { yield fn.apply(this, args); @@ -302,7 +302,7 @@ function markTyped(aURIs, aTitle) gNextTestSetupTasks.push([task_markTyped, arguments]); } -function task_markTyped(aURIs, aTitle) +function* task_markTyped(aURIs, aTitle) { for (let uri of aURIs) { yield PlacesTestUtils.addVisits({ diff --git a/toolkit/components/places/tests/browser/browser_bug248970.js b/toolkit/components/places/tests/browser/browser_bug248970.js index fbb9e9743718..ff1d97db492c 100644 --- a/toolkit/components/places/tests/browser/browser_bug248970.js +++ b/toolkit/components/places/tests/browser/browser_bug248970.js @@ -17,7 +17,7 @@ var visitedURIs = [ "http://www.test-download.com/" ].map(NetUtil.newURI.bind(NetUtil)); -add_task(function () { +add_task(function* () { let windowsToClose = []; let placeItemsCount = 0; diff --git a/toolkit/components/places/tests/expiration/test_debug_expiration.js b/toolkit/components/places/tests/expiration/test_debug_expiration.js index eb02791b8a71..2d0a866be121 100644 --- a/toolkit/components/places/tests/expiration/test_debug_expiration.js +++ b/toolkit/components/places/tests/expiration/test_debug_expiration.js @@ -72,7 +72,7 @@ add_task(function* test_expire_orphans_optionalarg() yield PlacesTestUtils.clearHistory(); }); -add_task(function test_expire_limited() +add_task(function* test_expire_limited() { // Add visits to 2 pages and force a single expiration. // Only 1 page should survive. @@ -96,7 +96,7 @@ add_task(function test_expire_limited() yield PlacesTestUtils.clearHistory(); }); -add_task(function test_expire_unlimited() +add_task(function* test_expire_unlimited() { // Add visits to 2 pages and force a single expiration. // Only 1 page should survive. diff --git a/toolkit/components/places/tests/migration/test_current_from_v19.js b/toolkit/components/places/tests/migration/test_current_from_v19.js index a23766398e0b..b8d837e6815b 100644 --- a/toolkit/components/places/tests/migration/test_current_from_v19.js +++ b/toolkit/components/places/tests/migration/test_current_from_v19.js @@ -34,7 +34,7 @@ add_task(function* database_is_valid() { Assert.equal((yield db.getSchemaVersion()), CURRENT_SCHEMA_VERSION); }); -add_task(function test_bookmark_guid_annotation_removed() +add_task(function* test_bookmark_guid_annotation_removed() { let db = yield PlacesUtils.promiseDBConnection(); Assert.equal((yield getTotalGuidAnnotationsCount(db)), 0, diff --git a/toolkit/components/places/tests/migration/test_current_from_v24.js b/toolkit/components/places/tests/migration/test_current_from_v24.js index f45a172e1960..513a76bcc9e0 100644 --- a/toolkit/components/places/tests/migration/test_current_from_v24.js +++ b/toolkit/components/places/tests/migration/test_current_from_v24.js @@ -13,7 +13,7 @@ add_task(function* database_is_valid() { Assert.equal((yield db.getSchemaVersion()), CURRENT_SCHEMA_VERSION); }); -add_task(function test_bookmark_guid_annotation_removed() +add_task(function* test_bookmark_guid_annotation_removed() { yield PlacesUtils.bookmarks.eraseEverything(); diff --git a/toolkit/components/places/tests/queries/head_queries.js b/toolkit/components/places/tests/queries/head_queries.js index b47944a135a8..3fc8c7a01e30 100644 --- a/toolkit/components/places/tests/queries/head_queries.js +++ b/toolkit/components/places/tests/queries/head_queries.js @@ -42,7 +42,7 @@ const olderthansixmonths = today - (DAY_MICROSEC * 31 * 7); function* task_populateDB(aArray) { // Iterate over aArray and execute all instructions. - for ([, data] in Iterator(aArray)) { + for (let data of aArray) { try { // make the data object into a query data object in order to create proper // default values for anything left unspecified diff --git a/toolkit/components/places/tests/queries/test_history_queries_titles_liveUpdate.js b/toolkit/components/places/tests/queries/test_history_queries_titles_liveUpdate.js index 49ef0db10dc1..d204b14e7683 100644 --- a/toolkit/components/places/tests/queries/test_history_queries_titles_liveUpdate.js +++ b/toolkit/components/places/tests/queries/test_history_queries_titles_liveUpdate.js @@ -158,16 +158,18 @@ add_task(function* pages_searchterm_is_title_query() let root = PlacesUtils.history.executeQuery(query, options).root; root.containerOpen = true; compareArrayToResult([], root); - gTestData.forEach(function (data) { + for (let data of gTestData) { let uri = NetUtil.newURI(data.uri); let origTitle = data.title; data.title = "match"; - yield PlacesTestUtils.addVisits({uri: uri, title: data.title}); + yield PlacesTestUtils.addVisits({ uri: uri, title: data.title, + visitDate: data.lastVisit }); compareArrayToResult([data], root); data.title = origTitle; - yield PlacesTestUtils.addVisits({uri: uri, title: data.title}); + yield PlacesTestUtils.addVisits({ uri: uri, title: data.title, + visitDate: data.lastVisit }); compareArrayToResult([], root); - }); + } root.containerOpen = false; yield PlacesTestUtils.clearHistory(); @@ -183,16 +185,18 @@ add_task(function* visits_searchterm_is_title_query() let root = PlacesUtils.history.executeQuery(query, options).root; root.containerOpen = true; compareArrayToResult([], root); - gTestData.forEach(function (data) { + for (let data of gTestData) { let uri = NetUtil.newURI(data.uri); let origTitle = data.title; data.title = "match"; - yield PlacesTestUtils.addVisits({uri: uri, title: data.title}); + yield PlacesTestUtils.addVisits({ uri: uri, title: data.title, + visitDate: data.lastVisit }); compareArrayToResult([data], root); data.title = origTitle; - yield PlacesTestUtils.addVisits({uri: uri, title: data.title}); + yield PlacesTestUtils.addVisits({ uri: uri, title: data.title, + visitDate: data.lastVisit }); compareArrayToResult([], root); - }); + } root.containerOpen = false; yield PlacesTestUtils.clearHistory(); diff --git a/toolkit/components/places/tests/queries/test_queryMultipleFolder.js b/toolkit/components/places/tests/queries/test_queryMultipleFolder.js index 1719b4a0f868..4f38330c1329 100644 --- a/toolkit/components/places/tests/queries/test_queryMultipleFolder.js +++ b/toolkit/components/places/tests/queries/test_queryMultipleFolder.js @@ -62,4 +62,4 @@ add_task(function* test_queryMultipleFolders() { Assert.equal(bookmarkIds[i], node.itemId, node.uri); } rootNode.containerOpen = false; -}); \ No newline at end of file +}); diff --git a/toolkit/components/places/tests/queries/test_sort-date-site-grouping.js b/toolkit/components/places/tests/queries/test_sort-date-site-grouping.js index a5e80a093356..0fa7dd1a28a4 100644 --- a/toolkit/components/places/tests/queries/test_sort-date-site-grouping.js +++ b/toolkit/components/places/tests/queries/test_sort-date-site-grouping.js @@ -154,7 +154,7 @@ add_task(function* test_sort_date_site_grouping() } // Test live updating. - testDataAddedLater.forEach(function(visit) { + for (let visit of testDataAddedLater) { yield task_populateDB([visit]); let oldLength = testData.length; let i = visit.levels[0]; @@ -163,7 +163,7 @@ add_task(function* test_sort_date_site_grouping() leveledTestData[i][j].push(oldLength); compareArrayToResult(leveledTestData[i][j]. map(x => testData[x]), roots[i][j]); - }); + } for (let i = 0; i < roots.length; i++) { for (let j = 0; j < roots[i].length; j++) diff --git a/toolkit/components/places/tests/queries/test_sorting.js b/toolkit/components/places/tests/queries/test_sorting.js index 8dfaa1a9f946..d6f36e84b97f 100644 --- a/toolkit/components/places/tests/queries/test_sorting.js +++ b/toolkit/components/places/tests/queries/test_sorting.js @@ -11,7 +11,7 @@ var tests = []; tests.push({ _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_NONE, - setup: function() { + *setup() { do_print("Sorting test 1: SORT BY NONE"); this._unsortedData = [ @@ -74,7 +74,7 @@ tests.push({ tests.push({ _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_TITLE_ASCENDING, - setup: function() { + *setup() { do_print("Sorting test 2: SORT BY TITLE"); this._unsortedData = [ @@ -149,7 +149,7 @@ tests.push({ tests.push({ _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_DATE_ASCENDING, - setup: function() { + *setup() { do_print("Sorting test 3: SORT BY DATE"); var timeInMicroseconds = Date.now() * 1000; @@ -249,7 +249,7 @@ tests.push({ tests.push({ _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_URI_ASCENDING, - setup: function() { + *setup() { do_print("Sorting test 4: SORT BY URI"); var timeInMicroseconds = Date.now() * 1000; @@ -355,7 +355,7 @@ tests.push({ tests.push({ _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_VISITCOUNT_ASCENDING, - setup: function() { + *setup() { do_print("Sorting test 5: SORT BY VISITCOUNT"); var timeInMicroseconds = Date.now() * 1000; @@ -456,7 +456,7 @@ tests.push({ tests.push({ _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_KEYWORD_ASCENDING, - setup: function() { + *setup() { do_print("Sorting test 6: SORT BY KEYWORD"); this._unsortedData = [ @@ -555,7 +555,7 @@ tests.push({ tests.push({ _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_DATEADDED_ASCENDING, - setup: function() { + *setup() { do_print("Sorting test 7: SORT BY DATEADDED"); var timeInMicroseconds = Date.now() * 1000; @@ -645,7 +645,7 @@ tests.push({ tests.push({ _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_LASTMODIFIED_ASCENDING, - setup: function() { + *setup() { do_print("Sorting test 8: SORT BY LASTMODIFIED"); var timeInMicroseconds = Date.now() * 1000; @@ -743,7 +743,7 @@ tests.push({ tests.push({ _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_TAGS_ASCENDING, - setup: function() { + *setup() { do_print("Sorting test 9: SORT BY TAGS"); this._unsortedData = [ @@ -844,7 +844,7 @@ tests.push({ tests.push({ _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_ANNOTATION_ASCENDING, - setup: function() { + *setup() { do_print("Sorting test 10: SORT BY ANNOTATION (int32)"); var timeInMicroseconds = Date.now() * 1000; @@ -940,7 +940,7 @@ tests.push({ tests.push({ _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_ANNOTATION_ASCENDING, - setup: function() { + *setup() { do_print("Sorting test 11: SORT BY ANNOTATION (int64)"); var timeInMicroseconds = Date.now() * 1000; @@ -1022,7 +1022,7 @@ tests.push({ tests.push({ _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_ANNOTATION_ASCENDING, - setup: function() { + *setup() { do_print("Sorting test 12: SORT BY ANNOTATION (string)"); var timeInMicroseconds = Date.now() * 1000; @@ -1104,7 +1104,7 @@ tests.push({ tests.push({ _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_ANNOTATION_ASCENDING, - setup: function() { + *setup() { do_print("Sorting test 13: SORT BY ANNOTATION (double)"); var timeInMicroseconds = Date.now() * 1000; @@ -1186,7 +1186,7 @@ tests.push({ tests.push({ _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_FRECENCY_ASCENDING, - setup: function() { + *setup() { do_print("Sorting test 13: SORT BY FRECENCY "); var timeInMicroseconds = Date.now() * 1000; diff --git a/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js b/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js index 87eb13ec9706..7551e83134ae 100644 --- a/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js +++ b/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js @@ -449,7 +449,7 @@ function* addTestEngine(basename, httpServer=undefined) { // Ensure we have a default search engine and the keyword.enabled preference // set. -add_task(function ensure_search_engine() { +add_task(function* ensure_search_engine() { // keyword.enabled is necessary for the tests to see keyword searches. Services.prefs.setBoolPref("keyword.enabled", true); diff --git a/toolkit/components/places/tests/unifiedcomplete/test_autoFill_default_behavior.js b/toolkit/components/places/tests/unifiedcomplete/test_autoFill_default_behavior.js index 3a8ce6b64560..482fcf4853f2 100644 --- a/toolkit/components/places/tests/unifiedcomplete/test_autoFill_default_behavior.js +++ b/toolkit/components/places/tests/unifiedcomplete/test_autoFill_default_behavior.js @@ -73,7 +73,7 @@ add_task(function* test_default_behavior_host() { do_print("Restrict history, bookmark, autoFill.typed = false, should autoFill"); yield check_autocomplete({ search: "bo", - matches: [ { uri: uri3, title: "bookmarked", style: [ "bookmark" ], style: [ "autofill", "heuristic" ], + matches: [ { uri: uri3, title: "bookmarked", style: [ "autofill", "heuristic" ], icon: "chrome://global/skin/icons/error-16.png" } ], autofilled: "bookmarked/", completed: "bookmarked/" diff --git a/toolkit/components/places/tests/unit/test_420331_wyciwyg.js b/toolkit/components/places/tests/unit/test_420331_wyciwyg.js index 5eecb671d4d4..d5d740913c70 100644 --- a/toolkit/components/places/tests/unit/test_420331_wyciwyg.js +++ b/toolkit/components/places/tests/unit/test_420331_wyciwyg.js @@ -17,7 +17,10 @@ add_task(function* test_execute() { yield PlacesTestUtils.addVisits(testURI); do_throw("Should have generated an exception."); - } catch (ex if ex && ex.result == Cr.NS_ERROR_ILLEGAL_VALUE) { + } catch (ex) { + if (ex.result != Cr.NS_ERROR_ILLEGAL_VALUE) { + throw ex; + } // Adding wyciwyg URIs should raise NS_ERROR_ILLEGAL_VALUE. } }); diff --git a/toolkit/components/places/tests/unit/test_425563.js b/toolkit/components/places/tests/unit/test_425563.js index 98c8a5b23805..3b2ee6cfe6fc 100644 --- a/toolkit/components/places/tests/unit/test_425563.js +++ b/toolkit/components/places/tests/unit/test_425563.js @@ -42,12 +42,12 @@ add_task(function* test_execute() ]); // check that all links are marked as visited - count_visited_URIs.forEach(function (visited_uri) { + for (let visited_uri of count_visited_URIs) { do_check_true(yield promiseIsURIVisited(uri(visited_uri))); - }); - notcount_visited_URIs.forEach(function (visited_uri) { + } + for (let visited_uri of notcount_visited_URIs) { do_check_true(yield promiseIsURIVisited(uri(visited_uri))); - }); + } // check that visit_count does not take in count embed and downloads // maxVisits query are directly binded to visit_count diff --git a/toolkit/components/places/tests/unit/test_486978_sort_by_date_queries.js b/toolkit/components/places/tests/unit/test_486978_sort_by_date_queries.js index 5fb195dabbfe..05f3f83e7f45 100644 --- a/toolkit/components/places/tests/unit/test_486978_sort_by_date_queries.js +++ b/toolkit/components/places/tests/unit/test_486978_sort_by_date_queries.js @@ -37,7 +37,8 @@ add_task(function* test_initialize() noon.setHours(12); // Add visits. - for ([pageIndex, page] in Iterator(pages)) { + for (let pageIndex = 0; pageIndex < pages.length; ++pageIndex) { + let page = pages[pageIndex]; yield PlacesTestUtils.addVisits({ uri: uri(page), visitDate: noon - (pages.length - pageIndex) * 1000 diff --git a/toolkit/components/places/tests/unit/test_async_history_api.js b/toolkit/components/places/tests/unit/test_async_history_api.js index 21e540e609d1..738973656943 100644 --- a/toolkit/components/places/tests/unit/test_async_history_api.js +++ b/toolkit/components/places/tests/unit/test_async_history_api.js @@ -371,7 +371,10 @@ add_task(function* test_non_addable_uri_errors() { }; places.push(place); } - catch (e if e.result === Cr.NS_ERROR_FAILURE) { + catch (e) { + if (e.result != Cr.NS_ERROR_FAILURE) { + throw e; + } // NetUtil.newURI() can throw if e.g. our app knows about imap:// // but the account is not set up and so the URL is invalid for us. // Note this in the log but ignore as it's not the subject of this test. @@ -1080,7 +1083,10 @@ add_task(function* test_callbacks_not_supplied() { }; places.push(place); } - catch (e if e.result === Cr.NS_ERROR_FAILURE) { + catch (e) { + if (e.result != Cr.NS_ERROR_FAILURE) { + throw e; + } // NetUtil.newURI() can throw if e.g. our app knows about imap:// // but the account is not set up and so the URL is invalid for us. // Note this in the log but ignore as it's not the subject of this test. diff --git a/toolkit/components/places/tests/unit/test_async_transactions.js b/toolkit/components/places/tests/unit/test_async_transactions.js index ca3fc6af2a45..1c164cc81ffb 100644 --- a/toolkit/components/places/tests/unit/test_async_transactions.js +++ b/toolkit/components/places/tests/unit/test_async_transactions.js @@ -327,7 +327,7 @@ function* ensureNonExistent(...aGuids) { } add_task(function* test_recycled_transactions() { - function ensureTransactThrowsFor(aTransaction) { + function* ensureTransactThrowsFor(aTransaction) { let [txns, undoPosition] = getTransactionsHistoryState(); try { yield aTransaction.transact(); diff --git a/toolkit/components/places/tests/unit/test_bookmarks_html.js b/toolkit/components/places/tests/unit/test_bookmarks_html.js index caecdbd97b06..ba8b4b4cb2a0 100644 --- a/toolkit/components/places/tests/unit/test_bookmarks_html.js +++ b/toolkit/components/places/tests/unit/test_bookmarks_html.js @@ -303,7 +303,7 @@ function* checkItem(aExpected, aNode) { let id = aNode.itemId; - return Task.spawn(function() { + return Task.spawn(function* () { for (prop in aExpected) { switch (prop) { case "type": diff --git a/toolkit/components/places/tests/unit/test_bookmarks_json.js b/toolkit/components/places/tests/unit/test_bookmarks_json.js index 7f224404ea34..1c77bfdb7c16 100644 --- a/toolkit/components/places/tests/unit/test_bookmarks_json.js +++ b/toolkit/components/places/tests/unit/test_bookmarks_json.js @@ -145,7 +145,7 @@ function* testImportedBookmarks() { function* checkItem(aExpected, aNode) { let id = aNode.itemId; - return Task.spawn(function() { + return Task.spawn(function* () { for (prop in aExpected) { switch (prop) { case "type": diff --git a/toolkit/components/places/tests/unit/test_bookmarks_restore_notification.js b/toolkit/components/places/tests/unit/test_bookmarks_restore_notification.js index a7553852c038..0f66f70d74cf 100644 --- a/toolkit/components/places/tests/unit/test_bookmarks_restore_notification.js +++ b/toolkit/components/places/tests/unit/test_bookmarks_restore_notification.js @@ -47,21 +47,19 @@ var tests = [ finalTopic: NSIOBSERVER_TOPIC_SUCCESS, data: NSIOBSERVER_DATA_JSON, folderId: null, - run: function () { - Task.spawn(function () { - this.file = yield promiseFile("bookmarks-test_restoreNotification.json"); - addBookmarks(); + run: Task.async(function* () { + this.file = yield promiseFile("bookmarks-test_restoreNotification.json"); + addBookmarks(); - yield BookmarkJSONUtils.exportToFile(this.file); - yield PlacesUtils.bookmarks.eraseEverything(); - try { - yield BookmarkJSONUtils.importFromFile(this.file, true); - } - catch (e) { - do_throw(" Restore should not have failed"); - } - }.bind(this)); - } + yield BookmarkJSONUtils.exportToFile(this.file); + yield PlacesUtils.bookmarks.eraseEverything(); + try { + yield BookmarkJSONUtils.importFromFile(this.file, true); + } + catch (e) { + do_throw(" Restore should not have failed"); + } + }) }, { @@ -70,17 +68,15 @@ var tests = [ finalTopic: NSIOBSERVER_TOPIC_SUCCESS, data: NSIOBSERVER_DATA_JSON, folderId: null, - run: function () { - Task.spawn(function() { - this.file = yield promiseFile("bookmarks-test_restoreNotification.json"); - try { - yield BookmarkJSONUtils.importFromFile(this.file, true); - } - catch (e) { - do_throw(" Restore should not have failed" + e); - } - }.bind(this)); - } + run: Task.async(function* () { + this.file = yield promiseFile("bookmarks-test_restoreNotification.json"); + try { + yield BookmarkJSONUtils.importFromFile(this.file, true); + } + catch (e) { + do_throw(" Restore should not have failed" + e); + } + }) }, { @@ -89,18 +85,16 @@ var tests = [ finalTopic: NSIOBSERVER_TOPIC_FAILED, data: NSIOBSERVER_DATA_JSON, folderId: null, - run: function () { + run: Task.async(function* () { this.file = Services.dirsvc.get("ProfD", Ci.nsILocalFile); this.file.append("this file doesn't exist because nobody created it 1"); - Task.spawn(function() { - try { - yield BookmarkJSONUtils.importFromFile(this.file, true); - do_throw(" Restore should have failed"); - } - catch (e) { - } - }.bind(this)); - } + try { + yield BookmarkJSONUtils.importFromFile(this.file, true); + do_throw(" Restore should have failed"); + } + catch (e) { + } + }) }, { @@ -109,21 +103,19 @@ var tests = [ finalTopic: NSIOBSERVER_TOPIC_SUCCESS, data: NSIOBSERVER_DATA_HTML, folderId: null, - run: function () { - Task.spawn(function() { - this.file = yield promiseFile("bookmarks-test_restoreNotification.html"); - addBookmarks(); - yield BookmarkHTMLUtils.exportToFile(this.file); - yield PlacesUtils.bookmarks.eraseEverything(); - try { - BookmarkHTMLUtils.importFromFile(this.file, false) - .then(null, do_report_unexpected_exception); - } - catch (e) { - do_throw(" Restore should not have failed"); - } - }.bind(this)); - } + run: Task.async(function* () { + this.file = yield promiseFile("bookmarks-test_restoreNotification.html"); + addBookmarks(); + yield BookmarkHTMLUtils.exportToFile(this.file); + yield PlacesUtils.bookmarks.eraseEverything(); + try { + BookmarkHTMLUtils.importFromFile(this.file, false) + .then(null, do_report_unexpected_exception); + } + catch (e) { + do_throw(" Restore should not have failed"); + } + }) }, { @@ -132,18 +124,16 @@ var tests = [ finalTopic: NSIOBSERVER_TOPIC_SUCCESS, data: NSIOBSERVER_DATA_HTML, folderId: null, - run: function () { - Task.spawn(function (){ - this.file = yield promiseFile("bookmarks-test_restoreNotification.init.html"); - try { - BookmarkHTMLUtils.importFromFile(this.file, false) - .then(null, do_report_unexpected_exception); - } - catch (e) { - do_throw(" Restore should not have failed"); - } - }.bind(this)); - } + run: Task.async(function* () { + this.file = yield promiseFile("bookmarks-test_restoreNotification.init.html"); + try { + BookmarkHTMLUtils.importFromFile(this.file, false) + .then(null, do_report_unexpected_exception); + } + catch (e) { + do_throw(" Restore should not have failed"); + } + }) }, { @@ -152,7 +142,7 @@ var tests = [ finalTopic: NSIOBSERVER_TOPIC_FAILED, data: NSIOBSERVER_DATA_HTML, folderId: null, - run: Task.async(function* () { + run: Task.async(function* () { this.file = Services.dirsvc.get("ProfD", Ci.nsILocalFile); this.file.append("this file doesn't exist because nobody created it 2"); try { @@ -160,7 +150,7 @@ var tests = [ do_throw("Should fail!"); } catch (e) {} - }.bind(this)) + }) }, { @@ -169,21 +159,19 @@ var tests = [ finalTopic: NSIOBSERVER_TOPIC_SUCCESS, data: NSIOBSERVER_DATA_HTML_INIT, folderId: null, - run: function () { - Task.spawn(function () { - this.file = yield promiseFile("bookmarks-test_restoreNotification.init.html"); - addBookmarks(); - yield BookmarkHTMLUtils.exportToFile(this.file); - yield PlacesUtils.bookmarks.eraseEverything(); - try { - BookmarkHTMLUtils.importFromFile(this.file, true) - .then(null, do_report_unexpected_exception); - } - catch (e) { - do_throw(" Restore should not have failed"); - } - }.bind(this)); - } + run: Task.async(function* () { + this.file = yield promiseFile("bookmarks-test_restoreNotification.init.html"); + addBookmarks(); + yield BookmarkHTMLUtils.exportToFile(this.file); + yield PlacesUtils.bookmarks.eraseEverything(); + try { + BookmarkHTMLUtils.importFromFile(this.file, true) + .then(null, do_report_unexpected_exception); + } + catch (e) { + do_throw(" Restore should not have failed"); + } + }) }, { @@ -192,18 +180,16 @@ var tests = [ finalTopic: NSIOBSERVER_TOPIC_SUCCESS, data: NSIOBSERVER_DATA_HTML_INIT, folderId: null, - run: function () { - Task.spawn(function () { - this.file = yield promiseFile("bookmarks-test_restoreNotification.init.html"); - try { - BookmarkHTMLUtils.importFromFile(this.file, true) - .then(null, do_report_unexpected_exception); - } - catch (e) { - do_throw(" Restore should not have failed"); - } - }.bind(this)); - } + run: Task.async(function* () { + this.file = yield promiseFile("bookmarks-test_restoreNotification.init.html"); + try { + BookmarkHTMLUtils.importFromFile(this.file, true) + .then(null, do_report_unexpected_exception); + } + catch (e) { + do_throw(" Restore should not have failed"); + } + }) }, { @@ -212,7 +198,7 @@ var tests = [ finalTopic: NSIOBSERVER_TOPIC_FAILED, data: NSIOBSERVER_DATA_HTML_INIT, folderId: null, - run: Task.async(function* () { + run: Task.async(function* () { this.file = Services.dirsvc.get("ProfD", Ci.nsILocalFile); this.file.append("this file doesn't exist because nobody created it 3"); try { @@ -220,7 +206,7 @@ var tests = [ do_throw("Should fail!"); } catch (e) {} - }.bind(this)) + }) } ]; diff --git a/toolkit/components/places/tests/unit/test_frecency.js b/toolkit/components/places/tests/unit/test_frecency.js index ccb29da55361..3c09bb65d727 100644 --- a/toolkit/components/places/tests/unit/test_frecency.js +++ b/toolkit/components/places/tests/unit/test_frecency.js @@ -122,7 +122,7 @@ try { do_throw("Could not get history service\n"); } -function task_setCountDate(aURI, aCount, aDate) +function* task_setCountDate(aURI, aCount, aDate) { // We need visits so that frecency can be computed over multiple visits let visits = []; diff --git a/toolkit/components/places/tests/unit/test_history_observer.js b/toolkit/components/places/tests/unit/test_history_observer.js index a606a30557d0..7fde8808edac 100644 --- a/toolkit/components/places/tests/unit/test_history_observer.js +++ b/toolkit/components/places/tests/unit/test_history_observer.js @@ -39,7 +39,7 @@ function onNotify(callback) { /** * Asynchronous task that adds a visit to the history database. */ -function task_add_visit(uri, timestamp, transition) { +function* task_add_visit(uri, timestamp, transition) { uri = uri || NetUtil.newURI("http://firefox.com/"); timestamp = timestamp || Date.now() * 1000; yield PlacesTestUtils.addVisits({ @@ -47,11 +47,7 @@ function task_add_visit(uri, timestamp, transition) { transition: transition || TRANSITION_TYPED, visitDate: timestamp }); - throw new Task.Result([uri, timestamp]); -} - -function run_test() { - run_next_test(); + return [uri, timestamp]; } add_task(function* test_onVisit() { diff --git a/toolkit/components/places/tests/unit/test_hosts_triggers.js b/toolkit/components/places/tests/unit/test_hosts_triggers.js index c2d365d53569..b4af016ea2a9 100644 --- a/toolkit/components/places/tests/unit/test_hosts_triggers.js +++ b/toolkit/components/places/tests/unit/test_hosts_triggers.js @@ -150,7 +150,7 @@ add_task(function* test_moz_hosts_typed_update() add_task(function* test_moz_hosts_www_remove() { - function test_removal(aURIToRemove, aURIToKeep, aCallback) { + function* test_removal(aURIToRemove, aURIToKeep, aCallback) { let places = [{ uri: aURIToRemove , title: "test for " + aURIToRemove.spec , transition: TRANSITION_TYPED diff --git a/toolkit/components/places/tests/unit/test_isvisited.js b/toolkit/components/places/tests/unit/test_isvisited.js index 7030315c8af1..4f1e9020f1bd 100644 --- a/toolkit/components/places/tests/unit/test_isvisited.js +++ b/toolkit/components/places/tests/unit/test_isvisited.js @@ -65,7 +65,10 @@ add_task(function* test_execute() try { yield PlacesTestUtils.addVisits({uri: cantAddUri, referrer: referrer}); do_throw("Should have generated an exception."); - } catch(ex if ex && ex.result == Cr.NS_ERROR_ILLEGAL_VALUE) { + } catch(ex) { + if (ex.result != Cr.NS_ERROR_ILLEGAL_VALUE) { + throw ex; + } } do_check_false(yield promiseIsURIVisited(cantAddUri)); } diff --git a/toolkit/components/places/tests/unit/test_null_interfaces.js b/toolkit/components/places/tests/unit/test_null_interfaces.js index 5ed3c01aa692..71237f9f7e48 100644 --- a/toolkit/components/places/tests/unit/test_null_interfaces.js +++ b/toolkit/components/places/tests/unit/test_null_interfaces.js @@ -68,22 +68,22 @@ function run_test() do_print("Must have been an expected nothrow, so no need to try again"); tryAgain = false; } - catch(ex if ex.result == Cr.NS_ERROR_ILLEGAL_VALUE) { - do_print(`Caught an expected exception: ${ex.name}`); - - do_print("Moving on to the next test.."); - tryAgain = false; - } - catch(ex if ex.result == Cr.NS_ERROR_XPC_NEED_OUT_OBJECT) { - let pos = Number(ex.message.match(/object arg (\d+)/)[1]); - do_print(`Function call expects an out object at ${pos}`); - args[pos] = {}; - } - catch(ex if ex.result == Cr.NS_ERROR_NOT_IMPLEMENTED) { - do_print(`Method not implemented exception: ${ex.name}`); - - do_print("Moving on to the next test.."); - tryAgain = false; + catch(ex) { + if (ex.result == Cr.NS_ERROR_ILLEGAL_VALUE) { + do_print(`Caught an expected exception: ${ex.name}`); + do_print("Moving on to the next test.."); + tryAgain = false; + } else if (ex.result == Cr.NS_ERROR_XPC_NEED_OUT_OBJECT) { + let pos = Number(ex.message.match(/object arg (\d+)/)[1]); + do_print(`Function call expects an out object at ${pos}`); + args[pos] = {}; + } else if (ex.result == Cr.NS_ERROR_NOT_IMPLEMENTED) { + do_print(`Method not implemented exception: ${ex.name}`); + do_print("Moving on to the next test.."); + tryAgain = false; + } else { + throw ex; + } } } } diff --git a/toolkit/components/places/tests/unit/test_preventive_maintenance.js b/toolkit/components/places/tests/unit/test_preventive_maintenance.js index e87e6ffaeadd..fe0d12a5b786 100644 --- a/toolkit/components/places/tests/unit/test_preventive_maintenance.js +++ b/toolkit/components/places/tests/unit/test_preventive_maintenance.js @@ -1074,7 +1074,7 @@ tests.push({ name: "L.2", desc: "Recalculate visit_count and last_visit_date", - setup: function() { + setup: function* () { function setVisitCount(aURL, aValue) { let stmt = mDBConn.createStatement( "UPDATE moz_places SET visit_count = :count WHERE url = :url" @@ -1267,7 +1267,7 @@ function run_test() run_next_test(); } -add_task(function test_preventive_maintenance() +add_task(function* test_preventive_maintenance() { // Force initialization of the bookmarks hash. This test could cause // it to go out of sync due to direct queries on the database. diff --git a/toolkit/components/places/tests/unit/test_promiseBookmarksTree.js b/toolkit/components/places/tests/unit/test_promiseBookmarksTree.js index 7182d95e1439..63d9c9af7b50 100644 --- a/toolkit/components/places/tests/unit/test_promiseBookmarksTree.js +++ b/toolkit/components/places/tests/unit/test_promiseBookmarksTree.js @@ -211,17 +211,17 @@ function* test_promiseBookmarksTreeAgainstResult(aItemGuid = "", add_task(function* () { // Add some bookmarks to cover various use cases. yield new_bookmark({ parentGuid: PlacesUtils.bookmarks.toolbarGuid }); - yield new_folder({ parentGuid: PlacesUtils.bookmarks.menuGuid - , annotations: [{ name: "TestAnnoA", value: "TestVal" - , name: "TestAnnoB", value: 0 }]}); + yield new_folder({ parentGuid: PlacesUtils.bookmarks.menuGuid, + annotations: [{ name: "TestAnnoA", value: "TestVal" }, + { name: "TestAnnoB", value: 0 }]}); let sepInfo = { parentGuid: PlacesUtils.bookmarks.menuGuid }; yield PlacesTransactions.NewSeparator(sepInfo).transact(); let folderGuid = yield new_folder({ parentGuid: PlacesUtils.bookmarks.menuGuid }); - yield new_bookmark({ title: null - , parentGuid: folderGuid - , keyword: "test_keyword" - , tags: ["TestTagA", "TestTagB"] - , annotations: [{ name: "TestAnnoA", value: "TestVal2"}]}); + yield new_bookmark({ title: null, + parentGuid: folderGuid, + keyword: "test_keyword", + tags: ["TestTagA", "TestTagB"], + annotations: [{ name: "TestAnnoA", value: "TestVal2"}]}); let urlWithCharsetAndFavicon = uri("http://charset.and.favicon"); yield new_bookmark({ parentGuid: folderGuid, url: urlWithCharsetAndFavicon }); yield PlacesUtils.setCharsetForURI(urlWithCharsetAndFavicon, "UTF-8"); diff --git a/toolkit/components/places/tests/unit/test_removeVisitsByTimeframe.js b/toolkit/components/places/tests/unit/test_removeVisitsByTimeframe.js index 261109639b59..1194d3b30a48 100644 --- a/toolkit/components/places/tests/unit/test_removeVisitsByTimeframe.js +++ b/toolkit/components/places/tests/unit/test_removeVisitsByTimeframe.js @@ -15,7 +15,7 @@ function* cleanup() { DBConn().executeSimpleSQL("DELETE FROM moz_places"); } -add_task(function remove_visits_outside_unbookmarked_uri() { +add_task(function* remove_visits_outside_unbookmarked_uri() { do_print("*** TEST: Remove some visits outside valid timeframe from an unbookmarked URI"); do_print("Add 10 visits for the URI from way in the past."); @@ -56,7 +56,7 @@ add_task(function remove_visits_outside_unbookmarked_uri() { yield cleanup(); }); -add_task(function remove_visits_outside_bookmarked_uri() { +add_task(function* remove_visits_outside_bookmarked_uri() { do_print("*** TEST: Remove some visits outside valid timeframe from a bookmarked URI"); do_print("Add 10 visits for the URI from way in the past."); @@ -103,7 +103,7 @@ add_task(function remove_visits_outside_bookmarked_uri() { yield cleanup(); }); -add_task(function remove_visits_unbookmarked_uri() { +add_task(function* remove_visits_unbookmarked_uri() { do_print("*** TEST: Remove some visits from an unbookmarked URI"); do_print("Add 10 visits for the URI from now to 9 usecs in the past."); @@ -144,7 +144,7 @@ add_task(function remove_visits_unbookmarked_uri() { yield cleanup(); }); -add_task(function remove_visits_bookmarked_uri() { +add_task(function* remove_visits_bookmarked_uri() { do_print("*** TEST: Remove some visits from a bookmarked URI"); do_print("Add 10 visits for the URI from now to 9 usecs in the past."); @@ -191,7 +191,7 @@ add_task(function remove_visits_bookmarked_uri() { yield cleanup(); }); -add_task(function remove_all_visits_unbookmarked_uri() { +add_task(function* remove_all_visits_unbookmarked_uri() { do_print("*** TEST: Remove all visits from an unbookmarked URI"); do_print("Add some visits for the URI."); @@ -224,7 +224,7 @@ add_task(function remove_all_visits_unbookmarked_uri() { yield cleanup(); }); -add_task(function remove_all_visits_unbookmarked_place_uri() { +add_task(function* remove_all_visits_unbookmarked_place_uri() { do_print("*** TEST: Remove all visits from an unbookmarked place: URI"); do_print("Add some visits for the URI."); let visits = []; @@ -260,7 +260,7 @@ add_task(function remove_all_visits_unbookmarked_place_uri() { yield cleanup(); }); -add_task(function remove_all_visits_bookmarked_uri() { +add_task(function* remove_all_visits_bookmarked_uri() { do_print("*** TEST: Remove all visits from a bookmarked URI"); do_print("Add some visits for the URI."); @@ -306,7 +306,7 @@ add_task(function remove_all_visits_bookmarked_uri() { yield cleanup(); }); -add_task(function remove_all_visits_bookmarked_uri() { +add_task(function* remove_all_visits_bookmarked_uri() { do_print("*** TEST: Remove some visits from a zero frecency URI retains zero frecency"); do_print("Add some visits for the URI."); @@ -326,7 +326,3 @@ add_task(function remove_all_visits_bookmarked_uri() { yield cleanup(); }); - -function run_test() { - run_next_test(); -}