| 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 "content/public/browser/resource_dispatcher_host.h" | 5 #include "content/public/browser/resource_dispatcher_host.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 // Navigate to a new cross-site page, to dispatch unload event and set the | 252 // Navigate to a new cross-site page, to dispatch unload event and set the |
| 253 // cookie. | 253 // cookie. |
| 254 CheckTitleTest( | 254 CheckTitleTest( |
| 255 net::URLRequestMockHTTPJob::GetMockUrl("content-sniffer-test0.html"), | 255 net::URLRequestMockHTTPJob::GetMockUrl("content-sniffer-test0.html"), |
| 256 "Content Sniffer Test 0"); | 256 "Content Sniffer Test 0"); |
| 257 | 257 |
| 258 // Check that the cookie was set. | 258 // Check that the cookie was set. |
| 259 EXPECT_EQ("onunloadCookie=foo", GetCookies(url)); | 259 EXPECT_EQ("onunloadCookie=foo", GetCookies(url)); |
| 260 } | 260 } |
| 261 | 261 |
| 262 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 263 CrossSiteOnunloadCookieInFrame) { |
| 264 ASSERT_TRUE(embedded_test_server()->Start()); |
| 265 |
| 266 CheckTitleTest( |
| 267 embedded_test_server()->GetURL("/onunload_cookie_wrapper.html"), |
| 268 "set cookie on unload"); |
| 269 |
| 270 // Navigate to a new cross-site page, to dispatch unload event and set the |
| 271 // cookie. |
| 272 CheckTitleTest( |
| 273 net::URLRequestMockHTTPJob::GetMockUrl("content-sniffer-test0.html"), |
| 274 "Content Sniffer Test 0"); |
| 275 |
| 276 // Currently, subframe unloads happen after the IPC filter for swapped out |
| 277 // renderers is installed, so we won't see the cookie set... |
| 278 EXPECT_EQ( |
| 279 "", GetCookies(embedded_test_server()->GetURL("/onunload_cookie.html"))); |
| 280 } |
| 281 |
| 262 // If this flakes, use http://crbug.com/130404 | 282 // If this flakes, use http://crbug.com/130404 |
| 263 // Tests that onunload is run for cross-site requests to URLs that complete | 283 // Tests that onunload is run for cross-site requests to URLs that complete |
| 264 // without network loads (e.g., about:blank, data URLs). | 284 // without network loads (e.g., about:blank, data URLs). |
| 265 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 285 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 266 DISABLED_CrossSiteImmediateLoadOnunloadCookie) { | 286 DISABLED_CrossSiteImmediateLoadOnunloadCookie) { |
| 267 ASSERT_TRUE(embedded_test_server()->Start()); | 287 ASSERT_TRUE(embedded_test_server()->Start()); |
| 268 | 288 |
| 269 GURL url = embedded_test_server()->GetURL("/onunload_cookie.html"); | 289 GURL url = embedded_test_server()->GetURL("/onunload_cookie.html"); |
| 270 CheckTitleTest(url, "set cookie on unload"); | 290 CheckTitleTest(url, "set cookie on unload"); |
| 271 | 291 |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 | 769 |
| 750 // Reload with Lo-Fi disabled. | 770 // Reload with Lo-Fi disabled. |
| 751 Reset(false); | 771 Reset(false); |
| 752 TestNavigationObserver tab_observer(shell()->web_contents(), 1); | 772 TestNavigationObserver tab_observer(shell()->web_contents(), 1); |
| 753 shell()->web_contents()->GetController().ReloadDisableLoFi(true); | 773 shell()->web_contents()->GetController().ReloadDisableLoFi(true); |
| 754 tab_observer.Wait(); | 774 tab_observer.Wait(); |
| 755 CheckResourcesRequested(false); | 775 CheckResourcesRequested(false); |
| 756 } | 776 } |
| 757 | 777 |
| 758 } // namespace content | 778 } // namespace content |
| OLD | NEW |