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

Unified Diff: content/browser/renderer_host/resource_dispatcher_host_uitest.cc

Issue 7080049: Tests for bug 5988. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/dynamic2.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c3d1d173f5de058d911ed308a838804f86d29833 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"
#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 dynamical 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 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 dynamical popup.
brettw 2011/06/01 01:58:57 dynamical -> dynamic
+ 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
« no previous file with comments | « chrome/test/data/dynamic2.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698