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

Side by Side Diff: content/renderer/render_view_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: Created 9 years, 4 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
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/basictypes.h" 5 #include "base/basictypes.h"
6 6
7 #include "base/shared_memory.h" 7 #include "base/shared_memory.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/common/chrome_notification_types.h"
10 #include "chrome/test/base/render_view_test.h" 12 #include "chrome/test/base/render_view_test.h"
13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/ui_test_utils.h"
11 #include "content/common/native_web_keyboard_event.h" 15 #include "content/common/native_web_keyboard_event.h"
12 #include "content/common/view_messages.h" 16 #include "content/common/view_messages.h"
17 #include "content/browser/tab_contents/tab_contents.h"
13 #include "net/base/net_errors.h" 18 #include "net/base/net_errors.h"
19 #include "net/test/test_server.h"
14 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
18 #include "ui/base/keycodes/keyboard_codes.h" 24 #include "ui/base/keycodes/keyboard_codes.h"
19 #include "ui/gfx/codec/jpeg_codec.h" 25 #include "ui/gfx/codec/jpeg_codec.h"
20 #include "webkit/glue/web_io_operators.h" 26 #include "webkit/glue/web_io_operators.h"
21 27
22 using WebKit::WebFrame; 28 using WebKit::WebFrame;
23 using WebKit::WebString; 29 using WebKit::WebString;
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 // Frame should stay in view-source mode. 849 // Frame should stay in view-source mode.
844 EXPECT_TRUE(web_frame->isViewSourceModeEnabled()); 850 EXPECT_TRUE(web_frame->isViewSourceModeEnabled());
845 } 851 }
846 852
847 // Regression test for http://crbug.com/41562 853 // Regression test for http://crbug.com/41562
848 TEST_F(RenderViewTest, UpdateTargetURLWithInvalidURL) { 854 TEST_F(RenderViewTest, UpdateTargetURLWithInvalidURL) {
849 const GURL invalid_gurl("http://"); 855 const GURL invalid_gurl("http://");
850 view_->setMouseOverURL(WebKit::WebURL(invalid_gurl)); 856 view_->setMouseOverURL(WebKit::WebURL(invalid_gurl));
851 EXPECT_EQ(invalid_gurl, view_->target_url_); 857 EXPECT_EQ(invalid_gurl, view_->target_url_);
852 } 858 }
859
860 class InProcessRenderViewBrowserTest : public InProcessBrowserTest {
861 public:
862 InProcessRenderViewBrowserTest() {
863 EnableDOMAutomation();
864 }
865 protected:
866 RenderViewHost* render_view_host() {
867 return browser()->GetSelectedTabContents()->render_view_host();
868 }
869
870 bool GetCreatedWindowName(const GURL& url,
871 const wchar_t* function,
872 std::string* window_name) {
873 ui_test_utils::NavigateToURL(browser(), url);
874
875 ui_test_utils::WindowedNotificationObserver observer(
876 chrome::NOTIFICATION_BROWSER_WINDOW_READY,
877 NotificationService::AllSources());
878
879 if (!ui_test_utils::ExecuteJavaScriptAndExtractString(
880 render_view_host(), L"", function, window_name))
881 return false;
882
883 // observer.Wait();
884 return true;
885 }
886 };
887
888 // Regression test for http://crbug.com/88129
889 IN_PROC_BROWSER_TEST_F(InProcessRenderViewBrowserTest, WindowOpen1) {
890 ASSERT_TRUE(test_server()->Start());
891
892 GURL url(test_server()->GetURL("files/window.open.blank.html"));
893 std::string window_name;
894 ASSERT_TRUE(GetCreatedWindowName(url, L"openWindow1();", &window_name));
895
896 EXPECT_EQ(window_name, "blank") << "Actual Window Name: " << window_name;
897 }
898
899 // Regression test for http://crbug.com/88129
900 IN_PROC_BROWSER_TEST_F(InProcessRenderViewBrowserTest, WindowOpen2) {
901 ASSERT_TRUE(test_server()->Start());
902
903 GURL url(test_server()->GetURL("files/window.open.blank.html"));
904 std::string window_name;
905 ASSERT_TRUE(GetCreatedWindowName(url, L"openWindow2();", &window_name));
906
907 EXPECT_EQ(window_name, "") << "Actual Window Name: " << window_name;
908 }
OLDNEW
« content/renderer/render_view.cc ('K') | « content/renderer/render_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698