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

Unified Diff: content/public/test/browser_test_utils.h

Issue 2453693003: Browser tests for OOPIF support for drag-n-drop. (Closed)
Patch Set: Giving up and going back to using notifications. Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: content/public/test/browser_test_utils.h
diff --git a/content/public/test/browser_test_utils.h b/content/public/test/browser_test_utils.h
index cb917f6f1e8e9cc13c3613cf97cacce85628e828..823dba059a9bd33e315bf0f7796ba1dc8973ce96 100644
--- a/content/public/test/browser_test_utils.h
+++ b/content/public/test/browser_test_utils.h
@@ -192,6 +192,49 @@ RenderFrameHost* ConvertToRenderFrameHost(RenderViewHost* render_view_host);
RenderFrameHost* ConvertToRenderFrameHost(RenderFrameHost* render_view_host);
RenderFrameHost* ConvertToRenderFrameHost(WebContents* web_contents);
+class DOMAutomationWaiter : public NotificationObserver,
ncarter (slow) 2016/11/01 19:50:52 Can we do this as an enhancement to the existing D
Łukasz Anforowicz 2016/11/01 23:43:41 Agreed that DOMAutomationWaiter can be scraped and
+ public WebContentsObserver {
+ public:
+ // Starts monitoring the |target| for calls to
+ // window.domAutomationController.send(...).
+ explicit DOMAutomationWaiter(WebContents* target);
+
+ ~DOMAutomationWaiter() override;
+
+ // Waits until the window.domAutomationController.send(response) is called
+ // inside the |target| (the one that was passed to the constructor) and
+ // ShouldStopWaiting returns true for the |response| received from |target|.
+ //
+ // If |out_response| is not null, then it will receive the |response| from the
+ // |target|. It is okay if |out_response| is null.
+ //
+ // Returns true if the expected response was received (and false if the wait
+ // was intrrupted for other reasons - e.g. if a renderer crashed).
+ bool WaitAndGetResponse(std::unique_ptr<base::Value>* out_response)
+ WARN_UNUSED_RESULT;
+
+ protected:
+ // Returns whether to stop waiting for the given |response| value (passed by
+ // javascript to window.domAutomationController.send). In default
+ // implementation all |response| values stop waiting.
+ virtual bool ShouldStopWaiting(const base::Value& response);
Łukasz Anforowicz 2016/11/01 23:43:41 Yesterday I read an article arguing for minimizing
+
+ private:
+ // WebContentsObserver overrides,
ncarter (slow) 2016/11/01 19:50:52 , -> .
Łukasz Anforowicz 2016/11/01 23:43:41 Acknowledged. (not applicable anymore after remov
+ void RenderProcessGone(base::TerminationStatus status) override;
+
+ // NotificationObserver overrides.
+ void Observe(int type,
+ const NotificationSource& source,
+ const NotificationDetails& details) override;
+
+ std::unique_ptr<base::Value> response_;
+ scoped_refptr<MessageLoopRunner> message_loop_runner_;
+ NotificationRegistrar registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(DOMAutomationWaiter);
+};
+
// Executes the passed |script| in the specified frame. The |script| should not
// invoke domAutomationController.send(); otherwise, your test will hang or be
// flaky. If you want to extract a result, use one of the below functions.

Powered by Google App Engine
This is Rietveld 408576698