Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/utf_string_conversions.h" | |
| 6 #include "chrome/browser/ui/browser.h" | |
| 7 #include "chrome/browser/ui/browser_list.h" | |
| 8 #include "chrome/test/in_process_browser_test.h" | |
| 9 #include "chrome/test/ui_test_utils.h" | |
| 10 #include "content/common/notification_type.h" | |
| 11 #include "content/browser/tab_contents/tab_contents.h" | |
| 12 #include "net/test/test_server.h" | |
| 13 | |
| 14 class ResourceDispatcherHostBrowserTest : public InProcessBrowserTest { | |
| 15 public: | |
| 16 ResourceDispatcherHostBrowserTest() { | |
| 17 EnableDOMAutomation(); | |
| 18 } | |
| 19 | |
| 20 protected: | |
| 21 RenderViewHost* render_view_host() { | |
| 22 return browser()->GetSelectedTabContents()->render_view_host(); | |
| 23 } | |
| 24 | |
| 25 string16 GetPopupTitle(GURL url); | |
| 26 }; | |
| 27 | |
| 28 string16 ResourceDispatcherHostBrowserTest::GetPopupTitle(GURL url) { | |
|
Paweł Hajdan Jr.
2011/06/07 08:28:55
nit: Why not const GURL& url?
shinyak (Google)
2011/06/07 08:54:14
Done.
| |
| 29 ui_test_utils::NavigateToURL(browser(), url); | |
| 30 | |
| 31 ui_test_utils::WindowedNotificationObserver observer( | |
| 32 NotificationType::BROWSER_WINDOW_READY, | |
| 33 NotificationService::AllSources()); | |
| 34 | |
| 35 // Create dynamic popup. | |
| 36 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( | |
|
Paweł Hajdan Jr.
2011/06/07 08:28:55
When this fails, observer.Wait() below will hang.
shinyak (Google)
2011/06/07 08:54:14
Done.
| |
| 37 render_view_host(), L"", L"OpenPopup();")); | |
| 38 | |
| 39 observer.Wait(); | |
| 40 | |
| 41 std::set<Browser*> excluded; | |
| 42 excluded.insert(browser()); | |
| 43 Browser* popup = ui_test_utils::GetBrowserNotInSet(excluded); | |
| 44 | |
| 45 EXPECT_TRUE(popup); | |
|
Paweł Hajdan Jr.
2011/06/07 08:28:55
Similarly here, if popup is false the next line wi
shinyak (Google)
2011/06/07 08:54:14
Done.
| |
| 46 | |
| 47 return popup->GetWindowTitleForCurrentTab(); | |
| 48 } | |
| 49 | |
| 50 // Test title for content created by javascript window.open(). | |
| 51 // See http://crbug.com/5988 | |
| 52 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, DynamicTitle1) { | |
| 53 ASSERT_TRUE(test_server()->Start()); | |
| 54 | |
| 55 GURL url(test_server()->GetURL("files/dynamic1.html")); | |
| 56 string16 title = GetPopupTitle(url); | |
| 57 ASSERT_EQ(string16::size_type(0), | |
|
Paweł Hajdan Jr.
2011/06/07 08:28:55
nit: I just realized it may be simpler to use Star
shinyak (Google)
2011/06/07 08:54:14
Done.
| |
| 58 title.find(ASCIIToUTF16("My Popup Title"))) | |
| 59 << "Actual title: " << title; | |
| 60 } | |
| 61 | |
| 62 // Test title for content created by javascript window.open(). | |
| 63 // See http://crbug.com/5988 | |
| 64 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, DynamicTitle2) { | |
| 65 ASSERT_TRUE(test_server()->Start()); | |
| 66 | |
| 67 GURL url(test_server()->GetURL("files/dynamic2.html")); | |
| 68 string16 title = GetPopupTitle(url); | |
| 69 ASSERT_EQ(string16::size_type(0), | |
| 70 title.find(ASCIIToUTF16("My Dynamic Title"))) | |
| 71 << "Actual title: " << title; | |
| 72 } | |
| OLD | NEW |