summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authorjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-23 19:16:20 +0000
committerjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-23 19:16:20 +0000
commit50f53164ebbceb30b69578e96e863375f5cb4f9b (patch)
tree853541075c0a2ac5adb3d4f3a389401d92405edf /chrome_frame
parent117fd71c37c932c5ffcbf59eb42d118d3dfb431f (diff)
downloadchromium_src-50f53164ebbceb30b69578e96e863375f5cb4f9b.zip
chromium_src-50f53164ebbceb30b69578e96e863375f5cb4f9b.tar.gz
chromium_src-50f53164ebbceb30b69578e96e863375f5cb4f9b.tar.bz2
Enhance extension UI testing by enabling you to select which extension
APIs to forward (and thus stub out in your test), while others will keep being fulfilled as per usual. This lets you build tests that stub out one piece of behavior while testing that some side effects of another API happen as expected. BUG=none TEST=Run ui_tests.exe Review URL: http://codereview.chromium.org/314015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29919 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/chrome_frame_activex.cc13
-rw-r--r--chrome_frame/chrome_frame_automation.cc4
-rw-r--r--chrome_frame/chrome_frame_automation.h11
-rw-r--r--chrome_frame/chrome_frame_npapi.cc11
-rw-r--r--chrome_frame/chrome_frame_npapi_unittest.cc7
-rw-r--r--chrome_frame/chrome_frame_plugin.h9
-rw-r--r--chrome_frame/chrome_tab.idl5
-rw-r--r--chrome_frame/test/chrome_frame_unittests.cc3
8 files changed, 50 insertions, 13 deletions
diff --git a/chrome_frame/chrome_frame_activex.cc b/chrome_frame/chrome_frame_activex.cc
index 78b09fa..16f5dda 100644
--- a/chrome_frame/chrome_frame_activex.cc
+++ b/chrome_frame/chrome_frame_activex.cc
@@ -337,6 +337,19 @@ HRESULT ChromeFrameActivex::IOleObject_SetClientSite(
chrome_extra_arguments.assign(extra_arguments_arg,
extra_arguments_arg.Length());
+ ScopedBstr automated_functions_arg;
+ service_hr = service->GetExtensionApisToAutomate(
+ automated_functions_arg.Receive());
+ if (S_OK == service_hr && automated_functions_arg) {
+ std::string automated_functions(
+ WideToASCII(static_cast<BSTR>(automated_functions_arg)));
+ functions_enabled_.clear();
+ // SplitString writes one empty entry for blank strings, so we need this
+ // to allow specifying zero automation of API functions.
+ if (!automated_functions.empty())
+ SplitString(automated_functions, ',', &functions_enabled_);
+ }
+
ScopedBstr profile_name_arg;
service_hr = service->GetChromeProfileName(profile_name_arg.Receive());
if (S_OK == service_hr && profile_name_arg)
diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc
index 17fb43d..2d22bbd 100644
--- a/chrome_frame/chrome_frame_automation.cc
+++ b/chrome_frame/chrome_frame_automation.cc
@@ -738,11 +738,11 @@ void ChromeFrameAutomationClient::CreateExternalTabComplete(HWND chrome_window,
}
void ChromeFrameAutomationClient::SetEnableExtensionAutomation(
- bool enable_automation) {
+ const std::vector<std::string>& functions_enabled) {
if (!is_initialized())
return;
- automation_server_->SetEnableExtensionAutomation(enable_automation);
+ automation_server_->SetEnableExtensionAutomation(functions_enabled);
}
// Invoked in launch background thread.
diff --git a/chrome_frame/chrome_frame_automation.h b/chrome_frame/chrome_frame_automation.h
index e1a34d7..6eca88d 100644
--- a/chrome_frame/chrome_frame_automation.h
+++ b/chrome_frame/chrome_frame_automation.h
@@ -41,7 +41,8 @@ struct DECLSPEC_NOVTABLE ChromeFrameAutomationProxy {
virtual std::string server_version() = 0;
virtual void SendProxyConfig(const std::string&) = 0;
- virtual void SetEnableExtensionAutomation(bool enable) = 0;
+ virtual void SetEnableExtensionAutomation(
+ const std::vector<std::string>& functions_enabled) = 0;
protected:
~ChromeFrameAutomationProxy() {}
};
@@ -72,8 +73,9 @@ class ChromeFrameAutomationProxyImpl : public ChromeFrameAutomationProxy,
AutomationProxy::SendProxyConfig(p);
}
- virtual void SetEnableExtensionAutomation(bool e) {
- AutomationProxy::SetEnableExtensionAutomation(e);
+ virtual void SetEnableExtensionAutomation(
+ const std::vector<std::string>& functions_enabled) {
+ AutomationProxy::SetEnableExtensionAutomation(functions_enabled);
}
protected:
@@ -202,7 +204,8 @@ class ChromeFrameAutomationClient
const std::string& target);
bool SetProxySettings(const std::string& json_encoded_proxy_settings);
- virtual void SetEnableExtensionAutomation(bool enable_automation);
+ virtual void SetEnableExtensionAutomation(
+ const std::vector<std::string>& functions_enabled);
void FindInPage(const std::wstring& search_string,
FindInPageDirection forward,
diff --git a/chrome_frame/chrome_frame_npapi.cc b/chrome_frame/chrome_frame_npapi.cc
index 6c9791f..ec324e0 100644
--- a/chrome_frame/chrome_frame_npapi.cc
+++ b/chrome_frame/chrome_frame_npapi.cc
@@ -102,6 +102,10 @@ static const char kPluginChromeExtraArguments[] = "chrome_extra_arguments";
// If privileged mode is enabled, the string value of this argument will
// be used as the profile name for our chrome.exe instance.
static const char kPluginChromeProfileName[] = "chrome_profile_name";
+// If privileged mode is enabled, this argument will be taken as a
+// comma-separated list of API function calls to automate.
+static const char kPluginChromeFunctionsAutomatedAttribute[] =
+ "chrome_functions_automated";
// If chrome network stack is to be used
static const char kPluginUseChromeNetwork[] = "usechromenetwork";
@@ -377,6 +381,13 @@ bool ChromeFrameNPAPI::Initialize(NPMIMEType mime_type, NPP instance,
chrome_extra_arguments_arg = argv[i];
} else if (LowerCaseEqualsASCII(argn[i], kPluginChromeProfileName)) {
chrome_profile_name_arg = argv[i];
+ } else if (LowerCaseEqualsASCII(argn[i],
+ kPluginChromeFunctionsAutomatedAttribute)) {
+ functions_enabled_.clear();
+ // SplitString writes one empty entry for blank strings, so we need this
+ // to allow specifying zero automation of API functions.
+ if (argv[i][0] != '\0')
+ SplitString(argv[i], ',', &functions_enabled_);
} else if (LowerCaseEqualsASCII(argn[i], kPluginUseChromeNetwork)) {
chrome_network_arg_set = true;
chrome_network_arg = atoi(argv[i]) ? true : false;
diff --git a/chrome_frame/chrome_frame_npapi_unittest.cc b/chrome_frame/chrome_frame_npapi_unittest.cc
index d2c9b4e..b30d5e8 100644
--- a/chrome_frame/chrome_frame_npapi_unittest.cc
+++ b/chrome_frame/chrome_frame_npapi_unittest.cc
@@ -83,7 +83,8 @@ class MockAutomationClient: public ChromeFrameAutomationClient {
MOCK_METHOD6(Initialize, bool(ChromeFrameDelegate*, int, bool,
const std::wstring&, const std::wstring&,
bool));
- MOCK_METHOD1(SetEnableExtensionAutomation, void(bool)); // NOLINT
+ MOCK_METHOD1(SetEnableExtensionAutomation,
+ void(const std::vector<std::string>&)); // NOLINT
};
class MockProxyService: public NpProxyService {
@@ -219,7 +220,7 @@ TEST_F(TestNPAPIPrivilegedApi, PrivilegedAllowsArgsAndProfile) {
L"-bar=far"); // Extra arguments expected
// With privileged mode we expect automation to be enabled.
- EXPECT_CALL(*mock_automation, SetEnableExtensionAutomation(true))
+ EXPECT_CALL(*mock_automation, SetEnableExtensionAutomation(_))
.Times(1);
char* argn[] = {
@@ -386,7 +387,7 @@ class TestNPAPIPrivilegedProperty: public TestNPAPIPrivilegedApi {
// And we should expect SetEnableExtensionAutomation to be called
// for privileged tests.
- EXPECT_CALL(*mock_automation, SetEnableExtensionAutomation(true))
+ EXPECT_CALL(*mock_automation, SetEnableExtensionAutomation(_))
.WillRepeatedly(Return());
// Initializes identifiers.
diff --git a/chrome_frame/chrome_frame_plugin.h b/chrome_frame/chrome_frame_plugin.h
index b0814bb..fbc3f77 100644
--- a/chrome_frame/chrome_frame_plugin.h
+++ b/chrome_frame/chrome_frame_plugin.h
@@ -19,6 +19,7 @@ class ChromeFramePlugin : public ChromeFrameDelegateImpl {
ChromeFramePlugin()
: ignore_setfocus_(false),
is_privileged_(false) {
+ functions_enabled_.push_back("*");
}
~ChromeFramePlugin() {
Uninitialize();
@@ -78,7 +79,7 @@ END_MSG_MAP()
// Issue the extension automation request if we're privileged to
// allow this control to handle extension requests from Chrome.
if (is_privileged_)
- automation_client_->SetEnableExtensionAutomation(true);
+ automation_client_->SetEnableExtensionAutomation(functions_enabled_);
}
virtual bool IsValid() const {
@@ -170,7 +171,7 @@ END_MSG_MAP()
// modified as well (enable/disable commands, add/remove items).
// Override in most-derived class if needed.
bool PreProcessContextMenu(HMENU menu) {
- // Add an "About" item.
+ // Add an "About" item.
// TODO: The string should be localized and menu should
// be modified in ExternalTabContainer:: once we go public.
AppendMenu(menu, MF_STRING, IDC_ABOUT_CHROME_FRAME,
@@ -208,6 +209,10 @@ END_MSG_MAP()
//
// When privileged, additional interfaces are made available to the user.
bool is_privileged_;
+
+ // List of functions to enable for automation, or a single entry "*" to enable
+ // all functions for automation. Ignored unless is_privileged_ is true.
+ std::vector<std::string> functions_enabled_;
};
#endif // CHROME_FRAME_CHROME_FRAME_PLUGIN_H_
diff --git a/chrome_frame/chrome_tab.idl b/chrome_frame/chrome_tab.idl
index afb364e..c234c29 100644
--- a/chrome_frame/chrome_tab.idl
+++ b/chrome_frame/chrome_tab.idl
@@ -77,7 +77,7 @@ interface IChromeFrame : IDispatch {
[
object,
- uuid(679E292F-DBAB-46b8-8693-03084CEF61BE),
+ uuid(655A11E0-EF63-4fbe-9DF6-C182D2FCD6DC),
oleautomation,
nonextensible,
hidden,
@@ -91,6 +91,9 @@ interface IChromeFramePrivileged: IUnknown {
HRESULT GetChromeExtraArguments([out] BSTR *args);
// The profile name we want to use.
HRESULT GetChromeProfileName([out] BSTR *profile_name);
+ // The comma-separated list of extension API functions you wish to automate.
+ // Return S_FALSE to leave the default, which is to automate all functions.
+ HRESULT GetExtensionApisToAutomate([out] BSTR *extension_apis);
};
// Expose this service to the ChromeFrame control to trigger privileged
diff --git a/chrome_frame/test/chrome_frame_unittests.cc b/chrome_frame/test/chrome_frame_unittests.cc
index 5bf33c1..37be881 100644
--- a/chrome_frame/test/chrome_frame_unittests.cc
+++ b/chrome_frame/test/chrome_frame_unittests.cc
@@ -790,7 +790,8 @@ class MockAutomationProxy : public ChromeFrameAutomationProxy {
MOCK_METHOD1(CreateTabProxy, scoped_refptr<TabProxy>(int handle));
MOCK_METHOD0(server_version, std::string(void));
MOCK_METHOD1(SendProxyConfig, void(const std::string&));
- MOCK_METHOD1(SetEnableExtensionAutomation, void(bool enable));
+ MOCK_METHOD1(SetEnableExtensionAutomation,
+ void(const std::vector<std::string>&));
~MockAutomationProxy() {}
};