Bug 1538948 - Add missing LoadInfo in NNTP code. r+a=jorgk
--- a/mailnews/news/src/nsNntpIncomingServer.cpp
+++ b/mailnews/news/src/nsNntpIncomingServer.cpp
@@ -28,16 +28,17 @@
#include "nsNetUtil.h"
#include "nsISimpleEnumerator.h"
#include "nsMsgUtils.h"
#include "mozilla/Services.h"
#include "mozilla/dom/Element.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/XULTreeElement.h"
#include "mozilla/dom/DataTransfer.h"
+#include "mozilla/LoadInfo.h"
#define INVALID_VERSION 0
#define VALID_VERSION 2
#define NEW_NEWS_DIR_NAME "News"
#define PREF_MAIL_NEWSRC_ROOT "mail.newsrc_root"
#define PREF_MAIL_NEWSRC_ROOT_REL "mail.newsrc_root-rel"
#define PREF_MAILNEWS_VIEW_DEFAULT_CHARSET "mailnews.view_default_charset"
#define HOSTINFO_FILE_NAME "hostinfo.dat"
@@ -547,23 +548,36 @@ nsNntpIncomingServer::GetNntpChannel(nsI
NS_IMETHODIMP
nsNntpIncomingServer::LoadNewsUrl(nsIURI *aURI, nsIMsgWindow *aMsgWindow,
nsISupports *aConsumer) {
nsCOMPtr<nsINNTPProtocol> protocol;
nsresult rv = GetNntpConnection(aURI, aMsgWindow, getter_AddRefs(protocol));
NS_ENSURE_SUCCESS(rv, rv);
- if (protocol) return protocol->LoadNewsUrl(aURI, aConsumer);
+ nsCOMPtr<nsILoadInfo> loadInfo = new mozilla::net::LoadInfo(
+ nsContentUtils::GetSystemPrincipal(), nullptr, nullptr,
+ nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
+ nsIContentPolicy::TYPE_OTHER);
+
+ if (protocol) {
+ nsCOMPtr<nsIChannel> chan = do_QueryInterface(protocol, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = chan->SetLoadInfo(loadInfo);
+ NS_ENSURE_SUCCESS(rv, rv);
+ return protocol->LoadNewsUrl(aURI, aConsumer);
+ }
// No protocol? We need our mock channel.
nsNntpMockChannel *channel =
new nsNntpMockChannel(aURI, aMsgWindow, aConsumer);
if (!channel) return NS_ERROR_OUT_OF_MEMORY;
+ rv = channel->SetLoadInfo(loadInfo);
+ NS_ENSURE_SUCCESS(rv, rv);
m_queuedChannels.AppendElement(channel);
return NS_OK;
}
NS_IMETHODIMP
nsNntpIncomingServer::PrepareForNextUrl(nsNNTPProtocol *aConnection) {
NS_ENSURE_ARG(aConnection);
--- a/mailnews/news/test/unit/test_server.js
+++ b/mailnews/news/test/unit/test_server.js
@@ -83,26 +83,30 @@ function testRFC977() {
var thread = gThreadManager.currentThread;
while (thread.hasPendingEvents())
thread.processNextEvent(true);
}
function testConnectionLimit() {
var server = makeServer(NNTP_RFC977_handler, daemon);
server.start(NNTP_PORT);
+ // 1 is the default, but other tests do change it, so let's be explicit.
+ _server.maximumConnectionsNumber = 1;
var prefix = "news://localhost:" + NNTP_PORT + "/";
// To test make connections limit, we run two URIs simultaneously.
var url = URLCreator.newURI(prefix + "*");
_server.loadNewsUrl(url, null, null);
setupProtocolTest(NNTP_PORT, prefix + "TSS1@nntp.invalid");
server.performTest();
// We should have length one... which means this must be a transaction object,
// containing only us and them
+ // (playTransactions() returns an array of transaction objects if there is
+ // more than one of them, so this assert will fail in that case).
Assert.ok("us" in server.playTransaction());
server.stop();
var thread = gThreadManager.currentThread;
while (thread.hasPendingEvents())
thread.processNextEvent(true);
}