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

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

Issue 829263004: Add WaitForInterstitialReady to browser_test_utils. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: content/public/test/browser_test_utils.cc
diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc
index 89dd3430e96dbca0330338b1fc035951d215e908..52f5fd72a62f96608beef9fe63b6c6e4d7c66a95 100644
--- a/content/public/test/browser_test_utils.cc
+++ b/content/public/test/browser_test_utils.cc
@@ -21,6 +21,7 @@
#include "content/public/browser/browser_context.h"
#include "content/public/browser/dom_operation_notification_details.h"
#include "content/public/browser/histogram_fetcher.h"
+#include "content/public/browser/interstitial_page.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
@@ -723,6 +724,29 @@ void RunTaskAndWaitForInterstitialDetach(content::WebContents* web_contents,
loop_runner->Run();
}
+bool WaitForInterstitialReady(content::InterstitialPage* interstitial) {
+ content::RenderFrameHost* rfh = interstitial->GetMainFrame();
mattm 2015/01/22 02:28:32 Since the rest of this function isn't interstitial
meacer 2015/01/22 03:18:07 Done.
+ if (!rfh)
+ return false;
+ bool load_complete = false;
+ EXPECT_TRUE(
+ content::ExecuteScriptAndExtractBool(
+ rfh,
+ "(function() {"
+ " var done = false;"
+ " function checkState() {"
+ " if (!done && document.readyState == 'complete') {"
+ " done = true;"
+ " window.domAutomationController.send(true);"
+ " }"
+ " }"
+ " checkState();"
+ " document.addEventListener('readystatechange', checkState);"
+ "})();",
+ &load_complete));
+ return load_complete;
+}
+
TitleWatcher::TitleWatcher(WebContents* web_contents,
const base::string16& expected_title)
: WebContentsObserver(web_contents),

Powered by Google App Engine
This is Rietveld 408576698