| OLD | NEW |
| 1 // Copyright 2008-2009, Google Inc. | 1 // Copyright 2008-2009, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 testing::UnitTest::GetInstance()->current_test_info(); | 73 testing::UnitTest::GetInstance()->current_test_info(); |
| 74 if (strcmp(test_info->name(), "MediaPlayerNew") == 0) { | 74 if (strcmp(test_info->name(), "MediaPlayerNew") == 0) { |
| 75 // The installer adds our process names to the registry key below. Since | 75 // The installer adds our process names to the registry key below. Since |
| 76 // the installer might not have run on this machine, add it manually. | 76 // the installer might not have run on this machine, add it manually. |
| 77 RegKey regkey; | 77 RegKey regkey; |
| 78 if (regkey.Open(HKEY_LOCAL_MACHINE, | 78 if (regkey.Open(HKEY_LOCAL_MACHINE, |
| 79 L"Software\\Microsoft\\MediaPlayer\\ShimInclusionList", | 79 L"Software\\Microsoft\\MediaPlayer\\ShimInclusionList", |
| 80 KEY_WRITE)) { | 80 KEY_WRITE)) { |
| 81 regkey.CreateKey(L"CHROME.EXE", KEY_READ); | 81 regkey.CreateKey(L"CHROME.EXE", KEY_READ); |
| 82 } | 82 } |
| 83 launch_arguments_.AppendSwitch(kNoNativeActiveXShimSwitch); | |
| 84 | |
| 85 } else if (strcmp(test_info->name(), "MediaPlayerOld") == 0) { | 83 } else if (strcmp(test_info->name(), "MediaPlayerOld") == 0) { |
| 86 // When testing the old WMP plugin, we need to force Chrome to not load | 84 // When testing the old WMP plugin, we need to force Chrome to not load |
| 87 // the new plugin. | 85 // the new plugin. |
| 88 launch_arguments_.AppendSwitch(kUseOldWMPPluginSwitch); | 86 launch_arguments_.AppendSwitch(kUseOldWMPPluginSwitch); |
| 89 launch_arguments_.AppendSwitch(kNoNativeActiveXShimSwitch); | |
| 90 } else if (strcmp(test_info->name(), "FlashSecurity") == 0) { | 87 } else if (strcmp(test_info->name(), "FlashSecurity") == 0) { |
| 91 launch_arguments_.AppendSwitchWithValue(switches::kTestSandbox, | 88 launch_arguments_.AppendSwitchWithValue(switches::kTestSandbox, |
| 92 L"security_tests.dll"); | 89 L"security_tests.dll"); |
| 93 } | 90 } |
| 94 | 91 |
| 95 UITest::SetUp(); | 92 UITest::SetUp(); |
| 96 } | 93 } |
| 97 | 94 |
| 98 void TestPlugin(const std::wstring& test_case, | 95 void TestPlugin(const std::wstring& test_case, |
| 99 int timeout, | 96 int timeout, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 } | 173 } |
| 177 | 174 |
| 178 // http://crbug.com/8690 | 175 // http://crbug.com/8690 |
| 179 TEST_F(PluginTest, DISABLED_Java) { | 176 TEST_F(PluginTest, DISABLED_Java) { |
| 180 TestPlugin(L"Java.html", kShortWaitTimeout, false); | 177 TestPlugin(L"Java.html", kShortWaitTimeout, false); |
| 181 } | 178 } |
| 182 | 179 |
| 183 TEST_F(PluginTest, Silverlight) { | 180 TEST_F(PluginTest, Silverlight) { |
| 184 TestPlugin(L"silverlight.html", kShortWaitTimeout, false); | 181 TestPlugin(L"silverlight.html", kShortWaitTimeout, false); |
| 185 } | 182 } |
| 186 | |
| 187 typedef HRESULT (__stdcall* DllRegUnregServerFunc)(); | |
| 188 | |
| 189 class ActiveXTest : public PluginTest { | |
| 190 public: | |
| 191 ActiveXTest() { | |
| 192 dll_registered = false; | |
| 193 } | |
| 194 protected: | |
| 195 void TestActiveX(const std::wstring& test_case, int timeout, bool reg_dll) { | |
| 196 if (reg_dll) { | |
| 197 RegisterTestControl(true); | |
| 198 dll_registered = true; | |
| 199 } | |
| 200 TestPlugin(test_case, timeout, false); | |
| 201 } | |
| 202 virtual void TearDown() { | |
| 203 PluginTest::TearDown(); | |
| 204 if (dll_registered) | |
| 205 RegisterTestControl(false); | |
| 206 } | |
| 207 void RegisterTestControl(bool register_server) { | |
| 208 std::wstring test_control_path = browser_directory_.ToWStringHack() + | |
| 209 L"\\activex_test_control.dll"; | |
| 210 HMODULE h = LoadLibrary(test_control_path.c_str()); | |
| 211 ASSERT_TRUE(h != NULL) << "Failed to load activex_test_control.dll"; | |
| 212 const char* func_name = register_server ? | |
| 213 "DllRegisterServer" : "DllUnregisterServer"; | |
| 214 DllRegUnregServerFunc func = reinterpret_cast<DllRegUnregServerFunc>( | |
| 215 GetProcAddress(h, func_name)); | |
| 216 // This should never happen actually. | |
| 217 ASSERT_TRUE(func != NULL) << "Failed to find reg/unreg function."; | |
| 218 HRESULT hr = func(); | |
| 219 const char* error_message = register_server ? "Failed to register dll." | |
| 220 : "Failed to unregister dll"; | |
| 221 ASSERT_TRUE(SUCCEEDED(hr)) << error_message; | |
| 222 FreeLibrary(h); | |
| 223 } | |
| 224 private: | |
| 225 bool dll_registered; | |
| 226 }; | |
| 227 | |
| 228 TEST_F(ActiveXTest, EmbeddedWMP) { | |
| 229 TestActiveX(L"activex_embedded_wmp.html", kLongWaitTimeout, false); | |
| 230 } | |
| 231 | |
| 232 TEST_F(ActiveXTest, WMP) { | |
| 233 TestActiveX(L"activex_wmp.html", kLongWaitTimeout, false); | |
| 234 } | |
| 235 | |
| 236 TEST_F(ActiveXTest, WMPNoEmbedMimeType) { | |
| 237 TestActiveX(L"activex_wmp_no_embed_mime_type.html", kLongWaitTimeout, false); | |
| 238 } | |
| 239 | |
| 240 TEST_F(ActiveXTest, DISABLED_CustomScripting) { | |
| 241 TestActiveX(L"activex_custom_scripting.html", kShortWaitTimeout, true); | |
| 242 } | |
| 243 | |
| 244 TEST_F(ActiveXTest, DISABLED_EmbeddedMP3) { | |
| 245 TestActiveX(L"mp3_test.html", kLongWaitTimeout, false); | |
| 246 } | |
| 247 | |
| 248 TEST_F(ActiveXTest, DISABLED_EmbeddedMPE) { | |
| 249 TestActiveX(L"mpe_test.html", kLongWaitTimeout, false); | |
| 250 } | |
| 251 | |
| 252 | |
| 253 // The default plugin tests defined below rely on the following webkit | |
| 254 // functions and the IsPluginProcess function which is defined in the global | |
| 255 // namespace. Stubbed these out for now. | |
| 256 namespace webkit_glue { | |
| 257 | |
| 258 bool DownloadUrl(const std::string& url, HWND caller_window) { | |
| 259 return false; | |
| 260 } | |
| 261 | |
| 262 bool GetPluginFinderURL(std::string* plugin_finder_url) { | |
| 263 return true; | |
| 264 } | |
| 265 | |
| 266 } // namespace webkit_glue | |
| 267 | |
| 268 bool IsPluginProcess() { | |
| 269 return false; | |
| 270 } | |
| 271 | |
| 272 TEST_F(PluginTest, DefaultPluginParsingTest) { | |
| 273 PluginInstallerImpl plugin_installer(NP_EMBED); | |
| 274 NPP_t plugin_instance = {0}; | |
| 275 | |
| 276 char *arg_names[] = { | |
| 277 "classid", | |
| 278 "codebase" | |
| 279 }; | |
| 280 | |
| 281 char *arg_values[] = { | |
| 282 "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", | |
| 283 "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab", | |
| 284 }; | |
| 285 | |
| 286 bool is_activex = false; | |
| 287 std::string raw_activex_clsid; | |
| 288 std::string activex_clsid; | |
| 289 std::string activex_codebase; | |
| 290 std::string plugin_download_url; | |
| 291 std::string plugin_finder_url; | |
| 292 | |
| 293 ASSERT_TRUE(PluginInstallerImpl::ParseInstantiationArguments( | |
| 294 "application/x-shockwave-flash", | |
| 295 &plugin_instance, | |
| 296 arraysize(arg_names), | |
| 297 arg_names, | |
| 298 arg_values, | |
| 299 &raw_activex_clsid, | |
| 300 &is_activex, | |
| 301 &activex_clsid, | |
| 302 &activex_codebase, | |
| 303 &plugin_download_url, | |
| 304 &plugin_finder_url)); | |
| 305 | |
| 306 EXPECT_EQ(is_activex, false); | |
| 307 | |
| 308 | |
| 309 ASSERT_TRUE(PluginInstallerImpl::ParseInstantiationArguments( | |
| 310 "", | |
| 311 &plugin_instance, | |
| 312 arraysize(arg_names), | |
| 313 arg_names, | |
| 314 arg_values, | |
| 315 &raw_activex_clsid, | |
| 316 &is_activex, | |
| 317 &activex_clsid, | |
| 318 &activex_codebase, | |
| 319 &plugin_download_url, | |
| 320 &plugin_finder_url)); | |
| 321 | |
| 322 EXPECT_EQ(is_activex, true); | |
| 323 EXPECT_EQ( | |
| 324 activex_codebase, | |
| 325 "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"); | |
| 326 | |
| 327 EXPECT_EQ(activex_clsid, "{D27CDB6E-AE6D-11cf-96B8-444553540000}"); | |
| 328 EXPECT_EQ(raw_activex_clsid, "D27CDB6E-AE6D-11cf-96B8-444553540000"); | |
| 329 | |
| 330 EXPECT_EQ( | |
| 331 activex_codebase, | |
| 332 "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"); | |
| 333 } | |
| OLD | NEW |