mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 399606 - Places counts auto-refreshes as page visits. Patch by Dietrich Ayala <dietrich@mozilla.com>, Seth Spitzer <moco@sspitzer.org>, and Shawn Wilsher <me@shawnwilsher.com>. r=dietrich, a=beltzner. Note, this is mostly tests with a three line code change. If this goes orange, please don't panic
This commit is contained in:
parent
c907c4e13b
commit
c6301f346a
@ -3654,6 +3654,13 @@ nsNavHistory::AddVisitChain(nsIURI* aURI, PRTime aTime,
|
||||
transitionType = nsINavHistoryService::TRANSITION_EMBED;
|
||||
}
|
||||
} else if (aReferrer) {
|
||||
// We do not want to add a new visit if the referring site is the same as
|
||||
// the new site. This is the situation where a page refreshes itself to
|
||||
// give the user updated information.
|
||||
PRBool referrerIsSame;
|
||||
if (NS_SUCCEEDED(aURI->Equals(aReferrer, &referrerIsSame)) && referrerIsSame)
|
||||
return NS_OK;
|
||||
|
||||
// If there is a referrer, we know you came from somewhere, either manually
|
||||
// or automatically. For toplevel windows, assume its manual and you want
|
||||
// to see this in history. For other things, it's some kind of embedded
|
||||
@ -3679,8 +3686,9 @@ nsNavHistory::AddVisitChain(nsIURI* aURI, PRTime aTime,
|
||||
// most commonly happens on redirects.
|
||||
visitTime = PR_Now();
|
||||
|
||||
// try to turn the referrer into a visit
|
||||
if (! FindLastVisit(aReferrer, &referringVisit, aSessionID)) {
|
||||
// Try to turn the referrer into a visit.
|
||||
// This also populates the session id.
|
||||
if (!FindLastVisit(aReferrer, &referringVisit, aSessionID)) {
|
||||
// we couldn't find a visit for the referrer, don't set it
|
||||
*aSessionID = GetNewSessionID();
|
||||
}
|
||||
|
@ -50,7 +50,10 @@ XPCSHELL_TESTS = unit \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_MOCHITEST
|
||||
DIRS = chrome
|
||||
DIRS = \
|
||||
chrome \
|
||||
browser \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -0,0 +1,11 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>history.go(0)</title>
|
||||
<script>
|
||||
setTimeout('history.go(0)', 1000);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
Testing history.go(0)
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,8 @@
|
||||
<html><head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
|
||||
<meta http-equiv="refresh" content="1">
|
||||
<title>httprefresh</title>
|
||||
</head><body>
|
||||
Testing httprefresh
|
||||
</body></html>
|
@ -0,0 +1,11 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>location.reload()</title>
|
||||
<script>
|
||||
setTimeout('location.reload();', 100);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
Testing location.reload();
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,11 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>location.replace</title>
|
||||
<script>
|
||||
setTimeout('location.replace(window.location.href)', 1000);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
Testing location.replace
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,11 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>window.location.href</title>
|
||||
<script>
|
||||
setTimeout('window.location.href = window.location.href', 1000);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
Testing window.location.href
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,11 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>window.location</title>
|
||||
<script>
|
||||
setTimeout('window.location = window.location', 1000);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
Testing window.location
|
||||
</body>
|
||||
</html>
|
72
toolkit/components/places/tests/browser/Makefile.in
Normal file
72
toolkit/components/places/tests/browser/Makefile.in
Normal file
@ -0,0 +1,72 @@
|
||||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2008
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Shawn Wilsher <me@shawnwisher.com> (Original Author)
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
relativesrcdir = toolkit/components/places/tests/browser
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_BROWSER_FILES = \
|
||||
browser_bug413985-httprefresh.js \
|
||||
browser_bug413985-location.reload.js \
|
||||
browser_bug413985-location.replace.js \
|
||||
browser_bug413985-window.location.href.js \
|
||||
browser_bug413985-window.location.js \
|
||||
browser_bug413985-history.go-0.js \
|
||||
$(NULL)
|
||||
|
||||
# These are files that need to be loaded via the HTTP proxy server
|
||||
# Access them through http://example.com/
|
||||
_HTTP_FILES = \
|
||||
399606-httprefresh.html \
|
||||
399606-location.reload.html \
|
||||
399606-location.replace.html \
|
||||
399606-window.location.href.html \
|
||||
399606-window.location.html \
|
||||
399606-history.go-0.html \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_BROWSER_FILES)
|
||||
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
|
||||
|
||||
libs:: $(_HTTP_FILES)
|
||||
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
|
@ -0,0 +1,116 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2008
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Shawn Wilsher <me@shawnwilsher.com> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
function test()
|
||||
{
|
||||
const TEST_URI = "http://example.com/tests/toolkit/components/places/tests/browser/399606-history.go-0.html";
|
||||
|
||||
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
|
||||
// create and add history observer
|
||||
var observer = {
|
||||
onBeginUpdateBatch: function() {},
|
||||
onEndUpdateBatch: function() {},
|
||||
onVisit: function(aURI, aVisitID, aTime, aSessionID, aReferringID,
|
||||
aTransitionType) {
|
||||
dump("onVisit: " + aURI.spec + "\n");
|
||||
confirm_results();
|
||||
|
||||
histsvc.removeObserver(observer, false);
|
||||
win.content.document.location.href = "about:blank";
|
||||
finish();
|
||||
},
|
||||
onTitleChanged: function(aURI, aPageTitle) {},
|
||||
onDeleteURI: function(aURI) {},
|
||||
onClearHistory: function() {},
|
||||
onPageChanged: function(aURI, aWhat, aValue) {},
|
||||
onPageExpired: function(aURI, aVisitTime, aWholeEntry) {},
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(Ci.nsINavHistoryObserver) ||
|
||||
iid.equals(Ci.nsISupports)) {
|
||||
return this;
|
||||
}
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
};
|
||||
|
||||
histsvc.addObserver(observer, false);
|
||||
|
||||
// If LAZY_ADD is ever disabled, this function will not be correct
|
||||
var loadCount = 0;
|
||||
function confirm_results() {
|
||||
var options = histsvc.getNewQueryOptions();
|
||||
options.resultType = options.RESULTS_AS_VISIT;
|
||||
options.includeHidden = true;
|
||||
var query = histsvc.getNewQuery();
|
||||
var uri = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService).
|
||||
newURI(TEST_URI, null, null);
|
||||
dump("query uri is " + uri.spec + "\n");
|
||||
query.uri = uri;
|
||||
var result = histsvc.executeQuery(query, options);
|
||||
var root = result.root;
|
||||
root.containerOpen = true;
|
||||
var cc = root.childCount;
|
||||
// TODO bug 415004
|
||||
todo_is(cc, 1, "Visit count is what we expect");
|
||||
ok(loadCount > 1, "Load count is greater than 1");
|
||||
root.containerOpen = false;
|
||||
}
|
||||
|
||||
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
|
||||
getService(Ci.nsIWindowMediator);
|
||||
var win = wm.getMostRecentWindow("navigator:browser");
|
||||
|
||||
function handleLoad(aEvent) {
|
||||
dump("location is " + aEvent.originalTarget.location.href + "\n");
|
||||
loadCount++;
|
||||
dump("new load count is " + loadCount + "\n");
|
||||
|
||||
if (loadCount == 3)
|
||||
win.getBrowser().removeEventListener("DOMContentLoaded", handleLoad, false);
|
||||
}
|
||||
|
||||
win.getBrowser().addEventListener("DOMContentLoaded", handleLoad, false);
|
||||
|
||||
// load page
|
||||
win.content.document.location.href = TEST_URI;
|
||||
|
||||
// let our load handler handle the rest of the test
|
||||
waitForExplicitFinish();
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2008
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Shawn Wilsher <me@shawnwilsher.com> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
function test()
|
||||
{
|
||||
const TEST_URI = "http://example.com/tests/toolkit/components/places/tests/browser/399606-httprefresh.html";
|
||||
|
||||
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
|
||||
// create and add history observer
|
||||
var observer = {
|
||||
onBeginUpdateBatch: function() {},
|
||||
onEndUpdateBatch: function() {},
|
||||
onVisit: function(aURI, aVisitID, aTime, aSessionID, aReferringID,
|
||||
aTransitionType) {
|
||||
dump("onVisit: " + aURI.spec + "\n");
|
||||
confirm_results();
|
||||
|
||||
histsvc.removeObserver(observer, false);
|
||||
win.content.document.location.href = "about:blank";
|
||||
finish();
|
||||
},
|
||||
onTitleChanged: function(aURI, aPageTitle) {},
|
||||
onDeleteURI: function(aURI) {},
|
||||
onClearHistory: function() {},
|
||||
onPageChanged: function(aURI, aWhat, aValue) {},
|
||||
onPageExpired: function(aURI, aVisitTime, aWholeEntry) {},
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(Ci.nsINavHistoryObserver) ||
|
||||
iid.equals(Ci.nsISupports)) {
|
||||
return this;
|
||||
}
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
};
|
||||
|
||||
histsvc.addObserver(observer, false);
|
||||
|
||||
// If LAZY_ADD is ever disabled, this function will not be correct
|
||||
var loadCount = 0;
|
||||
function confirm_results() {
|
||||
var options = histsvc.getNewQueryOptions();
|
||||
options.resultType = options.RESULTS_AS_VISIT;
|
||||
options.includeHidden = true;
|
||||
var query = histsvc.getNewQuery();
|
||||
var uri = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService).
|
||||
newURI(TEST_URI, null, null);
|
||||
dump("query uri is " + uri.spec + "\n");
|
||||
query.uri = uri;
|
||||
var result = histsvc.executeQuery(query, options);
|
||||
var root = result.root;
|
||||
root.containerOpen = true;
|
||||
var cc = root.childCount;
|
||||
is(cc, 1, "Visit count is what we expect");
|
||||
ok(loadCount > 1, "Load count is greater than 1");
|
||||
root.containerOpen = false;
|
||||
}
|
||||
|
||||
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
|
||||
getService(Ci.nsIWindowMediator);
|
||||
var win = wm.getMostRecentWindow("navigator:browser");
|
||||
|
||||
function handleLoad(aEvent) {
|
||||
dump("location is " + aEvent.originalTarget.location.href + "\n");
|
||||
loadCount++;
|
||||
dump("new load count is " + loadCount + "\n");
|
||||
|
||||
if (loadCount == 3)
|
||||
win.getBrowser().removeEventListener("DOMContentLoaded", handleLoad, false);
|
||||
}
|
||||
|
||||
win.getBrowser().addEventListener("DOMContentLoaded", handleLoad, false);
|
||||
|
||||
// load page
|
||||
win.content.document.location.href = TEST_URI;
|
||||
|
||||
// let our load handler handle the rest of the test
|
||||
waitForExplicitFinish();
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2008
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Shawn Wilsher <me@shawnwilsher.com> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
function test()
|
||||
{
|
||||
const TEST_URI = "http://example.com/tests/toolkit/components/places/tests/browser/399606-location.reload.html";
|
||||
|
||||
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
|
||||
// create and add history observer
|
||||
var observer = {
|
||||
onBeginUpdateBatch: function() {},
|
||||
onEndUpdateBatch: function() {},
|
||||
onVisit: function(aURI, aVisitID, aTime, aSessionID, aReferringID,
|
||||
aTransitionType) {
|
||||
dump("onVisit: " + aURI.spec + "\n");
|
||||
confirm_results();
|
||||
|
||||
histsvc.removeObserver(observer, false);
|
||||
win.content.document.location.href = "about:blank";
|
||||
finish();
|
||||
},
|
||||
onTitleChanged: function(aURI, aPageTitle) {},
|
||||
onDeleteURI: function(aURI) {},
|
||||
onClearHistory: function() {},
|
||||
onPageChanged: function(aURI, aWhat, aValue) {},
|
||||
onPageExpired: function(aURI, aVisitTime, aWholeEntry) {},
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(Ci.nsINavHistoryObserver) ||
|
||||
iid.equals(Ci.nsISupports)) {
|
||||
return this;
|
||||
}
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
};
|
||||
|
||||
histsvc.addObserver(observer, false);
|
||||
|
||||
// If LAZY_ADD is ever disabled, this function will not be correct
|
||||
var loadCount = 0;
|
||||
function confirm_results() {
|
||||
var options = histsvc.getNewQueryOptions();
|
||||
options.resultType = options.RESULTS_AS_VISIT;
|
||||
options.includeHidden = true;
|
||||
var query = histsvc.getNewQuery();
|
||||
var uri = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService).
|
||||
newURI(TEST_URI, null, null);
|
||||
dump("query uri is " + uri.spec + "\n");
|
||||
query.uri = uri;
|
||||
var result = histsvc.executeQuery(query, options);
|
||||
var root = result.root;
|
||||
root.containerOpen = true;
|
||||
var cc = root.childCount;
|
||||
is(cc, 1, "Visit count is what we expect");
|
||||
ok(loadCount > 1, "Load count is greater than 1");
|
||||
root.containerOpen = false;
|
||||
}
|
||||
|
||||
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
|
||||
getService(Ci.nsIWindowMediator);
|
||||
var win = wm.getMostRecentWindow("navigator:browser");
|
||||
|
||||
function handleLoad(aEvent) {
|
||||
dump("location is " + aEvent.originalTarget.location.href + "\n");
|
||||
loadCount++;
|
||||
dump("new load count is " + loadCount + "\n");
|
||||
|
||||
if (loadCount == 3)
|
||||
win.getBrowser().removeEventListener("DOMContentLoaded", handleLoad, true);
|
||||
}
|
||||
|
||||
win.getBrowser().addEventListener("DOMContentLoaded", handleLoad, true);
|
||||
|
||||
// load page
|
||||
win.content.document.location.href = TEST_URI;
|
||||
|
||||
// let our load handler handle the rest of the test
|
||||
waitForExplicitFinish();
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2008
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Shawn Wilsher <me@shawnwilsher.com> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
function test()
|
||||
{
|
||||
const TEST_URI = "http://example.com/tests/toolkit/components/places/tests/browser/399606-location.replace.html";
|
||||
|
||||
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
|
||||
// create and add history observer
|
||||
var observer = {
|
||||
onBeginUpdateBatch: function() {},
|
||||
onEndUpdateBatch: function() {},
|
||||
onVisit: function(aURI, aVisitID, aTime, aSessionID, aReferringID,
|
||||
aTransitionType) {
|
||||
dump("onVisit: " + aURI.spec + "\n");
|
||||
confirm_results();
|
||||
|
||||
histsvc.removeObserver(observer, false);
|
||||
win.content.document.location.href = "about:blank";
|
||||
finish();
|
||||
},
|
||||
onTitleChanged: function(aURI, aPageTitle) {},
|
||||
onDeleteURI: function(aURI) {},
|
||||
onClearHistory: function() {},
|
||||
onPageChanged: function(aURI, aWhat, aValue) {},
|
||||
onPageExpired: function(aURI, aVisitTime, aWholeEntry) {},
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(Ci.nsINavHistoryObserver) ||
|
||||
iid.equals(Ci.nsISupports)) {
|
||||
return this;
|
||||
}
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
};
|
||||
|
||||
histsvc.addObserver(observer, false);
|
||||
|
||||
// If LAZY_ADD is ever disabled, this function will not be correct
|
||||
var loadCount = 0;
|
||||
function confirm_results() {
|
||||
var options = histsvc.getNewQueryOptions();
|
||||
options.resultType = options.RESULTS_AS_VISIT;
|
||||
options.includeHidden = true;
|
||||
var query = histsvc.getNewQuery();
|
||||
var uri = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService).
|
||||
newURI(TEST_URI, null, null);
|
||||
dump("query uri is " + uri.spec + "\n");
|
||||
query.uri = uri;
|
||||
var result = histsvc.executeQuery(query, options);
|
||||
var root = result.root;
|
||||
root.containerOpen = true;
|
||||
var cc = root.childCount;
|
||||
is(cc, 1, "Visit count is what we expect");
|
||||
ok(loadCount > 1, "Load count is greater than 1");
|
||||
root.containerOpen = false;
|
||||
}
|
||||
|
||||
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
|
||||
getService(Ci.nsIWindowMediator);
|
||||
var win = wm.getMostRecentWindow("navigator:browser");
|
||||
|
||||
function handleLoad(aEvent) {
|
||||
dump("location is " + aEvent.originalTarget.location.href + "\n");
|
||||
loadCount++;
|
||||
dump("new load count is " + loadCount + "\n");
|
||||
|
||||
if (loadCount == 3)
|
||||
win.getBrowser().removeEventListener("DOMContentLoaded", handleLoad, true);
|
||||
}
|
||||
|
||||
win.getBrowser().addEventListener("DOMContentLoaded", handleLoad, true);
|
||||
|
||||
// load page
|
||||
win.content.document.location.href = TEST_URI;
|
||||
|
||||
// let our load handler handle the rest of the test
|
||||
waitForExplicitFinish();
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2008
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Shawn Wilsher <me@shawnwilsher.com> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
function test()
|
||||
{
|
||||
const TEST_URI = "http://example.com/tests/toolkit/components/places/tests/browser/399606-window.location.href.html";
|
||||
|
||||
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
|
||||
// create and add history observer
|
||||
var observer = {
|
||||
onBeginUpdateBatch: function() {},
|
||||
onEndUpdateBatch: function() {},
|
||||
onVisit: function(aURI, aVisitID, aTime, aSessionID, aReferringID,
|
||||
aTransitionType) {
|
||||
dump("onVisit: " + aURI.spec + "\n");
|
||||
confirm_results();
|
||||
|
||||
histsvc.removeObserver(observer, false);
|
||||
win.content.document.location.href = "about:blank";
|
||||
finish();
|
||||
},
|
||||
onTitleChanged: function(aURI, aPageTitle) {},
|
||||
onDeleteURI: function(aURI) {},
|
||||
onClearHistory: function() {},
|
||||
onPageChanged: function(aURI, aWhat, aValue) {},
|
||||
onPageExpired: function(aURI, aVisitTime, aWholeEntry) {},
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(Ci.nsINavHistoryObserver) ||
|
||||
iid.equals(Ci.nsISupports)) {
|
||||
return this;
|
||||
}
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
};
|
||||
|
||||
histsvc.addObserver(observer, false);
|
||||
|
||||
// If LAZY_ADD is ever disabled, this function will not be correct
|
||||
var loadCount = 0;
|
||||
function confirm_results() {
|
||||
var options = histsvc.getNewQueryOptions();
|
||||
options.resultType = options.RESULTS_AS_VISIT;
|
||||
options.includeHidden = true;
|
||||
var query = histsvc.getNewQuery();
|
||||
var uri = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService).
|
||||
newURI(TEST_URI, null, null);
|
||||
dump("query uri is " + uri.spec + "\n");
|
||||
query.uri = uri;
|
||||
var result = histsvc.executeQuery(query, options);
|
||||
var root = result.root;
|
||||
root.containerOpen = true;
|
||||
var cc = root.childCount;
|
||||
is(cc, 1, "Visit count is what we expect");
|
||||
ok(loadCount > 1, "Load count is greater than 1");
|
||||
root.containerOpen = false;
|
||||
}
|
||||
|
||||
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
|
||||
getService(Ci.nsIWindowMediator);
|
||||
var win = wm.getMostRecentWindow("navigator:browser");
|
||||
|
||||
function handleLoad(aEvent) {
|
||||
dump("location is " + aEvent.originalTarget.location.href + "\n");
|
||||
loadCount++;
|
||||
dump("new load count is " + loadCount + "\n");
|
||||
|
||||
if (loadCount == 3)
|
||||
win.getBrowser().removeEventListener("DOMContentLoaded", handleLoad, true);
|
||||
}
|
||||
|
||||
win.getBrowser().addEventListener("DOMContentLoaded", handleLoad, true);
|
||||
|
||||
// load page
|
||||
win.content.document.location.href = TEST_URI;
|
||||
|
||||
// let our load handler handle the rest of the test
|
||||
waitForExplicitFinish();
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2008
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Shawn Wilsher <me@shawnwilsher.com> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
function test()
|
||||
{
|
||||
const TEST_URI = "http://example.com/tests/toolkit/components/places/tests/browser/399606-window.location.html";
|
||||
|
||||
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
|
||||
// create and add history observer
|
||||
var observer = {
|
||||
onBeginUpdateBatch: function() {},
|
||||
onEndUpdateBatch: function() {},
|
||||
onVisit: function(aURI, aVisitID, aTime, aSessionID, aReferringID,
|
||||
aTransitionType) {
|
||||
dump("onVisit: " + aURI.spec + "\n");
|
||||
confirm_results();
|
||||
|
||||
histsvc.removeObserver(observer, false);
|
||||
win.content.document.location.href = "about:blank";
|
||||
finish();
|
||||
},
|
||||
onTitleChanged: function(aURI, aPageTitle) {},
|
||||
onDeleteURI: function(aURI) {},
|
||||
onClearHistory: function() {},
|
||||
onPageChanged: function(aURI, aWhat, aValue) {},
|
||||
onPageExpired: function(aURI, aVisitTime, aWholeEntry) {},
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(Ci.nsINavHistoryObserver) ||
|
||||
iid.equals(Ci.nsISupports)) {
|
||||
return this;
|
||||
}
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
};
|
||||
|
||||
histsvc.addObserver(observer, false);
|
||||
|
||||
// If LAZY_ADD is ever disabled, this function will not be correct
|
||||
var loadCount = 0;
|
||||
function confirm_results() {
|
||||
var options = histsvc.getNewQueryOptions();
|
||||
options.resultType = options.RESULTS_AS_VISIT;
|
||||
options.includeHidden = true;
|
||||
var query = histsvc.getNewQuery();
|
||||
var uri = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService).
|
||||
newURI(TEST_URI, null, null);
|
||||
dump("query uri is " + uri.spec + "\n");
|
||||
query.uri = uri;
|
||||
var result = histsvc.executeQuery(query, options);
|
||||
var root = result.root;
|
||||
root.containerOpen = true;
|
||||
var cc = root.childCount;
|
||||
is(cc, 1, "Visit count is what we expect");
|
||||
ok(loadCount > 1, "Load count is greater than 1");
|
||||
root.containerOpen = false;
|
||||
}
|
||||
|
||||
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
|
||||
getService(Ci.nsIWindowMediator);
|
||||
var win = wm.getMostRecentWindow("navigator:browser");
|
||||
|
||||
function handleLoad(aEvent) {
|
||||
dump("location is " + aEvent.originalTarget.location.href + "\n");
|
||||
loadCount++;
|
||||
dump("new load count is " + loadCount + "\n");
|
||||
|
||||
if (loadCount == 3)
|
||||
win.getBrowser().removeEventListener("DOMContentLoaded", handleLoad, true);
|
||||
}
|
||||
|
||||
win.getBrowser().addEventListener("DOMContentLoaded", handleLoad, true);
|
||||
|
||||
// load page
|
||||
win.content.document.location.href = TEST_URI;
|
||||
|
||||
// let our load handler handle the rest of the test
|
||||
waitForExplicitFinish();
|
||||
}
|
102
toolkit/components/places/tests/unit/test_399606.js
Normal file
102
toolkit/components/places/tests/unit/test_399606.js
Normal file
@ -0,0 +1,102 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Google Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Darin Fisher <darin@meer.net>
|
||||
* Dietrich Ayala <dietrich@mozilla.com>
|
||||
* Dan Mills <thunder@mozilla.com>
|
||||
* Seth Spitzer <sspitzer@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// AddURI transactions are created lazily.
|
||||
do_test_pending();
|
||||
|
||||
// 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 ghist = Cc["@mozilla.org/browser/global-history;2"].getService(Ci.nsIGlobalHistory2);
|
||||
|
||||
// create and add history observer
|
||||
var observer = {
|
||||
onBeginUpdateBatch: function() {},
|
||||
onEndUpdateBatch: function() {},
|
||||
visitCount: 0,
|
||||
onVisit: function(aURI, aVisitID, aTime, aSessionID, aReferringID, aTransitionType) {
|
||||
this.visitCount++;
|
||||
dump("onVisit: " + aURI.spec + "\n");
|
||||
confirm_results();
|
||||
},
|
||||
onTitleChanged: function(aURI, aPageTitle) {},
|
||||
onDeleteURI: function(aURI) {},
|
||||
onClearHistory: function() {},
|
||||
onPageChanged: function(aURI, aWhat, aValue) {},
|
||||
onPageExpired: function(aURI, aVisitTime, aWholeEntry) {},
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(Ci.nsINavHistoryObserver) ||
|
||||
iid.equals(Ci.nsISupports)) {
|
||||
return this;
|
||||
}
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
};
|
||||
|
||||
histsvc.addObserver(observer, false);
|
||||
|
||||
// main
|
||||
function run_test() {
|
||||
var now = Date.now();
|
||||
var testURI = uri("http://fez.com");
|
||||
ghist.addURI(testURI, false, true, null);
|
||||
ghist.addURI(testURI, false, true, testURI);
|
||||
// lazy message timer is 3000, see LAZY_MESSAGE_TIMEOUT
|
||||
do_timeout(3500, "confirm_results();");
|
||||
}
|
||||
|
||||
function confirm_results() {
|
||||
var options = histsvc.getNewQueryOptions();
|
||||
options.resultType = options.RESULTS_AS_VISIT;
|
||||
options.includeHidden = true;
|
||||
var query = histsvc.getNewQuery();
|
||||
var result = histsvc.executeQuery(query, options);
|
||||
var root = result.root;
|
||||
root.containerOpen = true;
|
||||
var cc = root.childCount;
|
||||
do_check_eq(cc, 1);
|
||||
root.containerOpen = false;
|
||||
do_test_finished();
|
||||
}
|
Loading…
Reference in New Issue
Block a user