| OLD | NEW |
| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 L"files/sync_xmlhttprequest.html")); | 100 L"files/sync_xmlhttprequest.html")); |
| 101 | 101 |
| 102 // Let's check the XMLHttpRequest ran successfully. | 102 // Let's check the XMLHttpRequest ran successfully. |
| 103 bool success = false; | 103 bool success = false; |
| 104 EXPECT_TRUE(tab->ExecuteAndExtractBool(L"", | 104 EXPECT_TRUE(tab->ExecuteAndExtractBool(L"", |
| 105 L"window.domAutomationController.send(DidSyncRequestSucceed());", | 105 L"window.domAutomationController.send(DidSyncRequestSucceed());", |
| 106 &success)); | 106 &success)); |
| 107 EXPECT_TRUE(success); | 107 EXPECT_TRUE(success); |
| 108 } | 108 } |
| 109 | 109 |
| 110 TEST_F(ResourceDispatcherTest, SyncXMLHttpRequest_Disallowed) { |
| 111 const wchar_t kDocRoot[] = L"chrome/test/data"; |
| 112 scoped_refptr<HTTPTestServer> server = |
| 113 HTTPTestServer::CreateServer(kDocRoot, NULL); |
| 114 ASSERT_TRUE(NULL != server.get()); |
| 115 |
| 116 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); |
| 117 EXPECT_TRUE(browser_proxy.get()); |
| 118 scoped_ptr<TabProxy> tab(browser_proxy->GetActiveTab()); |
| 119 tab->NavigateToURL(server->TestServerPageW( |
| 120 L"files/sync_xmlhttprequest_disallowed.html")); |
| 121 |
| 122 // Let's check the XMLHttpRequest ran successfully. |
| 123 bool success = false; |
| 124 EXPECT_TRUE(tab->ExecuteAndExtractBool(L"", |
| 125 L"window.domAutomationController.send(DidSucceed());", |
| 126 &success)); |
| 127 EXPECT_TRUE(success); |
| 128 } |
| 129 |
| 110 // Test for bug #1159553 -- A synchronous xhr (whose content-type is | 130 // Test for bug #1159553 -- A synchronous xhr (whose content-type is |
| 111 // downloadable) would trigger download and hang the renderer process, | 131 // downloadable) would trigger download and hang the renderer process, |
| 112 // if executed while navigating to a new page. | 132 // if executed while navigating to a new page. |
| 113 TEST_F(ResourceDispatcherTest, SyncXMLHttpRequestDuringUnload) { | 133 TEST_F(ResourceDispatcherTest, SyncXMLHttpRequest_DuringUnload) { |
| 114 const wchar_t kDocRoot[] = L"chrome/test/data"; | 134 const wchar_t kDocRoot[] = L"chrome/test/data"; |
| 115 scoped_refptr<HTTPTestServer> server = | 135 scoped_refptr<HTTPTestServer> server = |
| 116 HTTPTestServer::CreateServer(kDocRoot, NULL); | 136 HTTPTestServer::CreateServer(kDocRoot, NULL); |
| 117 ASSERT_TRUE(NULL != server.get()); | 137 ASSERT_TRUE(NULL != server.get()); |
| 118 | 138 |
| 119 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); | 139 scoped_ptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); |
| 120 EXPECT_TRUE(browser_proxy.get()); | 140 EXPECT_TRUE(browser_proxy.get()); |
| 121 scoped_ptr<TabProxy> tab(browser_proxy->GetActiveTab()); | 141 scoped_ptr<TabProxy> tab(browser_proxy->GetActiveTab()); |
| 122 | 142 |
| 123 tab->NavigateToURL( | 143 tab->NavigateToURL( |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 // the onunload handler, and the navigation would fail. | 289 // the onunload handler, and the navigation would fail. |
| 270 // (Test by redirecting to javascript:window.location='someURL'.) | 290 // (Test by redirecting to javascript:window.location='someURL'.) |
| 271 GURL test_url(server->TestServerPageW(L"files/title2.html")); | 291 GURL test_url(server->TestServerPageW(L"files/title2.html")); |
| 272 std::wstring redirect_url = L"javascript:window.location='" + | 292 std::wstring redirect_url = L"javascript:window.location='" + |
| 273 ASCIIToWide(test_url.possibly_invalid_spec()) + L"'"; | 293 ASCIIToWide(test_url.possibly_invalid_spec()) + L"'"; |
| 274 tab->NavigateToURLAsync(GURL(redirect_url)); | 294 tab->NavigateToURLAsync(GURL(redirect_url)); |
| 275 Sleep(sleep_timeout_ms()); // Wait for JavaScript redirect to happen. | 295 Sleep(sleep_timeout_ms()); // Wait for JavaScript redirect to happen. |
| 276 EXPECT_TRUE(tab->GetTabTitle(&tab_title)); | 296 EXPECT_TRUE(tab->GetTabTitle(&tab_title)); |
| 277 EXPECT_EQ(L"Title Of Awesomeness", tab_title); | 297 EXPECT_EQ(L"Title Of Awesomeness", tab_title); |
| 278 } | 298 } |
| OLD | NEW |