OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_path.h" | 9 #include "base/file_path.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 CheckTitleTest(L"content-disposition-empty.html", L"success", 1); | 72 CheckTitleTest(L"content-disposition-empty.html", L"success", 1); |
73 } | 73 } |
74 | 74 |
75 TEST_F(ResourceDispatcherTest, ContentDispositionInline) { | 75 TEST_F(ResourceDispatcherTest, ContentDispositionInline) { |
76 CheckTitleTest(L"content-disposition-inline.html", L"success", 1); | 76 CheckTitleTest(L"content-disposition-inline.html", L"success", 1); |
77 } | 77 } |
78 | 78 |
79 // Test for bug #1091358. | 79 // Test for bug #1091358. |
80 TEST_F(ResourceDispatcherTest, SyncXMLHttpRequest) { | 80 TEST_F(ResourceDispatcherTest, SyncXMLHttpRequest) { |
81 const wchar_t kDocRoot[] = L"chrome/test/data"; | 81 const wchar_t kDocRoot[] = L"chrome/test/data"; |
82 scoped_refptr<HTTPTestServer> server = | 82 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot)); |
83 HTTPTestServer::CreateServer(kDocRoot, NULL); | |
84 ASSERT_TRUE(NULL != server.get()); | 83 ASSERT_TRUE(NULL != server.get()); |
85 | 84 |
86 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); | 85 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); |
87 ASSERT_TRUE(browser_proxy.get()); | 86 ASSERT_TRUE(browser_proxy.get()); |
88 scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); | 87 scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); |
89 ASSERT_TRUE(tab.get()); | 88 ASSERT_TRUE(tab.get()); |
90 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 89 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
91 tab->NavigateToURL(server->TestServerPage( | 90 tab->NavigateToURL(server->TestServerPage( |
92 "files/sync_xmlhttprequest.html"))); | 91 "files/sync_xmlhttprequest.html"))); |
93 | 92 |
94 // Let's check the XMLHttpRequest ran successfully. | 93 // Let's check the XMLHttpRequest ran successfully. |
95 bool success = false; | 94 bool success = false; |
96 EXPECT_TRUE(tab->ExecuteAndExtractBool(L"", | 95 EXPECT_TRUE(tab->ExecuteAndExtractBool(L"", |
97 L"window.domAutomationController.send(DidSyncRequestSucceed());", | 96 L"window.domAutomationController.send(DidSyncRequestSucceed());", |
98 &success)); | 97 &success)); |
99 EXPECT_TRUE(success); | 98 EXPECT_TRUE(success); |
100 } | 99 } |
101 | 100 |
102 TEST_F(ResourceDispatcherTest, SyncXMLHttpRequest_Disallowed) { | 101 TEST_F(ResourceDispatcherTest, SyncXMLHttpRequest_Disallowed) { |
103 const wchar_t kDocRoot[] = L"chrome/test/data"; | 102 const wchar_t kDocRoot[] = L"chrome/test/data"; |
104 scoped_refptr<HTTPTestServer> server = | 103 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot)); |
105 HTTPTestServer::CreateServer(kDocRoot, NULL); | |
106 ASSERT_TRUE(NULL != server.get()); | 104 ASSERT_TRUE(NULL != server.get()); |
107 | 105 |
108 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); | 106 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); |
109 ASSERT_TRUE(browser_proxy.get()); | 107 ASSERT_TRUE(browser_proxy.get()); |
110 scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); | 108 scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); |
111 ASSERT_TRUE(tab.get()); | 109 ASSERT_TRUE(tab.get()); |
112 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 110 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
113 tab->NavigateToURL(server->TestServerPage( | 111 tab->NavigateToURL(server->TestServerPage( |
114 "files/sync_xmlhttprequest_disallowed.html"))); | 112 "files/sync_xmlhttprequest_disallowed.html"))); |
115 | 113 |
116 // Let's check the XMLHttpRequest ran successfully. | 114 // Let's check the XMLHttpRequest ran successfully. |
117 bool success = false; | 115 bool success = false; |
118 EXPECT_TRUE(tab->ExecuteAndExtractBool(L"", | 116 EXPECT_TRUE(tab->ExecuteAndExtractBool(L"", |
119 L"window.domAutomationController.send(DidSucceed());", | 117 L"window.domAutomationController.send(DidSucceed());", |
120 &success)); | 118 &success)); |
121 EXPECT_TRUE(success); | 119 EXPECT_TRUE(success); |
122 } | 120 } |
123 | 121 |
124 // Test for bug #1159553 -- A synchronous xhr (whose content-type is | 122 // Test for bug #1159553 -- A synchronous xhr (whose content-type is |
125 // downloadable) would trigger download and hang the renderer process, | 123 // downloadable) would trigger download and hang the renderer process, |
126 // if executed while navigating to a new page. | 124 // if executed while navigating to a new page. |
127 TEST_F(ResourceDispatcherTest, SyncXMLHttpRequest_DuringUnload) { | 125 TEST_F(ResourceDispatcherTest, SyncXMLHttpRequest_DuringUnload) { |
128 const wchar_t kDocRoot[] = L"chrome/test/data"; | 126 const wchar_t kDocRoot[] = L"chrome/test/data"; |
129 scoped_refptr<HTTPTestServer> server = | 127 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot)); |
130 HTTPTestServer::CreateServer(kDocRoot, NULL); | |
131 ASSERT_TRUE(NULL != server.get()); | 128 ASSERT_TRUE(NULL != server.get()); |
132 | 129 |
133 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); | 130 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); |
134 ASSERT_TRUE(browser_proxy.get()); | 131 ASSERT_TRUE(browser_proxy.get()); |
135 scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); | 132 scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); |
136 ASSERT_TRUE(tab.get()); | 133 ASSERT_TRUE(tab.get()); |
137 | 134 |
138 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 135 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
139 tab->NavigateToURL(server->TestServerPage( | 136 tab->NavigateToURL(server->TestServerPage( |
140 "files/sync_xmlhttprequest_during_unload.html"))); | 137 "files/sync_xmlhttprequest_during_unload.html"))); |
(...skipping 15 matching lines...) Expand all Loading... |
156 bool shelf_is_visible = false; | 153 bool shelf_is_visible = false; |
157 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 154 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
158 ASSERT_TRUE(browser.get()); | 155 ASSERT_TRUE(browser.get()); |
159 EXPECT_TRUE(browser->IsShelfVisible(&shelf_is_visible)); | 156 EXPECT_TRUE(browser->IsShelfVisible(&shelf_is_visible)); |
160 EXPECT_FALSE(shelf_is_visible); | 157 EXPECT_FALSE(shelf_is_visible); |
161 } | 158 } |
162 | 159 |
163 // Tests that onunload is run for cross-site requests. (Bug 1114994) | 160 // Tests that onunload is run for cross-site requests. (Bug 1114994) |
164 TEST_F(ResourceDispatcherTest, CrossSiteOnunloadCookie) { | 161 TEST_F(ResourceDispatcherTest, CrossSiteOnunloadCookie) { |
165 const wchar_t kDocRoot[] = L"chrome/test/data"; | 162 const wchar_t kDocRoot[] = L"chrome/test/data"; |
166 scoped_refptr<HTTPTestServer> server = | 163 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot)); |
167 HTTPTestServer::CreateServer(kDocRoot, NULL); | |
168 ASSERT_TRUE(NULL != server.get()); | 164 ASSERT_TRUE(NULL != server.get()); |
169 | 165 |
170 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); | 166 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); |
171 ASSERT_TRUE(browser_proxy.get()); | 167 ASSERT_TRUE(browser_proxy.get()); |
172 scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); | 168 scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); |
173 ASSERT_TRUE(tab.get()); | 169 ASSERT_TRUE(tab.get()); |
174 | 170 |
175 GURL url(server->TestServerPage("files/onunload_cookie.html")); | 171 GURL url(server->TestServerPage("files/onunload_cookie.html")); |
176 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(url)); | 172 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(url)); |
177 | 173 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 247 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
252 tab->NavigateToURL(net::FilePathToFileURL(test_file))); | 248 tab->NavigateToURL(net::FilePathToFileURL(test_file))); |
253 EXPECT_EQ(L"Title Of Awesomeness", GetActiveTabTitle()); | 249 EXPECT_EQ(L"Title Of Awesomeness", GetActiveTabTitle()); |
254 } | 250 } |
255 | 251 |
256 // Tests that a cross-site navigation to an error page (resulting in the link | 252 // Tests that a cross-site navigation to an error page (resulting in the link |
257 // doctor page) still runs the onunload handler and can support navigations | 253 // doctor page) still runs the onunload handler and can support navigations |
258 // away from the link doctor page. (Bug 1235537) | 254 // away from the link doctor page. (Bug 1235537) |
259 TEST_F(ResourceDispatcherTest, CrossSiteNavigationErrorPage) { | 255 TEST_F(ResourceDispatcherTest, CrossSiteNavigationErrorPage) { |
260 const wchar_t kDocRoot[] = L"chrome/test/data"; | 256 const wchar_t kDocRoot[] = L"chrome/test/data"; |
261 scoped_refptr<HTTPTestServer> server = | 257 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot)); |
262 HTTPTestServer::CreateServer(kDocRoot, NULL); | |
263 ASSERT_TRUE(NULL != server.get()); | 258 ASSERT_TRUE(NULL != server.get()); |
264 | 259 |
265 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); | 260 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); |
266 ASSERT_TRUE(browser_proxy.get()); | 261 ASSERT_TRUE(browser_proxy.get()); |
267 scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); | 262 scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); |
268 ASSERT_TRUE(tab.get()); | 263 ASSERT_TRUE(tab.get()); |
269 | 264 |
270 GURL url(server->TestServerPage("files/onunload_cookie.html")); | 265 GURL url(server->TestServerPage("files/onunload_cookie.html")); |
271 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(url)); | 266 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(url)); |
272 | 267 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 GURL broken_url("chrome://theme"); | 329 GURL broken_url("chrome://theme"); |
335 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(broken_url)); | 330 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(broken_url)); |
336 | 331 |
337 // Make sure the navigation finishes. | 332 // Make sure the navigation finishes. |
338 std::wstring tab_title; | 333 std::wstring tab_title; |
339 EXPECT_TRUE(tab->GetTabTitle(&tab_title)); | 334 EXPECT_TRUE(tab->GetTabTitle(&tab_title)); |
340 EXPECT_EQ(L"chrome://theme/ is not available", tab_title); | 335 EXPECT_EQ(L"chrome://theme/ is not available", tab_title); |
341 } | 336 } |
342 | 337 |
343 } // namespace | 338 } // namespace |
OLD | NEW |