|
| 1 | +diff --git a/content/browser/webauth/webauth_browsertest.cc b/content/browser/webauth/webauth_browsertest.cc |
| 2 | +index 0ebb28807bfd6b9fc543db8d829700213c3fa581..be781a5818b855df4893d8476f63e25866788b69 100644 |
| 3 | +--- a/content/browser/webauth/webauth_browsertest.cc |
| 4 | ++++ b/content/browser/webauth/webauth_browsertest.cc |
| 5 | +@@ -40,6 +40,7 @@ |
| 6 | + #include "content/browser/renderer_host/render_frame_host_impl.h" |
| 7 | + #include "content/browser/webauth/authenticator_environment.h" |
| 8 | + #include "content/browser/webauth/authenticator_impl.h" |
| 9 | ++#include "content/browser/webauth/webauth_request_security_checker.h" |
| 10 | + #include "content/public/browser/authenticator_request_client_delegate.h" |
| 11 | + #include "content/public/browser/navigation_handle.h" |
| 12 | + #include "content/public/browser/navigation_throttle.h" |
| 13 | +@@ -179,6 +180,11 @@ constexpr char kRpIdNoEntryMessage[] = |
| 14 | + ".well-known/webauthn resource of the claimed RP ID was " |
| 15 | + "successful, but no listed origin matched the caller."; |
| 16 | + |
| 17 | ++constexpr char kRpIdFetchFailedMessage[] = |
| 18 | ++ "SecurityError: The relying party ID is not a registrable domain suffix " |
| 19 | ++ "of, nor equal to the current domain. Subsequently, an attempt to fetch " |
| 20 | ++ "the .well-known/webauthn resource of the claimed RP ID failed."; |
| 21 | ++ |
| 22 | + constexpr char kMaxLargeBlobMessage[] = |
| 23 | + "NotSupportedError: The 'largeBlob' extension's 'write' parameter exceeds " |
| 24 | + "the maximum allowed size (2kb)"; |
| 25 | +@@ -1810,6 +1816,8 @@ IN_PROC_BROWSER_TEST_F(WebAuthCrossDomainTest, Create) { |
| 26 | + parameters.rp_id = "foo.com"; |
| 27 | + test_client()->set_webauthn_origins_response( |
| 28 | + "application/json", GetHttpsURL("www.acme.com", "/").spec()); |
| 29 | ++ WebAuthRequestSecurityChecker::UseSystemSharedURLLoaderFactoryForTesting() = |
| 30 | ++ true; |
| 31 | + std::string result = EvalJs(shell()->web_contents()->GetPrimaryMainFrame(), |
| 32 | + BuildCreateCallWithParameters(parameters)) |
| 33 | + .ExtractString(); |
| 34 | +@@ -1817,11 +1825,30 @@ IN_PROC_BROWSER_TEST_F(WebAuthCrossDomainTest, Create) { |
| 35 | + EXPECT_EQ(kOkMessage, result); |
| 36 | + } |
| 37 | + |
| 38 | ++IN_PROC_BROWSER_TEST_F(WebAuthCrossDomainTest, CreateFetchFailed) { |
| 39 | ++ CreateParameters parameters; |
| 40 | ++ parameters.rp_id = "foo.com"; |
| 41 | ++ // Set up the system URL loader factory to respond to requests, but do not |
| 42 | ++ // force its use. This will result in the browser context-specific URL |
| 43 | ++ // loader factory being used, which will fail to handle the request. |
| 44 | ++ test_client()->set_webauthn_origins_response( |
| 45 | ++ "application/json", GetHttpsURL("www.acme.com", "/").spec()); |
| 46 | ++ WebAuthRequestSecurityChecker::UseSystemSharedURLLoaderFactoryForTesting() = |
| 47 | ++ false; |
| 48 | ++ std::string result = EvalJs(shell()->web_contents()->GetPrimaryMainFrame(), |
| 49 | ++ BuildCreateCallWithParameters(parameters)) |
| 50 | ++ .ExtractString(); |
| 51 | ++ |
| 52 | ++ EXPECT_EQ(kRpIdFetchFailedMessage, result); |
| 53 | ++} |
| 54 | ++ |
| 55 | + IN_PROC_BROWSER_TEST_F(WebAuthCrossDomainTest, CreateBadContentType) { |
| 56 | + CreateParameters parameters; |
| 57 | + parameters.rp_id = "foo.com"; |
| 58 | + test_client()->set_webauthn_origins_response( |
| 59 | + "text/plain", GetHttpsURL("www.acme.com", "/").spec()); |
| 60 | ++ WebAuthRequestSecurityChecker::UseSystemSharedURLLoaderFactoryForTesting() = |
| 61 | ++ true; |
| 62 | + std::string result = EvalJs(shell()->web_contents()->GetPrimaryMainFrame(), |
| 63 | + BuildCreateCallWithParameters(parameters)) |
| 64 | + .ExtractString(); |
| 65 | +@@ -1834,6 +1861,8 @@ IN_PROC_BROWSER_TEST_F(WebAuthCrossDomainTest, CreateBadOrigin) { |
| 66 | + parameters.rp_id = "foo.com"; |
| 67 | + test_client()->set_webauthn_origins_response("application/json", |
| 68 | + "https://nottherightdomain.com"); |
| 69 | ++ WebAuthRequestSecurityChecker::UseSystemSharedURLLoaderFactoryForTesting() = |
| 70 | ++ true; |
| 71 | + std::string result = EvalJs(shell()->web_contents()->GetPrimaryMainFrame(), |
| 72 | + BuildCreateCallWithParameters(parameters)) |
| 73 | + .ExtractString(); |
| 74 | +@@ -1847,6 +1876,8 @@ IN_PROC_BROWSER_TEST_F(WebAuthCrossDomainTest, Timeout) { |
| 75 | + parameters.rp_id = "foo.com"; |
| 76 | + parameters.timeout = kShortTimeout; |
| 77 | + test_client()->sinkhole_webauthn_origins_requests(); |
| 78 | ++ WebAuthRequestSecurityChecker::UseSystemSharedURLLoaderFactoryForTesting() = |
| 79 | ++ true; |
| 80 | + std::string result = EvalJs(shell()->web_contents()->GetPrimaryMainFrame(), |
| 81 | + BuildCreateCallWithParameters(parameters)) |
| 82 | + .ExtractString(); |
| 83 | +@@ -1867,6 +1898,8 @@ IN_PROC_BROWSER_TEST_F(WebAuthCrossDomainTest, Get) { |
| 84 | + parameters.rp_id = "foo.com"; |
| 85 | + test_client()->set_webauthn_origins_response( |
| 86 | + "application/json", GetHttpsURL("www.acme.com", "/").spec()); |
| 87 | ++ WebAuthRequestSecurityChecker::UseSystemSharedURLLoaderFactoryForTesting() = |
| 88 | ++ true; |
| 89 | + std::string result = EvalJs(shell()->web_contents()->GetPrimaryMainFrame(), |
| 90 | + BuildGetCallWithParameters(parameters)) |
| 91 | + .ExtractString(); |
0 commit comments