Commit 1fe06c56 authored by Sam Goto's avatar Sam Goto Committed by Commit Bot

[sms] Assert that manual cancels are plumbed through

Bug: 670299
Change-Id: I3aebfce7baf6e25fb07ead2a74951a051bdb91cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1715915
Commit-Queue: Sam Goto <goto@chromium.org>
Reviewed-by: default avatarAyu Ishii <ayui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680558}
parent 7fd66c18
...@@ -16,9 +16,11 @@ ...@@ -16,9 +16,11 @@
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
using ::testing::_; using ::testing::_;
using ::testing::ByMove;
using ::testing::Invoke; using ::testing::Invoke;
using ::testing::NiceMock; using ::testing::NiceMock;
using ::testing::Return; using ::testing::Return;
using ::testing::StrictMock;
namespace content { namespace content {
...@@ -220,4 +222,45 @@ IN_PROC_BROWSER_TEST_F(SmsBrowserTest, SmsReceivedAfterTabIsClosed) { ...@@ -220,4 +222,45 @@ IN_PROC_BROWSER_TEST_F(SmsBrowserTest, SmsReceivedAfterTabIsClosed) {
provider->NotifyReceive(url::Origin::Create(url), "hello"); provider->NotifyReceive(url::Origin::Create(url), "hello");
} }
IN_PROC_BROWSER_TEST_F(SmsBrowserTest, Cancels) {
GURL url = GetTestUrl(nullptr, "simple_page.html");
NavigateToURL(shell(), url);
auto* provider = new NiceMock<MockSmsProvider>();
BrowserMainLoop::GetInstance()->SetSmsProviderForTesting(
base::WrapUnique(provider));
StrictMock<MockWebContentsDelegate> delegate;
shell()->web_contents()->SetDelegate(&delegate);
auto* dialog = new StrictMock<MockSmsDialog>();
EXPECT_CALL(delegate, CreateSmsDialog())
.WillOnce(Return(ByMove(base::WrapUnique(dialog))));
EXPECT_CALL(*dialog, Open(_, _, _))
.WillOnce(
Invoke([](content::RenderFrameHost*, base::OnceClosure on_continue,
base::OnceClosure on_cancel) {
// Simulates the user pressing "cancel".
std::move(on_cancel).Run();
}));
EXPECT_CALL(*dialog, Close()).WillOnce(Return());
std::string script = R"(
(async () => {
try {
await navigator.sms.receive({timeout: 10});
return false;
} catch (e) {
// Expects an exception to be thrown.
return e.name;
}
}) ();
)";
EXPECT_EQ("AbortError", EvalJs(shell(), script));
}
} // namespace content } // namespace content
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