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

Side by Side Diff: chrome/test/base/in_process_browser_test.h

Issue 2013573007: Catch CSP violations in InProcessBrowserTest Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: double check test is run Created 4 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
« no previous file with comments | « chrome/test/BUILD.gn ('k') | chrome/test/base/in_process_browser_test.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_TEST_BASE_IN_PROCESS_BROWSER_TEST_H_ 5 #ifndef CHROME_TEST_BASE_IN_PROCESS_BROWSER_TEST_H_
6 #define CHROME_TEST_BASE_IN_PROCESS_BROWSER_TEST_H_ 6 #define CHROME_TEST_BASE_IN_PROCESS_BROWSER_TEST_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
15 #include "content/public/test/browser_test.h" 15 #include "content/public/test/browser_test.h"
16 #include "content/public/test/browser_test_base.h" 16 #include "content/public/test/browser_test_base.h"
17 #include "content/public/test/content_browser_test_utils.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "ui/base/page_transition_types.h" 19 #include "ui/base/page_transition_types.h"
19 20
20 namespace base { 21 namespace base {
21 22
22 class CommandLine; 23 class CommandLine;
23 24
24 #if defined(OS_MACOSX) 25 #if defined(OS_MACOSX)
25 namespace mac { 26 namespace mac {
26 class ScopedNSAutoreleasePool; 27 class ScopedNSAutoreleasePool;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // it should override this method. 152 // it should override this method.
152 virtual void SetUpDefaultCommandLine(base::CommandLine* command_line); 153 virtual void SetUpDefaultCommandLine(base::CommandLine* command_line);
153 154
154 // Initializes the contents of the user data directory. Called by SetUp() 155 // Initializes the contents of the user data directory. Called by SetUp()
155 // after creating the user data directory, but before any browser is launched. 156 // after creating the user data directory, but before any browser is launched.
156 // If a test wishes to set up some initial non-empty state in the user data 157 // If a test wishes to set up some initial non-empty state in the user data
157 // directory before the browser starts up, it can do so here. Returns true if 158 // directory before the browser starts up, it can do so here. Returns true if
158 // successful. 159 // successful.
159 virtual bool SetUpUserDataDirectory() WARN_UNUSED_RESULT; 160 virtual bool SetUpUserDataDirectory() WARN_UNUSED_RESULT;
160 161
162 // After the test, assert whether CSP error messages should've shown up during
163 // the test. Default false. If you expect these errors, set to true.
164 void SetExpectCSPErrorMessages(bool expect);
165
161 // BrowserTestBase: 166 // BrowserTestBase:
162 void RunTestOnMainThreadLoop() override; 167 void RunTestOnMainThreadLoop() override;
163 168
164 // Ensures that no devtools are open, and then opens the devtools. 169 // Ensures that no devtools are open, and then opens the devtools.
165 void OpenDevToolsWindow(content::WebContents* web_contents); 170 void OpenDevToolsWindow(content::WebContents* web_contents);
166 171
167 // Opens |url| in an incognito browser window with the incognito profile of 172 // Opens |url| in an incognito browser window with the incognito profile of
168 // |profile|, blocking until the navigation finishes. This will create a new 173 // |profile|, blocking until the navigation finishes. This will create a new
169 // browser if a browser with the incognito profile does not exist. Returns the 174 // browser if a browser with the incognito profile does not exist. Returns the
170 // incognito window Browser. 175 // incognito window Browser.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 // Temporary user data directory. Used only when a user data directory is not 245 // Temporary user data directory. Used only when a user data directory is not
241 // specified in the command line. 246 // specified in the command line.
242 base::ScopedTempDir temp_user_data_dir_; 247 base::ScopedTempDir temp_user_data_dir_;
243 248
244 // True if we should exit the tests after the last browser instance closes. 249 // True if we should exit the tests after the last browser instance closes.
245 bool exit_when_last_browser_closes_; 250 bool exit_when_last_browser_closes_;
246 251
247 // True if the about:blank tab should be opened when the browser is launched. 252 // True if the about:blank tab should be opened when the browser is launched.
248 bool open_about_blank_on_browser_launch_; 253 bool open_about_blank_on_browser_launch_;
249 254
255 // True if CSP error messages are expected. Fail the test if not matching.
256 bool expect_csp_messages_;
257
258 content::ConsoleObserverDelegate* console_delegate_;
259
250 // True if the accessibility test should run for a particular test case. 260 // True if the accessibility test should run for a particular test case.
251 // This is reset for every test case. 261 // This is reset for every test case.
252 bool run_accessibility_checks_for_test_case_; 262 bool run_accessibility_checks_for_test_case_;
253 263
254 #if defined(OS_MACOSX) 264 #if defined(OS_MACOSX)
255 base::mac::ScopedNSAutoreleasePool* autorelease_pool_; 265 base::mac::ScopedNSAutoreleasePool* autorelease_pool_;
256 std::unique_ptr<ScopedBundleSwizzlerMac> bundle_swizzler_; 266 std::unique_ptr<ScopedBundleSwizzlerMac> bundle_swizzler_;
257 #endif // OS_MACOSX 267 #endif // OS_MACOSX
258 268
259 #if defined(OS_WIN) 269 #if defined(OS_WIN)
260 std::unique_ptr<base::win::ScopedCOMInitializer> com_initializer_; 270 std::unique_ptr<base::win::ScopedCOMInitializer> com_initializer_;
261 #endif 271 #endif
262 }; 272 };
263 273
264 #endif // CHROME_TEST_BASE_IN_PROCESS_BROWSER_TEST_H_ 274 #endif // CHROME_TEST_BASE_IN_PROCESS_BROWSER_TEST_H_
OLDNEW
« no previous file with comments | « chrome/test/BUILD.gn ('k') | chrome/test/base/in_process_browser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698