Index: content/browser/renderer_host/resource_dispatcher_host_browsertest.cc |
diff --git a/content/browser/renderer_host/resource_dispatcher_host_browsertest.cc b/content/browser/renderer_host/resource_dispatcher_host_browsertest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..712097f35c4ccd1c60ba6bb405a66d589562ed3c |
--- /dev/null |
+++ b/content/browser/renderer_host/resource_dispatcher_host_browsertest.cc |
@@ -0,0 +1,70 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "base/utf_string_conversions.h" |
+#include "chrome/browser/ui/browser.h" |
+#include "chrome/browser/ui/browser_list.h" |
+#include "chrome/test/in_process_browser_test.h" |
+#include "chrome/test/ui_test_utils.h" |
+#include "content/common/notification_type.h" |
+#include "content/browser/tab_contents/tab_contents.h" |
+#include "net/test/test_server.h" |
+ |
+class ResourceDispatcherHostBrowserTest : public InProcessBrowserTest { |
+ public: |
+ ResourceDispatcherHostBrowserTest() { |
+ EnableDOMAutomation(); |
+ } |
+ |
+ protected: |
+ RenderViewHost* render_view_host() { |
+ return browser()->GetSelectedTabContents()->render_view_host(); |
+ } |
+}; |
+ |
+// Test title for content created by javascript window.open(). |
+// See bug 5988 |
Paweł Hajdan Jr.
2011/06/04 09:33:55
nit: It's useful to put a URL instead of just a nu
|
+IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, DynamicTitle1) { |
+ ASSERT_TRUE(test_server()->Start()); |
+ |
+ GURL url(test_server()->GetURL("files/dynamic1.html")); |
+ ui_test_utils::NavigateToURL(browser(), url); |
+ |
+ // Create dynamic popup. |
+ EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( |
+ render_view_host(), L"", L"OpenPopup();")); |
+ |
+ std::set<Browser*> excluded; |
+ excluded.insert(browser()); |
+ Browser* popup = ui_test_utils::WaitForBrowserNotInSet(excluded); |
Paweł Hajdan Jr.
2011/06/04 09:33:55
Why not just WaitForNewBrowser? If that'd have a r
|
+ |
+ ASSERT_TRUE(popup); |
+ |
+ string16 title = popup->GetWindowTitleForCurrentTab(); |
+ ASSERT_EQ(string16::size_type(0), |
Paweł Hajdan Jr.
2011/06/04 09:33:55
nit: Please use << to make the actual title a part
|
+ title.find(ASCIIToUTF16("My Popup Title"))); |
+} |
+ |
+// Test title for content created by javascript window.open(). |
+// See bug 5988 |
+IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, DynamicTitle2) { |
+ ASSERT_TRUE(test_server()->Start()); |
+ |
+ GURL url(test_server()->GetURL("files/dynamic2.html")); |
+ ui_test_utils::NavigateToURL(browser(), url); |
+ |
+ // Create dynamic popup. |
+ EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( |
+ render_view_host(), L"", L"OpenPopup();")); |
+ |
+ std::set<Browser*> excluded; |
+ excluded.insert(browser()); |
+ Browser* popup = ui_test_utils::WaitForBrowserNotInSet(excluded); |
+ |
+ ASSERT_TRUE(popup); |
+ |
+ string16 title = popup->GetWindowTitleForCurrentTab(); |
+ ASSERT_EQ(string16::size_type(0), |
+ title.find(ASCIIToUTF16("My Dynamic Title"))); |
+} |