| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" |
| 9 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
| 10 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
| 11 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
| 12 #include "content/public/test/browser_test_utils.h" | 13 #include "content/public/test/browser_test_utils.h" |
| 13 #include "content/public/test/content_browser_test.h" | 14 #include "content/public/test/content_browser_test.h" |
| 14 #include "content/public/test/content_browser_test_utils.h" | 15 #include "content/public/test/content_browser_test_utils.h" |
| 15 #include "content/public/test/test_navigation_observer.h" | 16 #include "content/public/test/test_navigation_observer.h" |
| 16 #include "content/shell/browser/shell.h" | 17 #include "content/shell/browser/shell.h" |
| 17 #include "net/dns/mock_host_resolver.h" | 18 #include "net/dns/mock_host_resolver.h" |
| 18 #include "net/test/embedded_test_server/embedded_test_server.h" | 19 #include "net/test/embedded_test_server/embedded_test_server.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 BrowserThread::IO, FROM_HERE, | 182 BrowserThread::IO, FROM_HERE, |
| 182 base::Bind(&net::URLRequestFailedJob::AddUrlHandler)); | 183 base::Bind(&net::URLRequestFailedJob::AddUrlHandler)); |
| 183 NavigateToURL(shell(), error_url); | 184 NavigateToURL(shell(), error_url); |
| 184 EXPECT_EQ(error_url, observer.last_navigation_url()); | 185 EXPECT_EQ(error_url, observer.last_navigation_url()); |
| 185 NavigationEntry* entry = | 186 NavigationEntry* entry = |
| 186 shell()->web_contents()->GetController().GetLastCommittedEntry(); | 187 shell()->web_contents()->GetController().GetLastCommittedEntry(); |
| 187 EXPECT_EQ(PAGE_TYPE_ERROR, entry->GetPageType()); | 188 EXPECT_EQ(PAGE_TYPE_ERROR, entry->GetPageType()); |
| 188 } | 189 } |
| 189 } | 190 } |
| 190 | 191 |
| 192 // Ensure that browser side navigation handles POST navigations correctly. |
| 193 IN_PROC_BROWSER_TEST_F(BrowserSideNavigationBrowserTest, POSTNavigation) { |
| 194 GURL url(embedded_test_server()->GetURL("/session_history/form.html")); |
| 195 GURL post_url = embedded_test_server()->GetURL("/echotitle"); |
| 196 |
| 197 // Navigate to a page with a form. |
| 198 TestNavigationObserver observer(shell()->web_contents()); |
| 199 NavigateToURL(shell(), url); |
| 200 EXPECT_EQ(url, observer.last_navigation_url()); |
| 201 EXPECT_TRUE(observer.last_navigation_succeeded()); |
| 202 |
| 203 // Submit the form. |
| 204 GURL submit_url("javascript:submitForm('isubmit')"); |
| 205 NavigateToURL(shell(), submit_url); |
| 206 |
| 207 // Check that a proper POST navigation was done. |
| 208 EXPECT_EQ("text=&select=a", |
| 209 base::UTF16ToASCII(shell()->web_contents()->GetTitle())); |
| 210 EXPECT_EQ(post_url, shell()->web_contents()->GetLastCommittedURL()); |
| 211 EXPECT_TRUE(shell() |
| 212 ->web_contents() |
| 213 ->GetController() |
| 214 .GetActiveEntry() |
| 215 ->GetHasPostData()); |
| 216 } |
| 217 |
| 191 } // namespace content | 218 } // namespace content |
| OLD | NEW |