summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/tests/queries/test_results-as-visit.js
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-02-25 15:07:00 -0500
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 12:55:19 +0200
commiteb70e6e3d0bff11c25f14b1196025791bf2308fb (patch)
tree5ef4ce17db83c74d7b05ec12c8f59e095a6dd5bd /toolkit/components/places/tests/queries/test_results-as-visit.js
parent32ead795290b3399d56b4708fc75b77d296f6a1a (diff)
downloadUXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.gz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.lz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.xz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.zip
Issue #439 - Remove tests from toolkit/
Diffstat (limited to 'toolkit/components/places/tests/queries/test_results-as-visit.js')
-rw-r--r--toolkit/components/places/tests/queries/test_results-as-visit.js119
1 files changed, 0 insertions, 119 deletions
diff --git a/toolkit/components/places/tests/queries/test_results-as-visit.js b/toolkit/components/places/tests/queries/test_results-as-visit.js
deleted file mode 100644
index d0f270bd2..000000000
--- a/toolkit/components/places/tests/queries/test_results-as-visit.js
+++ /dev/null
@@ -1,119 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim:set ts=2 sw=2 sts=2 et: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-var testData = [];
-var timeInMicroseconds = PlacesUtils.toPRTime(Date.now() - 10000);
-
-function newTimeInMicroseconds() {
- timeInMicroseconds = timeInMicroseconds + 1000;
- return timeInMicroseconds;
-}
-
-function createTestData() {
- function generateVisits(aPage) {
- for (var i = 0; i < aPage.visitCount; i++) {
- testData.push({ isInQuery: aPage.inQuery,
- isVisit: true,
- title: aPage.title,
- uri: aPage.uri,
- lastVisit: newTimeInMicroseconds(),
- isTag: aPage.tags && aPage.tags.length > 0,
- tagArray: aPage.tags });
- }
- }
-
- var pages = [
- { uri: "http://foo.com/", title: "amo", tags: ["moz"], visitCount: 3, inQuery: true },
- { uri: "http://moilla.com/", title: "bMoz", tags: ["bugzilla"], visitCount: 5, inQuery: true },
- { uri: "http://foo.mail.com/changeme1.html", title: "c Moz", visitCount: 7, inQuery: true },
- { uri: "http://foo.mail.com/changeme2.html", tags: ["moz"], title: "", visitCount: 1, inQuery: false },
- { uri: "http://foo.mail.com/changeme3.html", title: "zydeco", visitCount: 5, inQuery: false },
- ];
- pages.forEach(generateVisits);
-}
-
-/**
- * This test will test Queries that use relative search terms and URI options
- */
-function run_test()
-{
- run_next_test();
-}
-
-add_task(function* test_results_as_visit()
-{
- createTestData();
- yield task_populateDB(testData);
- var query = PlacesUtils.history.getNewQuery();
- query.searchTerms = "moz";
- query.minVisits = 2;
-
- // Options
- var options = PlacesUtils.history.getNewQueryOptions();
- options.sortingMode = options.SORT_BY_VISITCOUNT_ASCENDING;
- options.resultType = options.RESULTS_AS_VISIT;
-
- // Results
- var result = PlacesUtils.history.executeQuery(query, options);
- var root = result.root;
- root.containerOpen = true;
-
- do_print("Number of items in result set: " + root.childCount);
- for (let i=0; i < root.childCount; ++i) {
- do_print("result: " + root.getChild(i).uri + " Title: " + root.getChild(i).title);
- }
-
- // Check our inital result set
- compareArrayToResult(testData, root);
-
- // If that passes, check liveupdate
- // Add to the query set
- do_print("Adding item to query")
- var tmp = [];
- for (let i=0; i < 2; i++) {
- tmp.push({ isVisit: true,
- uri: "http://foo.com/added.html",
- title: "ab moz" });
- }
- yield task_populateDB(tmp);
- for (let i=0; i < 2; i++)
- do_check_eq(root.getChild(i).title, "ab moz");
-
- // Update an existing URI
- do_print("Updating Item");
- var change2 = [{ isVisit: true,
- title: "moz",
- uri: "http://foo.mail.com/changeme2.html" }];
- yield task_populateDB(change2);
- do_check_true(isInResult(change2, root));
-
- // Update some visits - add one and take one out of query set, and simply
- // change one so that it still applies to the query.
- do_print("Updating More Items");
- var change3 = [{ isVisit: true,
- lastVisit: newTimeInMicroseconds(),
- uri: "http://foo.mail.com/changeme1.html",
- title: "foo"},
- { isVisit: true,
- lastVisit: newTimeInMicroseconds(),
- uri: "http://foo.mail.com/changeme3.html",
- title: "moz",
- isTag: true,
- tagArray: ["foo", "moz"] }];
- yield task_populateDB(change3);
- do_check_false(isInResult({uri: "http://foo.mail.com/changeme1.html"}, root));
- do_check_true(isInResult({uri: "http://foo.mail.com/changeme3.html"}, root));
-
- // And now, delete one
- do_print("Delete item outside of batch");
- var change4 = [{ isVisit: true,
- lastVisit: newTimeInMicroseconds(),
- uri: "http://moilla.com/",
- title: "mo,z" }];
- yield task_populateDB(change4);
- do_check_false(isInResult(change4, root));
-
- root.containerOpen = false;
-});