Chromium Code Reviews| 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..8acd4299cfd3e5f6f3e6932fcdd1c2f2dd5ebfc2 |
| --- /dev/null |
| +++ b/content/browser/renderer_host/resource_dispatcher_host_browsertest.cc |
| @@ -0,0 +1,76 @@ |
| +// 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/string_util.h" |
| +#include "base/utf_string_conversions.h" |
| +#include "chrome/browser/ui/browser.h" |
| +#include "chrome/browser/ui/browser_list.h" |
|
Paweł Hajdan Jr.
2011/06/07 09:46:18
nit: Is this #include needed?
shinyak (Google)
2011/06/07 13:28:48
Done.
|
| +#include "chrome/test/in_process_browser_test.h" |
| +#include "chrome/test/ui_test_utils.h" |
| +#include "content/browser/tab_contents/tab_contents.h" |
| +#include "content/common/notification_type.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(); |
| + } |
| + |
| + bool GetPopupTitle(const GURL& url, string16* title); |
| +}; |
| + |
| +bool ResourceDispatcherHostBrowserTest::GetPopupTitle(const GURL& url, |
| + string16* title) { |
| + ui_test_utils::NavigateToURL(browser(), url); |
| + |
| + ui_test_utils::WindowedNotificationObserver observer( |
| + NotificationType::BROWSER_WINDOW_READY, |
| + NotificationService::AllSources()); |
| + |
| + // Create dynamic popup. |
| + if (!ui_test_utils::ExecuteJavaScript( |
| + render_view_host(), L"", L"OpenPopup();")) |
| + return false; |
| + |
| + observer.Wait(); |
| + |
| + std::set<Browser*> excluded; |
| + excluded.insert(browser()); |
| + Browser* popup = ui_test_utils::GetBrowserNotInSet(excluded); |
| + if (!popup) |
| + return false; |
| + |
| + *title = popup->GetWindowTitleForCurrentTab(); |
| + return true; |
| +} |
| + |
| +// Test title for content created by javascript window.open(). |
| +// See http://crbug.com/5988 |
| +IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, DynamicTitle1) { |
| + ASSERT_TRUE(test_server()->Start()); |
| + |
| + GURL url(test_server()->GetURL("files/dynamic1.html")); |
| + string16 title; |
| + ASSERT_TRUE(GetPopupTitle(url, &title)); |
| + EXPECT_TRUE(StartsWith(title, ASCIIToUTF16("My Popup Title"), false)) |
|
Paweł Hajdan Jr.
2011/06/07 09:46:18
nit: Are you sure you want a case-insensitive comp
shinyak (Google)
2011/06/07 13:28:48
Done.
|
| + << "Actual title: " << title; |
| +} |
| + |
| +// Test title for content created by javascript window.open(). |
| +// See http://crbug.com/5988 |
| +IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, DynamicTitle2) { |
| + ASSERT_TRUE(test_server()->Start()); |
| + |
| + GURL url(test_server()->GetURL("files/dynamic2.html")); |
| + string16 title; |
| + ASSERT_TRUE(GetPopupTitle(url, &title)); |
| + EXPECT_TRUE(StartsWith(title, ASCIIToUTF16("My Dynamic Title"), false)) |
| + << "Actual title: " << title; |
| +} |