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

Side by Side Diff: content/browser/renderer_host/render_view_host_browsertest.cc

Issue 7497058: New windows opened in javascript with target = "_blank" should (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Moving Test To renderer_host Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/data/window.open.blank.html ('k') | content/renderer/render_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/time.h" 5 #include "base/time.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/common/chrome_notification_types.h"
9 #include "chrome/test/base/in_process_browser_test.h" 10 #include "chrome/test/base/in_process_browser_test.h"
10 #include "chrome/test/base/ui_test_utils.h" 11 #include "chrome/test/base/ui_test_utils.h"
11 #include "content/browser/renderer_host/render_view_host.h" 12 #include "content/browser/renderer_host/render_view_host.h"
12 #include "content/browser/tab_contents/tab_contents.h" 13 #include "content/browser/tab_contents/tab_contents.h"
13 #include "content/browser/tab_contents/tab_contents_observer.h" 14 #include "content/browser/tab_contents/tab_contents_observer.h"
14 #include "content/common/view_messages.h" 15 #include "content/common/view_messages.h"
15 #include "net/base/host_port_pair.h" 16 #include "net/base/host_port_pair.h"
16 #include "net/test/test_server.h" 17 #include "net/test/test_server.h"
17 18
18 typedef std::pair<int, Value*> ExecuteDetailType; 19 typedef std::pair<int, Value*> ExecuteDetailType;
(...skipping 24 matching lines...) Expand all
43 int id_; 44 int id_;
44 scoped_ptr<Value> value_; 45 scoped_ptr<Value> value_;
45 46
46 DISALLOW_COPY_AND_ASSIGN(ExecuteNotificationObserver); 47 DISALLOW_COPY_AND_ASSIGN(ExecuteNotificationObserver);
47 }; 48 };
48 49
49 } // namespace 50 } // namespace
50 51
51 class RenderViewHostTest : public InProcessBrowserTest { 52 class RenderViewHostTest : public InProcessBrowserTest {
52 public: 53 public:
53 RenderViewHostTest() : last_execute_id_(0) {} 54 RenderViewHostTest() : last_execute_id_(0) {
55 EnableDOMAutomation();
56 }
54 57
55 void ExecuteJavascriptAndGetValue(const char* script, 58 void ExecuteJavascriptAndGetValue(const char* script,
56 ExecuteNotificationObserver* out_result) { 59 ExecuteNotificationObserver* out_result) {
57 RenderViewHost* rvh = 60 RenderViewHost* rvh =
58 browser()->GetSelectedTabContents()->render_view_host(); 61 browser()->GetSelectedTabContents()->render_view_host();
59 ASSERT_TRUE(rvh); 62 ASSERT_TRUE(rvh);
60 int execute_id = rvh->ExecuteJavascriptInWebFrameNotifyResult( 63 int execute_id = rvh->ExecuteJavascriptInWebFrameNotifyResult(
61 string16(), 64 string16(),
62 ASCIIToUTF16(script)); 65 ASCIIToUTF16(script));
63 EXPECT_NE(execute_id, last_execute_id_); 66 EXPECT_NE(execute_id, last_execute_id_);
64 ExecuteNotificationObserver observer; 67 ExecuteNotificationObserver observer;
65 ui_test_utils::RegisterAndWait( 68 ui_test_utils::RegisterAndWait(
66 out_result, 69 out_result,
67 content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT, 70 content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT,
68 Source<RenderViewHost>(rvh)); 71 Source<RenderViewHost>(rvh));
69 EXPECT_EQ(execute_id, out_result->id()); 72 EXPECT_EQ(execute_id, out_result->id());
70 ASSERT_TRUE(out_result->value()); 73 ASSERT_TRUE(out_result->value());
71 last_execute_id_ = execute_id; 74 last_execute_id_ = execute_id;
72 } 75 }
73 76
77 protected:
78 bool GetCreatedWindowName(const GURL& url,
79 const wchar_t* function,
80 std::string* window_name) {
81 ui_test_utils::NavigateToURL(browser(), url);
82
83 ui_test_utils::WindowedNotificationObserver observer(
84 chrome::NOTIFICATION_BROWSER_WINDOW_READY,
85 NotificationService::AllSources());
86
87 if (!ui_test_utils::ExecuteJavaScriptAndExtractString(
88 browser()->GetSelectedTabContents()->render_view_host(),
89 L"", function, window_name))
90 return false;
91
92 // observer.Wait();
darin (slow to review) 2011/08/29 17:33:41 why is this code commented out?
93 return true;
94 }
95
74 private: 96 private:
75 int last_execute_id_; 97 int last_execute_id_;
76 }; 98 };
77 99
78 100
79 // Makes sure ExecuteJavascriptInWebFrameNotifyResult works. 101 // Makes sure ExecuteJavascriptInWebFrameNotifyResult works.
80 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, 102 IN_PROC_BROWSER_TEST_F(RenderViewHostTest,
81 ExecuteJavascriptInWebFrameNotifyResult) { 103 ExecuteJavascriptInWebFrameNotifyResult) {
82 ASSERT_TRUE(test_server()->Start()); 104 ASSERT_TRUE(test_server()->Start());
83 GURL empty_url(test_server()->GetURL("files/empty.html")); 105 GURL empty_url(test_server()->GetURL("files/empty.html"));
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 RenderViewHostTestTabContentsObserver observer( 259 RenderViewHostTestTabContentsObserver observer(
238 browser()->GetSelectedTabContents()); 260 browser()->GetSelectedTabContents());
239 261
240 GURL test_url = test_server()->GetURL("files/simple.html"); 262 GURL test_url = test_server()->GetURL("files/simple.html");
241 ui_test_utils::NavigateToURL(browser(), test_url); 263 ui_test_utils::NavigateToURL(browser(), test_url);
242 264
243 EXPECT_EQ(test_server()->host_port_pair().ToString(), 265 EXPECT_EQ(test_server()->host_port_pair().ToString(),
244 observer.observed_socket_address().ToString()); 266 observer.observed_socket_address().ToString());
245 EXPECT_EQ(1, observer.navigation_count()); 267 EXPECT_EQ(1, observer.navigation_count());
246 } 268 }
269
270 // Regression test for http://crbug.com/88129
271 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, WindowOpen1) {
272 ASSERT_TRUE(test_server()->Start());
273
274 GURL url(test_server()->GetURL("files/window.open.blank.html"));
275 std::string window_name;
276 ASSERT_TRUE(GetCreatedWindowName(url, L"openWindow1();", &window_name));
277
278 EXPECT_EQ(window_name, "blank") << "Actual Window Name: " << window_name;
279 }
280
281 // Regression test for http://crbug.com/88129
282 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, WindowOpen2) {
283 ASSERT_TRUE(test_server()->Start());
284
285 GURL url(test_server()->GetURL("files/window.open.blank.html"));
286 std::string window_name;
287 ASSERT_TRUE(GetCreatedWindowName(url, L"openWindow2();", &window_name));
288
289 EXPECT_EQ(window_name, "") << "Actual Window Name: " << window_name;
290 }
OLDNEW
« no previous file with comments | « chrome/test/data/window.open.blank.html ('k') | content/renderer/render_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698