| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/string_util.h" | 5 #include "base/string_util.h" |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "content/browser/download/download_manager_impl.h" | 7 #include "content/browser/download/download_manager_impl.h" |
| 8 #include "content/browser/web_contents/web_contents_impl.h" | 8 #include "content/browser/web_contents/web_contents_impl.h" |
| 9 #include "content/public/browser/browser_context.h" | 9 #include "content/public/browser/browser_context.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 11 #include "content/public/browser/notification_service.h" | 11 #include "content/public/browser/notification_service.h" |
| 12 #include "content/public/browser/notification_types.h" | 12 #include "content/public/browser/notification_types.h" |
| 13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 #include "content/public/common/url_constants.h" | 14 #include "content/public/common/url_constants.h" |
| 15 #include "content/public/test/browser_test_utils.h" | 15 #include "content/public/test/browser_test_utils.h" |
| 16 #include "content/public/test/test_utils.h" | 16 #include "content/public/test/test_utils.h" |
| 17 #include "content/shell/shell.h" | 17 #include "content/shell/shell.h" |
| 18 #include "content/test/content_browser_test.h" | 18 #include "content/test/content_browser_test.h" |
| 19 #include "content/test/content_browser_test_utils.h" | 19 #include "content/test/content_browser_test_utils.h" |
| 20 #include "content/test/net/url_request_failed_job.h" | 20 #include "content/test/net/url_request_failed_job.h" |
| 21 #include "content/test/net/url_request_mock_http_job.h" | 21 #include "content/test/net/url_request_mock_http_job.h" |
| 22 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
| 23 #include "net/test/spawned_test_server/spawned_test_server.h" | 23 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 24 #include "net/test/embedded_test_server/http_response.h" |
| 25 #include "net/test/embedded_test_server/http_request.h" |
| 24 | 26 |
| 25 namespace content { | 27 namespace content { |
| 26 | 28 |
| 27 class ResourceDispatcherHostBrowserTest : public ContentBrowserTest, | 29 class ResourceDispatcherHostBrowserTest : public ContentBrowserTest, |
| 28 public DownloadManager::Observer { | 30 public DownloadManager::Observer { |
| 29 public: | 31 public: |
| 30 ResourceDispatcherHostBrowserTest() : got_downloads_(false) {} | 32 ResourceDispatcherHostBrowserTest() : got_downloads_(false) {} |
| 31 | 33 |
| 32 protected: | 34 protected: |
| 33 virtual void SetUpOnMainThread() OVERRIDE { | 35 virtual void SetUpOnMainThread() OVERRIDE { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 83 |
| 82 bool got_downloads() const { return got_downloads_; } | 84 bool got_downloads() const { return got_downloads_; } |
| 83 | 85 |
| 84 private: | 86 private: |
| 85 bool got_downloads_; | 87 bool got_downloads_; |
| 86 }; | 88 }; |
| 87 | 89 |
| 88 // Test title for content created by javascript window.open(). | 90 // Test title for content created by javascript window.open(). |
| 89 // See http://crbug.com/5988 | 91 // See http://crbug.com/5988 |
| 90 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, DynamicTitle1) { | 92 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, DynamicTitle1) { |
| 91 ASSERT_TRUE(test_server()->Start()); | 93 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 92 | 94 |
| 93 GURL url(test_server()->GetURL("files/dynamic1.html")); | 95 GURL url(embedded_test_server()->GetURL("/dynamic1.html")); |
| 94 string16 title; | 96 string16 title; |
| 95 ASSERT_TRUE(GetPopupTitle(url, &title)); | 97 ASSERT_TRUE(GetPopupTitle(url, &title)); |
| 96 EXPECT_TRUE(StartsWith(title, ASCIIToUTF16("My Popup Title"), true)) | 98 EXPECT_TRUE(StartsWith(title, ASCIIToUTF16("My Popup Title"), true)) |
| 97 << "Actual title: " << title; | 99 << "Actual title: " << title; |
| 98 } | 100 } |
| 99 | 101 |
| 100 // Test title for content created by javascript window.open(). | 102 // Test title for content created by javascript window.open(). |
| 101 // See http://crbug.com/5988 | 103 // See http://crbug.com/5988 |
| 102 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, DynamicTitle2) { | 104 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, DynamicTitle2) { |
| 103 ASSERT_TRUE(test_server()->Start()); | 105 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 104 | 106 |
| 105 GURL url(test_server()->GetURL("files/dynamic2.html")); | 107 GURL url(embedded_test_server()->GetURL("/dynamic2.html")); |
| 106 string16 title; | 108 string16 title; |
| 107 ASSERT_TRUE(GetPopupTitle(url, &title)); | 109 ASSERT_TRUE(GetPopupTitle(url, &title)); |
| 108 EXPECT_TRUE(StartsWith(title, ASCIIToUTF16("My Dynamic Title"), true)) | 110 EXPECT_TRUE(StartsWith(title, ASCIIToUTF16("My Dynamic Title"), true)) |
| 109 << "Actual title: " << title; | 111 << "Actual title: " << title; |
| 110 } | 112 } |
| 111 | 113 |
| 112 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 114 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 113 SniffHTMLWithNoContentType) { | 115 SniffHTMLWithNoContentType) { |
| 114 CheckTitleTest(GetMockURL("content-sniffer-test0.html"), | 116 CheckTitleTest(GetMockURL("content-sniffer-test0.html"), |
| 115 "Content Sniffer Test 0"); | 117 "Content Sniffer Test 0"); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 CheckTitleTest(GetMockURL("content-disposition-empty.html"), "success"); | 151 CheckTitleTest(GetMockURL("content-disposition-empty.html"), "success"); |
| 150 } | 152 } |
| 151 | 153 |
| 152 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 154 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 153 ContentDispositionInline) { | 155 ContentDispositionInline) { |
| 154 CheckTitleTest(GetMockURL("content-disposition-inline.html"), "success"); | 156 CheckTitleTest(GetMockURL("content-disposition-inline.html"), "success"); |
| 155 } | 157 } |
| 156 | 158 |
| 157 // Test for bug #1091358. | 159 // Test for bug #1091358. |
| 158 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, SyncXMLHttpRequest) { | 160 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, SyncXMLHttpRequest) { |
| 159 ASSERT_TRUE(test_server()->Start()); | 161 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 160 NavigateToURL( | 162 NavigateToURL( |
| 161 shell(), test_server()->GetURL("files/sync_xmlhttprequest.html")); | 163 shell(), embedded_test_server()->GetURL("/sync_xmlhttprequest.html")); |
| 162 | 164 |
| 163 // Let's check the XMLHttpRequest ran successfully. | 165 // Let's check the XMLHttpRequest ran successfully. |
| 164 bool success = false; | 166 bool success = false; |
| 165 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 167 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 166 shell()->web_contents(), | 168 shell()->web_contents(), |
| 167 "window.domAutomationController.send(DidSyncRequestSucceed());", | 169 "window.domAutomationController.send(DidSyncRequestSucceed());", |
| 168 &success)); | 170 &success)); |
| 169 EXPECT_TRUE(success); | 171 EXPECT_TRUE(success); |
| 170 } | 172 } |
| 171 | 173 |
| 172 // If this flakes, use http://crbug.com/62776. | 174 // If this flakes, use http://crbug.com/62776. |
| 173 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 175 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 174 SyncXMLHttpRequest_Disallowed) { | 176 SyncXMLHttpRequest_Disallowed) { |
| 175 ASSERT_TRUE(test_server()->Start()); | 177 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 176 NavigateToURL( | 178 NavigateToURL( |
| 177 shell(), | 179 shell(), |
| 178 test_server()->GetURL("files/sync_xmlhttprequest_disallowed.html")); | 180 embedded_test_server()->GetURL("/sync_xmlhttprequest_disallowed.html")); |
| 179 | 181 |
| 180 // Let's check the XMLHttpRequest ran successfully. | 182 // Let's check the XMLHttpRequest ran successfully. |
| 181 bool success = false; | 183 bool success = false; |
| 182 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 184 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 183 shell()->web_contents(), | 185 shell()->web_contents(), |
| 184 "window.domAutomationController.send(DidSucceed());", | 186 "window.domAutomationController.send(DidSucceed());", |
| 185 &success)); | 187 &success)); |
| 186 EXPECT_TRUE(success); | 188 EXPECT_TRUE(success); |
| 187 } | 189 } |
| 188 | 190 |
| 189 // Test for bug #1159553 -- A synchronous xhr (whose content-type is | 191 // Test for bug #1159553 -- A synchronous xhr (whose content-type is |
| 190 // downloadable) would trigger download and hang the renderer process, | 192 // downloadable) would trigger download and hang the renderer process, |
| 191 // if executed while navigating to a new page. | 193 // if executed while navigating to a new page. |
| 192 // If this flakes, use http://crbug.com/56264. | 194 // If this flakes, use http://crbug.com/56264. |
| 193 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 195 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 194 SyncXMLHttpRequest_DuringUnload) { | 196 SyncXMLHttpRequest_DuringUnload) { |
| 195 ASSERT_TRUE(test_server()->Start()); | 197 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 196 BrowserContext::GetDownloadManager( | 198 BrowserContext::GetDownloadManager( |
| 197 shell()->web_contents()->GetBrowserContext())->AddObserver(this); | 199 shell()->web_contents()->GetBrowserContext())->AddObserver(this); |
| 198 | 200 |
| 199 CheckTitleTest( | 201 CheckTitleTest( |
| 200 test_server()->GetURL("files/sync_xmlhttprequest_during_unload.html"), | 202 embedded_test_server()->GetURL("/sync_xmlhttprequest_during_unload.html"), |
| 201 "sync xhr on unload"); | 203 "sync xhr on unload"); |
| 202 | 204 |
| 203 // Navigate to a new page, to dispatch unload event and trigger xhr. | 205 // Navigate to a new page, to dispatch unload event and trigger xhr. |
| 204 // (the bug would make this step hang the renderer). | 206 // (the bug would make this step hang the renderer). |
| 205 CheckTitleTest( | 207 CheckTitleTest( |
| 206 test_server()->GetURL("files/title2.html"), "Title Of Awesomeness"); | 208 embedded_test_server()->GetURL("/title2.html"), "Title Of Awesomeness"); |
| 207 | 209 |
| 208 ASSERT_FALSE(got_downloads()); | 210 ASSERT_FALSE(got_downloads()); |
| 209 } | 211 } |
| 210 | 212 |
| 211 // Tests that onunload is run for cross-site requests. (Bug 1114994) | 213 // Tests that onunload is run for cross-site requests. (Bug 1114994) |
| 212 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 214 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 213 CrossSiteOnunloadCookie) { | 215 CrossSiteOnunloadCookie) { |
| 214 ASSERT_TRUE(test_server()->Start()); | 216 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 215 | 217 |
| 216 GURL url = test_server()->GetURL("files/onunload_cookie.html"); | 218 GURL url = embedded_test_server()->GetURL("/onunload_cookie.html"); |
| 217 CheckTitleTest(url, "set cookie on unload"); | 219 CheckTitleTest(url, "set cookie on unload"); |
| 218 | 220 |
| 219 // Navigate to a new cross-site page, to dispatch unload event and set the | 221 // Navigate to a new cross-site page, to dispatch unload event and set the |
| 220 // cookie. | 222 // cookie. |
| 221 CheckTitleTest(GetMockURL("content-sniffer-test0.html"), | 223 CheckTitleTest(GetMockURL("content-sniffer-test0.html"), |
| 222 "Content Sniffer Test 0"); | 224 "Content Sniffer Test 0"); |
| 223 | 225 |
| 224 // Check that the cookie was set. | 226 // Check that the cookie was set. |
| 225 EXPECT_EQ("onunloadCookie=foo", GetCookies(url)); | 227 EXPECT_EQ("onunloadCookie=foo", GetCookies(url)); |
| 226 } | 228 } |
| 227 | 229 |
| 228 // If this flakes, use http://crbug.com/130404 | 230 // If this flakes, use http://crbug.com/130404 |
| 229 // Tests that onunload is run for cross-site requests to URLs that complete | 231 // Tests that onunload is run for cross-site requests to URLs that complete |
| 230 // without network loads (e.g., about:blank, data URLs). | 232 // without network loads (e.g., about:blank, data URLs). |
| 231 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 233 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 232 DISABLED_CrossSiteImmediateLoadOnunloadCookie) { | 234 DISABLED_CrossSiteImmediateLoadOnunloadCookie) { |
| 233 ASSERT_TRUE(test_server()->Start()); | 235 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 234 | 236 |
| 235 GURL url = test_server()->GetURL("files/onunload_cookie.html"); | 237 GURL url = embedded_test_server()->GetURL("/onunload_cookie.html"); |
| 236 CheckTitleTest(url, "set cookie on unload"); | 238 CheckTitleTest(url, "set cookie on unload"); |
| 237 | 239 |
| 238 // Navigate to a cross-site page that loads immediately without making a | 240 // Navigate to a cross-site page that loads immediately without making a |
| 239 // network request. The unload event should still be run. | 241 // network request. The unload event should still be run. |
| 240 NavigateToURL(shell(), GURL("about:blank")); | 242 NavigateToURL(shell(), GURL("about:blank")); |
| 241 | 243 |
| 242 // Check that the cookie was set. | 244 // Check that the cookie was set. |
| 243 EXPECT_EQ("onunloadCookie=foo", GetCookies(url)); | 245 EXPECT_EQ("onunloadCookie=foo", GetCookies(url)); |
| 244 } | 246 } |
| 245 | 247 |
| 248 namespace { |
| 249 |
| 250 // Handles |request| by serving a redirect response. |
| 251 scoped_ptr<net::test_server::HttpResponse> NoContentResponseHandler( |
| 252 const std::string& path, |
| 253 const net::test_server::HttpRequest& request) { |
| 254 if (!StartsWithASCII(path, request.relative_url, true)) |
| 255 return scoped_ptr<net::test_server::HttpResponse>(NULL); |
| 256 |
| 257 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
| 258 new net::test_server::BasicHttpResponse); |
| 259 http_response->set_code(net::test_server::NO_CONTENT); |
| 260 return http_response.PassAs<net::test_server::HttpResponse>(); |
| 261 } |
| 262 |
| 263 } // namespace |
| 264 |
| 246 // Tests that the unload handler is not run for 204 responses. | 265 // Tests that the unload handler is not run for 204 responses. |
| 247 // If this flakes use http://crbug.com/80596. | 266 // If this flakes use http://crbug.com/80596. |
| 248 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 267 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 249 CrossSiteNoUnloadOn204) { | 268 CrossSiteNoUnloadOn204) { |
| 250 ASSERT_TRUE(test_server()->Start()); | 269 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 251 | 270 |
| 252 // Start with a URL that sets a cookie in its unload handler. | 271 // Start with a URL that sets a cookie in its unload handler. |
| 253 GURL url = test_server()->GetURL("files/onunload_cookie.html"); | 272 GURL url = embedded_test_server()->GetURL("/onunload_cookie.html"); |
| 254 CheckTitleTest(url, "set cookie on unload"); | 273 CheckTitleTest(url, "set cookie on unload"); |
| 255 | 274 |
| 256 // Navigate to a cross-site URL that returns a 204 No Content response. | 275 // Navigate to a cross-site URL that returns a 204 No Content response. |
| 257 NavigateToURL(shell(), test_server()->GetURL("nocontent")); | 276 const char kNoContentPath[] = "/nocontent"; |
| 277 embedded_test_server()->RegisterRequestHandler( |
| 278 base::Bind(&NoContentResponseHandler, kNoContentPath)); |
| 279 NavigateToURL(shell(), embedded_test_server()->GetURL(kNoContentPath)); |
| 258 | 280 |
| 259 // Check that the unload cookie was not set. | 281 // Check that the unload cookie was not set. |
| 260 EXPECT_EQ("", GetCookies(url)); | 282 EXPECT_EQ("", GetCookies(url)); |
| 261 } | 283 } |
| 262 | 284 |
| 263 #if !defined(OS_MACOSX) | 285 #if !defined(OS_MACOSX) |
| 264 // Tests that the onbeforeunload and onunload logic is short-circuited if the | 286 // Tests that the onbeforeunload and onunload logic is short-circuited if the |
| 265 // old renderer is gone. In that case, we don't want to wait for the old | 287 // old renderer is gone. In that case, we don't want to wait for the old |
| 266 // renderer to run the handlers. | 288 // renderer to run the handlers. |
| 267 // We need to disable this on Mac because the crash causes the OS CrashReporter | 289 // We need to disable this on Mac because the crash causes the OS CrashReporter |
| (...skipping 30 matching lines...) Expand all Loading... |
| 298 GURL url = GetTestUrl("", "title2.html"); | 320 GURL url = GetTestUrl("", "title2.html"); |
| 299 CheckTitleTest(url, "Title Of Awesomeness"); | 321 CheckTitleTest(url, "Title Of Awesomeness"); |
| 300 } | 322 } |
| 301 | 323 |
| 302 // Tests that a cross-site navigation to an error page (resulting in the link | 324 // Tests that a cross-site navigation to an error page (resulting in the link |
| 303 // doctor page) still runs the onunload handler and can support navigations | 325 // doctor page) still runs the onunload handler and can support navigations |
| 304 // away from the link doctor page. (Bug 1235537) | 326 // away from the link doctor page. (Bug 1235537) |
| 305 // Flaky: http://crbug.com/100823 | 327 // Flaky: http://crbug.com/100823 |
| 306 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 328 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 307 CrossSiteNavigationErrorPage) { | 329 CrossSiteNavigationErrorPage) { |
| 308 ASSERT_TRUE(test_server()->Start()); | 330 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 309 | 331 |
| 310 GURL url(test_server()->GetURL("files/onunload_cookie.html")); | 332 GURL url(embedded_test_server()->GetURL("/onunload_cookie.html")); |
| 311 CheckTitleTest(url, "set cookie on unload"); | 333 CheckTitleTest(url, "set cookie on unload"); |
| 312 | 334 |
| 313 // Navigate to a new cross-site URL that results in an error. | 335 // Navigate to a new cross-site URL that results in an error. |
| 314 // TODO(creis): If this causes crashes or hangs, it might be for the same | 336 // TODO(creis): If this causes crashes or hangs, it might be for the same |
| 315 // reason as ErrorPageTest::DNSError. See bug 1199491 and | 337 // reason as ErrorPageTest::DNSError. See bug 1199491 and |
| 316 // http://crbug.com/22877. | 338 // http://crbug.com/22877. |
| 317 GURL failed_url = URLRequestFailedJob::GetMockHttpUrl( | 339 GURL failed_url = URLRequestFailedJob::GetMockHttpUrl( |
| 318 net::ERR_NAME_NOT_RESOLVED); | 340 net::ERR_NAME_NOT_RESOLVED); |
| 319 NavigateToURL(shell(), failed_url); | 341 NavigateToURL(shell(), failed_url); |
| 320 | 342 |
| 321 EXPECT_NE(ASCIIToUTF16("set cookie on unload"), | 343 EXPECT_NE(ASCIIToUTF16("set cookie on unload"), |
| 322 shell()->web_contents()->GetTitle()); | 344 shell()->web_contents()->GetTitle()); |
| 323 | 345 |
| 324 // Check that the cookie was set, meaning that the onunload handler ran. | 346 // Check that the cookie was set, meaning that the onunload handler ran. |
| 325 EXPECT_EQ("onunloadCookie=foo", GetCookies(url)); | 347 EXPECT_EQ("onunloadCookie=foo", GetCookies(url)); |
| 326 | 348 |
| 327 // Check that renderer-initiated navigations still work. In a previous bug, | 349 // Check that renderer-initiated navigations still work. In a previous bug, |
| 328 // the ResourceDispatcherHost would think that such navigations were | 350 // the ResourceDispatcherHost would think that such navigations were |
| 329 // cross-site, because we didn't clean up from the previous request. Since | 351 // cross-site, because we didn't clean up from the previous request. Since |
| 330 // WebContentsImpl was in the NORMAL state, it would ignore the attempt to run | 352 // WebContentsImpl was in the NORMAL state, it would ignore the attempt to run |
| 331 // the onunload handler, and the navigation would fail. We can't test by | 353 // the onunload handler, and the navigation would fail. We can't test by |
| 332 // redirecting to javascript:window.location='someURL', since javascript: | 354 // redirecting to javascript:window.location='someURL', since javascript: |
| 333 // URLs are prohibited by policy from interacting with sensitive chrome | 355 // URLs are prohibited by policy from interacting with sensitive chrome |
| 334 // pages of which the error page is one. Instead, use automation to kick | 356 // pages of which the error page is one. Instead, use automation to kick |
| 335 // off the navigation, and wait to see that the tab loads. | 357 // off the navigation, and wait to see that the tab loads. |
| 336 string16 expected_title16(ASCIIToUTF16("Title Of Awesomeness")); | 358 string16 expected_title16(ASCIIToUTF16("Title Of Awesomeness")); |
| 337 TitleWatcher title_watcher(shell()->web_contents(), expected_title16); | 359 TitleWatcher title_watcher(shell()->web_contents(), expected_title16); |
| 338 | 360 |
| 339 bool success; | 361 bool success; |
| 340 GURL test_url(test_server()->GetURL("files/title2.html")); | 362 GURL test_url(embedded_test_server()->GetURL("/title2.html")); |
| 341 std::string redirect_script = "window.location='" + | 363 std::string redirect_script = "window.location='" + |
| 342 test_url.possibly_invalid_spec() + "';" + | 364 test_url.possibly_invalid_spec() + "';" + |
| 343 "window.domAutomationController.send(true);"; | 365 "window.domAutomationController.send(true);"; |
| 344 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 366 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 345 shell()->web_contents(), | 367 shell()->web_contents(), |
| 346 redirect_script, | 368 redirect_script, |
| 347 &success)); | 369 &success)); |
| 348 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | 370 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
| 349 } | 371 } |
| 350 | 372 |
| 351 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 373 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 352 CrossSiteNavigationErrorPage2) { | 374 CrossSiteNavigationErrorPage2) { |
| 353 ASSERT_TRUE(test_server()->Start()); | 375 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 354 | 376 |
| 355 GURL url(test_server()->GetURL("files/title2.html")); | 377 GURL url(embedded_test_server()->GetURL("/title2.html")); |
| 356 CheckTitleTest(url, "Title Of Awesomeness"); | 378 CheckTitleTest(url, "Title Of Awesomeness"); |
| 357 | 379 |
| 358 // Navigate to a new cross-site URL that results in an error. | 380 // Navigate to a new cross-site URL that results in an error. |
| 359 // TODO(creis): If this causes crashes or hangs, it might be for the same | 381 // TODO(creis): If this causes crashes or hangs, it might be for the same |
| 360 // reason as ErrorPageTest::DNSError. See bug 1199491 and | 382 // reason as ErrorPageTest::DNSError. See bug 1199491 and |
| 361 // http://crbug.com/22877. | 383 // http://crbug.com/22877. |
| 362 GURL failed_url = URLRequestFailedJob::GetMockHttpUrl( | 384 GURL failed_url = URLRequestFailedJob::GetMockHttpUrl( |
| 363 net::ERR_NAME_NOT_RESOLVED); | 385 net::ERR_NAME_NOT_RESOLVED); |
| 364 | 386 |
| 365 NavigateToURL(shell(), failed_url); | 387 NavigateToURL(shell(), failed_url); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 392 CrossSiteFailedRequest) { | 414 CrossSiteFailedRequest) { |
| 393 // Visit another URL first to trigger a cross-site navigation. | 415 // Visit another URL first to trigger a cross-site navigation. |
| 394 NavigateToURL(shell(), GetTestUrl("", "simple_page.html")); | 416 NavigateToURL(shell(), GetTestUrl("", "simple_page.html")); |
| 395 | 417 |
| 396 // Visit a URL that fails without calling ResourceDispatcherHost::Read. | 418 // Visit a URL that fails without calling ResourceDispatcherHost::Read. |
| 397 GURL broken_url("chrome://theme"); | 419 GURL broken_url("chrome://theme"); |
| 398 NavigateToURL(shell(), broken_url); | 420 NavigateToURL(shell(), broken_url); |
| 399 } | 421 } |
| 400 | 422 |
| 401 } // namespace content | 423 } // namespace content |
| OLD | NEW |