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

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

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