Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: chrome/browser/renderer_host/test/render_view_host_manager_browsertest.cc

Issue 328017: Second attempt to swap processes on rel=noreferrer, target=blank links.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/renderer/render_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/browser/browser.h" 5 #include "chrome/browser/browser.h"
6 #include "chrome/browser/tab_contents/tab_contents.h"
7 #include "chrome/browser/download/download_manager.h" 6 #include "chrome/browser/download/download_manager.h"
8 #include "chrome/browser/profile.h" 7 #include "chrome/browser/profile.h"
8 #include "chrome/browser/renderer_host/site_instance.h"
9 #include "chrome/browser/tab_contents/tab_contents.h"
9 #include "chrome/common/chrome_paths.h" 10 #include "chrome/common/chrome_paths.h"
10 #include "chrome/common/chrome_switches.h" 11 #include "chrome/common/chrome_switches.h"
11 #include "chrome/common/notification_details.h" 12 #include "chrome/common/notification_details.h"
12 #include "chrome/common/notification_observer.h" 13 #include "chrome/common/notification_observer.h"
13 #include "chrome/common/notification_registrar.h" 14 #include "chrome/common/notification_registrar.h"
14 #include "chrome/common/notification_service.h" 15 #include "chrome/common/notification_service.h"
15 #include "chrome/common/notification_type.h" 16 #include "chrome/common/notification_type.h"
16 #include "chrome/common/extensions/extension_error_reporter.h" 17 #include "chrome/common/extensions/extension_error_reporter.h"
17 #include "chrome/test/in_process_browser_test.h" 18 #include "chrome/test/in_process_browser_test.h"
18 #include "chrome/test/ui_test_utils.h" 19 #include "chrome/test/ui_test_utils.h"
19 #include "net/base/net_util.h" 20 #include "net/base/net_util.h"
20 21
21 class RenderViewHostManagerTest : public InProcessBrowserTest { 22 class RenderViewHostManagerTest : public InProcessBrowserTest {
22 public: 23 public:
23 RenderViewHostManagerTest() { 24 RenderViewHostManagerTest() {
24 EnableDOMAutomation(); 25 EnableDOMAutomation();
25 } 26 }
26 }; 27 };
27 28
29 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer
30 // and target=_blank should create a new SiteInstance.
31 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
32 SwapProcessWithRelNoreferrerAndTargetBlank) {
33 // Start two servers with different sites.
34 const wchar_t kDocRoot[] = L"chrome/test/data";
35 scoped_refptr<HTTPTestServer> http_server =
36 HTTPTestServer::CreateServer(kDocRoot, NULL);
37 scoped_refptr<HTTPSTestServer> https_server =
38 HTTPSTestServer::CreateGoodServer(kDocRoot);
39
40 // Load a page with links that open in a new window.
41 ui_test_utils::NavigateToURL(browser(), http_server->TestServerPageW(
42 L"files/click-noreferrer-links.html"));
43
44 // Get the original SiteInstance for later comparison.
45 scoped_refptr<SiteInstance> orig_site_instance(
46 browser()->GetSelectedTabContents()->GetSiteInstance());
47 EXPECT_TRUE(orig_site_instance != NULL);
48
49 // Test clicking a rel=noreferrer + target=blank link.
50 bool success = false;
51 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
52 browser()->GetSelectedTabContents()->render_view_host(), L"",
53 L"window.domAutomationController.send(clickNoRefTargetBlankLink());",
54 &success));
55 EXPECT_TRUE(success);
56 // Wait for the cross-site transition to finish.
57 ui_test_utils::WaitForLoadStop(
58 &(browser()->GetSelectedTabContents()->controller()));
59
60 // Opens in new tab.
61 EXPECT_EQ(2, browser()->tab_count());
62 EXPECT_EQ(1, browser()->selected_index());
63 EXPECT_EQ(L"Title Of Awesomeness",
64 browser()->GetSelectedTabContents()->GetTitle());
65
66 // Should have a new SiteInstance.
67 scoped_refptr<SiteInstance> noref_blank_site_instance(
68 browser()->GetSelectedTabContents()->GetSiteInstance());
69 EXPECT_NE(orig_site_instance, noref_blank_site_instance);
70 }
71
72 // Test for crbug.com/24447. Following a cross-site link with just
73 // target=_blank should not create a new SiteInstance.
74 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
75 DontSwapProcessWithOnlyTargetBlank) {
76 // Start two servers with different sites.
77 const wchar_t kDocRoot[] = L"chrome/test/data";
78 scoped_refptr<HTTPTestServer> http_server =
79 HTTPTestServer::CreateServer(kDocRoot, NULL);
80 scoped_refptr<HTTPSTestServer> https_server =
81 HTTPSTestServer::CreateGoodServer(kDocRoot);
82
83 // Load a page with links that open in a new window.
84 ui_test_utils::NavigateToURL(browser(), http_server->TestServerPageW(
85 L"files/click-noreferrer-links.html"));
86
87 // Get the original SiteInstance for later comparison.
88 scoped_refptr<SiteInstance> orig_site_instance(
89 browser()->GetSelectedTabContents()->GetSiteInstance());
90 EXPECT_TRUE(orig_site_instance != NULL);
91
92 // Test clicking a target=blank link.
93 bool success = false;
94 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
95 browser()->GetSelectedTabContents()->render_view_host(), L"",
96 L"window.domAutomationController.send(clickTargetBlankLink());",
97 &success));
98 EXPECT_TRUE(success);
99 // Wait for the cross-site transition to finish.
100 ui_test_utils::WaitForLoadStop(
101 &(browser()->GetSelectedTabContents()->controller()));
102
103 // Opens in new tab.
104 EXPECT_EQ(2, browser()->tab_count());
105 EXPECT_EQ(1, browser()->selected_index());
106 EXPECT_EQ(L"Title Of Awesomeness",
107 browser()->GetSelectedTabContents()->GetTitle());
108
109 // Should have the same SiteInstance.
110 scoped_refptr<SiteInstance> blank_site_instance(
111 browser()->GetSelectedTabContents()->GetSiteInstance());
112 EXPECT_EQ(orig_site_instance, blank_site_instance);
113 }
114
115 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer
116 // and no target=_blank should not create a new SiteInstance.
117 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
118 DontSwapProcessWithOnlyRelNoreferrer) {
119 // Start two servers with different sites.
120 const wchar_t kDocRoot[] = L"chrome/test/data";
121 scoped_refptr<HTTPTestServer> http_server =
122 HTTPTestServer::CreateServer(kDocRoot, NULL);
123 scoped_refptr<HTTPSTestServer> https_server =
124 HTTPSTestServer::CreateGoodServer(kDocRoot);
125
126 // Load a page with links that open in a new window.
127 ui_test_utils::NavigateToURL(browser(), http_server->TestServerPageW(
128 L"files/click-noreferrer-links.html"));
129
130 // Get the original SiteInstance for later comparison.
131 scoped_refptr<SiteInstance> orig_site_instance(
132 browser()->GetSelectedTabContents()->GetSiteInstance());
133 EXPECT_TRUE(orig_site_instance != NULL);
134
135 // Test clicking a rel=noreferrer link.
136 bool success = false;
137 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
138 browser()->GetSelectedTabContents()->render_view_host(), L"",
139 L"window.domAutomationController.send(clickNoRefLink());",
140 &success));
141 EXPECT_TRUE(success);
142 // Wait for the cross-site transition to finish.
143 ui_test_utils::WaitForLoadStop(
144 &(browser()->GetSelectedTabContents()->controller()));
145
146 // Opens in same tab.
147 EXPECT_EQ(1, browser()->tab_count());
148 EXPECT_EQ(0, browser()->selected_index());
149 EXPECT_EQ(L"Title Of Awesomeness",
150 browser()->GetSelectedTabContents()->GetTitle());
151
152 // Should have the same SiteInstance.
153 scoped_refptr<SiteInstance> noref_site_instance(
154 browser()->GetSelectedTabContents()->GetSiteInstance());
155 EXPECT_EQ(orig_site_instance, noref_site_instance);
156 }
157
28 // Test for crbug.com/14505. This tests that chrome:// urls are still functional 158 // Test for crbug.com/14505. This tests that chrome:// urls are still functional
29 // after download of a file while viewing another chrome://. 159 // after download of a file while viewing another chrome://.
30 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, 160 IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
31 DISABLED_ChromeURLAfterDownload) { 161 DISABLED_ChromeURLAfterDownload) {
32 GURL downloads_url("chrome://downloads"); 162 GURL downloads_url("chrome://downloads");
33 GURL extensions_url("chrome://extensions"); 163 GURL extensions_url("chrome://extensions");
34 FilePath zip_download; 164 FilePath zip_download;
35 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &zip_download)); 165 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &zip_download));
36 zip_download = zip_download.AppendASCII("zip").AppendASCII("test.zip"); 166 zip_download = zip_download.AppendASCII("zip").AppendASCII("test.zip");
37 GURL zip_url = net::FilePathToFileURL(zip_download); 167 GURL zip_url = net::FilePathToFileURL(zip_download);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 &result)); 232 &result));
103 EXPECT_TRUE(result); 233 EXPECT_TRUE(result);
104 ui_test_utils::NavigateToURL(browser(), zip_url); 234 ui_test_utils::NavigateToURL(browser(), zip_url);
105 235
106 ui_test_utils::WaitForDownloadCount( 236 ui_test_utils::WaitForDownloadCount(
107 browser()->profile()->GetDownloadManager(), 1); 237 browser()->profile()->GetDownloadManager(), 1);
108 238
109 browser()->CloseWindow(); 239 browser()->CloseWindow();
110 BrowserClosedObserver wait_for_close(browser()); 240 BrowserClosedObserver wait_for_close(browser());
111 } 241 }
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/render_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698