summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/tests/browser/browser_visituri.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/browser/browser_visituri.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/browser/browser_visituri.js')
-rw-r--r--toolkit/components/places/tests/browser/browser_visituri.js84
1 files changed, 0 insertions, 84 deletions
diff --git a/toolkit/components/places/tests/browser/browser_visituri.js b/toolkit/components/places/tests/browser/browser_visituri.js
deleted file mode 100644
index 8ba2b7272..000000000
--- a/toolkit/components/places/tests/browser/browser_visituri.js
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * One-time observer callback.
- */
-function promiseObserve(name, checkFn) {
- return new Promise(resolve => {
- Services.obs.addObserver(function observer(subject) {
- if (checkFn(subject)) {
- Services.obs.removeObserver(observer, name);
- resolve();
- }
- }, name, false);
- });
-}
-
-var conn = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase).DBConnection;
-
-/**
- * Gets a single column value from either the places or historyvisits table.
- */
-function getColumn(table, column, fromColumnName, fromColumnValue) {
- let sql = `SELECT ${column}
- FROM ${table}
- WHERE ${fromColumnName} = :val
- ${fromColumnName == "url" ? "AND url_hash = hash(:val)" : ""}
- LIMIT 1`;
- let stmt = conn.createStatement(sql);
- try {
- stmt.params.val = fromColumnValue;
- ok(stmt.executeStep(), "Expect to get a row");
- return stmt.row[column];
- }
- finally {
- stmt.reset();
- }
-}
-
-add_task(function* () {
- // Make sure places visit chains are saved correctly with a redirect
- // transitions.
-
- // Part 1: observe history events that fire when a visit occurs.
- // Make sure visits appear in order, and that the visit chain is correct.
- var expectedUrls = [
- "http://example.com/tests/toolkit/components/places/tests/browser/begin.html",
- "http://example.com/tests/toolkit/components/places/tests/browser/redirect_twice.sjs",
- "http://example.com/tests/toolkit/components/places/tests/browser/redirect_once.sjs",
- "http://example.com/tests/toolkit/components/places/tests/browser/final.html"
- ];
- var currentIndex = 0;
-
- function checkObserver(subject) {
- var uri = subject.QueryInterface(Ci.nsIURI);
- var expected = expectedUrls[currentIndex];
- is(uri.spec, expected, "Saved URL visit " + uri.spec);
-
- var placeId = getColumn("moz_places", "id", "url", uri.spec);
- var fromVisitId = getColumn("moz_historyvisits", "from_visit", "place_id", placeId);
-
- if (currentIndex == 0) {
- is(fromVisitId, 0, "First visit has no from visit");
- }
- else {
- var lastVisitId = getColumn("moz_historyvisits", "place_id", "id", fromVisitId);
- var fromVisitUrl = getColumn("moz_places", "url", "id", lastVisitId);
- is(fromVisitUrl, expectedUrls[currentIndex - 1],
- "From visit was " + expectedUrls[currentIndex - 1]);
- }
-
- currentIndex++;
- return (currentIndex >= expectedUrls.length);
- }
- let visitUriPromise = promiseObserve("uri-visit-saved", checkObserver);
-
- const testUrl = "http://example.com/tests/toolkit/components/places/tests/browser/begin.html";
- yield BrowserTestUtils.openNewForegroundTab(gBrowser, testUrl);
-
- // Load begin page, click link on page to record visits.
- yield BrowserTestUtils.synthesizeMouseAtCenter("#clickme", { }, gBrowser.selectedBrowser);
- yield visitUriPromise;
-
- yield PlacesTestUtils.clearHistory();
-
- gBrowser.removeCurrentTab();
-});