158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// found in the LICENSE file.
458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#ifndef CHROME_BROWSER_EXTENSIONS_BROWSERTEST_UTIL_H_
658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#define CHROME_BROWSER_EXTENSIONS_BROWSERTEST_UTIL_H_
758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include <string>
958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
1058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)class Profile;
1158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
1258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)namespace extensions {
1358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)namespace browsertest_util {
1458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
1558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// Waits until |script| calls "window.domAutomationController.send(result)",
1658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// where |result| is a string, and returns |result|. Fails the test and returns
1758537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// an empty string if |extension_id| isn't installed in |profile| or doesn't
1858537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)// have a background page, or if executing the script fails.
1958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)std::string ExecuteScriptInBackgroundPage(Profile* profile,
2058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)                                          const std::string& extension_id,
2158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)                                          const std::string& script);
2258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
230529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch// Same as ExecuteScriptInBackgroundPage, but doesn't wait for the script
240529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch// to return a result. Fails the test and returns false if |extension_id|
250529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch// isn't installed in |profile| or doesn't have a background page, or if
260529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch// executing the script fails.
270529e5d033099cbfc42635f6f6183833b09dff6eBen Murdochbool ExecuteScriptInBackgroundPageNoWait(Profile* profile,
280529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                                         const std::string& extension_id,
290529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch                                         const std::string& script);
300529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch
3158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)}  // namespace browsertest_util
3258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)}  // namespace extensions
3358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)
3458537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#endif  // CHROME_BROWSER_EXTENSIONS_BROWSERTEST_UTIL_H_
35