summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshinyak@google.com <shinyak@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-14 05:30:44 +0000
committershinyak@google.com <shinyak@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-14 05:30:44 +0000
commitfac06f33c10b64eedcc8035f735d1ddfe1dfe1e2 (patch)
tree3ae92cce10279623226f474a46700af72f332a09
parent1d494fbbb7b71676fc3a2f101ee6e52cfe42f0e9 (diff)
downloadchromium_src-fac06f33c10b64eedcc8035f735d1ddfe1dfe1e2.zip
chromium_src-fac06f33c10b64eedcc8035f735d1ddfe1dfe1e2.tar.gz
chromium_src-fac06f33c10b64eedcc8035f735d1ddfe1dfe1e2.tar.bz2
Tests for bug 5988.
BUG=5988 TEST=ResourceDispatcherTest.DynamicTitle* Review URL: http://codereview.chromium.org/7080049 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88960 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/chrome_tests.gypi1
-rw-r--r--chrome/test/data/dynamic1.html27
-rw-r--r--chrome/test/data/dynamic2.html31
-rw-r--r--content/browser/renderer_host/resource_dispatcher_host_browsertest.cc75
4 files changed, 134 insertions, 0 deletions
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 59373d98..79aab3b 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -2522,6 +2522,7 @@
'../content/browser/renderer_host/render_process_host_browsertest.h',
'../content/browser/renderer_host/render_view_host_browsertest.cc',
'../content/browser/renderer_host/render_view_host_manager_browsertest.cc',
+ '../content/browser/renderer_host/resource_dispatcher_host_browsertest.cc',
'../content/browser/speech/speech_input_browsertest.cc',
'../content/renderer/render_view_browsertest.cc',
'../content/renderer/render_view_browsertest_mac.mm',
diff --git a/chrome/test/data/dynamic1.html b/chrome/test/data/dynamic1.html
new file mode 100644
index 0000000..07ff336
--- /dev/null
+++ b/chrome/test/data/dynamic1.html
@@ -0,0 +1,27 @@
+<html>
+<head>
+<title>Test Title</title>
+<script type="text/javascript">
+function OpenPopup() {
+ // Create a new popup window
+ var oWnd = window.open('','MyPopupName','width=350,height=300',false);
+
+ // Dynamically generate the HTML content for popup window
+ var sHtml =
+ '<html>'
+ + '<head><title>My Popup Title</title></head>'
+ + '<body></body>'
+ + '</html>';
+
+ // Push the HTML into that window
+ oWnd.document.write(sHtml);
+
+ // Finish
+ oWnd.document.close();
+}
+</script>
+</head>
+<body>
+ <p>This is dynamic1.html</p>
+</body>
+</html>
diff --git a/chrome/test/data/dynamic2.html b/chrome/test/data/dynamic2.html
new file mode 100644
index 0000000..297c534
--- /dev/null
+++ b/chrome/test/data/dynamic2.html
@@ -0,0 +1,31 @@
+<html>
+<head>
+<title>Test Title</title>
+<script type="text/javascript">
+function OpenPopup() {
+ // Create a new popup window
+ var oWnd = window.open('','MyPopupName','width=350,height=300',false);
+
+ // Dynamically generate the HTML content for popup window
+ var sHtml =
+ '<html>'
+ + '<head><title>My Popup Title</title></head>'
+ + '<body>'
+ + '<script type="text/javascript">'
+ + 'document.title="My Dynamic Title";'
+ + '<\/script>'
+ + '</body>'
+ + '</html>';
+
+ // Push the HTML into that window
+ oWnd.document.write(sHtml);
+
+ // Finish
+ oWnd.document.close();
+}
+</script>
+</head>
+<body>
+ <p>This is dynamic2.html</p>
+</body>
+</html>
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 0000000..846ca3b
--- /dev/null
+++ b/content/browser/renderer_host/resource_dispatcher_host_browsertest.cc
@@ -0,0 +1,75 @@
+// 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/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"), true))
+ << "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"), true))
+ << "Actual title: " << title;
+}