michael@0: /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: var tests = []; michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: tests.push({ michael@0: _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_NONE, michael@0: michael@0: setup: function() { michael@0: LOG("Sorting test 1: SORT BY NONE"); michael@0: michael@0: this._unsortedData = [ michael@0: { isBookmark: true, michael@0: uri: "http://example.com/b", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: title: "y", michael@0: keyword: "b", michael@0: isInQuery: true }, michael@0: michael@0: { isBookmark: true, michael@0: uri: "http://example.com/a", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: title: "z", michael@0: keyword: "a", michael@0: isInQuery: true }, michael@0: michael@0: { isBookmark: true, michael@0: uri: "http://example.com/c", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: title: "x", michael@0: keyword: "c", michael@0: isInQuery: true }, michael@0: ]; michael@0: michael@0: this._sortedData = this._unsortedData; michael@0: michael@0: // This function in head_queries.js creates our database with the above data michael@0: yield task_populateDB(this._unsortedData); michael@0: }, michael@0: michael@0: check: function() { michael@0: // Query michael@0: var query = PlacesUtils.history.getNewQuery(); michael@0: query.setFolders([PlacesUtils.bookmarks.toolbarFolder], 1); michael@0: query.onlyBookmarked = true; michael@0: michael@0: // query options michael@0: var options = PlacesUtils.history.getNewQueryOptions(); michael@0: options.sortingMode = this._sortingMode; michael@0: michael@0: // Results - this gets the result set and opens it for reading and modification. michael@0: var result = PlacesUtils.history.executeQuery(query, options); michael@0: var root = result.root; michael@0: root.containerOpen = true; michael@0: compareArrayToResult(this._sortedData, root); michael@0: root.containerOpen = false; michael@0: }, michael@0: michael@0: check_reverse: function() { michael@0: // no reverse sorting for SORT BY NONE michael@0: } michael@0: }); michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: tests.push({ michael@0: _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_TITLE_ASCENDING, michael@0: michael@0: setup: function() { michael@0: LOG("Sorting test 2: SORT BY TITLE"); michael@0: michael@0: this._unsortedData = [ michael@0: { isBookmark: true, michael@0: uri: "http://example.com/b1", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: title: "y", michael@0: isInQuery: true }, michael@0: michael@0: { isBookmark: true, michael@0: uri: "http://example.com/a", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: title: "z", michael@0: isInQuery: true }, michael@0: michael@0: { isBookmark: true, michael@0: uri: "http://example.com/c", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: title: "x", michael@0: isInQuery: true }, michael@0: michael@0: // if titles are equal, should fall back to URI michael@0: { isBookmark: true, michael@0: uri: "http://example.com/b2", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: title: "y", michael@0: isInQuery: true }, michael@0: ]; michael@0: michael@0: this._sortedData = [ michael@0: this._unsortedData[2], michael@0: this._unsortedData[0], michael@0: this._unsortedData[3], michael@0: this._unsortedData[1], michael@0: ]; michael@0: michael@0: // This function in head_queries.js creates our database with the above data michael@0: yield task_populateDB(this._unsortedData); michael@0: }, michael@0: michael@0: check: function() { michael@0: // Query michael@0: var query = PlacesUtils.history.getNewQuery(); michael@0: query.setFolders([PlacesUtils.bookmarks.toolbarFolder], 1); michael@0: query.onlyBookmarked = true; michael@0: michael@0: // query options michael@0: var options = PlacesUtils.history.getNewQueryOptions(); michael@0: options.sortingMode = this._sortingMode; michael@0: michael@0: // Results - this gets the result set and opens it for reading and modification. michael@0: var result = PlacesUtils.history.executeQuery(query, options); michael@0: var root = result.root; michael@0: root.containerOpen = true; michael@0: compareArrayToResult(this._sortedData, root); michael@0: root.containerOpen = false; michael@0: }, michael@0: michael@0: check_reverse: function() { michael@0: this._sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_TITLE_DESCENDING; michael@0: this._sortedData.reverse(); michael@0: this.check(); michael@0: } michael@0: }); michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: tests.push({ michael@0: _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_DATE_ASCENDING, michael@0: michael@0: setup: function() { michael@0: LOG("Sorting test 3: SORT BY DATE"); michael@0: michael@0: var timeInMicroseconds = Date.now() * 1000; michael@0: this._unsortedData = [ michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: isBookmark: true, michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 0, michael@0: uri: "http://example.com/c1", michael@0: lastVisit: timeInMicroseconds - 2, michael@0: title: "x1", michael@0: isInQuery: true }, michael@0: michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: isBookmark: true, michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 1, michael@0: uri: "http://example.com/a", michael@0: lastVisit: timeInMicroseconds - 1, michael@0: title: "z", michael@0: isInQuery: true }, michael@0: michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: isBookmark: true, michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 2, michael@0: uri: "http://example.com/b", michael@0: lastVisit: timeInMicroseconds - 3, michael@0: title: "y", michael@0: isInQuery: true }, michael@0: michael@0: // if dates are equal, should fall back to title michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: isBookmark: true, michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 3, michael@0: uri: "http://example.com/c2", michael@0: lastVisit: timeInMicroseconds - 2, michael@0: title: "x2", michael@0: isInQuery: true }, michael@0: michael@0: // if dates and title are equal, should fall back to bookmark index michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: isBookmark: true, michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 4, michael@0: uri: "http://example.com/c2", michael@0: lastVisit: timeInMicroseconds - 2, michael@0: title: "x2", michael@0: isInQuery: true }, michael@0: ]; michael@0: michael@0: this._sortedData = [ michael@0: this._unsortedData[2], michael@0: this._unsortedData[0], michael@0: this._unsortedData[3], michael@0: this._unsortedData[4], michael@0: this._unsortedData[1], michael@0: ]; michael@0: michael@0: // This function in head_queries.js creates our database with the above data michael@0: yield task_populateDB(this._unsortedData); michael@0: }, michael@0: michael@0: check: function() { michael@0: // Query michael@0: var query = PlacesUtils.history.getNewQuery(); michael@0: query.setFolders([PlacesUtils.bookmarks.toolbarFolder], 1); michael@0: query.onlyBookmarked = true; michael@0: michael@0: // query options michael@0: var options = PlacesUtils.history.getNewQueryOptions(); michael@0: options.sortingMode = this._sortingMode; michael@0: michael@0: // Results - this gets the result set and opens it for reading and modification. michael@0: var result = PlacesUtils.history.executeQuery(query, options); michael@0: var root = result.root; michael@0: root.containerOpen = true; michael@0: compareArrayToResult(this._sortedData, root); michael@0: root.containerOpen = false; michael@0: }, michael@0: michael@0: check_reverse: function() { michael@0: this._sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_DATE_DESCENDING; michael@0: this._sortedData.reverse(); michael@0: this.check(); michael@0: } michael@0: }); michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: tests.push({ michael@0: _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_URI_ASCENDING, michael@0: michael@0: setup: function() { michael@0: LOG("Sorting test 4: SORT BY URI"); michael@0: michael@0: var timeInMicroseconds = Date.now() * 1000; michael@0: this._unsortedData = [ michael@0: { isBookmark: true, michael@0: isDetails: true, michael@0: lastVisit: timeInMicroseconds, michael@0: uri: "http://example.com/b", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 0, michael@0: title: "y", michael@0: isInQuery: true }, michael@0: michael@0: { isBookmark: true, michael@0: uri: "http://example.com/c", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 1, michael@0: title: "x", michael@0: isInQuery: true }, michael@0: michael@0: { isBookmark: true, michael@0: uri: "http://example.com/a", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 2, michael@0: title: "z", michael@0: isInQuery: true }, michael@0: michael@0: // if URIs are equal, should fall back to date michael@0: { isBookmark: true, michael@0: isDetails: true, michael@0: lastVisit: timeInMicroseconds + 1, michael@0: uri: "http://example.com/c", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 3, michael@0: title: "x", michael@0: isInQuery: true }, michael@0: michael@0: // if no URI (e.g., node is a folder), should fall back to title michael@0: { isFolder: true, michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 4, michael@0: title: "a", michael@0: isInQuery: true }, michael@0: michael@0: // if URIs and dates are equal, should fall back to bookmark index michael@0: { isBookmark: true, michael@0: isDetails: true, michael@0: lastVisit: timeInMicroseconds + 1, michael@0: uri: "http://example.com/c", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 5, michael@0: title: "x", michael@0: isInQuery: true }, michael@0: michael@0: // if no URI and titles are equal, should fall back to bookmark index michael@0: { isFolder: true, michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 6, michael@0: title: "a", michael@0: isInQuery: true }, michael@0: ]; michael@0: michael@0: this._sortedData = [ michael@0: this._unsortedData[4], michael@0: this._unsortedData[6], michael@0: this._unsortedData[2], michael@0: this._unsortedData[0], michael@0: this._unsortedData[1], michael@0: this._unsortedData[3], michael@0: this._unsortedData[5], michael@0: ]; michael@0: michael@0: // This function in head_queries.js creates our database with the above data michael@0: yield task_populateDB(this._unsortedData); michael@0: }, michael@0: michael@0: check: function() { michael@0: // Query michael@0: var query = PlacesUtils.history.getNewQuery(); michael@0: query.setFolders([PlacesUtils.bookmarks.toolbarFolder], 1); michael@0: michael@0: // query options michael@0: var options = PlacesUtils.history.getNewQueryOptions(); michael@0: options.sortingMode = this._sortingMode; michael@0: michael@0: // Results - this gets the result set and opens it for reading and modification. michael@0: var result = PlacesUtils.history.executeQuery(query, options); michael@0: var root = result.root; michael@0: root.containerOpen = true; michael@0: compareArrayToResult(this._sortedData, root); michael@0: root.containerOpen = false; michael@0: }, michael@0: michael@0: check_reverse: function() { michael@0: this._sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_URI_DESCENDING; michael@0: this._sortedData.reverse(); michael@0: this.check(); michael@0: } michael@0: }); michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: tests.push({ michael@0: _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_VISITCOUNT_ASCENDING, michael@0: michael@0: setup: function() { michael@0: LOG("Sorting test 5: SORT BY VISITCOUNT"); michael@0: michael@0: var timeInMicroseconds = Date.now() * 1000; michael@0: this._unsortedData = [ michael@0: { isBookmark: true, michael@0: uri: "http://example.com/a", michael@0: lastVisit: timeInMicroseconds, michael@0: title: "z", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 0, michael@0: isInQuery: true }, michael@0: michael@0: { isBookmark: true, michael@0: uri: "http://example.com/c", michael@0: lastVisit: timeInMicroseconds, michael@0: title: "x", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 1, michael@0: isInQuery: true }, michael@0: michael@0: { isBookmark: true, michael@0: uri: "http://example.com/b1", michael@0: lastVisit: timeInMicroseconds, michael@0: title: "y1", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 2, michael@0: isInQuery: true }, michael@0: michael@0: // if visitCounts are equal, should fall back to date michael@0: { isBookmark: true, michael@0: uri: "http://example.com/b2", michael@0: lastVisit: timeInMicroseconds + 1, michael@0: title: "y2a", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 3, michael@0: isInQuery: true }, michael@0: michael@0: // if visitCounts and dates are equal, should fall back to bookmark index michael@0: { isBookmark: true, michael@0: uri: "http://example.com/b2", michael@0: lastVisit: timeInMicroseconds + 1, michael@0: title: "y2b", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 4, michael@0: isInQuery: true }, michael@0: ]; michael@0: michael@0: this._sortedData = [ michael@0: this._unsortedData[0], michael@0: this._unsortedData[2], michael@0: this._unsortedData[3], michael@0: this._unsortedData[4], michael@0: this._unsortedData[1], michael@0: ]; michael@0: michael@0: // This function in head_queries.js creates our database with the above data michael@0: yield task_populateDB(this._unsortedData); michael@0: // add visits to increase visit count michael@0: yield promiseAddVisits([ michael@0: { uri: uri("http://example.com/a"), transition: TRANSITION_TYPED, visitDate: timeInMicroseconds }, michael@0: { uri: uri("http://example.com/b1"), transition: TRANSITION_TYPED, visitDate: timeInMicroseconds }, michael@0: { uri: uri("http://example.com/b1"), transition: TRANSITION_TYPED, visitDate: timeInMicroseconds }, michael@0: { uri: uri("http://example.com/b2"), transition: TRANSITION_TYPED, visitDate: timeInMicroseconds + 1 }, michael@0: { uri: uri("http://example.com/b2"), transition: TRANSITION_TYPED, visitDate: timeInMicroseconds + 1 }, michael@0: { uri: uri("http://example.com/c"), transition: TRANSITION_TYPED, visitDate: timeInMicroseconds }, michael@0: { uri: uri("http://example.com/c"), transition: TRANSITION_TYPED, visitDate: timeInMicroseconds }, michael@0: { uri: uri("http://example.com/c"), transition: TRANSITION_TYPED, visitDate: timeInMicroseconds }, michael@0: ]); michael@0: }, michael@0: michael@0: check: function() { michael@0: // Query michael@0: var query = PlacesUtils.history.getNewQuery(); michael@0: query.setFolders([PlacesUtils.bookmarks.toolbarFolder], 1); michael@0: query.onlyBookmarked = true; michael@0: michael@0: // query options michael@0: var options = PlacesUtils.history.getNewQueryOptions(); michael@0: options.sortingMode = this._sortingMode; michael@0: michael@0: // Results - this gets the result set and opens it for reading and modification. michael@0: var result = PlacesUtils.history.executeQuery(query, options); michael@0: var root = result.root; michael@0: root.containerOpen = true; michael@0: compareArrayToResult(this._sortedData, root); michael@0: root.containerOpen = false; michael@0: }, michael@0: michael@0: check_reverse: function() { michael@0: this._sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_VISITCOUNT_DESCENDING; michael@0: this._sortedData.reverse(); michael@0: this.check(); michael@0: } michael@0: }); michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: tests.push({ michael@0: _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_KEYWORD_ASCENDING, michael@0: michael@0: setup: function() { michael@0: LOG("Sorting test 6: SORT BY KEYWORD"); michael@0: michael@0: this._unsortedData = [ michael@0: { isBookmark: true, michael@0: uri: "http://example.com/a", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: title: "z", michael@0: keyword: "a", michael@0: isInQuery: true }, michael@0: michael@0: { isBookmark: true, michael@0: uri: "http://example.com/c", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: title: "x", michael@0: keyword: "c", michael@0: isInQuery: true }, michael@0: michael@0: { isBookmark: true, michael@0: uri: "http://example.com/b1", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: title: "y9", michael@0: keyword: "b", michael@0: isInQuery: true }, michael@0: michael@0: // without a keyword, should fall back to title michael@0: { isBookmark: true, michael@0: uri: "http://example.com/null2", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: title: "null8", michael@0: keyword: null, michael@0: isInQuery: true }, michael@0: michael@0: // without a keyword, should fall back to title michael@0: { isBookmark: true, michael@0: uri: "http://example.com/null1", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: title: "null9", michael@0: keyword: null, michael@0: isInQuery: true }, michael@0: michael@0: // if keywords are equal, should fall back to title michael@0: { isBookmark: true, michael@0: uri: "http://example.com/b2", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: title: "y8", michael@0: keyword: "b", michael@0: isInQuery: true }, michael@0: ]; michael@0: michael@0: this._sortedData = [ michael@0: this._unsortedData[3], michael@0: this._unsortedData[4], michael@0: this._unsortedData[0], michael@0: this._unsortedData[5], michael@0: this._unsortedData[2], michael@0: this._unsortedData[1], michael@0: ]; michael@0: michael@0: // This function in head_queries.js creates our database with the above data michael@0: yield task_populateDB(this._unsortedData); michael@0: }, michael@0: michael@0: check: function() { michael@0: // Query michael@0: var query = PlacesUtils.history.getNewQuery(); michael@0: query.setFolders([PlacesUtils.bookmarks.toolbarFolder], 1); michael@0: query.onlyBookmarked = true; michael@0: michael@0: // query options michael@0: var options = PlacesUtils.history.getNewQueryOptions(); michael@0: options.sortingMode = this._sortingMode; michael@0: michael@0: // Results - this gets the result set and opens it for reading and modification. michael@0: var result = PlacesUtils.history.executeQuery(query, options); michael@0: var root = result.root; michael@0: root.containerOpen = true; michael@0: compareArrayToResult(this._sortedData, root); michael@0: root.containerOpen = false; michael@0: }, michael@0: michael@0: check_reverse: function() { michael@0: this._sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_KEYWORD_DESCENDING; michael@0: this._sortedData.reverse(); michael@0: this.check(); michael@0: } michael@0: }); michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: tests.push({ michael@0: _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_DATEADDED_ASCENDING, michael@0: michael@0: setup: function() { michael@0: LOG("Sorting test 7: SORT BY DATEADDED"); michael@0: michael@0: var timeInMicroseconds = Date.now() * 1000; michael@0: this._unsortedData = [ michael@0: { isBookmark: true, michael@0: uri: "http://example.com/b1", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 0, michael@0: title: "y1", michael@0: dateAdded: timeInMicroseconds -1, michael@0: isInQuery: true }, michael@0: michael@0: { isBookmark: true, michael@0: uri: "http://example.com/a", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 1, michael@0: title: "z", michael@0: dateAdded: timeInMicroseconds - 2, michael@0: isInQuery: true }, michael@0: michael@0: { isBookmark: true, michael@0: uri: "http://example.com/c", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 2, michael@0: title: "x", michael@0: dateAdded: timeInMicroseconds, michael@0: isInQuery: true }, michael@0: michael@0: // if dateAddeds are equal, should fall back to title michael@0: { isBookmark: true, michael@0: uri: "http://example.com/b2", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 3, michael@0: title: "y2", michael@0: dateAdded: timeInMicroseconds - 1, michael@0: isInQuery: true }, michael@0: michael@0: // if dateAddeds and titles are equal, should fall back to bookmark index michael@0: { isBookmark: true, michael@0: uri: "http://example.com/b3", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 4, michael@0: title: "y3", michael@0: dateAdded: timeInMicroseconds - 1, michael@0: isInQuery: true }, michael@0: ]; michael@0: michael@0: this._sortedData = [ michael@0: this._unsortedData[1], michael@0: this._unsortedData[0], michael@0: this._unsortedData[3], michael@0: this._unsortedData[4], michael@0: this._unsortedData[2], michael@0: ]; michael@0: michael@0: // This function in head_queries.js creates our database with the above data michael@0: yield task_populateDB(this._unsortedData); michael@0: }, michael@0: michael@0: check: function() { michael@0: // Query michael@0: var query = PlacesUtils.history.getNewQuery(); michael@0: query.setFolders([PlacesUtils.bookmarks.toolbarFolder], 1); michael@0: query.onlyBookmarked = true; michael@0: michael@0: // query options michael@0: var options = PlacesUtils.history.getNewQueryOptions(); michael@0: options.sortingMode = this._sortingMode; michael@0: michael@0: // Results - this gets the result set and opens it for reading and modification. michael@0: var result = PlacesUtils.history.executeQuery(query, options); michael@0: var root = result.root; michael@0: root.containerOpen = true; michael@0: compareArrayToResult(this._sortedData, root); michael@0: root.containerOpen = false; michael@0: }, michael@0: michael@0: check_reverse: function() { michael@0: this._sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_DATEADDED_DESCENDING; michael@0: this._sortedData.reverse(); michael@0: this.check(); michael@0: } michael@0: }); michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: tests.push({ michael@0: _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_LASTMODIFIED_ASCENDING, michael@0: michael@0: setup: function() { michael@0: LOG("Sorting test 8: SORT BY LASTMODIFIED"); michael@0: michael@0: var timeInMicroseconds = Date.now() * 1000; michael@0: this._unsortedData = [ michael@0: { isBookmark: true, michael@0: uri: "http://example.com/b1", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 0, michael@0: title: "y1", michael@0: lastModified: timeInMicroseconds -1, michael@0: isInQuery: true }, michael@0: michael@0: { isBookmark: true, michael@0: uri: "http://example.com/a", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 1, michael@0: title: "z", michael@0: lastModified: timeInMicroseconds - 2, michael@0: isInQuery: true }, michael@0: michael@0: { isBookmark: true, michael@0: uri: "http://example.com/c", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 2, michael@0: title: "x", michael@0: lastModified: timeInMicroseconds, michael@0: isInQuery: true }, michael@0: michael@0: // if lastModifieds are equal, should fall back to title michael@0: { isBookmark: true, michael@0: uri: "http://example.com/b2", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 3, michael@0: title: "y2", michael@0: lastModified: timeInMicroseconds - 1, michael@0: isInQuery: true }, michael@0: michael@0: // if lastModifieds and titles are equal, should fall back to bookmark michael@0: // index michael@0: { isBookmark: true, michael@0: uri: "http://example.com/b3", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: 4, michael@0: title: "y3", michael@0: lastModified: timeInMicroseconds - 1, michael@0: isInQuery: true }, michael@0: ]; michael@0: michael@0: this._sortedData = [ michael@0: this._unsortedData[1], michael@0: this._unsortedData[0], michael@0: this._unsortedData[3], michael@0: this._unsortedData[4], michael@0: this._unsortedData[2], michael@0: ]; michael@0: michael@0: // This function in head_queries.js creates our database with the above data michael@0: yield task_populateDB(this._unsortedData); michael@0: }, michael@0: michael@0: check: function() { michael@0: // Query michael@0: var query = PlacesUtils.history.getNewQuery(); michael@0: query.setFolders([PlacesUtils.bookmarks.toolbarFolder], 1); michael@0: query.onlyBookmarked = true; michael@0: michael@0: // query options michael@0: var options = PlacesUtils.history.getNewQueryOptions(); michael@0: options.sortingMode = this._sortingMode; michael@0: michael@0: // Results - this gets the result set and opens it for reading and modification. michael@0: var result = PlacesUtils.history.executeQuery(query, options); michael@0: var root = result.root; michael@0: root.containerOpen = true; michael@0: compareArrayToResult(this._sortedData, root); michael@0: root.containerOpen = false; michael@0: }, michael@0: michael@0: check_reverse: function() { michael@0: this._sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_LASTMODIFIED_DESCENDING; michael@0: this._sortedData.reverse(); michael@0: this.check(); michael@0: } michael@0: }); michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: tests.push({ michael@0: _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_TAGS_ASCENDING, michael@0: michael@0: setup: function() { michael@0: LOG("Sorting test 9: SORT BY TAGS"); michael@0: michael@0: this._unsortedData = [ michael@0: { isBookmark: true, michael@0: uri: "http://url2.com/", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: title: "title x", michael@0: isTag: true, michael@0: tagArray: ["x", "y", "z"], michael@0: isInQuery: true }, michael@0: michael@0: { isBookmark: true, michael@0: uri: "http://url1a.com/", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: title: "title y1", michael@0: isTag: true, michael@0: tagArray: ["a", "b"], michael@0: isInQuery: true }, michael@0: michael@0: { isBookmark: true, michael@0: uri: "http://url3a.com/", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: title: "title w1", michael@0: isInQuery: true }, michael@0: michael@0: { isBookmark: true, michael@0: uri: "http://url0.com/", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: title: "title z", michael@0: isTag: true, michael@0: tagArray: ["a", "y", "z"], michael@0: isInQuery: true }, michael@0: michael@0: // if tags are equal, should fall back to title michael@0: { isBookmark: true, michael@0: uri: "http://url1b.com/", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: title: "title y2", michael@0: isTag: true, michael@0: tagArray: ["b", "a"], michael@0: isInQuery: true }, michael@0: michael@0: // if tags are equal, should fall back to title michael@0: { isBookmark: true, michael@0: uri: "http://url3b.com/", michael@0: parentFolder: PlacesUtils.bookmarks.toolbarFolder, michael@0: index: PlacesUtils.bookmarks.DEFAULT_INDEX, michael@0: title: "title w2", michael@0: isInQuery: true }, michael@0: ]; michael@0: michael@0: this._sortedData = [ michael@0: this._unsortedData[2], michael@0: this._unsortedData[5], michael@0: this._unsortedData[1], michael@0: this._unsortedData[4], michael@0: this._unsortedData[3], michael@0: this._unsortedData[0], michael@0: ]; michael@0: michael@0: // This function in head_queries.js creates our database with the above data michael@0: yield task_populateDB(this._unsortedData); michael@0: }, michael@0: michael@0: check: function() { michael@0: // Query michael@0: var query = PlacesUtils.history.getNewQuery(); michael@0: query.setFolders([PlacesUtils.bookmarks.toolbarFolder], 1); michael@0: query.onlyBookmarked = true; michael@0: michael@0: // query options michael@0: var options = PlacesUtils.history.getNewQueryOptions(); michael@0: options.sortingMode = this._sortingMode; michael@0: michael@0: // Results - this gets the result set and opens it for reading and modification. michael@0: var result = PlacesUtils.history.executeQuery(query, options); michael@0: var root = result.root; michael@0: root.containerOpen = true; michael@0: compareArrayToResult(this._sortedData, root); michael@0: root.containerOpen = false; michael@0: }, michael@0: michael@0: check_reverse: function() { michael@0: this._sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_TAGS_DESCENDING; michael@0: this._sortedData.reverse(); michael@0: this.check(); michael@0: } michael@0: }); michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // SORT_BY_ANNOTATION_* (int32) michael@0: michael@0: tests.push({ michael@0: _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_ANNOTATION_ASCENDING, michael@0: michael@0: setup: function() { michael@0: LOG("Sorting test 10: SORT BY ANNOTATION (int32)"); michael@0: michael@0: var timeInMicroseconds = Date.now() * 1000; michael@0: this._unsortedData = [ michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: lastVisit: timeInMicroseconds, michael@0: uri: "http://example.com/b1", michael@0: title: "y1", michael@0: isPageAnnotation: true, michael@0: annoName: "sorting", michael@0: annoVal: 2, michael@0: annoFlags: 0, michael@0: annoExpiration: Ci.nsIAnnotationService.EXPIRE_NEVER, michael@0: isInQuery: true }, michael@0: michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: lastVisit: timeInMicroseconds, michael@0: uri: "http://example.com/a", michael@0: title: "z", michael@0: isPageAnnotation: true, michael@0: annoName: "sorting", michael@0: annoVal: 1, michael@0: annoFlags: 0, michael@0: annoExpiration: Ci.nsIAnnotationService.EXPIRE_NEVER, michael@0: isInQuery: true }, michael@0: michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: lastVisit: timeInMicroseconds, michael@0: uri: "http://example.com/c", michael@0: title: "x", michael@0: isPageAnnotation: true, michael@0: annoName: "sorting", michael@0: annoVal: 3, michael@0: annoFlags: 0, michael@0: annoExpiration: Ci.nsIAnnotationService.EXPIRE_NEVER, michael@0: isInQuery: true }, michael@0: michael@0: // if annotations are equal, should fall back to title michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: lastVisit: timeInMicroseconds, michael@0: uri: "http://example.com/b2", michael@0: title: "y2", michael@0: isPageAnnotation: true, michael@0: annoName: "sorting", michael@0: annoVal: 2, michael@0: annoFlags: 0, michael@0: annoExpiration: Ci.nsIAnnotationService.EXPIRE_NEVER, michael@0: isInQuery: true }, michael@0: ]; michael@0: michael@0: this._sortedData = [ michael@0: this._unsortedData[1], michael@0: this._unsortedData[0], michael@0: this._unsortedData[3], michael@0: this._unsortedData[2], michael@0: ]; michael@0: michael@0: // This function in head_queries.js creates our database with the above data michael@0: yield task_populateDB(this._unsortedData); michael@0: }, michael@0: michael@0: check: function() { michael@0: // Query michael@0: var query = PlacesUtils.history.getNewQuery(); michael@0: michael@0: // query options michael@0: var options = PlacesUtils.history.getNewQueryOptions(); michael@0: options.sortingAnnotation = "sorting"; michael@0: options.sortingMode = this._sortingMode; michael@0: michael@0: // Results - this gets the result set and opens it for reading and modification. michael@0: var result = PlacesUtils.history.executeQuery(query, options); michael@0: var root = result.root; michael@0: root.containerOpen = true; michael@0: compareArrayToResult(this._sortedData, root); michael@0: root.containerOpen = false; michael@0: }, michael@0: michael@0: check_reverse: function() { michael@0: this._sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_ANNOTATION_DESCENDING; michael@0: this._sortedData.reverse(); michael@0: this.check(); michael@0: } michael@0: }); michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // SORT_BY_ANNOTATION_* (int64) michael@0: michael@0: tests.push({ michael@0: _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_ANNOTATION_ASCENDING, michael@0: michael@0: setup: function() { michael@0: LOG("Sorting test 11: SORT BY ANNOTATION (int64)"); michael@0: michael@0: var timeInMicroseconds = Date.now() * 1000; michael@0: this._unsortedData = [ michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: uri: "http://moz.com/", michael@0: lastVisit: timeInMicroseconds, michael@0: title: "I", michael@0: isPageAnnotation: true, michael@0: annoName: "sorting", michael@0: annoVal: 0xffffffff1, michael@0: annoFlags: 0, michael@0: annoExpiration: Ci.nsIAnnotationService.EXPIRE_NEVER, michael@0: isInQuery: true }, michael@0: michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: uri: "http://is.com/", michael@0: lastVisit: timeInMicroseconds, michael@0: title: "love", michael@0: isPageAnnotation: true, michael@0: annoName: "sorting", michael@0: annoVal: 0xffffffff0, michael@0: annoFlags: 0, michael@0: annoExpiration: Ci.nsIAnnotationService.EXPIRE_NEVER, michael@0: isInQuery: true }, michael@0: michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: uri: "http://best.com/", michael@0: lastVisit: timeInMicroseconds, michael@0: title: "moz", michael@0: isPageAnnotation: true, michael@0: annoName: "sorting", michael@0: annoVal: 0xffffffff2, michael@0: annoFlags: 0, michael@0: annoExpiration: Ci.nsIAnnotationService.EXPIRE_NEVER, michael@0: isInQuery: true }, michael@0: ]; michael@0: michael@0: this._sortedData = [ michael@0: this._unsortedData[1], michael@0: this._unsortedData[0], michael@0: this._unsortedData[2], michael@0: ]; michael@0: michael@0: // This function in head_queries.js creates our database with the above data michael@0: yield task_populateDB(this._unsortedData); michael@0: }, michael@0: michael@0: check: function() { michael@0: // Query michael@0: var query = PlacesUtils.history.getNewQuery(); michael@0: michael@0: // query options michael@0: var options = PlacesUtils.history.getNewQueryOptions(); michael@0: options.sortingAnnotation = "sorting"; michael@0: options.sortingMode = this._sortingMode; michael@0: michael@0: // Results - this gets the result set and opens it for reading and modification. michael@0: var result = PlacesUtils.history.executeQuery(query, options); michael@0: var root = result.root; michael@0: root.containerOpen = true; michael@0: compareArrayToResult(this._sortedData, root); michael@0: root.containerOpen = false; michael@0: }, michael@0: michael@0: check_reverse: function() { michael@0: this._sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_ANNOTATION_DESCENDING; michael@0: this._sortedData.reverse(); michael@0: this.check(); michael@0: } michael@0: }); michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // SORT_BY_ANNOTATION_* (string) michael@0: michael@0: tests.push({ michael@0: _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_ANNOTATION_ASCENDING, michael@0: michael@0: setup: function() { michael@0: LOG("Sorting test 12: SORT BY ANNOTATION (string)"); michael@0: michael@0: var timeInMicroseconds = Date.now() * 1000; michael@0: this._unsortedData = [ michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: uri: "http://moz.com/", michael@0: lastVisit: timeInMicroseconds, michael@0: title: "I", michael@0: isPageAnnotation: true, michael@0: annoName: "sorting", michael@0: annoVal: "a", michael@0: annoFlags: 0, michael@0: annoExpiration: Ci.nsIAnnotationService.EXPIRE_NEVER, michael@0: isInQuery: true }, michael@0: michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: uri: "http://is.com/", michael@0: lastVisit: timeInMicroseconds, michael@0: title: "love", michael@0: isPageAnnotation: true, michael@0: annoName: "sorting", michael@0: annoVal: "", michael@0: annoFlags: 0, michael@0: annoExpiration: Ci.nsIAnnotationService.EXPIRE_NEVER, michael@0: isInQuery: true }, michael@0: michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: uri: "http://best.com/", michael@0: lastVisit: timeInMicroseconds, michael@0: title: "moz", michael@0: isPageAnnotation: true, michael@0: annoName: "sorting", michael@0: annoVal: "z", michael@0: annoFlags: 0, michael@0: annoExpiration: Ci.nsIAnnotationService.EXPIRE_NEVER, michael@0: isInQuery: true }, michael@0: ]; michael@0: michael@0: this._sortedData = [ michael@0: this._unsortedData[1], michael@0: this._unsortedData[0], michael@0: this._unsortedData[2], michael@0: ]; michael@0: michael@0: // This function in head_queries.js creates our database with the above data michael@0: yield task_populateDB(this._unsortedData); michael@0: }, michael@0: michael@0: check: function() { michael@0: // Query michael@0: var query = PlacesUtils.history.getNewQuery(); michael@0: michael@0: // query options michael@0: var options = PlacesUtils.history.getNewQueryOptions(); michael@0: options.sortingAnnotation = "sorting"; michael@0: options.sortingMode = this._sortingMode; michael@0: michael@0: // Results - this gets the result set and opens it for reading and modification. michael@0: var result = PlacesUtils.history.executeQuery(query, options); michael@0: var root = result.root; michael@0: root.containerOpen = true; michael@0: compareArrayToResult(this._sortedData, root); michael@0: root.containerOpen = false; michael@0: }, michael@0: michael@0: check_reverse: function() { michael@0: this._sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_ANNOTATION_DESCENDING; michael@0: this._sortedData.reverse(); michael@0: this.check(); michael@0: } michael@0: }); michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // SORT_BY_ANNOTATION_* (double) michael@0: michael@0: tests.push({ michael@0: _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_ANNOTATION_ASCENDING, michael@0: michael@0: setup: function() { michael@0: LOG("Sorting test 13: SORT BY ANNOTATION (double)"); michael@0: michael@0: var timeInMicroseconds = Date.now() * 1000; michael@0: this._unsortedData = [ michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: uri: "http://moz.com/", michael@0: lastVisit: timeInMicroseconds, michael@0: title: "I", michael@0: isPageAnnotation: true, michael@0: annoName: "sorting", michael@0: annoVal: 1.2, michael@0: annoFlags: 0, michael@0: annoExpiration: Ci.nsIAnnotationService.EXPIRE_NEVER, michael@0: isInQuery: true }, michael@0: michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: uri: "http://is.com/", michael@0: lastVisit: timeInMicroseconds, michael@0: title: "love", michael@0: isPageAnnotation: true, michael@0: annoName: "sorting", michael@0: annoVal: 1.1, michael@0: annoFlags: 0, michael@0: annoExpiration: Ci.nsIAnnotationService.EXPIRE_NEVER, michael@0: isInQuery: true }, michael@0: michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: uri: "http://best.com/", michael@0: lastVisit: timeInMicroseconds, michael@0: title: "moz", michael@0: isPageAnnotation: true, michael@0: annoName: "sorting", michael@0: annoVal: 1.3, michael@0: annoFlags: 0, michael@0: annoExpiration: Ci.nsIAnnotationService.EXPIRE_NEVER, michael@0: isInQuery: true }, michael@0: ]; michael@0: michael@0: this._sortedData = [ michael@0: this._unsortedData[1], michael@0: this._unsortedData[0], michael@0: this._unsortedData[2], michael@0: ]; michael@0: michael@0: // This function in head_queries.js creates our database with the above data michael@0: yield task_populateDB(this._unsortedData); michael@0: }, michael@0: michael@0: check: function() { michael@0: // Query michael@0: var query = PlacesUtils.history.getNewQuery(); michael@0: michael@0: // query options michael@0: var options = PlacesUtils.history.getNewQueryOptions(); michael@0: options.sortingAnnotation = "sorting"; michael@0: options.sortingMode = this._sortingMode; michael@0: michael@0: // Results - this gets the result set and opens it for reading and modification. michael@0: var result = PlacesUtils.history.executeQuery(query, options); michael@0: var root = result.root; michael@0: root.containerOpen = true; michael@0: compareArrayToResult(this._sortedData, root); michael@0: root.containerOpen = false; michael@0: }, michael@0: michael@0: check_reverse: function() { michael@0: this._sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_ANNOTATION_DESCENDING; michael@0: this._sortedData.reverse(); michael@0: this.check(); michael@0: } michael@0: }); michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // SORT_BY_FRECENCY_* michael@0: michael@0: tests.push({ michael@0: _sortingMode: Ci.nsINavHistoryQueryOptions.SORT_BY_FRECENCY_ASCENDING, michael@0: michael@0: setup: function() { michael@0: LOG("Sorting test 13: SORT BY FRECENCY "); michael@0: michael@0: var timeInMicroseconds = Date.now() * 1000; michael@0: this._unsortedData = [ michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: uri: "http://moz.com/", michael@0: lastVisit: timeInMicroseconds++, michael@0: title: "I", michael@0: isInQuery: true }, michael@0: michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: uri: "http://moz.com/", michael@0: lastVisit: timeInMicroseconds++, michael@0: title: "I", michael@0: isInQuery: true }, michael@0: michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: uri: "http://moz.com/", michael@0: lastVisit: timeInMicroseconds++, michael@0: title: "I", michael@0: isInQuery: true }, michael@0: michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: uri: "http://is.com/", michael@0: lastVisit: timeInMicroseconds++, michael@0: title: "love", michael@0: isInQuery: true }, michael@0: michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: uri: "http://best.com/", michael@0: lastVisit: timeInMicroseconds++, michael@0: title: "moz", michael@0: isInQuery: true }, michael@0: michael@0: { isVisit: true, michael@0: isDetails: true, michael@0: uri: "http://best.com/", michael@0: lastVisit: timeInMicroseconds++, michael@0: title: "moz", michael@0: isInQuery: true }, michael@0: ]; michael@0: michael@0: this._sortedData = [ michael@0: this._unsortedData[3], michael@0: this._unsortedData[5], michael@0: this._unsortedData[2], michael@0: ]; michael@0: michael@0: // This function in head_queries.js creates our database with the above data michael@0: yield task_populateDB(this._unsortedData); michael@0: }, michael@0: michael@0: check: function() { michael@0: var query = PlacesUtils.history.getNewQuery(); michael@0: var options = PlacesUtils.history.getNewQueryOptions(); michael@0: options.sortingMode = this._sortingMode; michael@0: michael@0: var root = PlacesUtils.history.executeQuery(query, options).root; michael@0: root.containerOpen = true; michael@0: compareArrayToResult(this._sortedData, root); michael@0: root.containerOpen = false; michael@0: }, michael@0: michael@0: check_reverse: function() { michael@0: this._sortingMode = Ci.nsINavHistoryQueryOptions.SORT_BY_FRECENCY_DESCENDING; michael@0: this._sortedData.reverse(); michael@0: this.check(); michael@0: } michael@0: }); michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: function run_test() michael@0: { michael@0: run_next_test(); michael@0: } michael@0: michael@0: add_task(function test_sorting() michael@0: { michael@0: for (let [, test] in Iterator(tests)) { michael@0: yield test.setup(); michael@0: yield promiseAsyncUpdates(); michael@0: test.check(); michael@0: // sorting reversed, usually SORT_BY have ASC and DESC michael@0: test.check_reverse(); michael@0: // Execute cleanup tasks michael@0: remove_all_bookmarks(); michael@0: yield promiseClearHistory(); michael@0: } michael@0: });