Back out b77834cb31ad (bug 580794) because of mochitest-browser-chrome timeouts

This commit is contained in:
Matt Brubeck 2012-07-25 16:19:02 -07:00
parent 89e69ff062
commit 484e4e066a
7 changed files with 1 additions and 242 deletions

View File

@ -3091,17 +3091,6 @@ const DOMLinkHandler = {
var targetDoc = link.ownerDocument;
var uri = makeURI(link.href, targetDoc.characterSet);
// strip the user:pass from the uri to prevent brute-forcing
// attempts unbeknownst to the user (favicon requests don't
// prompt for auth)
if (uri.userPass != "") {
// setting the userPass can throw, so try/catch it
try {
uri.userPass = null;
}
catch (e) {}
}
if (gBrowser.isFailedIcon(uri))
break;
@ -3146,7 +3135,7 @@ const DOMLinkHandler = {
break;
let tab = gBrowser.tabs[browserIndex];
gBrowser.setIcon(tab, uri);
gBrowser.setIcon(tab, link.href);
iconAdded = true;
}
break;

View File

@ -262,9 +262,6 @@ _BROWSER_FILES = \
social_panel.html \
social_sidebar.html \
social_worker.js \
browser_favicon_no_userPass.js \
favicon_no_userPass.html \
icon.ico \
$(NULL)
ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT))

View File

@ -1,96 +0,0 @@
var gTestRoot = getRootDirectory(gTestPath).replace("chrome://mochitests/content/", "http://127.0.0.1:8888/");
var gIOService = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
var gFaviconService = Cc["@mozilla.org/browser/favicon-service;1"]
.getService(Ci.nsIFaviconService);
var gTestBrowser = null;
var gNextTest = null;
var gOkayIfIconChanges = false;
Components.utils.import("resource://gre/modules/Services.jsm");
var gHistoryService = Cc["@mozilla.org/browser/nav-history-service;1"]
.getService(Ci.nsINavHistoryService);
var gHistoryObserver = {
onBeginUpdateBatch: function() {},
onEndUpdateBatch: function() {},
onVisit: function(aURI, aVisitID, aTime, aSessionID, aReferringID, aTransitionType) {},
onTitleChanged: function(aURI, aPageTitle) {},
onBeforeDeleteURI: function(aURI) {},
onDeleteURI: function(aURI) {},
onClearHistory: function() {},
onDeleteVisits: function() {},
QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryObserver]),
onPageChanged: function(aURI, aWhat, aValue) {
if (aWhat == Ci.nsINavHistoryObserver.ATTRIBUTE_FAVICON) {
if (gOkayIfIconChanges) {
ok(true, "favicon changed");
finishTest();
}
else {
ok(false, "favicon should not have changed now");
finishTest();
}
}
}
};
gHistoryService.addObserver(gHistoryObserver, false);
function test() {
waitForExplicitFinish();
var newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab;
gTestBrowser = gBrowser.selectedBrowser;
gTestBrowser.addEventListener("load", pageLoad, true);
gBrowser.selectedTab.addEventListener("error", part2, true);
prepareTest(stub1, gTestRoot + "favicon_no_userPass.html#link");
}
function pageLoad() {
executeSoon(gNextTest);
}
function prepareTest(nextTest, url) {
gNextTest = nextTest;
gTestBrowser.contentWindow.location = url;
}
function stub1() {
gNextTest = null;
}
function part2() {
ok(true, "got expected error for loading favicon");
gBrowser.selectedTab.removeEventListener("error", part2, true);
prepareTest(part3, gTestRoot + "favicon_no_userPass.html#img");
gTestBrowser.reload();
}
function part3() {
gBrowser.selectedTab.addEventListener("error", stub2, true);
gOkayIfIconChanges = true;
prepareTest(part4, gTestRoot + "favicon_no_userPass.html#link2");
gTestBrowser.reload();
}
function part4() {
gNextTest = null;
}
function stub2() {
ok(false, "got unexpected error for loading favicon the second time");
finishTest();
}
function finishTest() {
gTestBrowser.removeEventListener("load", pageLoad, true);
gHistoryService.removeObserver(gHistoryObserver);
gBrowser.selectedTab.removeEventListener("error", stub2, true);
gBrowser.removeCurrentTab();
window.focus();
finish();
}

View File

@ -1,32 +0,0 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<script>
var path = document.location.href.replace("127.0.0.1:8888", "guest:guest@127.0.0.1:8888/auth").split("/").slice(0,-1).join("/");
var frags = document.location.hash.substr(1).split(",");
for (var i in frags) {
if (frags[i] == "link") {
var link = document.createElement("link");
link.rel = "icon";
link.href = path + "/icon.ico";
document.head.appendChild(link);
}
if (frags[i] == "img") {
var img = document.createElement("img");
img.src = path + "/icon.ico";
document.body.appendChild(img);
}
if (frags[i] == "link2") {
var link = document.createElement("link");
link.rel = "icon";
link.href = path + "/icon.ico#foo";
document.head.appendChild(link);
}
}
</script>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -201,7 +201,6 @@ function createMochitestServer(serverBasePath)
server.registerDirectory("/", serverBasePath);
server.registerPathHandler("/server/shutdown", serverShutdown);
server.registerPathHandler("/server/debug", serverDebug);
server.registerPrefixHandler("/auth/", authPrefixHandler);
server.registerContentType("sjs", "sjs"); // .sjs == CGI-like functionality
server.registerContentType("jar", "application/x-jar");
server.registerContentType("ogg", "application/ogg");
@ -665,36 +664,3 @@ function defaultDirHandler(metadata, response)
response.write(ex);
}
}
/**
* Respond with 401 Authorization Required unless test sends proper
* authorization (user: guest, pass: guest, which happens to be
* "Z3Vlc3Q6Z3Vlc3Q=" encoded), in which case fall back to the default handler.
*/
function authPrefixHandler(metadata, response)
{
if (!metadata.hasHeader("Authorization")) {
response.setStatusLine("1.1", 401, "Authorization Required");
response.setHeader("WWW-Authenticate", 'Basic realm="secret"', false);
return;
}
let auth = metadata.getHeader("Authorization");
if (auth.indexOf("Basic ") == 0) {
let encoded = auth.substr(6);
if (encoded != "Z3Vlc3Q6Z3Vlc3Q=") {
response.setStatusLine("1.1", 401, "Authorization Required");
response.setHeader("WWW-Authenticate", 'Basic realm="secret"', false);
return;
}
// Breaking the abstraction... :(
// strip off the leading '/auth'
metadata._path = metadata.path.substr(5);
// call the default handler
server._handler._handleDefault(metadata, response);
} else {
response.setStatusLine("1.1", 400, "Bad Request");
return;
}
}

View File

@ -190,13 +190,6 @@ nsFaviconService::SetFaviconUrlForPage(nsIURI* aPageURI, nsIURI* aFaviconURI)
{
NS_ENSURE_ARG(aPageURI);
NS_ENSURE_ARG(aFaviconURI);
#ifdef DEBUG
nsCAutoString userPass;
if (NS_SUCCEEDED(aFaviconURI->GetUserPass(userPass)) &&
!userPass.IsEmpty()) {
NS_WARNING("security concern: favicon URIs should not have username/password");
}
#endif
// If we are about to expire all favicons, don't bother setting a new one.
if (mFaviconsExpirationRunning) {
@ -355,13 +348,6 @@ nsFaviconService::SetAndLoadFaviconForPage(nsIURI* aPageURI,
{
NS_ENSURE_ARG(aPageURI);
NS_ENSURE_ARG(aFaviconURI);
#ifdef DEBUG
nsCAutoString userPass;
if (NS_SUCCEEDED(aFaviconURI->GetUserPass(userPass)) &&
!userPass.IsEmpty()) {
NS_WARNING("security concern: favicon URIs should not have username/password");
}
#endif
if (mFaviconsExpirationRunning)
return NS_OK;
@ -478,13 +464,6 @@ nsFaviconService::SetFaviconData(nsIURI* aFaviconURI, const PRUint8* aData,
PRTime aExpiration)
{
NS_ENSURE_ARG(aFaviconURI);
#ifdef DEBUG
nsCAutoString userPass;
if (NS_SUCCEEDED(aFaviconURI->GetUserPass(userPass)) &&
!userPass.IsEmpty()) {
NS_WARNING("security concern: favicon URIs should not have username/password");
}
#endif
if (mFaviconsExpirationRunning)
return NS_OK;
@ -659,14 +638,6 @@ nsFaviconService::SetFaviconDataFromDataURL(nsIURI* aFaviconURI,
PRTime aExpiration)
{
NS_ENSURE_ARG(aFaviconURI);
#ifdef DEBUG
nsCAutoString userPass;
if (NS_SUCCEEDED(aFaviconURI->GetUserPass(userPass)) &&
!userPass.IsEmpty()) {
NS_WARNING("security concern: favicon URIs should not have username/password");
}
#endif
if (mFaviconsExpirationRunning)
return NS_OK;
@ -728,13 +699,6 @@ nsFaviconService::GetFaviconData(nsIURI* aFaviconURI, nsACString& aMimeType,
NS_ENSURE_ARG(aFaviconURI);
NS_ENSURE_ARG_POINTER(aDataLen);
NS_ENSURE_ARG_POINTER(aData);
#ifdef DEBUG
nsCAutoString userPass;
if (NS_SUCCEEDED(aFaviconURI->GetUserPass(userPass)) &&
!userPass.IsEmpty()) {
NS_WARNING("security concern: favicon URIs should not have username/password");
}
#endif
nsCOMPtr<nsIURI> defaultFaviconURI;
nsresult rv = GetDefaultFavicon(getter_AddRefs(defaultFaviconURI));
@ -813,13 +777,6 @@ nsFaviconService::GetFaviconDataAsDataURL(nsIURI* aFaviconURI,
nsAString& aDataURL)
{
NS_ENSURE_ARG(aFaviconURI);
#ifdef DEBUG
nsCAutoString userPass;
if (NS_SUCCEEDED(aFaviconURI->GetUserPass(userPass)) &&
!userPass.IsEmpty()) {
NS_WARNING("security concern: favicon URIs should not have username/password");
}
#endif
PRUint8* data;
PRUint32 dataLen;
@ -951,13 +908,6 @@ nsFaviconService::GetFaviconLinkForIcon(nsIURI* aFaviconURI,
{
NS_ENSURE_ARG(aFaviconURI);
NS_ENSURE_ARG_POINTER(aOutputURI);
#ifdef DEBUG
nsCAutoString userPass;
if (NS_SUCCEEDED(aFaviconURI->GetUserPass(userPass)) &&
!userPass.IsEmpty()) {
NS_WARNING("security concern: favicon URIs should not have username/password");
}
#endif
nsCAutoString spec;
if (aFaviconURI) {
@ -984,13 +934,6 @@ NS_IMETHODIMP
nsFaviconService::AddFailedFavicon(nsIURI* aFaviconURI)
{
NS_ENSURE_ARG(aFaviconURI);
#ifdef DEBUG
nsCAutoString userPass;
if (NS_SUCCEEDED(aFaviconURI->GetUserPass(userPass)) &&
!userPass.IsEmpty()) {
NS_WARNING("security concern: favicon URIs should not have username/password");
}
#endif
nsCAutoString spec;
nsresult rv = aFaviconURI->GetSpec(spec);
@ -1029,14 +972,6 @@ NS_IMETHODIMP
nsFaviconService::IsFailedFavicon(nsIURI* aFaviconURI, bool* _retval)
{
NS_ENSURE_ARG(aFaviconURI);
#ifdef DEBUG
nsCAutoString userPass;
if (NS_SUCCEEDED(aFaviconURI->GetUserPass(userPass)) &&
!userPass.IsEmpty()) {
NS_WARNING("security concern: favicon URIs should not have username/password");
}
#endif
nsCAutoString spec;
nsresult rv = aFaviconURI->GetSpec(spec);
NS_ENSURE_SUCCESS(rv, rv);