This source file includes following definitions.
- is_pepper_cdm_registered_
- no_codecs
- vp8_codec
- vp80_codec
- vorbis_codec
- vp8_and_vorbis_codecs
- avc1_codec
- avc1_extended_codec
- avc1_dot_codec
- avc2_codec
- avc3_codec
- avc3_extended_codec
- aac_codec
- avc1_and_aac_codecs
- unknown_codec
- mixed_codecs
- RegisterPepperCdm
- LoadTestPage
- IsConcreteSupportedKeySystem
- IsSupportedKeySystemWithMediaMimeType
- SetUpCommandLine
- SetUpCommandLine
- SetUpCommandLine
- SetUpCommandLine
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
#include <string>
#include <vector>
#include "base/base_switches.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test_utils.h"
#include "url/gurl.h"
#include "widevine_cdm_version.h"
#if defined(USE_PROPRIETARY_CODECS)
#define EXPECT_PROPRIETARY EXPECT_TRUE
#else
#define EXPECT_PROPRIETARY EXPECT_FALSE
#endif
#if defined(ENABLE_PEPPER_CDMS)
#define EXPECT_ECK EXPECT_TRUE
#define EXPECT_ECKPROPRIETARY EXPECT_PROPRIETARY
#else
#define EXPECT_ECK EXPECT_FALSE
#define EXPECT_ECKPROPRIETARY EXPECT_FALSE
#endif
#if defined(WIDEVINE_CDM_AVAILABLE) && !defined(WIDEVINE_CDM_IS_COMPONENT)
#define EXPECT_WV EXPECT_TRUE
#if defined(WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE)
#define EXPECT_WVMP4 EXPECT_TRUE
#define EXPECT_WVAVC1 EXPECT_TRUE
#if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE)
#define EXPECT_WVAVC1AAC EXPECT_TRUE
#else
#define EXPECT_WVAVC1AAC EXPECT_FALSE
#endif
#else
#define EXPECT_WVMP4 EXPECT_FALSE
#define EXPECT_WVAVC1 EXPECT_FALSE
#define EXPECT_WVAVC1AAC EXPECT_FALSE
#endif
#if defined(WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE)
#define EXPECT_WVAAC EXPECT_TRUE
#else
#define EXPECT_WVAAC EXPECT_FALSE
#endif
#else
#define EXPECT_WV EXPECT_FALSE
#define EXPECT_WVMP4 EXPECT_FALSE
#define EXPECT_WVAVC1 EXPECT_FALSE
#define EXPECT_WVAVC1AAC EXPECT_FALSE
#define EXPECT_WVAAC EXPECT_FALSE
#endif
namespace chrome {
const char kPrefixedClearKey[] = "webkit-org.w3.clearkey";
const char kPrefixedClearKeyParent[] = "webkit-org.w3";
const char kUnprefixedClearKey[] = "org.w3.clearkey";
const char kExternalClearKey[] = "org.chromium.externalclearkey";
const char kWidevineAlpha[] = "com.widevine.alpha";
const char kWidevine[] = "com.widevine";
const char kWidevineAlphaHr[] = "com.widevine.alpha.hr";
const char kWidevineAlphaHrNonCompositing[] =
"com.widevine.alpha.hrnoncompositing";
class EncryptedMediaIsTypeSupportedTest : public InProcessBrowserTest {
protected:
EncryptedMediaIsTypeSupportedTest()
: is_test_page_loaded_(false), is_pepper_cdm_registered_(false) {
vp8_codec_.push_back("vp8");
vp80_codec_.push_back("vp8.0");
vorbis_codec_.push_back("vorbis");
vp8_and_vorbis_codecs_.push_back("vp8");
vp8_and_vorbis_codecs_.push_back("vorbis");
avc1_codec_.push_back("avc1");
avc1_extended_codec_.push_back("avc1.4D400C");
avc1_dot_codec_.push_back("avc1.");
avc2_codec_.push_back("avc2");
avc3_codec_.push_back("avc3");
avc3_extended_codec_.push_back("avc3.64001f");
aac_codec_.push_back("mp4a");
avc1_and_aac_codecs_.push_back("avc1");
avc1_and_aac_codecs_.push_back("mp4a");
unknown_codec_.push_back("foo");
mixed_codecs_.push_back("vorbis");
mixed_codecs_.push_back("avc1");
}
typedef std::vector<std::string> CodecVector;
const CodecVector& no_codecs() const { return no_codecs_; }
const CodecVector& vp8_codec() const { return vp8_codec_; }
const CodecVector& vp80_codec() const { return vp80_codec_; }
const CodecVector& vorbis_codec() const { return vorbis_codec_; }
const CodecVector& vp8_and_vorbis_codecs() const {
return vp8_and_vorbis_codecs_;
}
const CodecVector& avc1_codec() const { return avc1_codec_; }
const CodecVector& avc1_extended_codec() const {
return avc1_extended_codec_;
}
const CodecVector& avc1_dot_codec() const { return avc1_dot_codec_; }
const CodecVector& avc2_codec() const { return avc2_codec_; }
const CodecVector& avc3_codec() const { return avc3_codec_; }
const CodecVector& avc3_extended_codec() const {
return avc3_extended_codec_;
}
const CodecVector& aac_codec() const { return aac_codec_; }
const CodecVector& avc1_and_aac_codecs() const {
return avc1_and_aac_codecs_;
}
const CodecVector& unknown_codec() const { return unknown_codec_; }
const CodecVector& mixed_codecs() const { return mixed_codecs_; }
void RegisterPepperCdm(CommandLine* command_line,
const std::string& adapter_name,
const std::string& pepper_type_for_key_system,
bool expect_adapter_exists = true) {
DCHECK(!is_pepper_cdm_registered_)
<< "RegisterPepperCdm() can only be called once.";
is_pepper_cdm_registered_ = true;
base::FilePath plugin_dir;
EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir));
base::FilePath plugin_lib = plugin_dir.AppendASCII(adapter_name);
EXPECT_EQ(expect_adapter_exists, base::PathExists(plugin_lib));
base::FilePath::StringType pepper_plugin = plugin_lib.value();
pepper_plugin.append(FILE_PATH_LITERAL("#CDM#0.1.0.0;"));
#if defined(OS_WIN)
pepper_plugin.append(base::ASCIIToWide(pepper_type_for_key_system));
#else
pepper_plugin.append(pepper_type_for_key_system);
#endif
command_line->AppendSwitchNative(switches::kRegisterPepperPlugins,
pepper_plugin);
}
void LoadTestPage() {
if (!is_test_page_loaded_) {
ASSERT_TRUE(test_server()->Start());
GURL gurl = test_server()->GetURL(
"files/media/test_key_system_instantiation.html");
ui_test_utils::NavigateToURL(browser(), gurl);
is_test_page_loaded_ = true;
}
}
bool IsConcreteSupportedKeySystem(const std::string& key) {
std::string command(
"window.domAutomationController.send(testKeySystemInstantiation('");
command.append(key);
command.append("'));");
LoadTestPage();
std::string result;
EXPECT_TRUE(content::ExecuteScriptAndExtractString(
browser()->tab_strip_model()->GetActiveWebContents(),
command,
&result));
CHECK(result == "success" || result == "NotSupportedError") << result;
return (result == "success");
}
bool IsSupportedKeySystemWithMediaMimeType(const std::string& type,
const CodecVector& codecs,
const std::string& keySystem) {
std::string command("document.createElement('video').canPlayType(");
if (type.empty()) {
command.append("null");
DCHECK(codecs.empty());
} else {
command.append("'");
command.append(type);
if (!codecs.empty()) {
command.append("; codecs=\"");
for (CodecVector::const_iterator it = codecs.begin();
it != codecs.end();
++it) {
command.append(*it);
command.append(",");
}
command.replace(command.length() - 1, 1, "\"");
}
command.append("'");
}
command.append(",'");
command.append(keySystem);
command.append("')");
std::string result;
EXPECT_TRUE(content::ExecuteScriptAndExtractString(
browser()->tab_strip_model()->GetActiveWebContents(),
"window.domAutomationController.send(" + command + ");",
&result));
return (result == "maybe" || result == "probably");
}
private:
const CodecVector no_codecs_;
CodecVector vp8_codec_;
CodecVector vp80_codec_;
CodecVector vorbis_codec_;
CodecVector vp8_and_vorbis_codecs_;
CodecVector avc1_codec_;
CodecVector avc1_extended_codec_;
CodecVector avc1_dot_codec_;
CodecVector avc2_codec_;
CodecVector avc3_codec_;
CodecVector avc3_extended_codec_;
CodecVector aac_codec_;
CodecVector avc1_and_aac_codecs_;
CodecVector unknown_codec_;
CodecVector mixed_codecs_;
bool is_test_page_loaded_;
bool is_pepper_cdm_registered_;
};
class EncryptedMediaIsTypeSupportedExternalClearKeyTest
: public EncryptedMediaIsTypeSupportedTest {
#if defined(ENABLE_PEPPER_CDMS)
protected:
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
const char adapter_file_name[] =
#if defined(OS_MACOSX)
"clearkeycdmadapter.plugin";
#elif defined(OS_WIN)
"clearkeycdmadapter.dll";
#elif defined(OS_POSIX)
"libclearkeycdmadapter.so";
#endif
const std::string pepper_name("application/x-ppapi-clearkey-cdm");
RegisterPepperCdm(command_line, adapter_file_name, pepper_name);
}
#endif
};
class EncryptedMediaIsTypeSupportedWidevineTest
: public EncryptedMediaIsTypeSupportedTest {
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS) && \
defined(WIDEVINE_CDM_IS_COMPONENT)
protected:
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
const char adapter_file_name[] =
#if defined(OS_MACOSX)
"widevinecdmadapter.plugin";
#elif defined(OS_WIN)
"widevinecdmadapter.dll";
#else
"libwidevinecdmadapter.so";
#endif
const std::string pepper_name("application/x-ppapi-widevine-cdm");
RegisterPepperCdm(command_line, adapter_file_name, pepper_name);
}
#endif
};
#if defined(ENABLE_PEPPER_CDMS)
class EncryptedMediaIsTypeSupportedClearKeyCDMRegisteredWithWrongPathTest
: public EncryptedMediaIsTypeSupportedTest {
protected:
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
RegisterPepperCdm(command_line,
"clearkeycdmadapterwrongname.dll",
"application/x-ppapi-clearkey-cdm",
false);
}
};
class EncryptedMediaIsTypeSupportedWidevineCDMRegisteredWithWrongPathTest
: public EncryptedMediaIsTypeSupportedTest {
protected:
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
RegisterPepperCdm(command_line,
"widevinecdmadapterwrongname.dll",
"application/x-ppapi-widevine-cdm",
false);
}
};
#endif
IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedTest, ClearKey_Basic) {
EXPECT_TRUE(IsConcreteSupportedKeySystem(kPrefixedClearKey));
EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kPrefixedClearKey));
EXPECT_FALSE(IsConcreteSupportedKeySystem(kUnprefixedClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kUnprefixedClearKey));
}
IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedTest, ClearKey_Parent) {
EXPECT_FALSE(IsConcreteSupportedKeySystem(kPrefixedClearKeyParent));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kPrefixedClearKeyParent));
}
IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedTest,
ClearKey_IsSupportedKeySystem_InvalidVariants) {
EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.ClEaRkEy"));
EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), "webkit-org.w3.ClEaRkEy"));
EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org."));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), "webkit-org."));
EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org"));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), "webkit-org"));
EXPECT_FALSE(IsConcreteSupportedKeySystem("org."));
EXPECT_FALSE(
IsSupportedKeySystemWithMediaMimeType("video/webm", no_codecs(), "org."));
EXPECT_FALSE(IsConcreteSupportedKeySystem("org"));
EXPECT_FALSE(
IsSupportedKeySystemWithMediaMimeType("video/webm", no_codecs(), "org"));
EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3."));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), "webkit-org.w3."));
EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.clearke"));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), "webkit-org.w3.clearke"));
EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.clearkeyz"));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), "webkit-org.w3.clearkeyz"));
EXPECT_FALSE(IsConcreteSupportedKeySystem("webkit-org.w3.clearkey.foo"));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), "webkit-org.w3.clearkey.foo"));
}
IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedTest,
IsSupportedKeySystemWithMediaMimeType_ClearKey_NoType) {
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
std::string(), no_codecs(), kPrefixedClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
std::string(), no_codecs(), kPrefixedClearKeyParent));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
std::string(), no_codecs(), "webkit-org.w3.foo"));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
std::string(), no_codecs(), "webkit-org.w3.clearkey.foo"));
}
IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedTest,
IsSupportedKeySystemWithMediaMimeType_ClearKey_WebM) {
EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kPrefixedClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kPrefixedClearKeyParent));
EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", vp8_codec(), kPrefixedClearKey));
EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", vp80_codec(), kPrefixedClearKey));
EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", vp8_and_vorbis_codecs(), kPrefixedClearKey));
EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", vorbis_codec(), kPrefixedClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", avc1_codec(), kPrefixedClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", unknown_codec(), kPrefixedClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", mixed_codecs(), kPrefixedClearKey));
EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
"audio/webm", no_codecs(), kPrefixedClearKey));
EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
"audio/webm", vorbis_codec(), kPrefixedClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/webm", vp8_codec(), kPrefixedClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/webm", vp8_and_vorbis_codecs(), kPrefixedClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/webm", aac_codec(), kPrefixedClearKey));
}
IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedTest,
IsSupportedKeySystemWithMediaMimeType_ClearKey_MP4) {
EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", no_codecs(), kPrefixedClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", no_codecs(), kPrefixedClearKeyParent));
EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc1_codec(), kPrefixedClearKey));
EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc1_and_aac_codecs(), kPrefixedClearKey));
EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc3_codec(), kPrefixedClearKey));
EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", aac_codec(), kPrefixedClearKey));
EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc1_extended_codec(), kPrefixedClearKey));
EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc3_extended_codec(), kPrefixedClearKey));
EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc1_dot_codec(), kPrefixedClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc2_codec(), kPrefixedClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", vp8_codec(), kPrefixedClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", unknown_codec(), kPrefixedClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", mixed_codecs(), kPrefixedClearKey));
EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", no_codecs(), kPrefixedClearKey));
EXPECT_PROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", aac_codec(), kPrefixedClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", avc1_codec(), kPrefixedClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", avc1_and_aac_codecs(), kPrefixedClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", avc3_codec(), kPrefixedClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", vorbis_codec(), kPrefixedClearKey));
}
IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedExternalClearKeyTest,
ExternalClearKey_Basic) {
EXPECT_ECK(IsConcreteSupportedKeySystem(kExternalClearKey));
EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kExternalClearKey));
}
IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedExternalClearKeyTest,
ExternalClearKey_Parent) {
const char* const kExternalClearKeyParent = "org.chromium";
EXPECT_FALSE(IsConcreteSupportedKeySystem(kExternalClearKeyParent));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kExternalClearKeyParent));
}
IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedExternalClearKeyTest,
ExternalClearKey_IsSupportedKeySystem_InvalidVariants) {
EXPECT_FALSE(IsConcreteSupportedKeySystem("org.chromium.ExTeRnAlClEaRkEy"));
EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), "org.chromium.ExTeRnAlClEaRkEy"));
EXPECT_FALSE(IsConcreteSupportedKeySystem("org."));
EXPECT_FALSE(
IsSupportedKeySystemWithMediaMimeType("video/webm", no_codecs(), "org."));
EXPECT_FALSE(IsConcreteSupportedKeySystem("org"));
EXPECT_FALSE(
IsSupportedKeySystemWithMediaMimeType("video/webm", no_codecs(), "org"));
EXPECT_FALSE(IsConcreteSupportedKeySystem("org.chromium."));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), "org.chromium."));
EXPECT_FALSE(IsConcreteSupportedKeySystem("org.chromium.externalclearke"));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), "org.chromium.externalclearke"));
EXPECT_FALSE(IsConcreteSupportedKeySystem("org.chromium.externalclearkeyz"));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), "org.chromium.externalclearkeyz"));
EXPECT_FALSE(
IsConcreteSupportedKeySystem("org.chromium.externalclearkey.foo"));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), "org.chromium.externalclearkey.foo"));
}
IN_PROC_BROWSER_TEST_F(
EncryptedMediaIsTypeSupportedExternalClearKeyTest,
IsSupportedKeySystemWithMediaMimeType_ExternalClearKey_NoType) {
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
std::string(), no_codecs(), kExternalClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
std::string(), no_codecs(), "org.chromium"));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
std::string(), no_codecs(), "org.chromium.foo"));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
std::string(), no_codecs(), "org.chromium.externalclearkey.foo"));
}
IN_PROC_BROWSER_TEST_F(
EncryptedMediaIsTypeSupportedExternalClearKeyTest,
IsSupportedKeySystemWithMediaMimeType_ExternalClearKey_WebM) {
EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kExternalClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), "org.chromium"));
EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType(
"video/webm", vp8_codec(), kExternalClearKey));
EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType(
"video/webm", vp80_codec(), kExternalClearKey));
EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType(
"video/webm", vp8_and_vorbis_codecs(), kExternalClearKey));
EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType(
"video/webm", vorbis_codec(), kExternalClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", avc1_codec(), kExternalClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", unknown_codec(), kExternalClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", mixed_codecs(), kExternalClearKey));
EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType(
"audio/webm", no_codecs(), kExternalClearKey));
EXPECT_ECK(IsSupportedKeySystemWithMediaMimeType(
"audio/webm", vorbis_codec(), kExternalClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/webm", vp8_codec(), kExternalClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/webm", vp8_and_vorbis_codecs(), kExternalClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/webm", aac_codec(), kExternalClearKey));
}
IN_PROC_BROWSER_TEST_F(
EncryptedMediaIsTypeSupportedExternalClearKeyTest,
IsSupportedKeySystemWithMediaMimeType_ExternalClearKey_MP4) {
EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", no_codecs(), kExternalClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", no_codecs(), "org.chromium"));
EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc1_codec(), kExternalClearKey));
EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc1_and_aac_codecs(), kExternalClearKey));
EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc3_codec(), kExternalClearKey));
EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", aac_codec(), kExternalClearKey));
EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc1_extended_codec(), kExternalClearKey));
EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc3_extended_codec(), kExternalClearKey));
EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc1_dot_codec(), kExternalClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc2_codec(), kExternalClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", vp8_codec(), kExternalClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", unknown_codec(), kExternalClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", mixed_codecs(), kExternalClearKey));
EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", no_codecs(), kExternalClearKey));
EXPECT_ECKPROPRIETARY(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", aac_codec(), kExternalClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", avc1_codec(), kExternalClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", avc1_and_aac_codecs(), kExternalClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", avc3_codec(), kExternalClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", vorbis_codec(), kExternalClearKey));
}
IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedWidevineTest,
Widevine_Basic) {
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
EXPECT_TRUE(IsConcreteSupportedKeySystem(kWidevineAlpha));
#else
EXPECT_WV(IsConcreteSupportedKeySystem(kWidevineAlpha));
#endif
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kWidevineAlpha));
}
IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedWidevineTest,
Widevine_Parent) {
EXPECT_FALSE(IsConcreteSupportedKeySystem(kWidevine));
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kWidevine));
}
IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedWidevineTest,
Widevine_IsSupportedKeySystem_InvalidVariants) {
EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.AlPhA"));
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), "com.widevine.AlPhA"));
EXPECT_FALSE(IsConcreteSupportedKeySystem("com."));
EXPECT_FALSE(
IsSupportedKeySystemWithMediaMimeType("video/webm", no_codecs(), "com."));
EXPECT_FALSE(IsConcreteSupportedKeySystem("com"));
EXPECT_FALSE(
IsSupportedKeySystemWithMediaMimeType("video/webm", no_codecs(), "com"));
EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine."));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), "com.widevine."));
EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.alph"));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), "com.widevine.alph"));
EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.alphab"));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), "com.widevine.alphab"));
EXPECT_FALSE(IsConcreteSupportedKeySystem("com.widevine.alpha.foo"));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), "com.widevine.alpha.foo"));
}
IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedWidevineTest,
IsSupportedKeySystemWithMediaMimeType_Widevine_NoType) {
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
std::string(), no_codecs(), kWidevineAlpha));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
std::string(), no_codecs(), kWidevine));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
std::string(), no_codecs(), "com.widevine.foo"));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
std::string(), no_codecs(), "com.widevine.alpha.foo"));
}
IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedWidevineTest,
IsSupportedKeySystemWithMediaMimeType_Widevine_WebM) {
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kWidevineAlpha));
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"video/webm", vp8_codec(), kWidevineAlpha));
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"video/webm", vp80_codec(), kWidevineAlpha));
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"video/webm", vp8_and_vorbis_codecs(), kWidevineAlpha));
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"video/webm", vorbis_codec(), kWidevineAlpha));
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kWidevine));
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"video/webm", vp8_codec(), kWidevine));
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"video/webm", vp80_codec(), kWidevine));
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"video/webm", vp8_and_vorbis_codecs(), kWidevine));
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"video/webm", vorbis_codec(), kWidevine));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", avc1_codec(), kWidevineAlpha));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", unknown_codec(), kWidevineAlpha));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", mixed_codecs(), kWidevineAlpha));
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"audio/webm", no_codecs(), kWidevineAlpha));
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"audio/webm", vorbis_codec(), kWidevineAlpha));
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"audio/webm", no_codecs(), kWidevine));
EXPECT_WV(IsSupportedKeySystemWithMediaMimeType(
"audio/webm", vorbis_codec(), kWidevine));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/webm", vp8_codec(), kWidevineAlpha));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/webm", vp8_and_vorbis_codecs(), kWidevineAlpha));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/webm", aac_codec(), kWidevineAlpha));
}
IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedWidevineTest,
IsSupportedKeySystemWithMediaMimeType_Widevine_MP4) {
EXPECT_WVMP4(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", no_codecs(), kWidevineAlpha));
EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc1_codec(), kWidevineAlpha));
EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc1_and_aac_codecs(), kWidevineAlpha));
EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc3_codec(), kWidevineAlpha));
EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", aac_codec(), kWidevineAlpha));
EXPECT_WVMP4(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", no_codecs(), kWidevine));
EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc1_codec(), kWidevine));
EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc1_and_aac_codecs(), kWidevine));
EXPECT_WVAVC1AAC(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", aac_codec(), kWidevine));
EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc1_extended_codec(), kWidevineAlpha));
EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc3_extended_codec(), kWidevineAlpha));
EXPECT_WVAVC1(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc1_dot_codec(), kWidevineAlpha));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", avc2_codec(), kWidevineAlpha));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", vp8_codec(), kWidevineAlpha));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", unknown_codec(), kWidevineAlpha));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/mp4", mixed_codecs(), kWidevineAlpha));
EXPECT_WVMP4(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", no_codecs(), kWidevineAlpha));
EXPECT_WVAAC(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", aac_codec(), kWidevineAlpha));
EXPECT_WVMP4(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", no_codecs(), kWidevine));
EXPECT_WVAAC(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", aac_codec(), kWidevine));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", avc1_codec(), kWidevineAlpha));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", avc1_and_aac_codecs(), kWidevineAlpha));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", avc3_codec(), kWidevineAlpha));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"audio/mp4", vorbis_codec(), kWidevineAlpha));
}
IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedWidevineTest,
Widevine_HR_Basic) {
EXPECT_FALSE(IsConcreteSupportedKeySystem(kWidevineAlphaHr));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kWidevineAlphaHr));
}
IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedWidevineTest,
Widevine_HR_NonCompositing_Basic) {
EXPECT_FALSE(IsConcreteSupportedKeySystem(kWidevineAlphaHrNonCompositing));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kWidevineAlphaHrNonCompositing));
}
#if defined(ENABLE_PEPPER_CDMS)
IN_PROC_BROWSER_TEST_F(EncryptedMediaIsTypeSupportedTest,
PepperCDMsNotRegistered) {
EXPECT_FALSE(IsConcreteSupportedKeySystem(kExternalClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kExternalClearKey));
#if !defined(WIDEVINE_CDM_AVAILABLE) || defined(WIDEVINE_CDM_IS_COMPONENT)
EXPECT_FALSE(IsConcreteSupportedKeySystem(kWidevineAlpha));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kWidevineAlpha));
#endif
EXPECT_TRUE(IsConcreteSupportedKeySystem(kPrefixedClearKey));
EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kPrefixedClearKey));
EXPECT_FALSE(IsConcreteSupportedKeySystem(kUnprefixedClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kUnprefixedClearKey));
}
IN_PROC_BROWSER_TEST_F(
EncryptedMediaIsTypeSupportedClearKeyCDMRegisteredWithWrongPathTest,
PepperCDMsRegisteredButAdapterNotPresent) {
EXPECT_FALSE(IsConcreteSupportedKeySystem(kExternalClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kExternalClearKey));
EXPECT_TRUE(IsConcreteSupportedKeySystem(kPrefixedClearKey));
EXPECT_TRUE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kPrefixedClearKey));
EXPECT_FALSE(IsConcreteSupportedKeySystem(kUnprefixedClearKey));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kUnprefixedClearKey));
}
#if !defined(WIDEVINE_CDM_AVAILABLE) || defined(WIDEVINE_CDM_IS_COMPONENT)
IN_PROC_BROWSER_TEST_F(
EncryptedMediaIsTypeSupportedWidevineCDMRegisteredWithWrongPathTest,
PepperCDMsRegisteredButAdapterNotPresent) {
EXPECT_FALSE(IsConcreteSupportedKeySystem(kWidevineAlpha));
EXPECT_FALSE(IsSupportedKeySystemWithMediaMimeType(
"video/webm", no_codecs(), kWidevineAlpha));
}
#endif
#endif
}