Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1109)

Unified Diff: chrome/browser/extensions/background_xhr_browsertest.cc

Issue 859213006: Cancel client auth requests when not promptable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@client-auth-cancel-1
Patch Set: worker_common.js was missing a license header (also a rebase) Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | chrome/browser/ssl/ssl_client_auth_observer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/background_xhr_browsertest.cc
diff --git a/chrome/browser/extensions/background_xhr_browsertest.cc b/chrome/browser/extensions/background_xhr_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6ff6debbb2a33c7660794e10f00be576667f663d
--- /dev/null
+++ b/chrome/browser/extensions/background_xhr_browsertest.cc
@@ -0,0 +1,82 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/bind.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/run_loop.h"
+#include "chrome/browser/extensions/extension_browsertest.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_io_data.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "content/public/browser/browser_thread.h"
+#include "extensions/common/extension.h"
+#include "extensions/test/result_catcher.h"
+#include "net/base/escape.h"
+#include "net/base/url_util.h"
+#include "net/ssl/client_cert_store.h"
+#include "net/test/spawned_test_server/spawned_test_server.h"
+#include "url/gurl.h"
+
+namespace {
+
+scoped_ptr<net::ClientCertStore> CreateNullCertStore() {
+ return nullptr;
+}
+
+void InstallNullCertStoreFactoryOnIOThread(
+ content::ResourceContext* resource_context) {
+ ProfileIOData::FromResourceContext(resource_context)
+ ->set_client_cert_store_factory_for_testing(
+ base::Bind(&CreateNullCertStore));
+}
+
+} // namespace
+
+class BackgroundXhrTest : public ExtensionBrowserTest {
+ protected:
+ void RunTest(const std::string& path, const GURL& url) {
+ const extensions::Extension* extension =
+ LoadExtension(test_data_dir_.AppendASCII("background_xhr"));
+ ASSERT_TRUE(extension);
+
+ extensions::ResultCatcher catcher;
+ GURL test_url = net::AppendQueryParameter(extension->GetResourceURL(path),
+ "url", url.spec());
+ ui_test_utils::NavigateToURL(browser(), test_url);
+ ASSERT_TRUE(catcher.GetNextResult());
+ }
+};
+
+// Test that fetching a URL using TLS client auth doesn't crash, hang, or
+// prompt.
+IN_PROC_BROWSER_TEST_F(BackgroundXhrTest, TlsClientAuth) {
+ // Install a null ClientCertStore so the client auth prompt isn't bypassed due
+ // to the system certificate store returning no certificates.
+ base::RunLoop loop;
+ content::BrowserThread::PostTaskAndReply(
+ content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&InstallNullCertStoreFactoryOnIOThread,
+ browser()->profile()->GetResourceContext()),
+ loop.QuitClosure());
+ loop.Run();
+
+ // Launch HTTPS server.
+ net::SpawnedTestServer::SSLOptions ssl_options;
+ ssl_options.request_client_certificate = true;
+ net::SpawnedTestServer https_server(
+ net::SpawnedTestServer::TYPE_HTTPS, ssl_options,
+ base::FilePath(FILE_PATH_LITERAL("content/test/data")));
+ ASSERT_TRUE(https_server.Start());
+
+ ASSERT_NO_FATAL_FAILURE(
+ RunTest("test_tls_client_auth.html", https_server.GetURL("")));
+}
+
+// Test that fetching a URL using HTTP auth doesn't crash, hang, or prompt.
+IN_PROC_BROWSER_TEST_F(BackgroundXhrTest, HttpAuth) {
+ ASSERT_TRUE(test_server()->Start());
+ ASSERT_NO_FATAL_FAILURE(
+ RunTest("test_http_auth.html", test_server()->GetURL("auth-basic")));
+}
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | chrome/browser/ssl/ssl_client_auth_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698