Commit bb588737 authored by Kevin Marshall's avatar Kevin Marshall Committed by Chromium LUCI CQ

[fuchsia] Handle ApiBindings disconnect before Frame attachment.

Produces ERROR logging and invokes error closure if the ApiBindings
service disconnected before AttachToFrame() was called.

Bug: 1071863
Change-Id: I4e514118f6f6227b38a976a49185f46531934804
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2577934
Commit-Queue: Kevin Marshall <kmarshall@chromium.org>
Auto-Submit: Kevin Marshall <kmarshall@chromium.org>
Reviewed-by: default avatarDavid Dorwin <ddorwin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834537}
parent 6af764ec
......@@ -54,6 +54,12 @@ void ApiBindingsClient::AttachToFrame(
DCHECK(bindings_)
<< "AttachToFrame() was called before bindings were received.";
if (!bindings_service_) {
LOG(ERROR) << "ApiBindings channel disconnect before attaching Frame.";
std::move(on_error_callback).Run();
return;
}
connector_ = connector;
frame_ = frame;
......
......@@ -37,7 +37,8 @@ class ApiBindingsClientTest : public cr_fuchsia::WebEngineBrowserTest {
void SetUp() override { cr_fuchsia::WebEngineBrowserTest::SetUp(); }
protected:
void StartClient() {
void StartClient(bool disconnect_before_attach,
base::OnceClosure on_error_closure) {
base::ScopedAllowBlockingForTesting allow_blocking;
// Get the bindings from |api_service_|.
......@@ -53,8 +54,13 @@ class ApiBindingsClientTest : public cr_fuchsia::WebEngineBrowserTest {
connector_ =
std::make_unique<NamedMessagePortConnectorFuchsia>(frame_.get());
if (disconnect_before_attach)
api_service_binding_.Unbind();
base::RunLoop().RunUntilIdle();
client_->AttachToFrame(frame_.get(), connector_.get(),
base::MakeExpectedNotRunClosure(FROM_HERE));
std::move(on_error_closure));
}
void SetUpOnMainThread() override {
......@@ -91,7 +97,7 @@ IN_PROC_BROWSER_TEST_F(ApiBindingsClientTest, EndToEnd) {
binding_list.emplace_back(std::move(echo_binding));
api_service_.set_bindings(std::move(binding_list));
StartClient();
StartClient(false, base::MakeExpectedNotRunClosure(FROM_HERE));
base::RunLoop post_message_responses_loop;
base::RepeatingClosure post_message_response_closure =
......@@ -143,4 +149,13 @@ IN_PROC_BROWSER_TEST_F(ApiBindingsClientTest, EndToEnd) {
post_message_responses_loop.Run();
}
IN_PROC_BROWSER_TEST_F(ApiBindingsClientTest,
ClientDisconnectsBeforeFrameAttached) {
bool error_signaled = false;
StartClient(
true, base::BindOnce([](bool* error_signaled) { *error_signaled = true; },
base::Unretained(&error_signaled)));
EXPECT_TRUE(error_signaled);
}
} // namespace
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