DocumentThreadableLoader::getShouldUseCredentialStorage should allow for synchronous callbacks from SubresourceLoader::create.
https://bugs.webkit.org/show_bug.cgi?id=28728
Patch by David Levin <levin@chromium.org> on 2009-08-25
Reviewed by Maciej Stachowiak.
Test: This code path is exercised while running xhr layout tests in chromium.
* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::getShouldUseCredentialStorage): When called
back synchronously, the loader is 0, so the assert is changed to allow for that.
(WebCore::DocumentThreadableLoader::loadRequest): Synchronous callbacks may be
done before SubresourceLoader::create finishes, so ensure that any previous loader
-- from a preflight request -- is cleared before calling SubresourceLoader::create.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@47770 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/loader/DocumentThreadableLoader.cpp b/WebCore/loader/DocumentThreadableLoader.cpp
index 57daa07..90f8941 100644
--- a/WebCore/loader/DocumentThreadableLoader.cpp
+++ b/WebCore/loader/DocumentThreadableLoader.cpp
@@ -251,7 +251,7 @@
bool DocumentThreadableLoader::getShouldUseCredentialStorage(SubresourceLoader* loader, bool& shouldUseCredentialStorage)
{
- ASSERT_UNUSED(loader, loader == m_loader);
+ ASSERT_UNUSED(loader, loader == m_loader || !m_loader);
if (!m_options.allowCredentials) {
shouldUseCredentialStorage = false;
@@ -299,6 +299,9 @@
// Don't sniff content or send load callbacks for the preflight request.
bool sendLoadCallbacks = m_options.sendLoadCallbacks && !m_actualRequest;
bool sniffContent = m_options.sniffContent && !m_actualRequest;
+
+ // Clear the loader so that any callbacks from SubresourceLoader::create will not have the old loader.
+ m_loader = 0;
m_loader = SubresourceLoader::create(m_document->frame(), this, request, skipCanLoadCheck, sendLoadCallbacks, sniffContent);
return;
}