зеркало из https://github.com/mozilla/gecko-dev.git
Bug 542941 - Part6: fix existing tests to check for the new transition type, r=dietrich
This commit is contained in:
Родитель
702b498222
Коммит
c006ade33b
|
@ -46,6 +46,7 @@ const TRANSITION_LINK = Ci.nsINavHistoryService.TRANSITION_LINK;
|
|||
const TRANSITION_TYPED = Ci.nsINavHistoryService.TRANSITION_TYPED;
|
||||
const TRANSITION_BOOKMARK = Ci.nsINavHistoryService.TRANSITION_BOOKMARK;
|
||||
const TRANSITION_EMBED = Ci.nsINavHistoryService.TRANSITION_EMBED;
|
||||
const TRANSITION_FRAMED_LINK = Ci.nsINavHistoryService.TRANSITION_FRAMED_LINK;
|
||||
const TRANSITION_REDIRECT_PERMANENT = Ci.nsINavHistoryService.TRANSITION_REDIRECT_PERMANENT;
|
||||
const TRANSITION_REDIRECT_TEMPORARY = Ci.nsINavHistoryService.TRANSITION_REDIRECT_TEMPORARY;
|
||||
const TRANSITION_DOWNLOAD = Ci.nsINavHistoryService.TRANSITION_DOWNLOAD;
|
||||
|
|
|
@ -38,29 +38,35 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* Tests bug 449406 to ensure that TRANSITION_DOWNLOAD and TRANSITION_EMBED
|
||||
* bookmarked uri's show up in the location bar.
|
||||
* Tests bug 449406 to ensure that TRANSITION_DOWNLOAD, TRANSITION_EMBED and
|
||||
* TRANSITION_FRAMED_LINK bookmarked uri's show up in the location bar.
|
||||
*/
|
||||
|
||||
// Define some shared uris and titles (each page needs its own uri)
|
||||
let kURIs = [
|
||||
"http://download/bookmarked",
|
||||
"http://embed/bookmarked",
|
||||
"http://framed/bookmarked",
|
||||
"http://download",
|
||||
"http://embed",
|
||||
"http://framed",
|
||||
];
|
||||
let kTitles = [
|
||||
"download-bookmark",
|
||||
"embed-bookmark",
|
||||
"framed-bookmark",
|
||||
"download2",
|
||||
"embed2",
|
||||
"framed2",
|
||||
];
|
||||
|
||||
// Add download and embed uris
|
||||
addPageBook(0, 0, 0, undefined, undefined, TRANSITION_DOWNLOAD);
|
||||
addPageBook(1, 1, 1, undefined, undefined, TRANSITION_EMBED);
|
||||
addPageBook(2, 2, undefined, undefined, undefined, TRANSITION_DOWNLOAD);
|
||||
addPageBook(3, 3, undefined, undefined, undefined, TRANSITION_EMBED);
|
||||
addPageBook(2, 2, 2, undefined, undefined, TRANSITION_FRAMED_LINK);
|
||||
addPageBook(3, 3, undefined, undefined, undefined, TRANSITION_DOWNLOAD);
|
||||
addPageBook(4, 4, undefined, undefined, undefined, TRANSITION_EMBED);
|
||||
addPageBook(5, 5, undefined, undefined, undefined, TRANSITION_FRAMED_LINK);
|
||||
|
||||
// Provide for each test: description; search terms; array of gPages indices of
|
||||
// pages that should match; optional function to be run before the test
|
||||
|
@ -69,8 +75,12 @@ let gTests = [
|
|||
kTitles[0], [0]],
|
||||
["1: Searching for bookmarked embed uri matches",
|
||||
kTitles[1], [1]],
|
||||
["2: Searching for download uri does not match",
|
||||
kTitles[2], []],
|
||||
["3: Searching for embed uri does not match",
|
||||
["2: Searching for bookmarked framed uri matches",
|
||||
kTitles[2], [2]],
|
||||
["3: Searching for download uri does not match",
|
||||
kTitles[3], []],
|
||||
["4: Searching for embed uri does not match",
|
||||
kTitles[4], []],
|
||||
["5: Searching for framed uri does not match",
|
||||
kTitles[5], []],
|
||||
];
|
||||
|
|
|
@ -36,32 +36,13 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
try {
|
||||
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].getService(Ci.nsINavHistoryService);
|
||||
} catch(ex) {
|
||||
do_throw("Could not get history service\n");
|
||||
}
|
||||
|
||||
// Get annotation service
|
||||
try {
|
||||
var annosvc= Cc["@mozilla.org/browser/annotation-service;1"].getService(Ci.nsIAnnotationService);
|
||||
} catch(ex) {
|
||||
do_throw("Could not get annotation service\n");
|
||||
}
|
||||
|
||||
function add_visit(aURI, aDate, aReferrer, aType, isRedirect, aSessionID) {
|
||||
var placeID = histsvc.addVisit(aURI,
|
||||
aDate,
|
||||
aReferrer,
|
||||
aType,
|
||||
isRedirect,
|
||||
aSessionID);
|
||||
do_check_true(placeID > 0);
|
||||
return placeID;
|
||||
}
|
||||
let histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
let annosvc = Cc["@mozilla.org/browser/annotation-service;1"].
|
||||
getService(Ci.nsIAnnotationService);
|
||||
|
||||
function modHistoryTypes(val){
|
||||
switch(val % 7) {
|
||||
switch(val % 8) {
|
||||
case 0:
|
||||
case 1:
|
||||
return histsvc.TRANSITION_LINK;
|
||||
|
@ -77,6 +58,8 @@ function modHistoryTypes(val){
|
|||
return histsvc.TRANSITION_REDIRECT_TEMPORARY;
|
||||
case 7:
|
||||
return histsvc.TRANSITION_DOWNLOAD;
|
||||
case 8:
|
||||
return histsvc.TRANSITION_FRAMED_LINK;
|
||||
}
|
||||
return histsvc.TRANSITION_TYPED;
|
||||
}
|
||||
|
@ -88,26 +71,28 @@ function modHistoryTypes(val){
|
|||
function buildTestDatabase() {
|
||||
// This is the set of visits that we will match - our min visit is 2 so that's
|
||||
// why we add more visits to the same URIs.
|
||||
var testURI = uri("http://www.foo.com");
|
||||
var testAnnoName = "moz-test-places/testing123";
|
||||
var testAnnoVal = "test";
|
||||
|
||||
for (var i=0; i < 12; ++i)
|
||||
add_visit(testURI,
|
||||
today,
|
||||
null,
|
||||
modHistoryTypes(i), // will work with different values, for ex: histsvc.TRANSITION_TYPED,
|
||||
false,
|
||||
0);
|
||||
let testURI = uri("http://www.foo.com");
|
||||
|
||||
for (let i = 0; i < 12; ++i) {
|
||||
histsvc.addVisit(testURI,
|
||||
today,
|
||||
null,
|
||||
modHistoryTypes(i), // will work with different values, for ex: histsvc.TRANSITION_TYPED,
|
||||
false,
|
||||
0);
|
||||
}
|
||||
|
||||
testURI = uri("http://foo.com/youdontseeme.html");
|
||||
for (var i=0; i < 12; ++i)
|
||||
add_visit(testURI,
|
||||
today,
|
||||
null,
|
||||
modHistoryTypes(i), // will work with different values, for ex: histsvc.TRANSITION_TYPED,
|
||||
false,
|
||||
0);
|
||||
let testAnnoName = "moz-test-places/testing123";
|
||||
let testAnnoVal = "test";
|
||||
for (let i = 0; i < 12; ++i) {
|
||||
histsvc.addVisit(testURI,
|
||||
today,
|
||||
null,
|
||||
modHistoryTypes(i), // will work with different values, for ex: histsvc.TRANSITION_TYPED,
|
||||
false,
|
||||
0);
|
||||
}
|
||||
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, 0);
|
||||
}
|
||||
|
||||
|
@ -122,7 +107,7 @@ function buildTestDatabase() {
|
|||
*/
|
||||
function run_test() {
|
||||
buildTestDatabase();
|
||||
var query = histsvc.getNewQuery();
|
||||
let query = histsvc.getNewQuery();
|
||||
query.annotation = "moz-test-places/testing123";
|
||||
query.beginTime = daybefore * 1000;
|
||||
query.beginTimeReference = histsvc.TIME_RELATIVE_NOW;
|
||||
|
@ -132,20 +117,20 @@ function run_test() {
|
|||
query.maxVisits = 10;
|
||||
|
||||
// Options
|
||||
var options = histsvc.getNewQueryOptions();
|
||||
let options = histsvc.getNewQueryOptions();
|
||||
options.sortingMode = options.SORT_BY_DATE_DESCENDING;
|
||||
options.resultType = options.RESULTS_AS_VISIT;
|
||||
|
||||
// Results
|
||||
var result = histsvc.executeQuery(query, options);
|
||||
var root = result.root;
|
||||
let root = histsvc.executeQuery(query, options).root;
|
||||
root.containerOpen = true;
|
||||
var cc = root.childCount;
|
||||
let cc = root.childCount;
|
||||
dump("----> cc is: " + cc + "\n");
|
||||
for(var i=0; i < root.childCount; ++i) {
|
||||
var resultNode = root.getChild(i);
|
||||
var accesstime = Date(resultNode.time);
|
||||
for(let i = 0; i < root.childCount; ++i) {
|
||||
let resultNode = root.getChild(i);
|
||||
let accesstime = Date(resultNode.time / 1000);
|
||||
dump("----> result: " + resultNode.uri + " Date: " + accesstime.toLocaleString() + "\n");
|
||||
}
|
||||
do_check_eq(cc,0);
|
||||
root.containerOpen = false;
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ function check_results_callback(aSequence) {
|
|||
case Ci.nsINavHistoryService.TRANSITION_DOWNLOAD:
|
||||
return redirectsMode != Ci.nsINavHistoryQueryOptions.REDIRECTS_MODE_TARGET;
|
||||
case Ci.nsINavHistoryService.TRANSITION_EMBED:
|
||||
case Ci.nsINavHistoryService.TRANSITION_FRAMED_LINK:
|
||||
return includeHidden && redirectsMode != Ci.nsINavHistoryQueryOptions.REDIRECTS_MODE_TARGET;
|
||||
case Ci.nsINavHistoryService.TRANSITION_REDIRECT_TEMPORARY:
|
||||
case Ci.nsINavHistoryService.TRANSITION_REDIRECT_PERMANENT:
|
||||
|
@ -224,6 +225,7 @@ function add_visits_to_database() {
|
|||
Ci.nsINavHistoryService.TRANSITION_TYPED,
|
||||
Ci.nsINavHistoryService.TRANSITION_BOOKMARK,
|
||||
Ci.nsINavHistoryService.TRANSITION_EMBED,
|
||||
Ci.nsINavHistoryService.TRANSITION_FRAMED_LINK,
|
||||
// Would make hard sorting by visit date because last_visit_date is actually
|
||||
// calculated excluding download transitions, but the query includes
|
||||
// downloads.
|
||||
|
@ -238,7 +240,8 @@ function add_visits_to_database() {
|
|||
uri: "http://" + transition + ".example.com/",
|
||||
title: transition + "-example",
|
||||
lastVisit: timeInMicroseconds--,
|
||||
visitCount: transition == Ci.nsINavHistoryService.TRANSITION_EMBED ? 0 : visitCount++,
|
||||
visitCount: (transition == Ci.nsINavHistoryService.TRANSITION_EMBED ||
|
||||
transition == Ci.nsINavHistoryService.TRANSITION_FRAMED_LINK) ? 0 : visitCount++,
|
||||
isInQuery: true }));
|
||||
|
||||
// Add a REDIRECT_TEMPORARY layer of visits for each of the above visits.
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
/*
|
||||
* This test checks that embed visits are not synced down to disk, we hold
|
||||
* them in memory since they're going to be purged at session close
|
||||
*
|
||||
* We instead sync to disk FRAMED_LINK visits.
|
||||
*/
|
||||
|
||||
var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
|
@ -65,6 +67,7 @@ var transitions = [ hs.TRANSITION_LINK,
|
|||
hs.TRANSITION_TYPED,
|
||||
hs.TRANSITION_BOOKMARK,
|
||||
hs.TRANSITION_EMBED,
|
||||
hs.TRANSITION_FRAMED_LINK,
|
||||
hs.TRANSITION_REDIRECT_PERMANENT,
|
||||
hs.TRANSITION_REDIRECT_TEMPORARY,
|
||||
hs.TRANSITION_DOWNLOAD ];
|
||||
|
|
|
@ -82,6 +82,7 @@ var bucketPrefs = [
|
|||
|
||||
var bonusPrefs = {
|
||||
embedVisitBonus: Ci.nsINavHistoryService.TRANSITION_EMBED,
|
||||
framedLinkVisitBonus: Ci.nsINavHistoryService.TRANSITION_FRAMED_LINK,
|
||||
linkVisitBonus: Ci.nsINavHistoryService.TRANSITION_LINK,
|
||||
typedVisitBonus: Ci.nsINavHistoryService.TRANSITION_TYPED,
|
||||
bookmarkVisitBonus: Ci.nsINavHistoryService.TRANSITION_BOOKMARK,
|
||||
|
@ -152,6 +153,7 @@ bucketPrefs.every(function(bucket) {
|
|||
if (!points) {
|
||||
if (!visitType ||
|
||||
visitType == Ci.nsINavHistoryService.TRANSITION_EMBED ||
|
||||
visitType == Ci.nsINavHistoryService.TRANSITION_FRAMED_LINK ||
|
||||
visitType == Ci.nsINavHistoryService.TRANSITION_DOWNLOAD ||
|
||||
bonusName == "defaultVisitBonus")
|
||||
frecency = 0;
|
||||
|
|
|
@ -40,38 +40,13 @@
|
|||
// https://wiki.mozilla.org/Firefox3.1/PrivateBrowsing/TestPlan#History
|
||||
// http://developer.mozilla.org/en/Using_the_Places_history_service
|
||||
|
||||
// Get global history service
|
||||
try {
|
||||
var bhist = Cc["@mozilla.org/browser/global-history;2"].
|
||||
getService(Ci.nsIBrowserHistory);
|
||||
} catch(ex) {
|
||||
do_throw("Could not get global history service");
|
||||
}
|
||||
|
||||
// Get bookmark service
|
||||
try {
|
||||
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
|
||||
getService(Ci.nsINavBookmarksService);
|
||||
} catch(ex) {
|
||||
do_throw("Could not get nav-bookmarks-service");
|
||||
}
|
||||
|
||||
// Get history service
|
||||
try {
|
||||
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
} catch(ex) {
|
||||
do_throw("Could not get history service");
|
||||
}
|
||||
|
||||
// Get the IO service
|
||||
try {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Components.interfaces.nsIIOService);
|
||||
} catch(ex) {
|
||||
do_throw("Could not get the io service");
|
||||
}
|
||||
|
||||
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
var bhist = histsvc.QueryInterface(Ci.nsIBrowserHistory);
|
||||
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
|
||||
getService(Ci.nsINavBookmarksService);
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Components.interfaces.nsIIOService);
|
||||
|
||||
/**
|
||||
* Function prohibits an attempt to pop up a confirmation
|
||||
|
@ -137,6 +112,7 @@ var visited_URIs = ["http://www.test-link.com/",
|
|||
"http://www.test-redirect-permanent.com/",
|
||||
"http://www.test-redirect-temporary.com/",
|
||||
"http://www.test-embed.com",
|
||||
"http://www.test-framed.com",
|
||||
"http://www.test-download.com"];
|
||||
|
||||
var nonvisited_URIs = ["http://www.google.ca/",
|
||||
|
@ -144,6 +120,7 @@ var nonvisited_URIs = ["http://www.google.ca/",
|
|||
"http://www.google.co.il/",
|
||||
"http://www.google.fr/",
|
||||
"http://www.google.es",
|
||||
"http://www.google.it",
|
||||
"http://www.google.com.tr",
|
||||
"http://www.google.de"];
|
||||
/**
|
||||
|
@ -155,10 +132,11 @@ function fill_history_visitedURI() {
|
|||
add_visit(visited_URIs[0], histsvc.TRANSITION_LINK);
|
||||
add_visit(visited_URIs[1], histsvc.TRANSITION_TYPED);
|
||||
add_visit(visited_URIs[2], histsvc.TRANSITION_BOOKMARK);
|
||||
add_visit(visited_URIs[3], histsvc.TRANSITION_EMBED);
|
||||
add_visit(visited_URIs[4], histsvc.TRANSITION_REDIRECT_PERMANENT);
|
||||
add_visit(visited_URIs[5], histsvc.TRANSITION_REDIRECT_TEMPORARY);
|
||||
add_visit(visited_URIs[6], histsvc.TRANSITION_DOWNLOAD);
|
||||
add_visit(visited_URIs[3], histsvc.TRANSITION_REDIRECT_PERMANENT);
|
||||
add_visit(visited_URIs[4], histsvc.TRANSITION_REDIRECT_TEMPORARY);
|
||||
add_visit(visited_URIs[5], histsvc.TRANSITION_EMBED);
|
||||
add_visit(visited_URIs[6], histsvc.TRANSITION_FRAMED_LINK);
|
||||
add_visit(visited_URIs[7], histsvc.TRANSITION_DOWNLOAD);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -173,15 +151,16 @@ function fill_history_nonvisitedURI() {
|
|||
add_visit(nonvisited_URIs[2], histsvc.TRANSITION_LINK);
|
||||
add_visit(nonvisited_URIs[3], histsvc.TRANSITION_DOWNLOAD);
|
||||
add_visit(nonvisited_URIs[4], histsvc.TRANSITION_EMBED);
|
||||
add_visit(nonvisited_URIs[5], histsvc.TRANSITION_REDIRECT_PERMANENT);
|
||||
add_visit(nonvisited_URIs[6], histsvc.TRANSITION_REDIRECT_TEMPORARY);
|
||||
add_visit(nonvisited_URIs[5], histsvc.TRANSITION_FRAMED_LINK);
|
||||
add_visit(nonvisited_URIs[6], histsvc.TRANSITION_REDIRECT_PERMANENT);
|
||||
add_visit(nonvisited_URIs[7], histsvc.TRANSITION_REDIRECT_TEMPORARY);
|
||||
}
|
||||
|
||||
// Initial batch of history items (7) + Bookmark_A (1)
|
||||
// This number should not change after tests enter private browsing
|
||||
// it will be set to 9 with the addition of Bookmark-B during private
|
||||
// it will be set to 10 with the addition of Bookmark-B during private
|
||||
// browsing mode.
|
||||
var num_places_entries = 8;
|
||||
var num_places_entries = 9;
|
||||
|
||||
/**
|
||||
* Function performs a really simple query on our places entries,
|
||||
|
@ -331,7 +310,7 @@ function run_test() {
|
|||
|
||||
// A check on the history count should be same as before, 7 history entries with
|
||||
// now 2 bookmark items (A) and bookmark (B), so we set num_places_entries to 9
|
||||
num_places_entries = 9; // Bookmark-B successfully added but not the history entries.
|
||||
num_places_entries = 10; // Bookmark-B successfully added but not the history entries.
|
||||
check_placesItem_Count();
|
||||
|
||||
// Exit Private Browsing Mode
|
||||
|
|
|
@ -40,22 +40,19 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// Get history service
|
||||
try {
|
||||
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].getService(Ci.nsINavHistoryService);
|
||||
} catch(ex) {
|
||||
do_throw("Could not get history service\n");
|
||||
}
|
||||
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
|
||||
// adds a test URI visit to the database, and checks for a valid place ID
|
||||
function add_visit(aURI, aWhen, aType) {
|
||||
var placeID = histsvc.addVisit(aURI,
|
||||
var visitID = histsvc.addVisit(aURI,
|
||||
aWhen,
|
||||
null, // no referrer
|
||||
aType,
|
||||
false, // not redirect
|
||||
0);
|
||||
do_check_true(placeID > 0);
|
||||
return placeID;
|
||||
do_check_true(visitID > 0);
|
||||
return visitID;
|
||||
}
|
||||
|
||||
const TOTAL_SITES = 20;
|
||||
|
@ -70,20 +67,23 @@ function run_test() {
|
|||
var testImageURI = uri(site + "blank.gif");
|
||||
var when = now + (i * TOTAL_SITES);
|
||||
add_visit(testURI, when, histsvc.TRANSITION_TYPED);
|
||||
add_visit(testImageURI, when + 1, histsvc.TRANSITION_EMBED);
|
||||
add_visit(testURI, when + 2, histsvc.TRANSITION_LINK);
|
||||
add_visit(testImageURI, ++when, histsvc.TRANSITION_EMBED);
|
||||
add_visit(testImageURI, ++when, histsvc.TRANSITION_FRAMED_LINK);
|
||||
add_visit(testURI, ++when, histsvc.TRANSITION_LINK);
|
||||
}
|
||||
|
||||
// verify our visits AS_VISIT, ordered by date descending
|
||||
// including hidden
|
||||
// we should get 60 visits:
|
||||
// we should get 80 visits:
|
||||
// http://www.test-19.com/
|
||||
// http://www.test-19.com/blank.gif
|
||||
// http://www.test-19.com/
|
||||
// http://www.test-19.com/
|
||||
// ...
|
||||
// http://www.test-0.com/
|
||||
// http://www.test-0.com/blank.gif
|
||||
// http://www.test-0.com/
|
||||
// http://www.test-0.com/
|
||||
var options = histsvc.getNewQueryOptions();
|
||||
options.sortingMode = options.SORT_BY_DATE_DESCENDING;
|
||||
options.resultType = options.RESULTS_AS_VISIT;
|
||||
|
@ -93,16 +93,20 @@ function run_test() {
|
|||
var root = result.root;
|
||||
root.containerOpen = true;
|
||||
var cc = root.childCount;
|
||||
do_check_eq(cc, 3 * TOTAL_SITES);
|
||||
for (var i=0; i < TOTAL_SITES; i++) {
|
||||
var node = root.getChild(i*3);
|
||||
do_check_eq(cc, 4 * TOTAL_SITES);
|
||||
for (var i = 0; i < TOTAL_SITES; i++) {
|
||||
var index = i * 4;
|
||||
var node = root.getChild(index);
|
||||
var site = "http://www.test-" + (TOTAL_SITES - 1 - i) + ".com/";
|
||||
do_check_eq(node.uri, site);
|
||||
do_check_eq(node.type, options.RESULTS_AS_VISIT);
|
||||
node = root.getChild(i*3+1);
|
||||
node = root.getChild(++index);
|
||||
do_check_eq(node.uri, site + "blank.gif");
|
||||
do_check_eq(node.type, options.RESULTS_AS_VISIT);
|
||||
node = root.getChild(i*3+2);
|
||||
node = root.getChild(++index);
|
||||
do_check_eq(node.uri, site + "blank.gif");
|
||||
do_check_eq(node.type, options.RESULTS_AS_VISIT);
|
||||
node = root.getChild(++index);
|
||||
do_check_eq(node.uri, site);
|
||||
do_check_eq(node.type, options.RESULTS_AS_VISIT);
|
||||
}
|
||||
|
@ -123,14 +127,15 @@ function run_test() {
|
|||
var root = result.root;
|
||||
root.containerOpen = true;
|
||||
var cc = root.childCount;
|
||||
// 2 * TOTAL_SITES because we count the TYPED and LINK, but not EMBED
|
||||
// 2 * TOTAL_SITES because we count the TYPED and LINK, but not EMBED or FRAMED
|
||||
do_check_eq(cc, 2 * TOTAL_SITES);
|
||||
for (var i=0; i < TOTAL_SITES; i++) {
|
||||
var node = root.getChild(i*2);
|
||||
var index = i * 2;
|
||||
var node = root.getChild(index);
|
||||
var site = "http://www.test-" + (TOTAL_SITES - 1 - i) + ".com/";
|
||||
do_check_eq(node.uri, site);
|
||||
do_check_eq(node.type, options.RESULTS_AS_VISIT);
|
||||
node = root.getChild(i*2+1);
|
||||
node = root.getChild(++index);
|
||||
do_check_eq(node.uri, site);
|
||||
do_check_eq(node.type, options.RESULTS_AS_VISIT);
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ function run_test() {
|
|||
// because these are embedded visits, they should not show up on our
|
||||
// query results. If they do, we have a problem.
|
||||
add_visit("http://www.hidden.com/hidden.gif", histsvc.TRANSITION_EMBED);
|
||||
add_visit("http://www.alsohidden.com/hidden.gif", histsvc.TRANSITION_FRAMED_LINK);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,24 +38,20 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// Get history services
|
||||
try {
|
||||
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
var bhist = histsvc.QueryInterface(Ci.nsIBrowserHistory);
|
||||
} catch(ex) {
|
||||
do_throw("Could not get history services\n");
|
||||
}
|
||||
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
var bhist = histsvc.QueryInterface(Ci.nsIBrowserHistory);
|
||||
|
||||
// adds a test URI visit to the database, and checks for a valid place ID
|
||||
function add_visit(aURI, aType) {
|
||||
var placeID = histsvc.addVisit(uri(aURI),
|
||||
var visitID = histsvc.addVisit(uri(aURI),
|
||||
Date.now() * 1000,
|
||||
null, // no referrer
|
||||
aType,
|
||||
false, // not redirect
|
||||
0);
|
||||
do_check_true(placeID > 0);
|
||||
return placeID;
|
||||
do_check_true(visitID > 0);
|
||||
return visitID;
|
||||
}
|
||||
|
||||
// main
|
||||
|
@ -67,13 +63,15 @@ function run_test() {
|
|||
"http://www.test-redirect-temporary.com/"];
|
||||
|
||||
var notcount_visited_URIs = ["http://www.test-embed.com/",
|
||||
"http://www.test-download.com/"];
|
||||
"http://www.test-download.com/",
|
||||
"http://www.test-framed.com/"];
|
||||
|
||||
// add visits, one for each transition type
|
||||
add_visit("http://www.test-link.com/", histsvc.TRANSITION_LINK);
|
||||
add_visit("http://www.test-typed.com/", histsvc.TRANSITION_TYPED);
|
||||
add_visit("http://www.test-bookmark.com/", histsvc.TRANSITION_BOOKMARK);
|
||||
add_visit("http://www.test-embed.com/", histsvc.TRANSITION_EMBED);
|
||||
add_visit("http://www.test-framed.com/", histsvc.TRANSITION_FRAMED_LINK);
|
||||
add_visit("http://www.test-redirect-permanent.com/", histsvc.TRANSITION_REDIRECT_PERMANENT);
|
||||
add_visit("http://www.test-redirect-temporary.com/", histsvc.TRANSITION_REDIRECT_TEMPORARY);
|
||||
add_visit("http://www.test-download.com/", histsvc.TRANSITION_DOWNLOAD);
|
||||
|
|
|
@ -37,13 +37,9 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// Get services
|
||||
try {
|
||||
var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
var mDBConn = hs.QueryInterface(Ci.nsPIPlacesDatabase).DBConnection;
|
||||
} catch(ex) {
|
||||
do_throw("Could not get services\n");
|
||||
}
|
||||
var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
var mDBConn = hs.QueryInterface(Ci.nsPIPlacesDatabase).DBConnection;
|
||||
|
||||
// Cache actual visit_count value, filled by add_visit, used by check_results
|
||||
var visit_count = 0;
|
||||
|
@ -57,6 +53,7 @@ function add_visit(aURI, aVisitDate, aVisitType) {
|
|||
// Increase visit_count if applicable
|
||||
if (aVisitType != 0 &&
|
||||
aVisitType != hs.TRANSITION_EMBED &&
|
||||
aVisitType != hs.TRANSITION_FRAMED_LINK &&
|
||||
aVisitType != hs.TRANSITION_DOWNLOAD)
|
||||
visit_count ++;
|
||||
// Get the place id
|
||||
|
@ -110,6 +107,9 @@ function run_test() {
|
|||
var placeId = add_visit(testURI, Date.now()*1000, hs.TRANSITION_EMBED);
|
||||
check_results(0, 1);
|
||||
|
||||
var placeId = add_visit(testURI, Date.now()*1000, hs.TRANSITION_FRAMED_LINK);
|
||||
check_results(0, 1);
|
||||
|
||||
// Add a visit that force unhide and check place id
|
||||
// - We expect that the place gets hidden = 0 while retaining the same
|
||||
// place_id and a correct visit_count.
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
* TEST DESCRIPTION:
|
||||
*
|
||||
* This test checks that in a basic history query all transition types visits
|
||||
* appear but TRANSITION_EMBED ones.
|
||||
* appear but TRANSITION_EMBED and TRANSITION_FRAMED_LINK ones.
|
||||
*/
|
||||
|
||||
var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
|
@ -63,6 +63,7 @@ var transitions = [ hs.TRANSITION_LINK,
|
|||
hs.TRANSITION_TYPED,
|
||||
hs.TRANSITION_BOOKMARK,
|
||||
hs.TRANSITION_EMBED,
|
||||
hs.TRANSITION_FRAMED_LINK,
|
||||
hs.TRANSITION_REDIRECT_PERMANENT,
|
||||
hs.TRANSITION_REDIRECT_TEMPORARY,
|
||||
hs.TRANSITION_DOWNLOAD ];
|
||||
|
@ -76,12 +77,13 @@ function runQuery(aResultType) {
|
|||
|
||||
root.containerOpen = true;
|
||||
var cc = root.childCount;
|
||||
do_check_eq(cc, transitions.length-1);
|
||||
do_check_eq(cc, transitions.length-2);
|
||||
|
||||
for (var i = 0; i < cc; i++) {
|
||||
var node = root.getChild(i);
|
||||
// Check that all transition types but TRANSITION_EMBED appear in results
|
||||
// Check that all transition types but EMBED and FRAMED appear in results
|
||||
do_check_neq(node.uri.substr(6,1), hs.TRANSITION_EMBED);
|
||||
do_check_neq(node.uri.substr(6,1), hs.TRANSITION_FRAMED_LINK);
|
||||
}
|
||||
root.containerOpen = false;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче