Index: chrome/browser/ui/login/login_prompt_browsertest.cc |
diff --git a/chrome/browser/ui/login/login_prompt_browsertest.cc b/chrome/browser/ui/login/login_prompt_browsertest.cc |
index 476b3f55a6ac23f47052fc4fbcb5709d55b00c0f..0dc57c85ef9543125a68363360a4489ce254d576 100644 |
--- a/chrome/browser/ui/login/login_prompt_browsertest.cc |
+++ b/chrome/browser/ui/login/login_prompt_browsertest.cc |
@@ -7,6 +7,7 @@ |
#include <map> |
#include "chrome/browser/browser_thread.h" |
+#include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/login/login_prompt.h" |
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
@@ -162,6 +163,8 @@ typedef WindowedNavigationObserver<NotificationType::AUTH_CANCELLED> |
typedef WindowedNavigationObserver<NotificationType::AUTH_SUPPLIED> |
WindowedAuthSuppliedObserver; |
+const char* kPrefetchAuthPage = "files/login/prefetch.html"; |
+ |
const char* kMultiRealmTestPage = "files/login/multi_realm.html"; |
const int kMultiRealmTestRealmCount = 2; |
const int kMultiRealmTestResourceCount = 4; |
@@ -169,6 +172,37 @@ const int kMultiRealmTestResourceCount = 4; |
const char* kSingleRealmTestPage = "files/login/single_realm.html"; |
const int kSingleRealmTestResourceCount = 6; |
+// Confirm that <link rel="prefetch"> targetting an auth required |
+// resource does not provide a login dialog. These types of requests |
+// should instead just cancel the auth. |
+ |
+// Unfortunately, this test doesn't assert on anything for its |
+// correctness. Instead, it relies on the auth dialog blocking the |
+// browser, and triggering a timeout to cause failure when the |
+// prefetch resource requires authorization. |
+IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, PrefetchAuthCancels) { |
cbentzel
2011/01/20 17:59:45
Should this test also add a LoginPromptBrowserTest
asanka (google)
2011/01/20 18:16:29
An alternative would be to wait for both AUTH_NEED
cbentzel
2011/01/20 18:19:20
In this case we do not expect an AUTH_NEEDED, so t
gavinp
2011/01/20 18:36:15
Added the assertion for the obvserver handlers bei
|
+ ASSERT_TRUE(test_server()->Start()); |
+ |
+ GURL test_page = test_server()->GetURL(kPrefetchAuthPage); |
+ |
+ const bool was_prefetch_enabled = |
cbentzel
2011/01/20 17:59:45
Would it make sense to add a simple RAII class to
gavinp
2011/01/20 18:36:15
Done.
|
+ ResourceDispatcherHost::is_prefetch_enabled(); |
+ ResourceDispatcherHost::set_is_prefetch_enabled(true); |
+ |
+ TabContentsWrapper* contents = |
+ browser()->GetSelectedTabContentsWrapper(); |
+ ASSERT_TRUE(contents); |
+ NavigationController* controller = &contents->controller(); |
+ |
+ WindowedLoadStopObserver load_stop_waiter(controller); |
+ browser()->OpenURL(test_page, GURL(), CURRENT_TAB, PageTransition::TYPED); |
+ |
+ load_stop_waiter.Wait(); |
+ |
+ ResourceDispatcherHost::set_is_prefetch_enabled(was_prefetch_enabled); |
+ EXPECT_TRUE(test_server()->Stop()); |
+} |
+ |
// Test handling of resources that require authentication even though |
// the page they are included on doesn't. In this case we should only |
// present the minimal number of prompts necessary for successfully |