encrypted_media_istypesupported_browsertest.cc revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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. 4 5#include <string> 6#include <vector> 7 8#include "base/base_switches.h" 9#include "base/command_line.h" 10#include "base/files/file_path.h" 11#include "base/path_service.h" 12#include "base/strings/utf_string_conversions.h" 13#include "chrome/browser/ui/browser.h" 14#include "chrome/browser/ui/tabs/tab_strip_model.h" 15#include "chrome/common/chrome_paths.h" 16#include "chrome/test/base/in_process_browser_test.h" 17#include "chrome/test/base/ui_test_utils.h" 18#include "content/public/common/content_switches.h" 19#include "content/public/test/browser_test_utils.h" 20#include "url/gurl.h" 21 22#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. 23 24#if defined(USE_PROPRIETARY_CODECS) 25#define EXPECT_PROPRIETARY EXPECT_TRUE 26#else 27#define EXPECT_PROPRIETARY EXPECT_FALSE 28#endif 29 30// Expectations for External Clear Key. 31#if defined(ENABLE_PEPPER_CDMS) 32#define EXPECT_ECK EXPECT_TRUE 33#define EXPECT_ECKPROPRIETARY EXPECT_PROPRIETARY 34#else 35#define EXPECT_ECK EXPECT_FALSE 36#define EXPECT_ECKPROPRIETARY EXPECT_FALSE 37#endif // defined(ENABLE_PEPPER_CDMS) 38 39// Expectations for Widevine. 40// Note: Widevine is not available on platforms using components because 41// RegisterPepperCdm() cannot set the codecs. 42// TODO(ddorwin): Enable these tests after we have the ability to use the CUS 43// in these tests. See http://crbug.com/311724. 44#if defined(WIDEVINE_CDM_AVAILABLE) && !defined(WIDEVINE_CDM_IS_COMPONENT) 45#define EXPECT_WV EXPECT_TRUE 46 47#if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) 48#define EXPECT_WVMP4 EXPECT_TRUE 49#define EXPECT_WVAVC1 EXPECT_TRUE 50#if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) 51#define EXPECT_WVAVC1AAC EXPECT_TRUE 52#else 53#define EXPECT_WVAVC1AAC EXPECT_FALSE 54#endif // defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) 55#else // !defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) 56#define EXPECT_WVMP4 EXPECT_FALSE 57#define EXPECT_WVAVC1 EXPECT_FALSE 58#define EXPECT_WVAVC1AAC EXPECT_FALSE 59#endif // defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE) 60 61#if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE) 62#define EXPECT_WVAAC EXPECT_TRUE 63#else 64#define EXPECT_WVAAC EXPECT_FALSE 65#endif 66 67#else // defined(WIDEVINE_CDM_AVAILABLE) && !defined(WIDEVINE_CDM_IS_COMPONENT) 68#define EXPECT_WV EXPECT_FALSE 69#define EXPECT_WVMP4 EXPECT_FALSE 70#define EXPECT_WVAVC1 EXPECT_FALSE 71#define EXPECT_WVAVC1AAC EXPECT_FALSE 72#define EXPECT_WVAAC EXPECT_FALSE 73#endif // defined(WIDEVINE_CDM_AVAILABLE) && 74 // !defined(WIDEVINE_CDM_IS_COMPONENT) 75 76namespace chrome { 77 78const char kPrefixedClearKey[] = "webkit-org.w3.clearkey"; 79const char kPrefixedClearKeyParent[] = "webkit-org.w3"; 80// TODO(ddorwin): Duplicate prefixed tests for unprefixed. 81const char kUnprefixedClearKey[] = "org.w3.clearkey"; 82const char kExternalClearKey[] = "org.chromium.externalclearkey"; 83const char kWidevineAlpha[] = "com.widevine.alpha"; 84const char kWidevine[] = "com.widevine"; 85const char kWidevineAlphaHr[] = "com.widevine.alpha.hr"; 86const char kWidevineAlphaHrNonCompositing[] = 87 "com.widevine.alpha.hrnoncompositing"; 88 89class EncryptedMediaIsTypeSupportedTest : public InProcessBrowserTest { 90 protected: 91 EncryptedMediaIsTypeSupportedTest() 92 : is_test_page_loaded_(false), is_pepper_cdm_registered_(false) { 93 vp8_codec_.push_back("vp8"); 94 95 vp80_codec_.push_back("vp8.0"); 96 97 vorbis_codec_.push_back("vorbis"); 98 99 vp8_and_vorbis_codecs_.push_back("vp8"); 100 vp8_and_vorbis_codecs_.push_back("vorbis"); 101 102 avc1_codec_.push_back("avc1"); 103 104 avc1_extended_codec_.push_back("avc1.4D400C"); 105 106 avc1_dot_codec_.push_back("avc1."); 107 108 avc2_codec_.push_back("avc2"); 109 110 avc3_codec_.push_back("avc3"); 111 112 avc3_extended_codec_.push_back("avc3.64001f"); 113 114 aac_codec_.push_back("mp4a"); 115 116 avc1_and_aac_codecs_.push_back("avc1"); 117 avc1_and_aac_codecs_.push_back("mp4a"); 118 119 unknown_codec_.push_back("foo"); 120 121 mixed_codecs_.push_back("vorbis"); 122 mixed_codecs_.push_back("avc1"); 123 } 124 125 typedef std::vector<std::string> CodecVector; 126 127 const CodecVector& no_codecs() const { return no_codecs_; } 128 const CodecVector& vp8_codec() const { return vp8_codec_; } 129 const CodecVector& vp80_codec() const { return vp80_codec_; } 130 const CodecVector& vorbis_codec() const { return vorbis_codec_; } 131 const CodecVector& vp8_and_vorbis_codecs() const { 132 return vp8_and_vorbis_codecs_; 133 } 134 const CodecVector& avc1_codec() const { return avc1_codec_; } 135 const CodecVector& avc1_extended_codec() const { 136 return avc1_extended_codec_; 137 } 138 const CodecVector& avc1_dot_codec() const { return avc1_dot_codec_; } 139 const CodecVector& avc2_codec() const { return avc2_codec_; } 140 const CodecVector& avc3_codec() const { return avc3_codec_; } 141 const CodecVector& avc3_extended_codec() const { 142 return avc3_extended_codec_; 143 } 144 const CodecVector& aac_codec() const { return aac_codec_; } 145 const CodecVector& avc1_and_aac_codecs() const { 146 return avc1_and_aac_codecs_; 147 } 148 const CodecVector& unknown_codec() const { return unknown_codec_; } 149 const CodecVector& mixed_codecs() const { return mixed_codecs_; } 150 151 // Update the command line to load |adapter_name| for 152 // |pepper_type_for_key_system|. 153 void RegisterPepperCdm(CommandLine* command_line, 154 const std::string& adapter_name, 155 const std::string& pepper_type_for_key_system, 156 bool expect_adapter_exists = true) { 157 DCHECK(!is_pepper_cdm_registered_) 158 << "RegisterPepperCdm() can only be called once."; 159 is_pepper_cdm_registered_ = true; 160 161 // Append the switch to register the appropriate adapter. 162 base::FilePath plugin_dir; 163 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir)); 164 base::FilePath plugin_lib = plugin_dir.AppendASCII(adapter_name); 165 EXPECT_EQ(expect_adapter_exists, base::PathExists(plugin_lib)); 166 base::FilePath::StringType pepper_plugin = plugin_lib.value(); 167 pepper_plugin.append(FILE_PATH_LITERAL("#CDM#0.1.0.0;")); 168#if defined(OS_WIN) 169 pepper_plugin.append(base::ASCIIToWide(pepper_type_for_key_system)); 170#else 171 pepper_plugin.append(pepper_type_for_key_system); 172#endif 173 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, 174 pepper_plugin); 175 } 176 177 void LoadTestPage() { 178 // Load the test page needed. IsConcreteSupportedKeySystem() needs some 179 // JavaScript and a video loaded in order to work. 180 if (!is_test_page_loaded_) { 181 ASSERT_TRUE(test_server()->Start()); 182 GURL gurl = test_server()->GetURL( 183 "files/media/test_key_system_instantiation.html"); 184 ui_test_utils::NavigateToURL(browser(), gurl); 185 is_test_page_loaded_ = true; 186 } 187 } 188 189 bool IsConcreteSupportedKeySystem(const std::string& key) { 190 std::string command( 191 "window.domAutomationController.send(testKeySystemInstantiation('"); 192 command.append(key); 193 command.append("'));"); 194 195 // testKeySystemInstantiation() is a JavaScript function which needs to 196 // be loaded. 197 LoadTestPage(); 198 199 std::string result; 200 EXPECT_TRUE(content::ExecuteScriptAndExtractString( 201 browser()->tab_strip_model()->GetActiveWebContents(), 202 command, 203 &result)); 204 CHECK(result == "success" || result == "NotSupportedError") << result; 205 return (result == "success"); 206 } 207 208 bool IsSupportedKeySystemWithMediaMimeType(const std::string& type, 209 const CodecVector& codecs, 210 const std::string& keySystem) { 211 std::string command("document.createElement('video').canPlayType("); 212 if (type.empty()) { 213 // Simple case, pass "null" as first argument. 214 command.append("null"); 215 DCHECK(codecs.empty()); 216 } else { 217 command.append("'"); 218 command.append(type); 219 if (!codecs.empty()) { 220 command.append("; codecs=\""); 221 for (CodecVector::const_iterator it = codecs.begin(); 222 it != codecs.end(); 223 ++it) { 224 command.append(*it); 225 command.append(","); 226 } 227 command.replace(command.length() - 1, 1, "\""); 228 } 229 command.append("'"); 230 } 231 command.append(",'"); 232 command.append(keySystem); 233 command.append("')"); 234 235 std::string result; 236 EXPECT_TRUE(content::ExecuteScriptAndExtractString( 237 browser()->tab_strip_model()->GetActiveWebContents(), 238 "window.domAutomationController.send(" + command + ");", 239 &result)); 240 return (result == "maybe" || result == "probably"); 241 } 242 243 private: 244 const CodecVector no_codecs_; 245 CodecVector vp8_codec_; 246 CodecVector vp80_codec_; 247 CodecVector vorbis_codec_; 248 CodecVector vp8_and_vorbis_codecs_; 249 CodecVector avc1_codec_; 250 CodecVector avc1_extended_codec_; 251 CodecVector avc1_dot_codec_; 252 CodecVector avc2_codec_; 253 CodecVector avc3_codec_; 254 CodecVector avc3_extended_codec_; 255 CodecVector aac_codec_; 256 CodecVector avc1_and_aac_codecs_; 257 CodecVector unknown_codec_; 258 CodecVector mixed_codecs_; 259 bool is_test_page_loaded_; 260 bool is_pepper_cdm_registered_; 261}; 262 263// For ExternalClearKey tests, ensure that the ClearKey adapter is loaded. 264class EncryptedMediaIsTypeSupportedExternalClearKeyTest 265 : public EncryptedMediaIsTypeSupportedTest { 266#if defined(ENABLE_PEPPER_CDMS) 267 protected: 268 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 269 // Platform-specific filename relative to the chrome executable. 270 const char adapter_file_name[] = 271#if defined(OS_MACOSX) 272 "clearkeycdmadapter.plugin"; 273#elif defined(OS_WIN) 274 "clearkeycdmadapter.dll"; 275#elif defined(OS_POSIX) 276 "libclearkeycdmadapter.so"; 277#endif 278 279 const std::string pepper_name("application/x-ppapi-clearkey-cdm"); 280 RegisterPepperCdm(command_line, adapter_file_name, pepper_name); 281 } 282#endif // defined(ENABLE_PEPPER_CDMS) 283}; 284 285// For Widevine tests, ensure that the Widevine adapter is loaded. 286class EncryptedMediaIsTypeSupportedWidevineTest 287 : public EncryptedMediaIsTypeSupportedTest { 288#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \ 289 defined(WIDEVINE_CDM_IS_COMPONENT) 290 protected: 291 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 292 // File name of the adapter on different platforms. 293 const char adapter_file_name[] = 294#if defined(OS_MACOSX) 295 "widevinecdmadapter.plugin"; 296#elif defined(OS_WIN) 297 "widevinecdmadapter.dll"; 298#else // OS_LINUX, etc. 299 "libwidevinecdmadapter.so"; 300#endif 301 302 const std::string pepper_name("application/x-ppapi-widevine-cdm"); 303 RegisterPepperCdm(command_line, adapter_file_name, pepper_name); 304 } 305#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && 306 // defined(WIDEVINE_CDM_IS_COMPONENT) 307}; 308 309#if defined(ENABLE_PEPPER_CDMS) 310// Registers ClearKey CDM with the wrong path (filename). 311class EncryptedMediaIsTypeSupportedClearKeyCDMRegisteredWithWrongPathTest 312 : public EncryptedMediaIsTypeSupportedTest { 313 protected: 314 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 315 RegisterPepperCdm(command_line, 316 "clearkeycdmadapterwrongname.dll", 317 "application/x-ppapi-clearkey-cdm", 318 false); 319 } 320}; 321 322// Registers Widevine CDM with the wrong path (filename). 323class EncryptedMediaIsTypeSupportedWidevineCDMRegisteredWithWrongPathTest 324 : public EncryptedMediaIsTypeSupportedTest { 325 protected: 326 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 327 RegisterPepperCdm(command_line, 328 "widevinecdmadapterwrongname.dll", 329 "application/x-ppapi-widevine-cdm", 330 false); 331 } 332}; 333#endif // defined(ENABLE_PEPPER_CDMS) 334 335IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedTest, ClearKey_Basic) { 336 EXPECT_TRUE(IsConcreteSupportedKeySystem(kPrefixedClearKey)); 337 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 338 "video/webm", no_codecs(), kPrefixedClearKey)); 339 340 // Not yet out from behind the vendor prefix. 341 EXPECT_FALSE(IsConcreteSupportedKeySystem(kUnprefixedClearKey)); 342 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 343 "video/webm", no_codecs(), kUnprefixedClearKey)); 344} 345 346IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedTest, ClearKey_Parent) { 347 // The parent should be supported but is not. See http://crbug.com/164303. 348 EXPECT_FALSE(IsConcreteSupportedKeySystem(kPrefixedClearKeyParent)); 349 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 350 "video/webm", no_codecs(), kPrefixedClearKeyParent)); 351} 352 353IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedTest, 354 ClearKey_IsSupportedKeySystem_InvalidVariants) { 355 // Case sensitive. 356 EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.ClEaRkEy")); 357 // This should fail, but currently canPlayType() converts it to lowercase. 358 // See http://crbug.com/286036. 359 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 360 "video/webm", no_codecs(), "webkit-org.w3.ClEaRkEy")); 361 362 // TLDs are not allowed. 363 EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.")); 364 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 365 "video/webm", no_codecs(), "webkit-org.")); 366 EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org")); 367 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 368 "video/webm", no_codecs(), "webkit-org")); 369 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.")); 370 EXPECT_FALSE( 371 IsSupportedKeySystemWithMediaMimeType("video/webm", no_codecs(), "org.")); 372 EXPECT_FALSE(IsConcreteSupportedKeySystem("org")); 373 EXPECT_FALSE( 374 IsSupportedKeySystemWithMediaMimeType("video/webm", no_codecs(), "org")); 375 376 // Extra period. 377 EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.")); 378 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 379 "video/webm", no_codecs(), "webkit-org.w3.")); 380 381 // Incomplete. 382 EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.clearke")); 383 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 384 "video/webm", no_codecs(), "webkit-org.w3.clearke")); 385 386 // Extra character. 387 EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.clearkeyz")); 388 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 389 "video/webm", no_codecs(), "webkit-org.w3.clearkeyz")); 390 391 // There are no child key systems for Clear Key. 392 EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.clearkey.foo")); 393 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 394 "video/webm", no_codecs(), "webkit-org.w3.clearkey.foo")); 395} 396 397IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedTest, 398 IsSupportedKeySystemWithMediaMimeType_ClearKey_NoType) { 399 // These two should be true. See http://crbug.com/164303. 400 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 401 std::string(), no_codecs(), kPrefixedClearKey)); 402 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 403 std::string(), no_codecs(), kPrefixedClearKeyParent)); 404 405 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 406 std::string(), no_codecs(), "webkit-org.w3.foo")); 407 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 408 std::string(), no_codecs(), "webkit-org.w3.clearkey.foo")); 409} 410 411IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedTest, 412 IsSupportedKeySystemWithMediaMimeType_ClearKey_WebM) { 413 // Valid video types. 414 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 415 "video/webm", no_codecs(), kPrefixedClearKey)); 416 // The parent should be supported but is not. See http://crbug.com/164303. 417 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 418 "video/webm", no_codecs(), kPrefixedClearKeyParent)); 419 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 420 "video/webm", vp8_codec(), kPrefixedClearKey)); 421 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 422 "video/webm", vp80_codec(), kPrefixedClearKey)); 423 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 424 "video/webm", vp8_and_vorbis_codecs(), kPrefixedClearKey)); 425 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 426 "video/webm", vorbis_codec(), kPrefixedClearKey)); 427 428 // Non-Webm codecs. 429 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 430 "video/webm", avc1_codec(), kPrefixedClearKey)); 431 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 432 "video/webm", unknown_codec(), kPrefixedClearKey)); 433 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 434 "video/webm", mixed_codecs(), kPrefixedClearKey)); 435 436 // Valid audio types. 437 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 438 "audio/webm", no_codecs(), kPrefixedClearKey)); 439 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 440 "audio/webm", vorbis_codec(), kPrefixedClearKey)); 441 442 // Non-audio codecs. 443 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 444 "audio/webm", vp8_codec(), kPrefixedClearKey)); 445 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 446 "audio/webm", vp8_and_vorbis_codecs(), kPrefixedClearKey)); 447 448 // Non-Webm codec. 449 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 450 "audio/webm", aac_codec(), kPrefixedClearKey)); 451} 452 453IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedTest, 454 IsSupportedKeySystemWithMediaMimeType_ClearKey_MP4) { 455 // Valid video types. 456 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( 457 "video/mp4", no_codecs(), kPrefixedClearKey)); 458 // The parent should be supported but is not. See http://crbug.com/164303. 459 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 460 "video/mp4", no_codecs(), kPrefixedClearKeyParent)); 461 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( 462 "video/mp4", avc1_codec(), kPrefixedClearKey)); 463 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( 464 "video/mp4", avc1_and_aac_codecs(), kPrefixedClearKey)); 465 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( 466 "video/mp4", avc3_codec(), kPrefixedClearKey)); 467 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( 468 "video/mp4", aac_codec(), kPrefixedClearKey)); 469 470 // Extended codecs. 471 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( 472 "video/mp4", avc1_extended_codec(), kPrefixedClearKey)); 473 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( 474 "video/mp4", avc3_extended_codec(), kPrefixedClearKey)); 475 476 // Invalid codec format, but canPlayType() strips away the period. 477 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( 478 "video/mp4", avc1_dot_codec(), kPrefixedClearKey)); 479 480 // Non-MP4 codecs. 481 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 482 "video/mp4", avc2_codec(), kPrefixedClearKey)); 483 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 484 "video/mp4", vp8_codec(), kPrefixedClearKey)); 485 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 486 "video/mp4", unknown_codec(), kPrefixedClearKey)); 487 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 488 "video/mp4", mixed_codecs(), kPrefixedClearKey)); 489 490 // Valid audio types. 491 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( 492 "audio/mp4", no_codecs(), kPrefixedClearKey)); 493 EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType( 494 "audio/mp4", aac_codec(), kPrefixedClearKey)); 495 496 // Non-audio codecs. 497 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 498 "audio/mp4", avc1_codec(), kPrefixedClearKey)); 499 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 500 "audio/mp4", avc1_and_aac_codecs(), kPrefixedClearKey)); 501 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 502 "audio/mp4", avc3_codec(), kPrefixedClearKey)); 503 504 // Non-MP4 codec. 505 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 506 "audio/mp4", vorbis_codec(), kPrefixedClearKey)); 507} 508 509// 510// External Clear Key 511// 512 513// When defined(ENABLE_PEPPER_CDMS), this also tests the Pepper CDM check. 514IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedExternalClearKeyTest, 515 ExternalClearKey_Basic) { 516 EXPECT_ECK(IsConcreteSupportedKeySystem(kExternalClearKey)); 517 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( 518 "video/webm", no_codecs(), kExternalClearKey)); 519} 520 521IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedExternalClearKeyTest, 522 ExternalClearKey_Parent) { 523 const char* const kExternalClearKeyParent = "org.chromium"; 524 525 // The parent should be supported but is not. See http://crbug.com/164303. 526 EXPECT_FALSE(IsConcreteSupportedKeySystem(kExternalClearKeyParent)); 527 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 528 "video/webm", no_codecs(), kExternalClearKeyParent)); 529} 530 531IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedExternalClearKeyTest, 532 ExternalClearKey_IsSupportedKeySystem_InvalidVariants) { 533 // Case sensitive. 534 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.chromium.ExTeRnAlClEaRkEy")); 535 // This should fail, but currently canPlayType() converts it to lowercase. 536 // See http://crbug.com/286036. 537 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 538 "video/webm", no_codecs(), "org.chromium.ExTeRnAlClEaRkEy")); 539 540 // TLDs are not allowed. 541 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.")); 542 EXPECT_FALSE( 543 IsSupportedKeySystemWithMediaMimeType("video/webm", no_codecs(), "org.")); 544 EXPECT_FALSE(IsConcreteSupportedKeySystem("org")); 545 EXPECT_FALSE( 546 IsSupportedKeySystemWithMediaMimeType("video/webm", no_codecs(), "org")); 547 548 // Extra period. 549 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.chromium.")); 550 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 551 "video/webm", no_codecs(), "org.chromium.")); 552 553 // Incomplete. 554 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.chromium.externalclearke")); 555 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 556 "video/webm", no_codecs(), "org.chromium.externalclearke")); 557 558 // Extra character. 559 EXPECT_FALSE(IsConcreteSupportedKeySystem("org.chromium.externalclearkeyz")); 560 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 561 "video/webm", no_codecs(), "org.chromium.externalclearkeyz")); 562 563 // There are no child key systems for Clear Key. 564 EXPECT_FALSE( 565 IsConcreteSupportedKeySystem("org.chromium.externalclearkey.foo")); 566 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 567 "video/webm", no_codecs(), "org.chromium.externalclearkey.foo")); 568} 569 570IN_PROC_BROWSER_TEST_F( 571 EncryptedMediaIsTypeSupportedExternalClearKeyTest, 572 IsSupportedKeySystemWithMediaMimeType_ExternalClearKey_NoType) { 573 // These two should be true. See http://crbug.com/164303. 574 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 575 std::string(), no_codecs(), kExternalClearKey)); 576 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 577 std::string(), no_codecs(), "org.chromium")); 578 579 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 580 std::string(), no_codecs(), "org.chromium.foo")); 581 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 582 std::string(), no_codecs(), "org.chromium.externalclearkey.foo")); 583} 584 585IN_PROC_BROWSER_TEST_F( 586 EncryptedMediaIsTypeSupportedExternalClearKeyTest, 587 IsSupportedKeySystemWithMediaMimeType_ExternalClearKey_WebM) { 588 // Valid video types. 589 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( 590 "video/webm", no_codecs(), kExternalClearKey)); 591 // The parent should be supported but is not. See http://crbug.com/164303. 592 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 593 "video/webm", no_codecs(), "org.chromium")); 594 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( 595 "video/webm", vp8_codec(), kExternalClearKey)); 596 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( 597 "video/webm", vp80_codec(), kExternalClearKey)); 598 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( 599 "video/webm", vp8_and_vorbis_codecs(), kExternalClearKey)); 600 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( 601 "video/webm", vorbis_codec(), kExternalClearKey)); 602 603 // Non-Webm codecs. 604 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 605 "video/webm", avc1_codec(), kExternalClearKey)); 606 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 607 "video/webm", unknown_codec(), kExternalClearKey)); 608 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 609 "video/webm", mixed_codecs(), kExternalClearKey)); 610 611 // Valid audio types. 612 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( 613 "audio/webm", no_codecs(), kExternalClearKey)); 614 EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType( 615 "audio/webm", vorbis_codec(), kExternalClearKey)); 616 617 // Non-audio codecs. 618 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 619 "audio/webm", vp8_codec(), kExternalClearKey)); 620 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 621 "audio/webm", vp8_and_vorbis_codecs(), kExternalClearKey)); 622 623 // Non-Webm codec. 624 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 625 "audio/webm", aac_codec(), kExternalClearKey)); 626} 627 628IN_PROC_BROWSER_TEST_F( 629 EncryptedMediaIsTypeSupportedExternalClearKeyTest, 630 IsSupportedKeySystemWithMediaMimeType_ExternalClearKey_MP4) { 631 // Valid video types. 632 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( 633 "video/mp4", no_codecs(), kExternalClearKey)); 634 // The parent should be supported but is not. See http://crbug.com/164303. 635 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 636 "video/mp4", no_codecs(), "org.chromium")); 637 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( 638 "video/mp4", avc1_codec(), kExternalClearKey)); 639 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( 640 "video/mp4", avc1_and_aac_codecs(), kExternalClearKey)); 641 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( 642 "video/mp4", avc3_codec(), kExternalClearKey)); 643 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( 644 "video/mp4", aac_codec(), kExternalClearKey)); 645 646 // Extended codecs. 647 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( 648 "video/mp4", avc1_extended_codec(), kExternalClearKey)); 649 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( 650 "video/mp4", avc3_extended_codec(), kExternalClearKey)); 651 652 // Invalid codec format, but canPlayType() strips away the period. 653 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( 654 "video/mp4", avc1_dot_codec(), kExternalClearKey)); 655 656 // Non-MP4 codecs. 657 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 658 "video/mp4", avc2_codec(), kExternalClearKey)); 659 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 660 "video/mp4", vp8_codec(), kExternalClearKey)); 661 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 662 "video/mp4", unknown_codec(), kExternalClearKey)); 663 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 664 "video/mp4", mixed_codecs(), kExternalClearKey)); 665 666 // Valid audio types. 667 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( 668 "audio/mp4", no_codecs(), kExternalClearKey)); 669 EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType( 670 "audio/mp4", aac_codec(), kExternalClearKey)); 671 672 // Non-audio codecs. 673 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 674 "audio/mp4", avc1_codec(), kExternalClearKey)); 675 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 676 "audio/mp4", avc1_and_aac_codecs(), kExternalClearKey)); 677 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 678 "audio/mp4", avc3_codec(), kExternalClearKey)); 679 680 // Non-MP4 codec. 681 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 682 "audio/mp4", vorbis_codec(), kExternalClearKey)); 683} 684 685// 686// Widevine 687// 688 689IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedWidevineTest, 690 Widevine_Basic) { 691#if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) 692 EXPECT_TRUE(IsConcreteSupportedKeySystem(kWidevineAlpha)); 693#else 694 EXPECT_WV(IsConcreteSupportedKeySystem(kWidevineAlpha)); 695#endif 696 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( 697 "video/webm", no_codecs(), kWidevineAlpha)); 698} 699 700IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedWidevineTest, 701 Widevine_Parent) { 702 // The parent system is not a concrete system but is supported. 703 EXPECT_FALSE(IsConcreteSupportedKeySystem(kWidevine)); 704 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( 705 "video/webm", no_codecs(), kWidevine)); 706} 707 708IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedWidevineTest, 709 Widevine_IsSupportedKeySystem_InvalidVariants) { 710 // Case sensitive. 711 EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.AlPhA")); 712 // This should fail, but currently canPlayType() converts it to lowercase. 713 // See http://crbug.com/286036. 714 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( 715 "video/webm", no_codecs(), "com.widevine.AlPhA")); 716 717 // TLDs are not allowed. 718 EXPECT_FALSE(IsConcreteSupportedKeySystem("com.")); 719 EXPECT_FALSE( 720 IsSupportedKeySystemWithMediaMimeType("video/webm", no_codecs(), "com.")); 721 EXPECT_FALSE(IsConcreteSupportedKeySystem("com")); 722 EXPECT_FALSE( 723 IsSupportedKeySystemWithMediaMimeType("video/webm", no_codecs(), "com")); 724 725 // Extra period. 726 EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.")); 727 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 728 "video/webm", no_codecs(), "com.widevine.")); 729 730 // Incomplete. 731 EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.alph")); 732 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 733 "video/webm", no_codecs(), "com.widevine.alph")); 734 735 // Extra character. 736 EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.alphab")); 737 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 738 "video/webm", no_codecs(), "com.widevine.alphab")); 739 740 // There are no child key systems for Widevine Alpha. 741 EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.alpha.foo")); 742 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 743 "video/webm", no_codecs(), "com.widevine.alpha.foo")); 744} 745 746IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedWidevineTest, 747 IsSupportedKeySystemWithMediaMimeType_Widevine_NoType) { 748 // These two should be true. See http://crbug.com/164303. 749 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 750 std::string(), no_codecs(), kWidevineAlpha)); 751 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 752 std::string(), no_codecs(), kWidevine)); 753 754 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 755 std::string(), no_codecs(), "com.widevine.foo")); 756 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 757 std::string(), no_codecs(), "com.widevine.alpha.foo")); 758} 759 760IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedWidevineTest, 761 IsSupportedKeySystemWithMediaMimeType_Widevine_WebM) { 762 // Valid video types. 763 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( 764 "video/webm", no_codecs(), kWidevineAlpha)); 765 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( 766 "video/webm", vp8_codec(), kWidevineAlpha)); 767 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( 768 "video/webm", vp80_codec(), kWidevineAlpha)); 769 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( 770 "video/webm", vp8_and_vorbis_codecs(), kWidevineAlpha)); 771 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( 772 "video/webm", vorbis_codec(), kWidevineAlpha)); 773 774 // Valid video types - parent key system. 775 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( 776 "video/webm", no_codecs(), kWidevine)); 777 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( 778 "video/webm", vp8_codec(), kWidevine)); 779 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( 780 "video/webm", vp80_codec(), kWidevine)); 781 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( 782 "video/webm", vp8_and_vorbis_codecs(), kWidevine)); 783 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( 784 "video/webm", vorbis_codec(), kWidevine)); 785 786 // Non-Webm codecs. 787 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 788 "video/webm", avc1_codec(), kWidevineAlpha)); 789 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 790 "video/webm", unknown_codec(), kWidevineAlpha)); 791 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 792 "video/webm", mixed_codecs(), kWidevineAlpha)); 793 794 // Valid audio types. 795 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( 796 "audio/webm", no_codecs(), kWidevineAlpha)); 797 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( 798 "audio/webm", vorbis_codec(), kWidevineAlpha)); 799 800 // Valid audio types - parent key system. 801 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( 802 "audio/webm", no_codecs(), kWidevine)); 803 EXPECT_WV(IsSupportedKeySystemWithMediaMimeType( 804 "audio/webm", vorbis_codec(), kWidevine)); 805 806 // Non-audio codecs. 807 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 808 "audio/webm", vp8_codec(), kWidevineAlpha)); 809 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 810 "audio/webm", vp8_and_vorbis_codecs(), kWidevineAlpha)); 811 812 // Non-Webm codec. 813 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 814 "audio/webm", aac_codec(), kWidevineAlpha)); 815} 816 817IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedWidevineTest, 818 IsSupportedKeySystemWithMediaMimeType_Widevine_MP4) { 819 // Valid video types. 820 EXPECT_WVMP4(IsSupportedKeySystemWithMediaMimeType( 821 "video/mp4", no_codecs(), kWidevineAlpha)); 822 EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType( 823 "video/mp4", avc1_codec(), kWidevineAlpha)); 824 EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType( 825 "video/mp4", avc1_and_aac_codecs(), kWidevineAlpha)); 826 EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType( 827 "video/mp4", avc3_codec(), kWidevineAlpha)); 828 EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType( 829 "video/mp4", aac_codec(), kWidevineAlpha)); 830 831 // Valid video types - parent key system. 832 EXPECT_WVMP4(IsSupportedKeySystemWithMediaMimeType( 833 "video/mp4", no_codecs(), kWidevine)); 834 EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType( 835 "video/mp4", avc1_codec(), kWidevine)); 836 EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType( 837 "video/mp4", avc1_and_aac_codecs(), kWidevine)); 838 EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType( 839 "video/mp4", aac_codec(), kWidevine)); 840 841 // Extended codecs. 842 EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType( 843 "video/mp4", avc1_extended_codec(), kWidevineAlpha)); 844 EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType( 845 "video/mp4", avc3_extended_codec(), kWidevineAlpha)); 846 847 // Invalid codec format, but canPlayType() strips away the period. 848 EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType( 849 "video/mp4", avc1_dot_codec(), kWidevineAlpha)); 850 851 // Non-MP4 codecs. 852 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 853 "video/mp4", avc2_codec(), kWidevineAlpha)); 854 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 855 "video/mp4", vp8_codec(), kWidevineAlpha)); 856 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 857 "video/mp4", unknown_codec(), kWidevineAlpha)); 858 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 859 "video/mp4", mixed_codecs(), kWidevineAlpha)); 860 861 // Valid audio types. 862 EXPECT_WVMP4(IsSupportedKeySystemWithMediaMimeType( 863 "audio/mp4", no_codecs(), kWidevineAlpha)); 864 EXPECT_WVAAC(IsSupportedKeySystemWithMediaMimeType( 865 "audio/mp4", aac_codec(), kWidevineAlpha)); 866 867 // Valid audio types - parent key system. 868 EXPECT_WVMP4(IsSupportedKeySystemWithMediaMimeType( 869 "audio/mp4", no_codecs(), kWidevine)); 870 EXPECT_WVAAC(IsSupportedKeySystemWithMediaMimeType( 871 "audio/mp4", aac_codec(), kWidevine)); 872 873 // Non-audio codecs. 874 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 875 "audio/mp4", avc1_codec(), kWidevineAlpha)); 876 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 877 "audio/mp4", avc1_and_aac_codecs(), kWidevineAlpha)); 878 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 879 "audio/mp4", avc3_codec(), kWidevineAlpha)); 880 881 // Non-MP4 codec. 882 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 883 "audio/mp4", vorbis_codec(), kWidevineAlpha)); 884} 885 886IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedWidevineTest, 887 Widevine_HR_Basic) { 888 // HR support cannot be detected in tests, so this is expected to fail 889 // everywhere. 890 EXPECT_FALSE(IsConcreteSupportedKeySystem(kWidevineAlphaHr)); 891 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 892 "video/webm", no_codecs(), kWidevineAlphaHr)); 893} 894 895IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedWidevineTest, 896 Widevine_HR_NonCompositing_Basic) { 897 // HR non-compositing support cannot be detected in tests, so this is expected 898 // to fail everywhere. 899 EXPECT_FALSE(IsConcreteSupportedKeySystem(kWidevineAlphaHrNonCompositing)); 900 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 901 "video/webm", no_codecs(), kWidevineAlphaHrNonCompositing)); 902} 903 904#if defined(ENABLE_PEPPER_CDMS) 905// Since this test fixture does not register the CDMs on the command line, the 906// check for the CDMs in chrome_key_systems.cc should fail, and they should not 907// be registered with KeySystems. 908IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedTest, 909 PepperCDMsNotRegistered) { 910 EXPECT_FALSE(IsConcreteSupportedKeySystem(kExternalClearKey)); 911 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 912 "video/webm", no_codecs(), kExternalClearKey)); 913 914 // This will fail in all builds unless widevine is available but not a 915 // component, in which case it is registered internally 916#if !defined(WIDEVINE_CDM_AVAILABLE) || defined(WIDEVINE_CDM_IS_COMPONENT) 917 EXPECT_FALSE(IsConcreteSupportedKeySystem(kWidevineAlpha)); 918 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 919 "video/webm", no_codecs(), kWidevineAlpha)); 920#endif 921 922 // Clear Key should still be registered. 923 EXPECT_TRUE(IsConcreteSupportedKeySystem(kPrefixedClearKey)); 924 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 925 "video/webm", no_codecs(), kPrefixedClearKey)); 926 927 // Not yet out from behind the vendor prefix. 928 EXPECT_FALSE(IsConcreteSupportedKeySystem(kUnprefixedClearKey)); 929 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 930 "video/webm", no_codecs(), kUnprefixedClearKey)); 931} 932 933// Since this test fixture does not register the CDMs on the command line, the 934// check for the CDMs in chrome_key_systems.cc should fail, and they should not 935// be registered with KeySystems. 936IN_PROC_BROWSER_TEST_F( 937 EncryptedMediaIsTypeSupportedClearKeyCDMRegisteredWithWrongPathTest, 938 PepperCDMsRegisteredButAdapterNotPresent) { 939 EXPECT_FALSE(IsConcreteSupportedKeySystem(kExternalClearKey)); 940 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 941 "video/webm", no_codecs(), kExternalClearKey)); 942 943 // Clear Key should still be registered. 944 EXPECT_TRUE(IsConcreteSupportedKeySystem(kPrefixedClearKey)); 945 EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType( 946 "video/webm", no_codecs(), kPrefixedClearKey)); 947 948 // Not yet out from behind the vendor prefix. 949 EXPECT_FALSE(IsConcreteSupportedKeySystem(kUnprefixedClearKey)); 950 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 951 "video/webm", no_codecs(), kUnprefixedClearKey)); 952} 953 954// This will fail in all builds unless Widevine is available but not a 955// component, in which case it is registered internally. 956// TODO(xhwang): Define EXPECT_WV and run this test in all cases. 957#if !defined(WIDEVINE_CDM_AVAILABLE) || defined(WIDEVINE_CDM_IS_COMPONENT) 958IN_PROC_BROWSER_TEST_F( 959 EncryptedMediaIsTypeSupportedWidevineCDMRegisteredWithWrongPathTest, 960 PepperCDMsRegisteredButAdapterNotPresent) { 961 EXPECT_FALSE(IsConcreteSupportedKeySystem(kWidevineAlpha)); 962 EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType( 963 "video/webm", no_codecs(), kWidevineAlpha)); 964} 965#endif // !defined(WIDEVINE_CDM_AVAILABLE) || defined(WIDEVINE_CDM_IS_COMPONENT) 966#endif // defined(ENABLE_PEPPER_CDMS) 967 968} // namespace chrome 969