Commit 6cacb2df authored by Hajime Hoshi's avatar Hajime Hoshi Committed by Commit Bot

scheduler: Avoid using default task runner at MockFetchContext

This is a part of efforts to forbid V8 execution on the default task
runner of the main thread.

Bug: 870606

Change-Id: I3aa11f7cb4f8d6da6b0015d8b5516b1b2ba53bbf
Reviewed-on: https://chromium-review.googlesource.com/1169037Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Hajime Hoshi <hajimehoshi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582120}
parent 7b85205d
......@@ -95,6 +95,12 @@ class ResourceFetcherTest : public testing::Test {
ResourceFetcherTest() = default;
~ResourceFetcherTest() override { GetMemoryCache()->EvictResources(); }
void RunUntilIdle() {
base::SingleThreadTaskRunner* runner =
Context()->GetLoadingTaskRunner().get();
static_cast<scheduler::FakeTaskRunner*>(runner)->RunUntilIdle();
}
protected:
MockFetchContext* Context() { return platform_->Context(); }
void AddResourceToMemoryCache(
......@@ -905,7 +911,7 @@ TEST_F(ResourceFetcherTest, StaleWhileRevalidate) {
new_resource = MockResource::Fetch(fetch_params, fetcher, nullptr);
EXPECT_EQ(resource, new_resource);
EXPECT_TRUE(GetMemoryCache()->Contains(resource));
platform_->RunUntilIdle();
RunUntilIdle();
platform_->GetURLLoaderMockFactory()->ServeAsynchronousRequests();
EXPECT_FALSE(GetMemoryCache()->Contains(resource));
}
......
......@@ -30,8 +30,7 @@ FetchTestingPlatformSupport::~FetchTestingPlatformSupport() {
MockFetchContext* FetchTestingPlatformSupport::Context() {
if (!context_) {
context_ =
MockFetchContext::Create(MockFetchContext::kShouldLoadNewResource,
scheduler_->DefaultTaskRunner());
MockFetchContext::Create(MockFetchContext::kShouldLoadNewResource);
}
return context_;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment