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

Unified Diff: third_party/WebKit/Source/core/css/CSSStyleSheetResourceTest.cpp

Issue 2013013002: Add a StyleResourceClient in CSSStyleSheetResourceTest to keep Resource alive Base URL: https://chromium.googlesource.com/chromium/src.git@MemoryCache_test0
Patch Set: Created 4 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/CSSStyleSheetResourceTest.cpp
diff --git a/third_party/WebKit/Source/core/css/CSSStyleSheetResourceTest.cpp b/third_party/WebKit/Source/core/css/CSSStyleSheetResourceTest.cpp
index c109a8594e3b04429a56c2dfffd54f57dd26684f..2eb757e418574eeed7f696446fc89df224753bc4 100644
--- a/third_party/WebKit/Source/core/css/CSSStyleSheetResourceTest.cpp
+++ b/third_party/WebKit/Source/core/css/CSSStyleSheetResourceTest.cpp
@@ -21,6 +21,7 @@
#include "core/fetch/FetchRequest.h"
#include "core/fetch/MemoryCache.h"
#include "core/fetch/ResourceFetcher.h"
+#include "core/fetch/StyleSheetResourceClient.h"
#include "core/testing/DummyPageHolder.h"
#include "platform/heap/Handle.h"
#include "platform/heap/Heap.h"
@@ -40,6 +41,11 @@ class Document;
namespace {
+class MockStyleSheetResourceClient : public StyleSheetResourceClient {
+public:
+ String debugName() const override { return "MockStyleSheetResourceClient"; }
+};
+
class CSSStyleSheetResourceTest : public ::testing::Test {
protected:
CSSStyleSheetResourceTest()
@@ -72,6 +78,8 @@ TEST_F(CSSStyleSheetResourceTest, PruneCanCauseEviction)
document()->fetcher()->setAutoLoadImages(false);
CSSStyleSheetResource* cssResource = CSSStyleSheetResource::createForTest(ResourceRequest(cssURL), "utf-8");
+ MockStyleSheetResourceClient client;
+ cssResource->addClient(&client);
memoryCache()->add(cssResource);
cssResource->responseReceived(ResourceResponse(cssURL, "style/css", 0, nullAtom, String()), nullptr);
cssResource->finish();
@@ -112,6 +120,7 @@ TEST_F(CSSStyleSheetResourceTest, PruneCanCauseEviction)
memoryCache()->update(imageResource, imageResource->size(), imageResource->size(), true);
}
ASSERT_TRUE(memoryCache()->isInSameLRUListForTest(cssResource, imageResource));
+ cssResource->removeClient(&client);
}
ThreadHeap::collectAllGarbage();
// This operation should not lead to crash!
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698