| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <string> |
| 6 |
| 7 #include "chrome/app/chrome_dll_resource.h" |
| 8 #include "chrome/browser/net/url_fixer_upper.h" |
| 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/common/url_constants.h" |
| 11 #include "chrome/test/automation/tab_proxy.h" |
| 12 #include "chrome/test/automation/browser_proxy.h" |
| 13 #include "chrome/test/ui/ui_test.h" |
| 14 #include "net/url_request/url_request_unittest.h" |
| 15 |
| 16 using std::wstring; |
| 17 |
| 18 namespace { |
| 19 |
| 20 const wchar_t kDocRoot[] = L"chrome/test/data"; |
| 21 |
| 22 } // namespace |
| 23 |
| 24 class RepostFormWarningTest : public UITest { |
| 25 }; |
| 26 |
| 27 |
| 28 TEST_F(RepostFormWarningTest, TestDoubleReload) { |
| 29 scoped_refptr<HTTPTestServer> server = |
| 30 HTTPTestServer::CreateServer(kDocRoot, NULL); |
| 31 ASSERT_TRUE(NULL != server.get()); |
| 32 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 33 EXPECT_TRUE(browser.get()); |
| 34 |
| 35 scoped_refptr<TabProxy> tab(browser->GetTab(0)); |
| 36 |
| 37 // Load a form. |
| 38 ASSERT_TRUE(tab->NavigateToURL(server->TestServerPageW(L"files/form.html"))); |
| 39 // Submit it. |
| 40 ASSERT_TRUE(tab->NavigateToURL(GURL( |
| 41 "javascript:document.getElementById('form').submit()"))); |
| 42 |
| 43 // Try to reload it twice, checking for repost. |
| 44 tab->ReloadAsync(); |
| 45 tab->ReloadAsync(); |
| 46 |
| 47 // Navigate away from the page (this is when the test usually crashes). |
| 48 ASSERT_TRUE(tab->NavigateToURL(server->TestServerPageW(L"bar"))); |
| 49 } |
| 50 |
| 51 TEST_F(RepostFormWarningTest, TestLoginAfterRepost) { |
| 52 scoped_refptr<HTTPTestServer> server = |
| 53 HTTPTestServer::CreateServer(kDocRoot, NULL); |
| 54 ASSERT_TRUE(NULL != server.get()); |
| 55 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 56 ASSERT_TRUE(browser.get()); |
| 57 |
| 58 scoped_refptr<TabProxy> tab(browser->GetTab(0)); |
| 59 |
| 60 // Load a form. |
| 61 ASSERT_TRUE(tab->NavigateToURL(server->TestServerPageW(L"files/form.html"))); |
| 62 // Submit it. |
| 63 ASSERT_TRUE(tab->NavigateToURL(GURL( |
| 64 "javascript:document.getElementById('form').submit()"))); |
| 65 |
| 66 // Try to reload it, checking for repost. |
| 67 tab->ReloadAsync(); |
| 68 |
| 69 // Navigate to a page that requires authentication, bringing up another |
| 70 // tab-modal sheet. |
| 71 ASSERT_TRUE(tab->NavigateToURL(server->TestServerPageW(L"auth-basic"))); |
| 72 |
| 73 // Try to reload it again. |
| 74 tab->ReloadAsync(); |
| 75 |
| 76 // Navigate away from the page. |
| 77 ASSERT_TRUE(tab->NavigateToURL(server->TestServerPageW(L"bar"))); |
| 78 } |
| OLD | NEW |