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

Side by Side Diff: chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc

Issue 17030: Revert 7508.7509 and 7510 (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <sstream> 5 #include <sstream>
6 #include <string> 6 #include <string>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 CheckTitleTest(L"content-disposition-empty.html", L"success"); 82 CheckTitleTest(L"content-disposition-empty.html", L"success");
83 } 83 }
84 84
85 TEST_F(ResourceDispatcherTest, ContentDispositionInline) { 85 TEST_F(ResourceDispatcherTest, ContentDispositionInline) {
86 CheckTitleTest(L"content-disposition-inline.html", L"success"); 86 CheckTitleTest(L"content-disposition-inline.html", L"success");
87 } 87 }
88 88
89 // Test for bug #1091358. 89 // Test for bug #1091358.
90 TEST_F(ResourceDispatcherTest, SyncXMLHttpRequest) { 90 TEST_F(ResourceDispatcherTest, SyncXMLHttpRequest) {
91 const wchar_t kDocRoot[] = L"chrome/test/data"; 91 const wchar_t kDocRoot[] = L"chrome/test/data";
92 scoped_refptr<HTTPTestServer> server = 92 TestServer server(kDocRoot);
93 HTTPTestServer::CreateServer(kDocRoot);
94 ASSERT_TRUE(NULL != server.get());
95 93
96 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); 94 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
97 EXPECT_TRUE(browser_proxy.get()); 95 EXPECT_TRUE(browser_proxy.get());
98 scoped_ptr<TabProxy> tab(browser_proxy->GetActiveTab()); 96 scoped_ptr<TabProxy> tab(browser_proxy->GetActiveTab());
99 tab->NavigateToURL(server->TestServerPageW( 97 tab->NavigateToURL(server.TestServerPageW(L"files/sync_xmlhttprequest.html"));
100 L"files/sync_xmlhttprequest.html"));
101 98
102 // Let's check the XMLHttpRequest ran successfully. 99 // Let's check the XMLHttpRequest ran successfully.
103 bool success = false; 100 bool success = false;
104 EXPECT_TRUE(tab->ExecuteAndExtractBool(L"", 101 EXPECT_TRUE(tab->ExecuteAndExtractBool(L"",
105 L"window.domAutomationController.send(DidSyncRequestSucceed());", 102 L"window.domAutomationController.send(DidSyncRequestSucceed());",
106 &success)); 103 &success));
107 EXPECT_TRUE(success); 104 EXPECT_TRUE(success);
108 } 105 }
109 106
110 // Test for bug #1159553 -- A synchronous xhr (whose content-type is 107 // Test for bug #1159553 -- A synchronous xhr (whose content-type is
111 // downloadable) would trigger download and hang the renderer process, 108 // downloadable) would trigger download and hang the renderer process,
112 // if executed while navigating to a new page. 109 // if executed while navigating to a new page.
113 TEST_F(ResourceDispatcherTest, SyncXMLHttpRequestDuringUnload) { 110 TEST_F(ResourceDispatcherTest, SyncXMLHttpRequestDuringUnload) {
114 const wchar_t kDocRoot[] = L"chrome/test/data"; 111 const wchar_t kDocRoot[] = L"chrome/test/data";
115 scoped_refptr<HTTPTestServer> server = 112 TestServer server(kDocRoot);
116 HTTPTestServer::CreateServer(kDocRoot);
117 ASSERT_TRUE(NULL != server.get());
118 113
119 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); 114 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
120 EXPECT_TRUE(browser_proxy.get()); 115 EXPECT_TRUE(browser_proxy.get());
121 scoped_ptr<TabProxy> tab(browser_proxy->GetActiveTab()); 116 scoped_ptr<TabProxy> tab(browser_proxy->GetActiveTab());
122 117
123 tab->NavigateToURL( 118 tab->NavigateToURL(
124 server->TestServerPageW(L"files/sync_xmlhttprequest_during_unload.html")); 119 server.TestServerPageW(L"files/sync_xmlhttprequest_during_unload.html"));
125 120
126 // Confirm that the page has loaded (since it changes its title during load). 121 // Confirm that the page has loaded (since it changes its title during load).
127 std::wstring tab_title; 122 std::wstring tab_title;
128 EXPECT_TRUE(tab->GetTabTitle(&tab_title)); 123 EXPECT_TRUE(tab->GetTabTitle(&tab_title));
129 EXPECT_EQ(L"sync xhr on unload", tab_title); 124 EXPECT_EQ(L"sync xhr on unload", tab_title);
130 125
131 // Navigate to a new page, to dispatch unload event and trigger xhr. 126 // Navigate to a new page, to dispatch unload event and trigger xhr.
132 // (the bug would make this step hang the renderer). 127 // (the bug would make this step hang the renderer).
133 bool timed_out = false; 128 bool timed_out = false;
134 tab->NavigateToURLWithTimeout(server->TestServerPageW(L"files/title2.html"), 129 tab->NavigateToURLWithTimeout(server.TestServerPageW(L"files/title2.html"),
135 kWaitForActionMaxMsec, 130 kWaitForActionMaxMsec,
136 &timed_out); 131 &timed_out);
137 EXPECT_FALSE(timed_out); 132 EXPECT_FALSE(timed_out);
138 133
139 // Check that the new page got loaded, and that no download was triggered. 134 // Check that the new page got loaded, and that no download was triggered.
140 bool shelf_is_visible = false; 135 bool shelf_is_visible = false;
141 EXPECT_TRUE(tab->GetTabTitle(&tab_title)); 136 EXPECT_TRUE(tab->GetTabTitle(&tab_title));
142 EXPECT_TRUE(tab->IsShelfVisible(&shelf_is_visible)); 137 EXPECT_TRUE(tab->IsShelfVisible(&shelf_is_visible));
143 EXPECT_EQ(L"Title Of Awesomeness", tab_title); 138 EXPECT_EQ(L"Title Of Awesomeness", tab_title);
144 EXPECT_FALSE(shelf_is_visible); 139 EXPECT_FALSE(shelf_is_visible);
145 } 140 }
146 141
147 // Tests that onunload is run for cross-site requests. (Bug 1114994) 142 // Tests that onunload is run for cross-site requests. (Bug 1114994)
148 TEST_F(ResourceDispatcherTest, CrossSiteOnunloadCookie) { 143 TEST_F(ResourceDispatcherTest, CrossSiteOnunloadCookie) {
149 const wchar_t kDocRoot[] = L"chrome/test/data"; 144 const wchar_t kDocRoot[] = L"chrome/test/data";
150 scoped_refptr<HTTPTestServer> server = 145 TestServer server(kDocRoot);
151 HTTPTestServer::CreateServer(kDocRoot);
152 ASSERT_TRUE(NULL != server.get());
153 146
154 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); 147 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
155 EXPECT_TRUE(browser_proxy.get()); 148 EXPECT_TRUE(browser_proxy.get());
156 scoped_ptr<TabProxy> tab(browser_proxy->GetActiveTab()); 149 scoped_ptr<TabProxy> tab(browser_proxy->GetActiveTab());
157 150
158 GURL url(server->TestServerPageW(L"files/onunload_cookie.html")); 151 GURL url(server.TestServerPageW(L"files/onunload_cookie.html"));
159 tab->NavigateToURL(url); 152 tab->NavigateToURL(url);
160 153
161 // Confirm that the page has loaded (since it changes its title during load). 154 // Confirm that the page has loaded (since it changes its title during load).
162 std::wstring tab_title; 155 std::wstring tab_title;
163 EXPECT_TRUE(tab->GetTabTitle(&tab_title)); 156 EXPECT_TRUE(tab->GetTabTitle(&tab_title));
164 EXPECT_EQ(L"set cookie on unload", tab_title); 157 EXPECT_EQ(L"set cookie on unload", tab_title);
165 158
166 // Navigate to a new cross-site page, to dispatch unload event and set the 159 // Navigate to a new cross-site page, to dispatch unload event and set the
167 // cookie. 160 // cookie.
168 CheckTitleTest(L"content-sniffer-test0.html", 161 CheckTitleTest(L"content-sniffer-test0.html",
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 &timed_out); 212 &timed_out);
220 EXPECT_FALSE(timed_out); 213 EXPECT_FALSE(timed_out);
221 EXPECT_EQ(L"Title Of Awesomeness", GetActiveTabTitle()); 214 EXPECT_EQ(L"Title Of Awesomeness", GetActiveTabTitle());
222 } 215 }
223 216
224 // Tests that a cross-site navigation to an error page (resulting in the link 217 // Tests that a cross-site navigation to an error page (resulting in the link
225 // doctor page) still runs the onunload handler and can support navigations 218 // doctor page) still runs the onunload handler and can support navigations
226 // away from the link doctor page. (Bug 1235537) 219 // away from the link doctor page. (Bug 1235537)
227 TEST_F(ResourceDispatcherTest, CrossSiteNavigationErrorPage) { 220 TEST_F(ResourceDispatcherTest, CrossSiteNavigationErrorPage) {
228 const wchar_t kDocRoot[] = L"chrome/test/data"; 221 const wchar_t kDocRoot[] = L"chrome/test/data";
229 scoped_refptr<HTTPTestServer> server = 222 TestServer server(kDocRoot);
230 HTTPTestServer::CreateServer(kDocRoot);
231 ASSERT_TRUE(NULL != server.get());
232 223
233 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); 224 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0));
234 EXPECT_TRUE(browser_proxy.get()); 225 EXPECT_TRUE(browser_proxy.get());
235 scoped_ptr<TabProxy> tab(browser_proxy->GetActiveTab()); 226 scoped_ptr<TabProxy> tab(browser_proxy->GetActiveTab());
236 227
237 GURL url(server->TestServerPageW(L"files/onunload_cookie.html")); 228 GURL url(server.TestServerPageW(L"files/onunload_cookie.html"));
238 tab->NavigateToURL(url); 229 tab->NavigateToURL(url);
239 230
240 // Confirm that the page has loaded (since it changes its title during load). 231 // Confirm that the page has loaded (since it changes its title during load).
241 std::wstring tab_title; 232 std::wstring tab_title;
242 EXPECT_TRUE(tab->GetTabTitle(&tab_title)); 233 EXPECT_TRUE(tab->GetTabTitle(&tab_title));
243 EXPECT_EQ(L"set cookie on unload", tab_title); 234 EXPECT_EQ(L"set cookie on unload", tab_title);
244 235
245 // Navigate to a new cross-site URL that results in an error page. We must 236 // Navigate to a new cross-site URL that results in an error page. We must
246 // wait for the error page to update the title. 237 // wait for the error page to update the title.
247 // TODO(creis): If this causes crashes or hangs, it might be for the same 238 // TODO(creis): If this causes crashes or hangs, it might be for the same
(...skipping 13 matching lines...) Expand all
261 EXPECT_TRUE(tab->GetCookieByName(url, "onunloadCookie", &value_result)); 252 EXPECT_TRUE(tab->GetCookieByName(url, "onunloadCookie", &value_result));
262 EXPECT_FALSE(value_result.empty()); 253 EXPECT_FALSE(value_result.empty());
263 EXPECT_STREQ("foo", value_result.c_str()); 254 EXPECT_STREQ("foo", value_result.c_str());
264 255
265 // Check that renderer-initiated navigations still work. In a previous bug, 256 // Check that renderer-initiated navigations still work. In a previous bug,
266 // the ResourceDispatcherHost would think that such navigations were 257 // the ResourceDispatcherHost would think that such navigations were
267 // cross-site, because we didn't clean up from the previous request. Since 258 // cross-site, because we didn't clean up from the previous request. Since
268 // WebContents was in the NORMAL state, it would ignore the attempt to run 259 // WebContents was in the NORMAL state, it would ignore the attempt to run
269 // the onunload handler, and the navigation would fail. 260 // the onunload handler, and the navigation would fail.
270 // (Test by redirecting to javascript:window.location='someURL'.) 261 // (Test by redirecting to javascript:window.location='someURL'.)
271 GURL test_url(server->TestServerPageW(L"files/title2.html")); 262 GURL test_url(server.TestServerPageW(L"files/title2.html"));
272 std::wstring redirect_url = L"javascript:window.location='" + 263 std::wstring redirect_url = L"javascript:window.location='" +
273 ASCIIToWide(test_url.possibly_invalid_spec()) + L"'"; 264 ASCIIToWide(test_url.possibly_invalid_spec()) + L"'";
274 tab->NavigateToURLAsync(GURL(redirect_url)); 265 tab->NavigateToURLAsync(GURL(redirect_url));
275 Sleep(kWaitForActionMsec); // Wait for JavaScript redirect to happen. 266 Sleep(kWaitForActionMsec); // Wait for JavaScript redirect to happen.
276 EXPECT_TRUE(tab->GetTabTitle(&tab_title)); 267 EXPECT_TRUE(tab->GetTabTitle(&tab_title));
277 EXPECT_EQ(L"Title Of Awesomeness", tab_title); 268 EXPECT_EQ(L"Title Of Awesomeness", tab_title);
278 } 269 }
279 270
OLDNEW
« no previous file with comments | « chrome/browser/printing/printing_layout_uitest.cc ('k') | chrome/browser/session_history_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698