diff options
author | phoglund@chromium.org <phoglund@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-28 09:56:28 +0000 |
---|---|---|
committer | phoglund@chromium.org <phoglund@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-28 09:56:28 +0000 |
commit | 73fcfc155b895722df4c49fc842ddf8222e86f19 (patch) | |
tree | bc22ccabdf1333a538ac938b47c8c9b6165ab38f /chrome/browser/media/webrtc_browsertest_base.cc | |
parent | 0a289730521a18c3dc10c165c908c4e14f80fbb3 (diff) | |
download | chromium_src-73fcfc155b895722df4c49fc842ddf8222e86f19.zip chromium_src-73fcfc155b895722df4c49fc842ddf8222e86f19.tar.gz chromium_src-73fcfc155b895722df4c49fc842ddf8222e86f19.tar.bz2 |
Workaround for problem where our javascript loads slow.
This is a very speculative fix since it's hard to repro locally. If this
patch solves the problem, there's a race between js loading and the test
which likely requires a deep look at how the navigation logic and test
javascript helpers interact with each other.
TBR=tommi@chromium.org
BUG=281268
Review URL: https://codereview.chromium.org/94513002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237753 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/media/webrtc_browsertest_base.cc')
-rw-r--r-- | chrome/browser/media/webrtc_browsertest_base.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/chrome/browser/media/webrtc_browsertest_base.cc b/chrome/browser/media/webrtc_browsertest_base.cc index d263ad2..007caa5 100644 --- a/chrome/browser/media/webrtc_browsertest_base.cc +++ b/chrome/browser/media/webrtc_browsertest_base.cc @@ -23,6 +23,21 @@ const char WebRtcTestBase::kVideoOnlyCallConstraints[] = "'{video: true}'"; const char WebRtcTestBase::kFailedWithPermissionDeniedError[] = "failed-with-error-PermissionDeniedError"; +// Work around an issue where javascript isn't always fully loaded when we +// invoke doGetUserMedia (crbug.com/281268). +static void EnsureOurJavascriptHasBeenLoaded( + content::WebContents* tab_contents) { + const std::string script = + "var gumDefined = typeof(doGetUserMedia) == typeof(Function); " + "window.domAutomationController.send(gumDefined);"; + bool get_user_media_defined = false; + while (!get_user_media_defined) { + EXPECT_TRUE(content::ExecuteScriptAndExtractBool( + tab_contents, script, &get_user_media_defined)); + SleepInJavascript(tab_contents, 100); + } +} + WebRtcTestBase::WebRtcTestBase() { } @@ -81,6 +96,8 @@ void WebRtcTestBase::GetUserMediaAndDismiss( void WebRtcTestBase::GetUserMedia(content::WebContents* tab_contents, const std::string& constraints) const { + EnsureOurJavascriptHasBeenLoaded(tab_contents); + // Request user media: this will launch the media stream info bar. std::string result; EXPECT_TRUE(content::ExecuteScriptAndExtractString( |