2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2008-01-31 14:17:00 -08:00
|
|
|
|
2010-07-22 05:09:10 -07:00
|
|
|
gBrowser.selectedTab = gBrowser.addTab();
|
|
|
|
|
2009-08-21 13:36:47 -07:00
|
|
|
function test() {
|
|
|
|
waitForExplicitFinish();
|
2008-01-31 14:17:00 -08:00
|
|
|
|
2009-08-21 13:36:47 -07:00
|
|
|
var URIs = [
|
|
|
|
"http://example.com/tests/toolkit/components/places/tests/browser/399606-window.location.href.html",
|
|
|
|
"http://example.com/tests/toolkit/components/places/tests/browser/399606-history.go-0.html",
|
|
|
|
"http://example.com/tests/toolkit/components/places/tests/browser/399606-location.replace.html",
|
|
|
|
"http://example.com/tests/toolkit/components/places/tests/browser/399606-location.reload.html",
|
|
|
|
"http://example.com/tests/toolkit/components/places/tests/browser/399606-httprefresh.html",
|
|
|
|
"http://example.com/tests/toolkit/components/places/tests/browser/399606-window.location.html",
|
|
|
|
];
|
|
|
|
var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
|
|
|
|
getService(Ci.nsINavHistoryService);
|
2008-01-31 14:17:00 -08:00
|
|
|
|
2009-08-21 13:36:47 -07:00
|
|
|
// Create and add history observer.
|
|
|
|
var historyObserver = {
|
|
|
|
visitCount: Array(),
|
2011-06-30 13:06:56 -07:00
|
|
|
onBeginUpdateBatch: function () {},
|
|
|
|
onEndUpdateBatch: function () {},
|
|
|
|
onVisit: function (aURI, aVisitID, aTime, aSessionID, aReferringID,
|
2008-01-31 14:17:00 -08:00
|
|
|
aTransitionType) {
|
2009-08-21 13:36:47 -07:00
|
|
|
info("Received onVisit: " + aURI.spec);
|
|
|
|
if (aURI.spec in this.visitCount)
|
|
|
|
this.visitCount[aURI.spec]++;
|
|
|
|
else
|
|
|
|
this.visitCount[aURI.spec] = 1;
|
2008-01-31 14:17:00 -08:00
|
|
|
},
|
2011-06-30 13:06:56 -07:00
|
|
|
onTitleChanged: function () {},
|
|
|
|
onDeleteURI: function () {},
|
|
|
|
onClearHistory: function () {},
|
|
|
|
onPageChanged: function () {},
|
|
|
|
onDeleteVisits: function () {},
|
2009-08-21 13:36:47 -07:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryObserver])
|
2008-01-31 14:17:00 -08:00
|
|
|
};
|
2009-08-21 13:36:47 -07:00
|
|
|
hs.addObserver(historyObserver, false);
|
|
|
|
|
2008-01-31 14:17:00 -08:00
|
|
|
function confirm_results() {
|
2010-07-22 05:09:10 -07:00
|
|
|
gBrowser.removeCurrentTab();
|
2009-08-21 13:36:47 -07:00
|
|
|
hs.removeObserver(historyObserver, false);
|
|
|
|
for (let aURI in historyObserver.visitCount) {
|
2010-04-16 14:48:38 -07:00
|
|
|
is(historyObserver.visitCount[aURI], 1,
|
|
|
|
"onVisit has been received right number of times for " + aURI);
|
2009-08-21 13:36:47 -07:00
|
|
|
}
|
2012-11-11 05:01:49 -08:00
|
|
|
promiseClearHistory().then(finish);
|
2008-01-31 14:17:00 -08:00
|
|
|
}
|
|
|
|
|
2009-08-21 13:36:47 -07:00
|
|
|
var loadCount = 0;
|
2008-01-31 14:17:00 -08:00
|
|
|
function handleLoad(aEvent) {
|
|
|
|
loadCount++;
|
2009-07-06 02:27:26 -07:00
|
|
|
info("new load count is " + loadCount);
|
2008-01-31 14:17:00 -08:00
|
|
|
|
2009-08-21 13:36:47 -07:00
|
|
|
if (loadCount == 3) {
|
2009-09-20 03:58:27 -07:00
|
|
|
gBrowser.removeEventListener("DOMContentLoaded", handleLoad, true);
|
|
|
|
content.location.href = "about:blank";
|
2009-08-21 13:36:47 -07:00
|
|
|
executeSoon(check_next_uri);
|
|
|
|
}
|
2008-01-31 14:17:00 -08:00
|
|
|
}
|
|
|
|
|
2009-08-21 13:36:47 -07:00
|
|
|
function check_next_uri() {
|
|
|
|
if (URIs.length) {
|
|
|
|
let uri = URIs.shift();
|
|
|
|
loadCount = 0;
|
2009-09-20 03:58:27 -07:00
|
|
|
gBrowser.addEventListener("DOMContentLoaded", handleLoad, true);
|
|
|
|
content.location.href = uri;
|
2009-08-21 13:36:47 -07:00
|
|
|
}
|
|
|
|
else {
|
2010-07-22 05:09:10 -07:00
|
|
|
confirm_results();
|
2009-08-21 13:36:47 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
executeSoon(check_next_uri);
|
2008-01-31 14:17:00 -08:00
|
|
|
}
|