Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / extensions / browsertest_util.h
blob435b2b681a11e70e1b93066c6f5525403e8692bf
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_BROWSERTEST_UTIL_H_
6 #define CHROME_BROWSER_EXTENSIONS_BROWSERTEST_UTIL_H_
8 #include <string>
10 class Profile;
12 namespace extensions {
13 namespace browsertest_util {
15 // Waits until |script| calls "window.domAutomationController.send(result)",
16 // where |result| is a string, and returns |result|. Fails the test and returns
17 // an empty string if |extension_id| isn't installed in |profile| or doesn't
18 // have a background page, or if executing the script fails.
19 std::string ExecuteScriptInBackgroundPage(Profile* profile,
20 const std::string& extension_id,
21 const std::string& script);
23 // Same as ExecuteScriptInBackgroundPage, but doesn't wait for the script
24 // to return a result. Fails the test and returns false if |extension_id|
25 // isn't installed in |profile| or doesn't have a background page, or if
26 // executing the script fails.
27 bool ExecuteScriptInBackgroundPageNoWait(Profile* profile,
28 const std::string& extension_id,
29 const std::string& script);
31 } // namespace browsertest_util
32 } // namespace extensions
34 #endif // CHROME_BROWSER_EXTENSIONS_BROWSERTEST_UTIL_H_