Commit 9d369c67 authored by danakj's avatar danakj Committed by Commit Bot

Deflake external/wpt/fetch/cross-origin-resource-policy/

The network process crashes flakily in these tests on trying to read a
file and being blocked:

[217947:217958:0403/143350.056670:FATAL:url_loader.cc(1828)] Check failed: response_.
#0 0x5604f137b829 base::debug::CollectStackTrace()
#1 0x5604f12a3ae3 base::debug::StackTrace::StackTrace()
#2 0x5604f12b9174 logging::LogMessage::~LogMessage()
#3 0x5604f2afe5d7 network::URLLoader::CompleteBlockedResponse()
#4 0x5604f2afcf29 network::URLLoader::OnReceivedRedirect()
#5 0x5604f194d027 net::URLRequestJob::NotifyHeadersComplete()
#6 0x5604f1950a04 net::URLRequestHttpJob::NotifyHeadersComplete()
#7 0x5604f1952ec2 net::URLRequestHttpJob::SaveCookiesAndNotifyHeadersComplete()
#8 0x5604f1951d28 net::URLRequestHttpJob::OnStartCompleted()
#9 0x5604f186697c net::HttpCache::Transaction::DoLoop()
#10 0x5604ee97ab9c base::internal::Invoker<>::Run()
#11 0x5604f185fae3 net::HttpNetworkTransaction::DoCallback()
#12 0x5604f1820853 net::HttpStreamParser::OnIOComplete()
#13 0x5604ee97ab9c base::internal::Invoker<>::Run()
#14 0x5604f18c8a69 net::TCPClientSocket::DidCompleteRead()
#15 0x5604f1983a9c net::TCPSocketPosix::ReadCompleted()
#16 0x5604f198526a base::internal::Invoker<>::RunOnce()
#17 0x5604f1987137 net::SocketPosix::RetryRead()
#18 0x5604f1987eff net::SocketPosix::ReadCompleted()
#19 0x5604f1987c28 net::SocketPosix::OnFileCanReadWithoutBlocking()

When that happens the StoragePartition's NetworkContext is recreated.
WebTestContentBrowserClient was storing the NetworkContext* into a
RepeatingCallback against the advice of the method returning it
(ie StoragePartition::GetNetworkContext()), and then if the process
crashed, the Callback would have a dead pointer bound.

This changes the tests to grab the pointer when the callback is run
instead. The WebTestClientImpl's cookie_manager_ will still become
useless after the network service crashes, but these tests don't
depend on that... and WebTestClientImpl is created per-renderer so
it should not impact other tests.

R=nasko@chromium.org

Bug: 1067445
Change-Id: Ieeaca88e5baee9aa3f1bf969c1486503819dcdf8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135424Reviewed-by: default avatarNasko Oskov <nasko@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756369}
parent dbbb87f9
......@@ -213,13 +213,10 @@ void WebTestContentBrowserClient::ExposeInterfacesToRenderer(
associated_registry->AddInterface(
base::BindRepeating(&WebTestContentBrowserClient::BindBlinkTestController,
base::Unretained(this)));
StoragePartition* partition =
BrowserContext::GetDefaultStoragePartition(browser_context());
associated_registry->AddInterface(base::BindRepeating(
&WebTestContentBrowserClient::BindWebTestController,
base::Unretained(this), render_process_host->GetID(),
partition->GetQuotaManager(), partition->GetDatabaseTracker(),
partition->GetNetworkContext()));
render_process_host->GetID(),
BrowserContext::GetDefaultStoragePartition(browser_context())));
}
base::Optional<service_manager::Manifest>
......@@ -471,14 +468,15 @@ void WebTestContentBrowserClient::BindBlinkTestController(
BlinkTestController::Get()->AddBlinkTestClientReceiver(std::move(receiver));
}
// static
void WebTestContentBrowserClient::BindWebTestController(
int render_process_id,
storage::QuotaManager* quota_manager,
storage::DatabaseTracker* database_tracker,
network::mojom::NetworkContext* network_context,
StoragePartition* partition,
mojo::PendingAssociatedReceiver<mojom::WebTestClient> receiver) {
WebTestClientImpl::Create(render_process_id, quota_manager, database_tracker,
network_context, std::move(receiver));
WebTestClientImpl::Create(render_process_id, partition->GetQuotaManager(),
partition->GetDatabaseTracker(),
partition->GetNetworkContext(),
std::move(receiver));
}
#if defined(OS_WIN)
......
......@@ -23,19 +23,7 @@
#include "third_party/blink/public/mojom/clipboard/clipboard.mojom.h"
#include "third_party/blink/public/mojom/permissions/permission_automation.mojom-forward.h"
namespace network {
namespace mojom {
class NetworkContext;
} // namespace mojom
} // namespace network
namespace storage {
class DatabaseTracker;
class QuotaManager;
} // namespace storage
namespace content {
class FakeBluetoothChooser;
class FakeBluetoothChooserFactory;
class FakeBluetoothDelegate;
......@@ -141,11 +129,9 @@ class WebTestContentBrowserClient : public ShellContentBrowserClient {
void BindBlinkTestController(
mojo::PendingAssociatedReceiver<mojom::BlinkTestClient> receiver);
void BindWebTestController(
static void BindWebTestController(
int render_process_id,
storage::QuotaManager* quota_manager,
storage::DatabaseTracker* database_tracker,
network::mojom::NetworkContext* network_context,
StoragePartition* partition,
mojo::PendingAssociatedReceiver<mojom::WebTestClient> receiver);
std::unique_ptr<MockPlatformNotificationService>
......
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