Commit f1458788 authored by Yi Gu's avatar Yi Gu Committed by Commit Bot

[WebOTP] Fix flaky test SameSiteNavigationResetsDocumentUsedWebOTP

Gives more time to propagate the WebOTP bit.

Bug: 1120305
Change-Id: Id350a03de42d3ea5895f01f47cdb5fff7ce801e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2405374Reviewed-by: default avatarKen Buchanan <kenrb@chromium.org>
Commit-Queue: Yi Gu <yigu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807065}
parent cdfefe9d
...@@ -3717,17 +3717,26 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest, ...@@ -3717,17 +3717,26 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
// Check that same site navigation correctly resets document_used_web_otp_. // Check that same site navigation correctly resets document_used_web_otp_.
IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest, IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest,
SameSiteNavigationResetsDocumentUsedWebOTP) { SameSiteNavigationResetsDocumentUsedWebOTP) {
const GURL first_url( const GURL first_url(embedded_test_server()->GetURL("/title1.html"));
embedded_test_server()->GetURL("/page_with_webotp.html"));
const GURL second_url(embedded_test_server()->GetURL("/empty.html"));
// Load a URL that maps to the same SiteInstance as the second URL, to make
// sure the second navigation will not be cross-process.
ASSERT_TRUE(NavigateToURL(shell(), first_url)); ASSERT_TRUE(NavigateToURL(shell(), first_url));
std::string script = R"(
var element = document.createElement('div');
document.body.appendChild(element);
navigator.credentials.get({
otp: {transport:['sms']}
})
.then(content => element.value = content.code);
)";
EXPECT_TRUE(ExecuteScript(web_contents(), script));
EXPECT_TRUE(WaitForLoadStop(web_contents()));
RenderFrameHostImpl* main_rfh = web_contents()->GetMainFrame(); RenderFrameHostImpl* main_rfh = web_contents()->GetMainFrame();
EXPECT_TRUE(main_rfh->DocumentUsedWebOTP()); EXPECT_TRUE(main_rfh->DocumentUsedWebOTP());
// Loads a URL that maps to the same SiteInstance as the first URL, to make
// sure the navigation will not be cross-process.
const GURL second_url(embedded_test_server()->GetURL("/title2.html"));
ASSERT_TRUE(NavigateToURL(shell(), second_url)); ASSERT_TRUE(NavigateToURL(shell(), second_url));
EXPECT_FALSE(main_rfh->DocumentUsedWebOTP()); EXPECT_FALSE(main_rfh->DocumentUsedWebOTP());
} }
......
<input autocomplete="one-time-code">
<script>
const ac = document.querySelector('input[autocomplete="one-time-code"]');
navigator.credentials.get({
otp: {transport:['sms']}
})
.then(content => ac.value = content.code);
</script>
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