Index: content/browser/renderer_host/resource_dispatcher_host_uitest.cc |
diff --git a/content/browser/renderer_host/resource_dispatcher_host_uitest.cc b/content/browser/renderer_host/resource_dispatcher_host_uitest.cc |
index 25dcc0fca020dc5a72af6adf1e978777c235c61e..d0edbb44dc91dc81c86ff2abb3ac63183afd6fd3 100644 |
--- a/content/browser/renderer_host/resource_dispatcher_host_uitest.cc |
+++ b/content/browser/renderer_host/resource_dispatcher_host_uitest.cc |
@@ -9,14 +9,17 @@ |
#include "base/file_path.h" |
#include "base/path_service.h" |
#include "base/string_util.h" |
+#include "base/utf_string_conversions.h" |
#include "base/test/test_timeouts.h" |
#include "chrome/browser/net/url_request_failed_dns_job.h" |
#include "chrome/browser/net/url_request_mock_http_job.h" |
#include "chrome/test/automation/browser_proxy.h" |
#include "chrome/test/automation/tab_proxy.h" |
+#include "chrome/test/automation/window_proxy.h" |
#include "chrome/test/ui/ui_test.h" |
#include "content/common/test_url_constants.h" |
#include "content/common/url_constants.h" |
+#include "chrome/test/ui_test_utils.h" |
Paweł Hajdan Jr.
2011/06/01 07:23:44
nit: Is this used?
|
#include "net/base/net_util.h" |
#include "net/test/test_server.h" |
@@ -398,4 +401,88 @@ TEST_F(ResourceDispatcherTest, CrossSiteFailedRequest) { |
EXPECT_EQ(L"chrome://theme/ is not available", tab_title); |
} |
+// Test title for content dynamically created by javascript. |
+// See bug 5988 |
+TEST_F(ResourceDispatcherTest, DynamicTitle1) { |
+ dom_automation_enabled_ = true; |
+ |
+ net::TestServer test_server(net::TestServer::TYPE_HTTP, |
+ FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
+ ASSERT_TRUE(test_server.Start()); |
+ |
+ scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); |
+ ASSERT_TRUE(browser_proxy.get()); |
+ scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); |
+ ASSERT_TRUE(tab.get()); |
+ |
+ GURL url(test_server.GetURL("files/dynamic1.html")); |
+ ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(url)); |
+ |
+ // Make sure the navigation finishes. |
+ std::wstring tab_title; |
+ EXPECT_TRUE(tab->GetTabTitle(&tab_title)); |
+ |
+ // Create dynamic popup. |
+ std::wstring jscript = |
+ L"OpenPopup(); window.domAutomationController.send('string');"; |
+ std::wstring value; |
+ ASSERT_TRUE(tab->ExecuteAndExtractString(L"", jscript, &value)); |
+ |
+ scoped_refptr<BrowserProxy> browser_proxy2(automation()->GetBrowserWindow(1)); |
+ ASSERT_TRUE(browser_proxy2.get()); |
+ scoped_refptr<WindowProxy> window2(browser_proxy2->GetWindow()); |
Paweł Hajdan Jr.
2011/06/01 07:23:44
WindowProxy are discouraged, do you really need it
|
+ ASSERT_TRUE(window2.get()); |
+ |
+ base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms()); |
Paweł Hajdan Jr.
2011/06/01 07:23:44
Are you trying to wait for the load to finish or f
|
+ |
+ string16 tab_title2; |
+ EXPECT_TRUE(window2->GetWindowTitle(&tab_title2)); |
+ |
+ // tab_title3 should start with 'My Dynamic Title' |
+ ASSERT_EQ(string16::size_type(0), |
+ tab_title2.find(ASCIIToUTF16("My Popup Title"))); |
+} |
+ |
+// Test title for content dynamically created by javascript. |
+// See Bug 5988 |
+TEST_F(ResourceDispatcherTest, DynamicTitle2) { |
+ dom_automation_enabled_ = true; |
+ |
+ net::TestServer test_server(net::TestServer::TYPE_HTTP, |
+ FilePath(FILE_PATH_LITERAL("chrome/test/data"))); |
+ ASSERT_TRUE(test_server.Start()); |
+ |
+ scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); |
+ ASSERT_TRUE(browser_proxy.get()); |
+ scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); |
+ ASSERT_TRUE(tab.get()); |
+ |
+ GURL url(test_server.GetURL("files/dynamic2.html")); |
+ ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(url)); |
+ |
+ // Make sure the navigation finishes. |
+ std::wstring tab_title; |
+ EXPECT_TRUE(tab->GetTabTitle(&tab_title)); |
+ |
+ // Create dynamic popup. |
+ std::wstring jscript = |
+ L"OpenPopup(); window.domAutomationController.send('string');"; |
+ std::wstring value; |
+ ASSERT_TRUE(tab->ExecuteAndExtractString(L"", jscript, &value)); |
+ |
+ scoped_refptr<BrowserProxy> browser_proxy2(automation()->GetBrowserWindow(1)); |
+ ASSERT_TRUE(browser_proxy2.get()); |
+ scoped_refptr<WindowProxy> window2(browser_proxy2->GetWindow()); |
+ ASSERT_TRUE(window2.get()); |
+ |
+ base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms()); |
+ |
+ string16 tab_title2; |
+ EXPECT_TRUE(window2->GetWindowTitle(&tab_title2)); |
+ |
+ // tab_title3 should start with 'My Dynamic Title' |
+ ASSERT_EQ(string16::size_type(0), |
+ tab_title2.find(ASCIIToUTF16("My Dynamic Title"))); |
+} |
+ |
} // namespace |