| Index: third_party/WebKit/Source/core/fetch/ResourceTest.cpp
|
| diff --git a/third_party/WebKit/Source/core/fetch/ResourceTest.cpp b/third_party/WebKit/Source/core/fetch/ResourceTest.cpp
|
| index e55a87fd2bed0360124e9dd3d0fff2e6cfa97dad..2bbbc601d7c39c3867e0b1cce125ef4d5dbf59fa 100644
|
| --- a/third_party/WebKit/Source/core/fetch/ResourceTest.cpp
|
| +++ b/third_party/WebKit/Source/core/fetch/ResourceTest.cpp
|
| @@ -5,6 +5,7 @@
|
| #include "core/fetch/Resource.h"
|
|
|
| #include "core/fetch/MemoryCache.h"
|
| +#include "core/fetch/MockResourceClients.h"
|
| #include "core/fetch/RawResource.h"
|
| #include "platform/SharedBuffer.h"
|
| #include "platform/network/ResourceRequest.h"
|
| @@ -52,6 +53,25 @@ void createTestResourceAndSetCachedMetadata(const ResourceResponse& response) {
|
| return;
|
| }
|
|
|
| +class TestProhibitAddRemoveClientResource final : public Resource {
|
| + public:
|
| + static TestProhibitAddRemoveClientResource* create() {
|
| + return new TestProhibitAddRemoveClientResource();
|
| + }
|
| + void testAddClient(ResourceClient* client) {
|
| + ProhibitAddRemoveClientInScope prohibitAddRemoveClient(this);
|
| + addClient(client);
|
| + }
|
| + void testRemoveClient(ResourceClient* client) {
|
| + ProhibitAddRemoveClientInScope prohibitAddRemoveClient(this);
|
| + removeClient(client);
|
| + }
|
| +
|
| + private:
|
| + TestProhibitAddRemoveClientResource()
|
| + : Resource(ResourceRequest(), Resource::Raw, ResourceLoaderOptions()) {}
|
| +};
|
| +
|
| } // anonymous namespace
|
|
|
| TEST(ResourceTest, SetCachedMetadata_SendsMetadataToPlatform) {
|
| @@ -90,4 +110,15 @@ TEST(ResourceTest, RevalidateWithFragment) {
|
| resource->responseReceived(revalidatingResponse, nullptr);
|
| }
|
|
|
| +TEST(ResourceTest, ProhibitAddRemoveClientInScope) {
|
| + TestProhibitAddRemoveClientResource* resource =
|
| + TestProhibitAddRemoveClientResource::create();
|
| + Persistent<MockResourceClient> client = new MockResourceClient();
|
| + EXPECT_DEATH(resource->testAddClient(client),
|
| + "!m_isAddRemoveClientProhibited");
|
| + resource->addClient(client);
|
| + EXPECT_DEATH(resource->testRemoveClient(client),
|
| + "!m_isAddRemoveClientProhibited");
|
| +}
|
| +
|
| } // namespace blink
|
|
|