Bug 716841. EventSource::GetInterface goes into infinite loop if redirected. r=bz

This commit is contained in:
Jason Duell 2012-02-24 11:37:30 -08:00
Родитель 4d9b05b171
Коммит c9d6d245cd
7 изменённых файлов: 82 добавлений и 7 удалений

Просмотреть файл

@ -903,13 +903,6 @@ nsEventSource::SetupHttpChannel()
NS_ENSURE_SUCCESS(rv, rv);
}
nsCOMPtr<nsIInterfaceRequestor> notificationCallbacks;
mHttpChannel->GetNotificationCallbacks(getter_AddRefs(notificationCallbacks));
if (notificationCallbacks != this) {
mNotificationCallbacks = notificationCallbacks;
mHttpChannel->SetNotificationCallbacks(this);
}
return NS_OK;
}
@ -952,6 +945,13 @@ nsEventSource::InitChannelAndRequestEventSource()
rv = SetupHttpChannel();
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIInterfaceRequestor> notificationCallbacks;
mHttpChannel->GetNotificationCallbacks(getter_AddRefs(notificationCallbacks));
if (notificationCallbacks != this) {
mNotificationCallbacks = notificationCallbacks;
mHttpChannel->SetNotificationCallbacks(this);
}
nsCOMPtr<nsIStreamListener> listener =
new nsCORSListenerProxy(this, mPrincipal, mHttpChannel,
mWithCredentials, &rv);

Просмотреть файл

@ -486,8 +486,13 @@ _TEST_FILES2 = \
test_blobbuilder.html \
fileutils.js \
test_bug338583.html \
test_EventSource_redirects.html \
eventsource.resource \
eventsource.resource^headers^ \
eventsource_redirect.resource \
eventsource_redirect.resource^headers^ \
eventsource_redirect_to.resource \
eventsource_redirect_to.resource^headers^ \
badContentType.eventsource \
badContentType.eventsource^headers^ \
badEventFieldName.eventsource \

Просмотреть файл

@ -0,0 +1,2 @@
redirected

Просмотреть файл

@ -0,0 +1,3 @@
HTTP 301 Moved Permanently
Location: eventsource_redirect_to.resource

Просмотреть файл

@ -0,0 +1,3 @@
retry:500
data: 1

Просмотреть файл

@ -0,0 +1,3 @@
Content-Type: text/event-stream
Cache-Control: no-cache, must-revalidate

Просмотреть файл

@ -0,0 +1,59 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=716841
-->
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<title>Test for Bug 338583</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body bgColor=white>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=716841">Mozilla Bug 716841</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
function doTest(test_id) {
oldPrefVal = SpecialPowers.getBoolPref("dom.server-events.enabled");
SpecialPowers.setBoolPref("dom.server-events.enabled", true);
ok(true, "here we go");
source = new EventSource("eventsource_redirect.resource");
ok(source.url == "http://mochi.test:8888/tests/content/base/test/eventsource_redirect.resource", "Test failed.");
ok(source.readyState == 0 || source.readyState == 1, "Test failed.");
source.onopen = function (event) {
ok(true, "opened");
};
source.onmessage = function (event) {
ok(true, "event received");
source.close();
SimpleTest.finish();
};
source.onerror = function (event) {
ok(false, "received onError: " + event);
source.close();
SimpleTest.finish();
};
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(doTest);
</script>
</pre>
</body>
</html>