diff options
author | yurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-01 10:51:56 +0000 |
---|---|---|
committer | yurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-01 10:51:56 +0000 |
commit | d14a0d6fe722ce04aac8a06f83a5a15d3e45e44a (patch) | |
tree | 9d37aa8673e45624eb6b3d48574ed4456e85b1d0 /chrome/browser/debugger | |
parent | 33f3e1c933e3504b8382ee226f92ef98dcd7d0d3 (diff) | |
download | chromium_src-d14a0d6fe722ce04aac8a06f83a5a15d3e45e44a.zip chromium_src-d14a0d6fe722ce04aac8a06f83a5a15d3e45e44a.tar.gz chromium_src-d14a0d6fe722ce04aac8a06f83a5a15d3e45e44a.tar.bz2 |
DevTools: check that devtools front-end JS files are loaded before running a test, otherwise the test will hang waiting for reponse from the front-end.
Review URL: http://codereview.chromium.org/151143
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19722 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/debugger')
-rw-r--r-- | chrome/browser/debugger/devtools_sanity_unittest.cc | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/chrome/browser/debugger/devtools_sanity_unittest.cc b/chrome/browser/debugger/devtools_sanity_unittest.cc index cf94b5e..ac479e9 100644 --- a/chrome/browser/debugger/devtools_sanity_unittest.cc +++ b/chrome/browser/debugger/devtools_sanity_unittest.cc @@ -56,13 +56,29 @@ class DevToolsSanityTest : public InProcessBrowserTest { void RunTest(const std::string& test_name, const std::wstring& test_page) { OpenDevToolsWindow(test_page); std::string result; + + // At first check that JavaScript part of the front-end is loaded by + // checking that global variable uiTests exists(it's created after all js + // files have been loaded) and has runTest method. ASSERT_TRUE( ui_test_utils::ExecuteJavaScriptAndExtractString( client_contents_, L"", - UTF8ToWide(StringPrintf("uiTests.runTest('%s')", test_name.c_str())), + L"window.domAutomationController.send(" + L"'' + (window.uiTests && (typeof uiTests.runTest)));", &result)); - EXPECT_EQ("[OK]", result); + + if (result == "function") { + ASSERT_TRUE( + ui_test_utils::ExecuteJavaScriptAndExtractString( + client_contents_, + L"", + UTF8ToWide(StringPrintf("uiTests.runTest('%s')", test_name.c_str())), + &result)); + EXPECT_EQ("[OK]", result); + } else { + FAIL() << "DevTools front-end is broken."; + } CloseDevToolsWindow(); } @@ -86,8 +102,11 @@ class DevToolsSanityTest : public InProcessBrowserTest { void CloseDevToolsWindow() { DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); + // UnregisterDevToolsClientHostFor may destroy window_ so store the browser + // first. + Browser* browser = window_->browser(); devtools_manager->UnregisterDevToolsClientHostFor(inspected_rvh_); - BrowserClosedObserver close_observer(window_->browser()); + BrowserClosedObserver close_observer(browser); } TabContents* client_contents_; |