| Index: third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandleTest.cpp
|
| diff --git a/third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandleTest.cpp b/third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandleTest.cpp
|
| index b49316cadfc7d072962900eae4f12073d30c9d11..a7f6a85451c8baf143e87cbb463802a025418a6d 100644
|
| --- a/third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandleTest.cpp
|
| +++ b/third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandleTest.cpp
|
| @@ -112,8 +112,9 @@
|
| = FetchBlobDataConsumerHandle::create(&document(), blobDataHandle, factory);
|
| testing::runPendingTasks();
|
|
|
| - size_t size = 0;
|
| - handle->obtainReader(nullptr)->read(nullptr, 0, kNone, &size);
|
| + char buffer[1];
|
| + size_t size = 0;
|
| + ASSERT_EQ(kShouldWait, handle->obtainReader(nullptr)->read(buffer, sizeof(buffer), kNone, &size));
|
| checkpoint.Call(1);
|
| testing::runPendingTasks();
|
| checkpoint.Call(2);
|
| @@ -134,6 +135,27 @@
|
| EXPECT_EQ(NotCORSEnabled, resourceLoaderOptions.corsEnabled);
|
| }
|
|
|
| +TEST_F(FetchBlobDataConsumerHandleTest, ZeroByteReadDoesNotCreateLoader)
|
| +{
|
| + auto factory = new StrictMock<MockLoaderFactory>;
|
| + Checkpoint checkpoint;
|
| +
|
| + InSequence s;
|
| + EXPECT_CALL(checkpoint, Call(1));
|
| + EXPECT_CALL(checkpoint, Call(2));
|
| +
|
| + RefPtr<BlobDataHandle> blobDataHandle = createBlobDataHandle("Once upon a time");
|
| + std::unique_ptr<WebDataConsumerHandle> handle
|
| + = FetchBlobDataConsumerHandle::create(&document(), blobDataHandle, factory);
|
| + testing::runPendingTasks();
|
| +
|
| + size_t size = 0;
|
| + ASSERT_EQ(kShouldWait, handle->obtainReader(nullptr)->read(nullptr, 0, kNone, &size));
|
| + checkpoint.Call(1);
|
| + testing::runPendingTasks();
|
| + checkpoint.Call(2);
|
| +}
|
| +
|
| TEST_F(FetchBlobDataConsumerHandleTest, CancelLoaderWhenStopped)
|
| {
|
| auto factory = new StrictMock<MockLoaderFactory>;
|
| @@ -154,8 +176,9 @@
|
| = FetchBlobDataConsumerHandle::create(&document(), blobDataHandle, factory);
|
| testing::runPendingTasks();
|
|
|
| - size_t size = 0;
|
| - handle->obtainReader(nullptr)->read(nullptr, 0, kNone, &size);
|
| + char buffer[1];
|
| + size_t size = 0;
|
| + ASSERT_EQ(kShouldWait, handle->obtainReader(nullptr)->read(buffer, sizeof(buffer), kNone, &size));
|
| checkpoint.Call(1);
|
| testing::runPendingTasks();
|
| checkpoint.Call(2);
|
| @@ -185,8 +208,9 @@
|
| std::unique_ptr<WebDataConsumerHandle::Reader> reader = handle->obtainReader(nullptr);
|
| testing::runPendingTasks();
|
|
|
| - size_t size = 0;
|
| - reader->read(nullptr, 0, kNone, &size);
|
| + char buffer[1];
|
| + size_t size = 0;
|
| + ASSERT_EQ(kShouldWait, reader->read(buffer, sizeof(buffer), kNone, &size));
|
| checkpoint.Call(1);
|
| testing::runPendingTasks();
|
| checkpoint.Call(2);
|
| @@ -223,8 +247,9 @@
|
| src->add(Command(Command::Wait));
|
| src->add(Command(Command::Done));
|
|
|
| - size_t size = 0;
|
| - handle->obtainReader(nullptr)->read(nullptr, 0, kNone, &size);
|
| + char buffer[1];
|
| + size_t size = 0;
|
| + ASSERT_EQ(kShouldWait, handle->obtainReader(nullptr)->read(buffer, sizeof(buffer), kNone, &size));
|
| checkpoint.Call(1);
|
| testing::runPendingTasks();
|
| checkpoint.Call(2);
|
| @@ -261,8 +286,9 @@
|
| src->add(Command(Command::Wait));
|
| src->add(Command(Command::Done));
|
|
|
| - size_t size = 0;
|
| - handle->obtainReader(nullptr)->read(nullptr, 0, kNone, &size);
|
| + char buffer[1];
|
| + size_t size = 0;
|
| + ASSERT_EQ(kShouldWait, handle->obtainReader(nullptr)->read(buffer, sizeof(buffer), kNone, &size));
|
| checkpoint.Call(1);
|
| testing::runPendingTasks();
|
| checkpoint.Call(2);
|
| @@ -291,8 +317,9 @@
|
| std::unique_ptr<WebDataConsumerHandle> handle
|
| = FetchBlobDataConsumerHandle::create(&document(), blobDataHandle, factory);
|
|
|
| - size_t size = 0;
|
| - handle->obtainReader(nullptr)->read(nullptr, 0, kNone, &size);
|
| + char buffer[1];
|
| + size_t size = 0;
|
| + ASSERT_EQ(kShouldWait, handle->obtainReader(nullptr)->read(buffer, sizeof(buffer), kNone, &size));
|
| checkpoint.Call(1);
|
| testing::runPendingTasks();
|
| checkpoint.Call(2);
|
| @@ -326,8 +353,9 @@
|
| src->add(Command(Command::Data, "hello, "));
|
| src->add(Command(Command::Error));
|
|
|
| - size_t size = 0;
|
| - handle->obtainReader(nullptr)->read(nullptr, 0, kNone, &size);
|
| + char buffer[1];
|
| + size_t size = 0;
|
| + ASSERT_EQ(kShouldWait, handle->obtainReader(nullptr)->read(buffer, sizeof(buffer), kNone, &size));
|
| checkpoint.Call(1);
|
| testing::runPendingTasks();
|
| checkpoint.Call(2);
|
|
|