| Index: chrome/browser/media/encrypted_media_browsertest.cc
|
| diff --git a/chrome/browser/media/encrypted_media_browsertest.cc b/chrome/browser/media/encrypted_media_browsertest.cc
|
| index ef44f3976d9d30b5084e4586a18018ca156b7158..e82276ec5629498d8245d60d1001524e8d94a6dd 100644
|
| --- a/chrome/browser/media/encrypted_media_browsertest.cc
|
| +++ b/chrome/browser/media/encrypted_media_browsertest.cc
|
| @@ -35,7 +35,8 @@ const char kClearKeyCdmPluginMimeType[] = "application/x-ppapi-clearkey-cdm";
|
| #endif // defined(ENABLE_PEPPER_CDMS)
|
|
|
| // Available key systems.
|
| -const char kClearKeyKeySystem[] = "webkit-org.w3.clearkey";
|
| +const char kClearKeyKeySystem[] = "org.w3.clearkey";
|
| +const char kPrefixedClearKeyKeySystem[] = "webkit-org.w3.clearkey";
|
| const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey";
|
| const char kExternalClearKeyDecryptOnlyKeySystem[] =
|
| "org.chromium.externalclearkey.decryptonly";
|
| @@ -71,6 +72,12 @@ enum SrcType {
|
| MSE
|
| };
|
|
|
| +// Whether to use prefixed or unprefixed EME.
|
| +enum EmeVersion {
|
| + PREFIXED,
|
| + UNPREFIXED
|
| +};
|
| +
|
| // MSE is available on all desktop platforms and on Android 4.1 and later.
|
| static bool IsMSESupported() {
|
| #if defined(OS_ANDROID)
|
| @@ -125,6 +132,7 @@ class EncryptedMediaTestBase : public MediaBrowserTest {
|
| const std::string& media_type,
|
| const std::string& key_system,
|
| SrcType src_type,
|
| + EmeVersion eme_version,
|
| const std::string& session_to_load,
|
| bool force_invalid_response,
|
| const std::string& expected_title) {
|
| @@ -138,6 +146,8 @@ class EncryptedMediaTestBase : public MediaBrowserTest {
|
| query_params.push_back(std::make_pair("keySystem", key_system));
|
| if (src_type == MSE)
|
| query_params.push_back(std::make_pair("useMSE", "1"));
|
| + if (eme_version == PREFIXED)
|
| + query_params.push_back(std::make_pair("usePrefixedEME", "1"));
|
| if (force_invalid_response)
|
| query_params.push_back(std::make_pair("forceInvalidResponse", "1"));
|
| if (!session_to_load.empty())
|
| @@ -149,13 +159,20 @@ class EncryptedMediaTestBase : public MediaBrowserTest {
|
| void RunSimpleEncryptedMediaTest(const std::string& media_file,
|
| const std::string& media_type,
|
| const std::string& key_system,
|
| - SrcType src_type) {
|
| + SrcType src_type,
|
| + EmeVersion eme_version) {
|
| std::string expected_title = kEnded;
|
| if (!IsPlayBackPossible(key_system))
|
| expected_title = kEmeKeyError;
|
|
|
| - RunEncryptedMediaTest("encrypted_media_player.html", media_file, media_type,
|
| - key_system, src_type, kNoSessionToLoad, false,
|
| + RunEncryptedMediaTest("encrypted_media_player.html",
|
| + media_file,
|
| + media_type,
|
| + key_system,
|
| + src_type,
|
| + eme_version,
|
| + kNoSessionToLoad,
|
| + false,
|
| expected_title);
|
| // Check KeyMessage received for all key systems.
|
| bool receivedKeyMessage = false;
|
| @@ -294,6 +311,7 @@ class ECKEncryptedMediaTest : public EncryptedMediaTestBase {
|
| kWebMAudioOnly,
|
| key_system,
|
| SRC,
|
| + PREFIXED,
|
| kNoSessionToLoad,
|
| false,
|
| expected_title);
|
| @@ -312,6 +330,7 @@ class WVEncryptedMediaTest : public EncryptedMediaTestBase {
|
| protected:
|
| virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
|
| EncryptedMediaTestBase::SetUpCommandLine(command_line);
|
| + command_line->AppendSwitch(switches::kEnableEncryptedMedia);
|
| SetUpCommandLineForKeySystem(kWidevineKeySystem, command_line);
|
| }
|
| };
|
| @@ -322,12 +341,15 @@ class WVEncryptedMediaTest : public EncryptedMediaTestBase {
|
| // Tests encrypted media playback with a combination of parameters:
|
| // - char*: Key system name.
|
| // - bool: True to load media using MSE, otherwise use src.
|
| +// - bool: True to use unprefixed EME, otherwise use prefixed EME.
|
| //
|
| // Note: Only parameterized (*_P) tests can be used. Non-parameterized (*_F)
|
| // tests will crash at GetParam(). To add non-parameterized tests, use
|
| // EncryptedMediaTestBase or one of its subclasses (e.g. WVEncryptedMediaTest).
|
| -class EncryptedMediaTest : public EncryptedMediaTestBase,
|
| - public testing::WithParamInterface<std::tr1::tuple<const char*, SrcType> > {
|
| +class EncryptedMediaTest
|
| + : public EncryptedMediaTestBase,
|
| + public testing::WithParamInterface<
|
| + std::tr1::tuple<const char*, SrcType, EmeVersion> > {
|
| public:
|
| std::string CurrentKeySystem() {
|
| return std::tr1::get<0>(GetParam());
|
| @@ -337,10 +359,17 @@ class EncryptedMediaTest : public EncryptedMediaTestBase,
|
| return std::tr1::get<1>(GetParam());
|
| }
|
|
|
| + EmeVersion CurrentEmeVersion() {
|
| + return std::tr1::get<2>(GetParam());
|
| + }
|
| +
|
| void TestSimplePlayback(const std::string& encrypted_media,
|
| const std::string& media_type) {
|
| - RunSimpleEncryptedMediaTest(
|
| - encrypted_media, media_type, CurrentKeySystem(), CurrentSourceType());
|
| + RunSimpleEncryptedMediaTest(encrypted_media,
|
| + media_type,
|
| + CurrentKeySystem(),
|
| + CurrentSourceType(),
|
| + CurrentEmeVersion());
|
| }
|
|
|
| void RunInvalidResponseTest() {
|
| @@ -349,6 +378,7 @@ class EncryptedMediaTest : public EncryptedMediaTestBase,
|
| kWebMAudioVideo,
|
| CurrentKeySystem(),
|
| CurrentSourceType(),
|
| + CurrentEmeVersion(),
|
| kNoSessionToLoad,
|
| true,
|
| kEmeKeyError);
|
| @@ -360,6 +390,7 @@ class EncryptedMediaTest : public EncryptedMediaTestBase,
|
| kWebMAudioVideo,
|
| CurrentKeySystem(),
|
| CurrentSourceType(),
|
| + CurrentEmeVersion(),
|
| kNoSessionToLoad,
|
| false,
|
| kEnded);
|
| @@ -370,6 +401,8 @@ class EncryptedMediaTest : public EncryptedMediaTestBase,
|
| std::vector<StringPair> query_params;
|
| query_params.push_back(std::make_pair("keySystem", CurrentKeySystem()));
|
| query_params.push_back(std::make_pair("runEncrypted", "1"));
|
| + if (CurrentEmeVersion() == PREFIXED)
|
| + query_params.push_back(std::make_pair("usePrefixedEME", "1"));
|
| RunEncryptedMediaTestPage("mse_config_change.html",
|
| CurrentKeySystem(),
|
| &query_params,
|
| @@ -380,6 +413,9 @@ class EncryptedMediaTest : public EncryptedMediaTestBase,
|
| virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
|
| EncryptedMediaTestBase::SetUpCommandLine(command_line);
|
| SetUpCommandLineForKeySystem(CurrentKeySystem(), command_line);
|
| +
|
| + if (CurrentEmeVersion() == UNPREFIXED)
|
| + command_line->AppendSwitch(switches::kEnableEncryptedMedia);
|
| }
|
| };
|
|
|
| @@ -387,30 +423,90 @@ using ::testing::Combine;
|
| using ::testing::Values;
|
|
|
| #if !defined(OS_ANDROID)
|
| -INSTANTIATE_TEST_CASE_P(SRC_ClearKey, EncryptedMediaTest,
|
| - Combine(Values(kClearKeyKeySystem), Values(SRC)));
|
| +INSTANTIATE_TEST_CASE_P(SRC_ClearKey_Prefixed,
|
| + EncryptedMediaTest,
|
| + Combine(Values(kPrefixedClearKeyKeySystem),
|
| + Values(SRC),
|
| + Values(PREFIXED)));
|
| +
|
| +// TODO(jrummell): Enable unprefixed tests before shipping unprefixed EME.
|
| +// Disabled now as they don't provide much additional coverage, but do take a
|
| +// bit of time to execute.
|
| +INSTANTIATE_TEST_CASE_P(DISABLED_SRC_ClearKey,
|
| + EncryptedMediaTest,
|
| + Combine(Values(kClearKeyKeySystem),
|
| + Values(SRC),
|
| + Values(UNPREFIXED)));
|
| #endif // !defined(OS_ANDROID)
|
|
|
| -INSTANTIATE_TEST_CASE_P(MSE_ClearKey, EncryptedMediaTest,
|
| - Combine(Values(kClearKeyKeySystem), Values(MSE)));
|
| +INSTANTIATE_TEST_CASE_P(MSE_ClearKey_Prefixed,
|
| + EncryptedMediaTest,
|
| + Combine(Values(kPrefixedClearKeyKeySystem),
|
| + Values(MSE),
|
| + Values(PREFIXED)));
|
| +INSTANTIATE_TEST_CASE_P(MSE_ClearKey,
|
| + EncryptedMediaTest,
|
| + Combine(Values(kClearKeyKeySystem),
|
| + Values(MSE),
|
| + Values(UNPREFIXED)));
|
|
|
| // External Clear Key is currently only used on platforms that use Pepper CDMs.
|
| #if defined(ENABLE_PEPPER_CDMS)
|
| -INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey, EncryptedMediaTest,
|
| - Combine(Values(kExternalClearKeyKeySystem), Values(SRC)));
|
| -INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey, EncryptedMediaTest,
|
| - Combine(Values(kExternalClearKeyKeySystem), Values(MSE)));
|
| +INSTANTIATE_TEST_CASE_P(SRC_ExternalClearKey_Prefixed,
|
| + EncryptedMediaTest,
|
| + Combine(Values(kExternalClearKeyKeySystem),
|
| + Values(SRC),
|
| + Values(PREFIXED)));
|
| +// TODO(jrummell): Enable unprefixed tests once the CDM can be loaded using
|
| +// MediaKeys.
|
| +INSTANTIATE_TEST_CASE_P(DISABLED_SRC_ExternalClearKey,
|
| + EncryptedMediaTest,
|
| + Combine(Values(kExternalClearKeyKeySystem),
|
| + Values(SRC),
|
| + Values(UNPREFIXED)));
|
| +INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKey_Prefixed,
|
| + EncryptedMediaTest,
|
| + Combine(Values(kExternalClearKeyKeySystem),
|
| + Values(MSE),
|
| + Values(PREFIXED)));
|
| +// TODO(jrummell): Enable unprefixed tests once the CDM can be loaded using
|
| +// MediaKeys.
|
| +INSTANTIATE_TEST_CASE_P(DISABLED_MSE_ExternalClearKey,
|
| + EncryptedMediaTest,
|
| + Combine(Values(kExternalClearKeyKeySystem),
|
| + Values(MSE),
|
| + Values(UNPREFIXED)));
|
| // To reduce test time, only run ExternalClearKeyDecryptOnly with MSE.
|
| -INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly, EncryptedMediaTest,
|
| - Combine(Values(kExternalClearKeyDecryptOnlyKeySystem), Values(MSE)));
|
| +INSTANTIATE_TEST_CASE_P(MSE_ExternalClearKeyDecryptOnly_Prefixed,
|
| + EncryptedMediaTest,
|
| + Combine(Values(kExternalClearKeyDecryptOnlyKeySystem),
|
| + Values(MSE),
|
| + Values(PREFIXED)));
|
| +// TODO(jrummell): Enable unprefixed tests once the CDM can be loaded using
|
| +// MediaKeys.
|
| +INSTANTIATE_TEST_CASE_P(DISABLED_MSE_ExternalClearKeyDecryptOnly,
|
| + EncryptedMediaTest,
|
| + Combine(Values(kExternalClearKeyDecryptOnlyKeySystem),
|
| + Values(MSE),
|
| + Values(UNPREFIXED)));
|
| #endif // defined(ENABLE_PEPPER_CDMS)
|
|
|
| #if defined(WIDEVINE_CDM_AVAILABLE)
|
| // This test doesn't fully test playback with Widevine. So we only run Widevine
|
| // test with MSE (no SRC) to reduce test time. Also, on Android EME only works
|
| // with MSE and we cannot run this test with SRC.
|
| -INSTANTIATE_TEST_CASE_P(MSE_Widevine, EncryptedMediaTest,
|
| - Combine(Values(kWidevineKeySystem), Values(MSE)));
|
| +INSTANTIATE_TEST_CASE_P(MSE_Widevine_Prefixed,
|
| + EncryptedMediaTest,
|
| + Combine(Values(kWidevineKeySystem),
|
| + Values(MSE),
|
| + Values(PREFIXED)));
|
| +// TODO(jrummell): Enable unprefixed tests once the CDM can be loaded using
|
| +// MediaKeys.
|
| +INSTANTIATE_TEST_CASE_P(DISABLED_MSE_Widevine,
|
| + EncryptedMediaTest,
|
| + Combine(Values(kWidevineKeySystem),
|
| + Values(MSE),
|
| + Values(UNPREFIXED)));
|
| #endif // defined(WIDEVINE_CDM_AVAILABLE)
|
|
|
| IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) {
|
| @@ -496,12 +592,27 @@ IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_MP4) {
|
|
|
| #if defined(WIDEVINE_CDM_AVAILABLE)
|
| // The parent key system cannot be used in generateKeyRequest.
|
| -IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) {
|
| +IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException_Prefixed) {
|
| + RunEncryptedMediaTest("encrypted_media_player.html",
|
| + "bear-a-enc_a.webm",
|
| + kWebMAudioOnly,
|
| + "com.widevine",
|
| + MSE,
|
| + PREFIXED,
|
| + kNoSessionToLoad,
|
| + false,
|
| + kEmeNotSupportedError);
|
| +}
|
| +
|
| +// TODO(jrummell): http://crbug.com/349181
|
| +// The parent key system cannot be used when creating MediaKeys.
|
| +IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, DISABLED_ParentThrowsException) {
|
| RunEncryptedMediaTest("encrypted_media_player.html",
|
| "bear-a-enc_a.webm",
|
| kWebMAudioOnly,
|
| "com.widevine",
|
| MSE,
|
| + UNPREFIXED,
|
| kNoSessionToLoad,
|
| false,
|
| kEmeNotSupportedError);
|
| @@ -529,6 +640,7 @@ IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) {
|
| kWebMVideoOnly,
|
| kExternalClearKeyKeySystem,
|
| SRC,
|
| + PREFIXED,
|
| kLoadableSession,
|
| false,
|
| kEnded);
|
| @@ -541,6 +653,7 @@ IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) {
|
| kWebMVideoOnly,
|
| kExternalClearKeyKeySystem,
|
| SRC,
|
| + PREFIXED,
|
| kUnknownSession,
|
| false,
|
| kEmeKeyError);
|
|
|