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

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: removed unnecessary #include 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/test/base/in_process_browser_test.h" 9 #include "chrome/test/base/in_process_browser_test.h"
10 #include "chrome/test/base/ui_test_utils.h" 10 #include "chrome/test/base/ui_test_utils.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 int id_; 43 int id_;
44 scoped_ptr<Value> value_; 44 scoped_ptr<Value> value_;
45 45
46 DISALLOW_COPY_AND_ASSIGN(ExecuteNotificationObserver); 46 DISALLOW_COPY_AND_ASSIGN(ExecuteNotificationObserver);
47 }; 47 };
48 48
49 } // namespace 49 } // namespace
50 50
51 class RenderViewHostTest : public InProcessBrowserTest { 51 class RenderViewHostTest : public InProcessBrowserTest {
52 public: 52 public:
53 RenderViewHostTest() : last_execute_id_(0) {} 53 RenderViewHostTest() : last_execute_id_(0) {
54 EnableDOMAutomation();
55 }
54 56
55 void ExecuteJavascriptAndGetValue(const char* script, 57 void ExecuteJavascriptAndGetValue(const char* script,
56 ExecuteNotificationObserver* out_result) { 58 ExecuteNotificationObserver* out_result) {
57 RenderViewHost* rvh = 59 RenderViewHost* rvh =
58 browser()->GetSelectedTabContents()->render_view_host(); 60 browser()->GetSelectedTabContents()->render_view_host();
59 ASSERT_TRUE(rvh); 61 ASSERT_TRUE(rvh);
60 int execute_id = rvh->ExecuteJavascriptInWebFrameNotifyResult( 62 int execute_id = rvh->ExecuteJavascriptInWebFrameNotifyResult(
61 string16(), 63 string16(),
62 ASCIIToUTF16(script)); 64 ASCIIToUTF16(script));
63 EXPECT_NE(execute_id, last_execute_id_); 65 EXPECT_NE(execute_id, last_execute_id_);
64 ExecuteNotificationObserver observer; 66 ExecuteNotificationObserver observer;
65 ui_test_utils::RegisterAndWait( 67 ui_test_utils::RegisterAndWait(
66 out_result, 68 out_result,
67 content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT, 69 content::NOTIFICATION_EXECUTE_JAVASCRIPT_RESULT,
68 Source<RenderViewHost>(rvh)); 70 Source<RenderViewHost>(rvh));
69 EXPECT_EQ(execute_id, out_result->id()); 71 EXPECT_EQ(execute_id, out_result->id());
70 ASSERT_TRUE(out_result->value()); 72 ASSERT_TRUE(out_result->value());
71 last_execute_id_ = execute_id; 73 last_execute_id_ = execute_id;
72 } 74 }
73 75
76 protected:
77 bool GetCreatedWindowName(const GURL& url,
78 const wchar_t* function,
79 std::string* window_name) {
80 ui_test_utils::NavigateToURL(browser(), url);
81
82 return ui_test_utils::ExecuteJavaScriptAndExtractString(
83 browser()->GetSelectedTabContents()->render_view_host(),
84 L"", function, window_name);
85 }
86
74 private: 87 private:
75 int last_execute_id_; 88 int last_execute_id_;
76 }; 89 };
77 90
78 91
79 // Makes sure ExecuteJavascriptInWebFrameNotifyResult works. 92 // Makes sure ExecuteJavascriptInWebFrameNotifyResult works.
80 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, 93 IN_PROC_BROWSER_TEST_F(RenderViewHostTest,
81 ExecuteJavascriptInWebFrameNotifyResult) { 94 ExecuteJavascriptInWebFrameNotifyResult) {
82 ASSERT_TRUE(test_server()->Start()); 95 ASSERT_TRUE(test_server()->Start());
83 GURL empty_url(test_server()->GetURL("files/empty.html")); 96 GURL empty_url(test_server()->GetURL("files/empty.html"));
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 private: 241 private:
229 net::HostPortPair observed_socket_address_; 242 net::HostPortPair observed_socket_address_;
230 int navigation_count_; 243 int navigation_count_;
231 244
232 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestTabContentsObserver); 245 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestTabContentsObserver);
233 }; 246 };
234 247
235 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, FrameNavigateSocketAddress) { 248 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, FrameNavigateSocketAddress) {
236 ASSERT_TRUE(test_server()->Start()); 249 ASSERT_TRUE(test_server()->Start());
237 RenderViewHostTestTabContentsObserver observer( 250 RenderViewHostTestTabContentsObserver observer(
238 browser()->GetSelectedTabContents()); 251 browser()->GetSelectedTabContents());
239 252
240 GURL test_url = test_server()->GetURL("files/simple.html"); 253 GURL test_url = test_server()->GetURL("files/simple.html");
241 ui_test_utils::NavigateToURL(browser(), test_url); 254 ui_test_utils::NavigateToURL(browser(), test_url);
242 255
243 EXPECT_EQ(test_server()->host_port_pair().ToString(), 256 EXPECT_EQ(test_server()->host_port_pair().ToString(),
244 observer.observed_socket_address().ToString()); 257 observer.observed_socket_address().ToString());
245 EXPECT_EQ(1, observer.navigation_count()); 258 EXPECT_EQ(1, observer.navigation_count());
246 } 259 }
260
261 // Regression test for http://crbug.com/88129
262 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, WindowOpen1) {
263 ASSERT_TRUE(test_server()->Start());
264
265 GURL url(test_server()->GetURL("files/window.open.blank.html"));
266 std::string window_name;
267 ASSERT_TRUE(GetCreatedWindowName(url, L"openWindow1();", &window_name));
268
269 EXPECT_EQ(window_name, "blank") << "Actual Window Name: " << window_name;
270 }
271
272 // Regression test for http://crbug.com/88129
273 IN_PROC_BROWSER_TEST_F(RenderViewHostTest, WindowOpen2) {
274 ASSERT_TRUE(test_server()->Start());
275
276 GURL url(test_server()->GetURL("files/window.open.blank.html"));
277 std::string window_name;
278 ASSERT_TRUE(GetCreatedWindowName(url, L"openWindow2();", &window_name));
279
280 EXPECT_EQ(window_name, "") << "Actual Window Name: " << window_name;
281 }
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