--HG--
extra : rebase_source : 5ff7e3a019f140ef26f5ac14210e19ad382e65f8
This commit is contained in:
Olli Pettay 2009-09-15 18:44:35 +03:00
Родитель fbfbf8e7c0
Коммит fcc767c1d8
4 изменённых файлов: 9 добавлений и 79 удалений

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

@ -2603,6 +2603,12 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
return rv;
}
// Now that we've successfully opened the channel, we can change state. Note
// that this needs to come after the AsyncOpen() and rv check, because this
// can run script that would try to restart this request, and that could end
// up doing our AsyncOpen on a null channel if the reentered AsyncOpen fails.
ChangeState(XML_HTTP_REQUEST_SENT);
// If we're synchronous, spin an event loop here and wait
if (!(mState & XML_HTTP_REQUEST_ASYNC)) {
mState |= XML_HTTP_REQUEST_SYNCLOOPING;
@ -2625,9 +2631,6 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
}
}
ChangeState(XML_HTTP_REQUEST_SENT);
// Note, calling ChangeState may have cleared
// XML_HTTP_REQUEST_SYNCLOOPING flag.
nsIThread *thread = NS_GetCurrentThread();
while (mState & XML_HTTP_REQUEST_SYNCLOOPING) {
if (!NS_ProcessNextEvent(thread)) {
@ -2644,11 +2647,6 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
NS_DispatchToCurrentThread(resumeTimeoutRunnable);
}
} else {
// Now that we've successfully opened the channel, we can change state. Note
// that this needs to come after the AsyncOpen() and rv check, because this
// can run script that would try to restart this request, and that could end
// up doing our AsyncOpen on a null channel if the reentered AsyncOpen fails.
ChangeState(XML_HTTP_REQUEST_SENT);
if (!mUploadComplete &&
HasListenersFor(NS_LITERAL_STRING(UPLOADPROGRESS_STR)) ||
(mUpload && mUpload->HasListenersFor(NS_LITERAL_STRING(PROGRESS_STR)))) {
@ -2966,11 +2964,9 @@ nsXMLHttpRequest::ChangeState(PRUint32 aState, PRBool aBroadcast)
mProgressNotifier->Cancel();
}
if ((aState & XML_HTTP_REQUEST_LOADSTATES) && // Broadcast load states only
aBroadcast &&
(mState & XML_HTTP_REQUEST_ASYNC ||
aState & XML_HTTP_REQUEST_OPENED ||
aState & XML_HTTP_REQUEST_COMPLETED)) {
if ((mState & XML_HTTP_REQUEST_ASYNC) &&
(aState & XML_HTTP_REQUEST_LOADSTATES) && // Broadcast load states only
aBroadcast) {
nsCOMPtr<nsIDOMEvent> event;
rv = CreateReadystatechangeEvent(getter_AddRefs(event));
NS_ENSURE_SUCCESS(rv, rv);

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

@ -310,8 +310,6 @@ _TEST_FILES = test_bug5141.html \
bug466409-empty.css \
test_bug466409.html \
test_classList.html \
test_bug313646.html \
bug313646.txt \
test_bug489925.xhtml \
test_bug514487.html \
$(NULL)

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

@ -1 +0,0 @@
Nothing to see here. Just need to request this file via XHR.

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

@ -1,63 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=313646
-->
<head>
<title>Test for Bug 313646</title>
<script type="text/javascript" src="/MochiKit/packed.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>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=313646">Mozilla Bug 313646</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 313646 **/
// content/base/test/bug313646.txt
SimpleTest.waitForExplicitFinish();
var count1 = 0;
var count2 = 0;
var count3 = 0;
var count4 = 0;
var innerXHRDone = 0;
var req = new XMLHttpRequest();
req.onreadystatechange = function(evt) {
++window["count" + evt.target.readyState];
// Do something a bit evil, start a new sync XHR in
// readyStateChange listener.
var innerXHR = new XMLHttpRequest();
innerXHR.onreadystatechange = function(e) {
if (e.target.readyState == 4) {
++innerXHRDone;
}
}
innerXHR.open("GET","bug313646.txt", false);
innerXHR.send();
}
// make the synchronous request
req.open("GET","bug313646.txt", false);
req.send();
ok(count1, "XMLHttpRequest wasn't in state 1");
is(count2, 0, "XMLHttpRequest shouldn't have been in state 2");
is(count3, 0, "XMLHttpRequest shouldn't have been in state 3");
ok(count4, "XMLHttpRequest wasn't in state 4");
is(innerXHRDone, 2, "There should have been 2 inner XHRs.");
SimpleTest.finish();
</script>
</pre>
</body>
</html>