OLD | NEW |
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 CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/command_line.h" |
13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
14 #include "base/files/scoped_temp_dir.h" | 15 #include "base/files/scoped_temp_dir.h" |
15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
16 #include "base/process/process.h" | 17 #include "base/process/process.h" |
17 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
18 #include "content/public/browser/browser_message_filter.h" | 19 #include "content/public/browser/browser_message_filter.h" |
19 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
20 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
21 #include "content/public/browser/render_process_host_observer.h" | 22 #include "content/public/browser/render_process_host_observer.h" |
22 #include "content/public/browser/web_contents_observer.h" | 23 #include "content/public/browser/web_contents_observer.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // Waits for an interstitial page to detach from given web contents. | 240 // Waits for an interstitial page to detach from given web contents. |
240 void WaitForInterstitialDetach(content::WebContents* web_contents); | 241 void WaitForInterstitialDetach(content::WebContents* web_contents); |
241 | 242 |
242 // Runs task and waits for an interstitial page to detach from given web | 243 // Runs task and waits for an interstitial page to detach from given web |
243 // contents. Prefer this over WaitForInterstitialDetach if web_contents may be | 244 // contents. Prefer this over WaitForInterstitialDetach if web_contents may be |
244 // destroyed by the time WaitForInterstitialDetach is called (e.g. when waiting | 245 // destroyed by the time WaitForInterstitialDetach is called (e.g. when waiting |
245 // for an interstitial detach after closing a tab). | 246 // for an interstitial detach after closing a tab). |
246 void RunTaskAndWaitForInterstitialDetach(content::WebContents* web_contents, | 247 void RunTaskAndWaitForInterstitialDetach(content::WebContents* web_contents, |
247 const base::Closure& task); | 248 const base::Closure& task); |
248 | 249 |
| 250 // Returns true if all sites are isolated. Typically used to bail from a test |
| 251 // that is incompatible with --site-per-process. |
| 252 bool AreAllSitesIsolatedForTesting(); |
| 253 |
| 254 // Appends --site-per-process to the command line, enabling tests to exercise |
| 255 // site isolation and cross-process iframes. |
| 256 // |
| 257 // TODO(nick): In some places this method is called from the top of a test |
| 258 // body. That's not strictly safe (it's setting a command line after it |
| 259 // already may have been read). We should try make that pattern safer, as it |
| 260 // makes browser tests easier to write. |
| 261 void IsolateAllSitesForTesting(base::CommandLine* command_line); |
| 262 |
249 // Waits until all resources have loaded in the given RenderFrameHost. | 263 // Waits until all resources have loaded in the given RenderFrameHost. |
250 // When the load completes, this function sends a "pageLoadComplete" message | 264 // When the load completes, this function sends a "pageLoadComplete" message |
251 // via domAutomationController. The caller should make sure this extra | 265 // via domAutomationController. The caller should make sure this extra |
252 // message is handled properly. | 266 // message is handled properly. |
253 bool WaitForRenderFrameReady(RenderFrameHost* rfh) WARN_UNUSED_RESULT; | 267 bool WaitForRenderFrameReady(RenderFrameHost* rfh) WARN_UNUSED_RESULT; |
254 | 268 |
255 // Watches title changes on a WebContents, blocking until an expected title is | 269 // Watches title changes on a WebContents, blocking until an expected title is |
256 // set. | 270 // set. |
257 class TitleWatcher : public WebContentsObserver { | 271 class TitleWatcher : public WebContentsObserver { |
258 public: | 272 public: |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 int routing_id_; | 464 int routing_id_; |
451 bool deleted_; | 465 bool deleted_; |
452 scoped_ptr<base::RunLoop> runner_; | 466 scoped_ptr<base::RunLoop> runner_; |
453 | 467 |
454 DISALLOW_COPY_AND_ASSIGN(RenderFrameDeletedObserver); | 468 DISALLOW_COPY_AND_ASSIGN(RenderFrameDeletedObserver); |
455 }; | 469 }; |
456 | 470 |
457 } // namespace content | 471 } // namespace content |
458 | 472 |
459 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 473 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
OLD | NEW |