| Index: content/test/content_browser_test_utils_internal.h
|
| diff --git a/content/test/content_browser_test_utils_internal.h b/content/test/content_browser_test_utils_internal.h
|
| index f4a4ddea552c7b37746fc87275a56e3bf0beaad2..a894eb284a8148001c4522b9ca104da94a997dba 100644
|
| --- a/content/test/content_browser_test_utils_internal.h
|
| +++ b/content/test/content_browser_test_utils_internal.h
|
| @@ -14,8 +14,11 @@
|
| #include <vector>
|
|
|
| #include "base/macros.h"
|
| +#include "base/memory/weak_ptr.h"
|
| #include "cc/surfaces/surface_id.h"
|
| +#include "content/public/browser/navigation_handle.h"
|
| #include "content/public/browser/resource_dispatcher_host_delegate.h"
|
| +#include "content/public/browser/web_contents_observer.h"
|
| #include "url/gurl.h"
|
|
|
| namespace cc {
|
| @@ -25,6 +28,7 @@ class SurfaceManager;
|
| namespace content {
|
|
|
| class FrameTreeNode;
|
| +class MessageLoopRunner;
|
| class RenderWidgetHostViewChildFrame;
|
| class Shell;
|
| class SiteInstance;
|
| @@ -34,6 +38,10 @@ class ToRenderFrameHost;
|
| // navigation finishes.
|
| void NavigateFrameToURL(FrameTreeNode* node, const GURL& url);
|
|
|
| +// Sets the DialogManager to proceed by default or not when showing a
|
| +// BeforeUnload dialog.
|
| +void SetShouldProceedOnBeforeUnload(Shell* shell, bool proceed);
|
| +
|
| // Creates compact textual representations of the state of the frame tree that
|
| // is appropriate for use in assertions.
|
| //
|
| @@ -103,6 +111,46 @@ class NavigationStallDelegate : public ResourceDispatcherHostDelegate {
|
| GURL url_;
|
| };
|
|
|
| +// This class can be used to pause and resume navigations, based on a URL
|
| +// match. Note that it only keeps track of one navigation at a time.
|
| +class TestNavigationManager : public WebContentsObserver {
|
| + public:
|
| + // Currently this monitors any frame in WebContents.
|
| + // TODO(clamy): Extend this class so that it can monitor a specific frame.
|
| + TestNavigationManager(WebContents* web_contents, const GURL& url);
|
| + ~TestNavigationManager() override;
|
| +
|
| + // Waits until the navigation request is ready to be sent to the network
|
| + // stack. The navigation will be paused until it is resumed by calling
|
| + // ResumeNavigation.
|
| + void WaitForWillStartRequest();
|
| +
|
| + // Resumes the navigation if it was previously paused.
|
| + void ResumeNavigation();
|
| +
|
| + // Waits until the navigation has been finished. Users of this method should
|
| + // first use WaitForWillStartRequest, then call ResumeNavigation, and only
|
| + // then WaitForNavigationFinished.
|
| + // TODO(clamy): Do not pause the navigation in WillStartRequest by default.
|
| + void WaitForNavigationFinished();
|
| +
|
| + private:
|
| + // WebContentsObserver implementation.
|
| + void DidStartNavigation(NavigationHandle* handle) override;
|
| + void DidFinishNavigation(NavigationHandle* handle) override;
|
| +
|
| + // Called when the NavigationThrottle pauses the navigation in
|
| + // WillStartRequest.
|
| + void OnWillStartRequest();
|
| +
|
| + const GURL url_;
|
| + bool navigation_paused_;
|
| + NavigationHandle* handle_;
|
| + scoped_refptr<MessageLoopRunner> loop_runner_;
|
| +
|
| + base::WeakPtrFactory<TestNavigationManager> weak_factory_;
|
| +};
|
| +
|
| // Helper class to assist with hit testing surfaces in multiple processes.
|
| // WaitForSurfaceReady() will only return after a Surface from |target_view|
|
| // has been composited in the top-level frame's Surface. At that point,
|
|
|