OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
9 #include "chrome/browser/browser_init.h" | 9 #include "chrome/browser/browser_init.h" |
10 #include "chrome/browser/browser_list.h" | 10 #include "chrome/browser/browser_list.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // testing sessions. | 44 // testing sessions. |
45 | 45 |
46 OpenURLsPopupObserver observer; | 46 OpenURLsPopupObserver observer; |
47 BrowserList::AddObserver(&observer); | 47 BrowserList::AddObserver(&observer); |
48 | 48 |
49 Browser* popup = Browser::CreateForType(Browser::TYPE_POPUP, | 49 Browser* popup = Browser::CreateForType(Browser::TYPE_POPUP, |
50 browser()->profile()); | 50 browser()->profile()); |
51 ASSERT_EQ(popup->type(), Browser::TYPE_POPUP); | 51 ASSERT_EQ(popup->type(), Browser::TYPE_POPUP); |
52 ASSERT_EQ(popup, observer.added_browser_); | 52 ASSERT_EQ(popup, observer.added_browser_); |
53 | 53 |
54 CommandLine dummy(CommandLine::ARGUMENTS_ONLY); | 54 CommandLine dummy(CommandLine::NO_PROGRAM); |
55 BrowserInit::LaunchWithProfile launch(FilePath(), dummy); | 55 BrowserInit::LaunchWithProfile launch(FilePath(), dummy); |
56 // This should create a new window, but re-use the profile from |popup|. If | 56 // This should create a new window, but re-use the profile from |popup|. If |
57 // it used a NULL or invalid profile, it would crash. | 57 // it used a NULL or invalid profile, it would crash. |
58 launch.OpenURLsInBrowser(popup, false, urls); | 58 launch.OpenURLsInBrowser(popup, false, urls); |
59 ASSERT_NE(popup, observer.added_browser_); | 59 ASSERT_NE(popup, observer.added_browser_); |
60 BrowserList::RemoveObserver(&observer); | 60 BrowserList::RemoveObserver(&observer); |
61 } | 61 } |
62 | 62 |
63 // Test that we prevent openning potentially dangerous schemes from the | 63 // Test that we prevent openning potentially dangerous schemes from the |
64 // command line. | 64 // command line. |
65 // TODO(jschuh): FLAKY because the process doesn't have sufficient time | 65 // TODO(jschuh): FLAKY because the process doesn't have sufficient time |
66 // to start on most BuildBot runs and I don't want to add longer delays to | 66 // to start on most BuildBot runs and I don't want to add longer delays to |
67 // the test. I'll circle back and make this work properly when i get a chance. | 67 // the test. I'll circle back and make this work properly when i get a chance. |
68 IN_PROC_BROWSER_TEST_F(BrowserInitTest, FLAKY_BlockBadURLs) { | 68 IN_PROC_BROWSER_TEST_F(BrowserInitTest, FLAKY_BlockBadURLs) { |
69 const char* testurlstr = "http://localhost/"; | 69 const char* testurlstr = "http://localhost/"; |
70 const GURL testurl(testurlstr); | 70 const GURL testurl(testurlstr); |
71 CommandLine cmdline(CommandLine::ARGUMENTS_ONLY); | 71 CommandLine cmdline(CommandLine::NO_PROGRAM); |
72 cmdline.AppendArg(testurlstr); | 72 cmdline.AppendArg(testurlstr); |
73 cmdline.AppendArg("javascript:alert('boo')"); | 73 cmdline.AppendArg("javascript:alert('boo')"); |
74 cmdline.AppendArg(testurlstr); | 74 cmdline.AppendArg(testurlstr); |
75 cmdline.AppendArg("view-source:http://localhost/"); | 75 cmdline.AppendArg("view-source:http://localhost/"); |
76 | 76 |
77 // This will pick up the current browser instance. | 77 // This will pick up the current browser instance. |
78 BrowserInit::LaunchWithProfile launch(FilePath(), cmdline); | 78 BrowserInit::LaunchWithProfile launch(FilePath(), cmdline); |
79 launch.Launch(browser()->profile(), false); | 79 launch.Launch(browser()->profile(), false); |
80 | 80 |
81 // TODO(jschuh): Give the browser a chance to start first. | 81 // TODO(jschuh): Give the browser a chance to start first. |
82 PlatformThread::Sleep(50); | 82 PlatformThread::Sleep(50); |
83 | 83 |
84 // Skip about:blank in the first tab | 84 // Skip about:blank in the first tab |
85 for (int i = 1; i < browser()->tab_count(); i++) { | 85 for (int i = 1; i < browser()->tab_count(); i++) { |
86 const GURL &url = browser()->GetTabContentsAt(i)->GetURL(); | 86 const GURL &url = browser()->GetTabContentsAt(i)->GetURL(); |
87 ASSERT_EQ(url, testurl); | 87 ASSERT_EQ(url, testurl); |
88 } | 88 } |
89 ASSERT_EQ(browser()->tab_count(), 3); | 89 ASSERT_EQ(browser()->tab_count(), 3); |
90 } | 90 } |
91 | 91 |
92 } // namespace | 92 } // namespace |
OLD | NEW |