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

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

Issue 1502963004: Use content::NavigateIframeToURL in ProcessManagerBrowserTest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avoid 2 concurrent domAutomationController to pass ChromeSitePerProcessTest.PluginWithRemoteTopFrame Created 5 years 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
« no previous file with comments | « chrome/test/data/iframe.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 79fd6170245e383d4f99aa70ed7ff58aec365016..895bfb41ddb99da42b6d8ca40c973b5f259ff6c3 100644
--- a/content/public/test/browser_test_utils.cc
+++ b/content/public/test/browser_test_utils.cc
@@ -313,19 +313,23 @@ bool NavigateIframeToURL(WebContents* web_contents,
// TODO(creis): This should wait for LOAD_STOP, but cross-site subframe
// navigations generate extra DidStartLoading and DidStopLoading messages.
// Until we replace swappedout:// with frame proxies, we need to listen for
- // something else. For now, we trigger NEW_SUBFRAME navigations and listen
- // for commit. See https://crbug.com/436250.
+ // something else. See https://crbug.com/436250.
Charlie Reis 2015/12/11 22:15:29 I've started reviewing this CL, but I'm wondering
robwu 2015/12/16 09:28:34 Your patch works, so I have reduced the patch to a
std::string script = base::StringPrintf(
- "setTimeout(\""
- "var iframes = document.getElementById('%s');iframes.src='%s';"
- "\",0)",
+ "var frame = document.getElementById('%s'), timer;"
+ "frame.onload = frame.onerror = function(event) {"
+ // This timer is ugly, but it is a general way to deal with the issue
+ // mentioned above. Assume that the load really finished when we don't
+ // receive any notifications for some arbitrarily chosen time.
+ " clearTimeout(timer);"
+ " timer = setTimeout(function() {"
+ " domAutomationController.send(event.type === 'load');"
+ " }, 500);"
+ "};"
+ "frame.src = '%s';",
iframe_id.c_str(), url.spec().c_str());
- WindowedNotificationObserver load_observer(
- NOTIFICATION_NAV_ENTRY_COMMITTED,
- Source<NavigationController>(&web_contents->GetController()));
- bool result = ExecuteScript(web_contents, script);
- load_observer.Wait();
- return result;
+ bool is_loaded = false;
+ bool result = ExecuteScriptAndExtractBool(web_contents, script, &is_loaded);
+ return result && is_loaded;
}
GURL GetFileUrlWithQuery(const base::FilePath& path,
« no previous file with comments | « chrome/test/data/iframe.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698