Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1089)

Unified Diff: Source/core/loader/cache/ResourceFetcherTest.cpp

Issue 19597008: If a resource load is started as the CachedResourceLoader is going away, make sure we remove the Ca… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: + test Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/loader/cache/ResourceFetcher.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/loader/cache/ResourceFetcherTest.cpp
diff --git a/Source/core/animation/AnimatableNeutralTest.cpp b/Source/core/loader/cache/ResourceFetcherTest.cpp
similarity index 50%
copy from Source/core/animation/AnimatableNeutralTest.cpp
copy to Source/core/loader/cache/ResourceFetcherTest.cpp
index 0eb0188666d28d1cb73d6699b85ae7f2766a0622..2f99f94905fb59160331d66ba4032ac8238462e3 100644
--- a/Source/core/animation/AnimatableNeutralTest.cpp
+++ b/Source/core/loader/cache/ResourceFetcherTest.cpp
@@ -29,29 +29,40 @@
*/
#include "config.h"
-#include "core/animation/AnimatableNeutral.h"
-
-#include "core/animation/AnimatableUnknown.h"
-#include "core/css/CSSArrayFunctionValue.h"
+#include "core/loader/cache/ResourceFetcher.h"
+#include "core/html/HTMLDocument.h"
+#include "core/loader/DocumentLoader.h"
+#include "core/loader/cache/CachedResourceHandle.h"
+#include "core/loader/cache/CachedResourceInitiatorInfo.h"
+#include "core/loader/cache/FetchRequest.h"
+#include "core/loader/cache/MemoryCache.h"
+#include "core/platform/network/ResourceRequest.h"
#include <gtest/gtest.h>
using namespace WebCore;
namespace {
-TEST(AnimatableNeutral, Create)
+TEST(ResourceFetcherTest, StartLoadAfterFrameDetach)
{
- EXPECT_TRUE(AnimatableValue::neutralValue());
-}
+ KURL testURL(ParsedURLString, "http://www.test.com/cancelTest.jpg");
-TEST(AnimatableNeutral, Add)
-{
- RefPtr<CSSValue> cssValue = CSSArrayFunctionValue::create();
- RefPtr<AnimatableValue> animatableUnknown = AnimatableUnknown::create(cssValue);
+ // Create a ResourceFetcher that has a real DocumentLoader and Document, but is not attached to a Frame.
+ // Technically, we're concerned about what happens after a Frame is detached (rather than before
+ // any attach occurs), but ResourceFetcher can't tell the difference.
+ RefPtr<DocumentLoader> documentLoader = DocumentLoader::create(ResourceRequest(testURL), SubstituteData());
+ RefPtr<HTMLDocument> document = HTMLDocument::create();
+ RefPtr<ResourceFetcher> fetcher(documentLoader->fetcher());
+ fetcher->setDocument(document.get());
+ EXPECT_EQ(fetcher->frame(), static_cast<Frame*>(0));
- EXPECT_EQ(cssValue, AnimatableValue::add(animatableUnknown.get(), AnimatableValue::neutralValue())->toCSSValue());
- EXPECT_EQ(cssValue, AnimatableValue::add(AnimatableValue::neutralValue(), animatableUnknown.get())->toCSSValue());
+ // Try to request a url. The request should fail, no resource should be returned,
+ // and no resource should be present in the cache.
+ FetchRequest fetchRequest = FetchRequest(ResourceRequest(testURL), CachedResourceInitiatorInfo());
+ CachedResourceHandle<CachedImage> image = fetcher->requestImage(fetchRequest);
+ EXPECT_EQ(image.get(), static_cast<CachedImage*>(0));
+ EXPECT_EQ(memoryCache()->resourceForURL(testURL), static_cast<CachedResource*>(0));
}
-}
+} // namespace
« no previous file with comments | « Source/core/loader/cache/ResourceFetcher.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698