| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
| 10 #include "chrome/browser/media/media_browsertest.h" | 10 #include "chrome/browser/media/media_browsertest.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 110 } |
| 111 | 111 |
| 112 #if defined(WIDEVINE_CDM_AVAILABLE) | 112 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 113 bool IsWidevine(const std::string& key_system) { | 113 bool IsWidevine(const std::string& key_system) { |
| 114 return key_system == kWidevineKeySystem; | 114 return key_system == kWidevineKeySystem; |
| 115 } | 115 } |
| 116 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 116 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 117 | 117 |
| 118 void RunEncryptedMediaTestPage(const std::string& html_page, | 118 void RunEncryptedMediaTestPage(const std::string& html_page, |
| 119 const std::string& key_system, | 119 const std::string& key_system, |
| 120 std::vector<StringPair>* query_params, | 120 std::vector<media::StringPair>* query_params, |
| 121 const std::string& expected_title) { | 121 const std::string& expected_title) { |
| 122 StartLicenseServerIfNeeded(key_system, query_params); | 122 StartLicenseServerIfNeeded(key_system, query_params); |
| 123 RunMediaTestPage(html_page, query_params, expected_title, true); | 123 RunMediaTestPage(html_page, query_params, expected_title, true); |
| 124 } | 124 } |
| 125 | 125 |
| 126 // Tests |html_page| using |media_file| (with |media_type|) and |key_system|. | 126 // Tests |html_page| using |media_file| (with |media_type|) and |key_system|. |
| 127 // When |session_to_load| is not empty, the test will try to load | 127 // When |session_to_load| is not empty, the test will try to load |
| 128 // |session_to_load| with stored keys, instead of creating a new session | 128 // |session_to_load| with stored keys, instead of creating a new session |
| 129 // and trying to update it with licenses. | 129 // and trying to update it with licenses. |
| 130 // When |force_invalid_response| is true, the test will provide invalid | 130 // When |force_invalid_response| is true, the test will provide invalid |
| 131 // responses, which should trigger errors. | 131 // responses, which should trigger errors. |
| 132 // TODO(xhwang): Find an easier way to pass multiple configuration test | 132 // TODO(xhwang): Find an easier way to pass multiple configuration test |
| 133 // options. | 133 // options. |
| 134 void RunEncryptedMediaTest(const std::string& html_page, | 134 void RunEncryptedMediaTest(const std::string& html_page, |
| 135 const std::string& media_file, | 135 const std::string& media_file, |
| 136 const std::string& media_type, | 136 const std::string& media_type, |
| 137 const std::string& key_system, | 137 const std::string& key_system, |
| 138 SrcType src_type, | 138 SrcType src_type, |
| 139 EmeVersion eme_version, | 139 EmeVersion eme_version, |
| 140 const std::string& session_to_load, | 140 const std::string& session_to_load, |
| 141 bool force_invalid_response, | 141 bool force_invalid_response, |
| 142 const std::string& expected_title) { | 142 const std::string& expected_title) { |
| 143 if (src_type == MSE && !IsMSESupported()) { | 143 if (src_type == MSE && !IsMSESupported()) { |
| 144 VLOG(0) << "Skipping test - MSE not supported."; | 144 VLOG(0) << "Skipping test - MSE not supported."; |
| 145 return; | 145 return; |
| 146 } | 146 } |
| 147 std::vector<StringPair> query_params; | 147 std::vector<media::StringPair> query_params; |
| 148 query_params.push_back(std::make_pair("mediaFile", media_file)); | 148 query_params.push_back(std::make_pair("mediaFile", media_file)); |
| 149 query_params.push_back(std::make_pair("mediaType", media_type)); | 149 query_params.push_back(std::make_pair("mediaType", media_type)); |
| 150 query_params.push_back(std::make_pair("keySystem", key_system)); | 150 query_params.push_back(std::make_pair("keySystem", key_system)); |
| 151 if (src_type == MSE) | 151 if (src_type == MSE) |
| 152 query_params.push_back(std::make_pair("useMSE", "1")); | 152 query_params.push_back(std::make_pair("useMSE", "1")); |
| 153 if (eme_version == PREFIXED) | 153 if (eme_version == PREFIXED) |
| 154 query_params.push_back(std::make_pair("usePrefixedEME", "1")); | 154 query_params.push_back(std::make_pair("usePrefixedEME", "1")); |
| 155 if (force_invalid_response) | 155 if (force_invalid_response) |
| 156 query_params.push_back(std::make_pair("forceInvalidResponse", "1")); | 156 query_params.push_back(std::make_pair("forceInvalidResponse", "1")); |
| 157 if (!session_to_load.empty()) | 157 if (!session_to_load.empty()) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 181 // Check KeyMessage received for all key systems. | 181 // Check KeyMessage received for all key systems. |
| 182 bool receivedKeyMessage = false; | 182 bool receivedKeyMessage = false; |
| 183 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 183 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 184 browser()->tab_strip_model()->GetActiveWebContents(), | 184 browser()->tab_strip_model()->GetActiveWebContents(), |
| 185 "window.domAutomationController.send(" | 185 "window.domAutomationController.send(" |
| 186 "document.querySelector('video').receivedKeyMessage);", | 186 "document.querySelector('video').receivedKeyMessage);", |
| 187 &receivedKeyMessage)); | 187 &receivedKeyMessage)); |
| 188 EXPECT_TRUE(receivedKeyMessage); | 188 EXPECT_TRUE(receivedKeyMessage); |
| 189 } | 189 } |
| 190 | 190 |
| 191 | 191 void StartLicenseServerIfNeeded( |
| 192 void StartLicenseServerIfNeeded(const std::string& key_system, | 192 const std::string& key_system, |
| 193 std::vector<StringPair>* query_params) { | 193 std::vector<media::StringPair>* query_params) { |
| 194 scoped_ptr<TestLicenseServerConfig> config = GetServerConfig(key_system); | 194 scoped_ptr<TestLicenseServerConfig> config = GetServerConfig(key_system); |
| 195 if (!config) | 195 if (!config) |
| 196 return; | 196 return; |
| 197 license_server_.reset(new TestLicenseServer(config.Pass())); | 197 license_server_.reset(new TestLicenseServer(config.Pass())); |
| 198 EXPECT_TRUE(license_server_->Start()); | 198 EXPECT_TRUE(license_server_->Start()); |
| 199 query_params->push_back(std::make_pair("licenseServerURL", | 199 query_params->push_back(std::make_pair("licenseServerURL", |
| 200 license_server_->GetServerURL())); | 200 license_server_->GetServerURL())); |
| 201 } | 201 } |
| 202 | 202 |
| 203 bool IsPlayBackPossible(const std::string& key_system) { | 203 bool IsPlayBackPossible(const std::string& key_system) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 // decrypt-and-decode mode. | 305 // decrypt-and-decode mode. |
| 306 class ECKEncryptedMediaTest : public EncryptedMediaTestBase { | 306 class ECKEncryptedMediaTest : public EncryptedMediaTestBase { |
| 307 public: | 307 public: |
| 308 // We use special |key_system| names to do non-playback related tests, e.g. | 308 // We use special |key_system| names to do non-playback related tests, e.g. |
| 309 // kExternalClearKeyFileIOTestKeySystem is used to test file IO. | 309 // kExternalClearKeyFileIOTestKeySystem is used to test file IO. |
| 310 void TestNonPlaybackCases(const std::string& key_system, | 310 void TestNonPlaybackCases(const std::string& key_system, |
| 311 const std::string& expected_title) { | 311 const std::string& expected_title) { |
| 312 // Since we do not test playback, arbitrarily choose a test file and source | 312 // Since we do not test playback, arbitrarily choose a test file and source |
| 313 // type. | 313 // type. |
| 314 RunEncryptedMediaTest(kDefaultEmePlayer, | 314 RunEncryptedMediaTest(kDefaultEmePlayer, |
| 315 "bear-a-enc_a.webm", | 315 "bear-a_enc-a.webm", |
| 316 kWebMAudioOnly, | 316 kWebMAudioOnly, |
| 317 key_system, | 317 key_system, |
| 318 SRC, | 318 SRC, |
| 319 PREFIXED, | 319 PREFIXED, |
| 320 kNoSessionToLoad, | 320 kNoSessionToLoad, |
| 321 false, | 321 false, |
| 322 expected_title); | 322 expected_title); |
| 323 } | 323 } |
| 324 | 324 |
| 325 protected: | 325 protected: |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 const std::string& media_type) { | 372 const std::string& media_type) { |
| 373 RunSimpleEncryptedMediaTest(encrypted_media, | 373 RunSimpleEncryptedMediaTest(encrypted_media, |
| 374 media_type, | 374 media_type, |
| 375 CurrentKeySystem(), | 375 CurrentKeySystem(), |
| 376 CurrentSourceType(), | 376 CurrentSourceType(), |
| 377 CurrentEmeVersion()); | 377 CurrentEmeVersion()); |
| 378 } | 378 } |
| 379 | 379 |
| 380 void RunInvalidResponseTest() { | 380 void RunInvalidResponseTest() { |
| 381 RunEncryptedMediaTest(kDefaultEmePlayer, | 381 RunEncryptedMediaTest(kDefaultEmePlayer, |
| 382 "bear-320x240-av-enc_av.webm", | 382 "bear-320x240-av_enc-av.webm", |
| 383 kWebMAudioVideo, | 383 kWebMAudioVideo, |
| 384 CurrentKeySystem(), | 384 CurrentKeySystem(), |
| 385 CurrentSourceType(), | 385 CurrentSourceType(), |
| 386 CurrentEmeVersion(), | 386 CurrentEmeVersion(), |
| 387 kNoSessionToLoad, | 387 kNoSessionToLoad, |
| 388 true, | 388 true, |
| 389 kEmeKeyError); | 389 kEmeKeyError); |
| 390 } | 390 } |
| 391 | 391 |
| 392 void TestFrameSizeChange() { | 392 void TestFrameSizeChange() { |
| 393 RunEncryptedMediaTest("encrypted_frame_size_change.html", | 393 RunEncryptedMediaTest("encrypted_frame_size_change.html", |
| 394 "frame_size_change-av-enc-v.webm", | 394 "frame_size_change-av_enc-v.webm", |
| 395 kWebMAudioVideo, | 395 kWebMAudioVideo, |
| 396 CurrentKeySystem(), | 396 CurrentKeySystem(), |
| 397 CurrentSourceType(), | 397 CurrentSourceType(), |
| 398 CurrentEmeVersion(), | 398 CurrentEmeVersion(), |
| 399 kNoSessionToLoad, | 399 kNoSessionToLoad, |
| 400 false, | 400 false, |
| 401 kEnded); | 401 kEnded); |
| 402 } | 402 } |
| 403 | 403 |
| 404 void TestConfigChange() { | 404 void TestConfigChange() { |
| 405 DCHECK(IsMSESupported()); | 405 DCHECK(IsMSESupported()); |
| 406 std::vector<StringPair> query_params; | 406 std::vector<media::StringPair> query_params; |
| 407 query_params.push_back(std::make_pair("keySystem", CurrentKeySystem())); | 407 query_params.push_back(std::make_pair("keySystem", CurrentKeySystem())); |
| 408 query_params.push_back(std::make_pair("runEncrypted", "1")); | 408 query_params.push_back(std::make_pair("runEncrypted", "1")); |
| 409 if (CurrentEmeVersion() == PREFIXED) | 409 if (CurrentEmeVersion() == PREFIXED) |
| 410 query_params.push_back(std::make_pair("usePrefixedEME", "1")); | 410 query_params.push_back(std::make_pair("usePrefixedEME", "1")); |
| 411 RunEncryptedMediaTestPage("mse_config_change.html", | 411 RunEncryptedMediaTestPage("mse_config_change.html", |
| 412 CurrentKeySystem(), | 412 CurrentKeySystem(), |
| 413 &query_params, | 413 &query_params, |
| 414 kEnded); | 414 kEnded); |
| 415 } | 415 } |
| 416 | 416 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 #if !defined(WIDEVINE_CDM_IS_COMPONENT) | 504 #if !defined(WIDEVINE_CDM_IS_COMPONENT) |
| 505 INSTANTIATE_TEST_CASE_P(MSE_Widevine, | 505 INSTANTIATE_TEST_CASE_P(MSE_Widevine, |
| 506 EncryptedMediaTest, | 506 EncryptedMediaTest, |
| 507 Combine(Values(kWidevineKeySystem), | 507 Combine(Values(kWidevineKeySystem), |
| 508 Values(MSE), | 508 Values(MSE), |
| 509 Values(UNPREFIXED))); | 509 Values(UNPREFIXED))); |
| 510 #endif // !defined(WIDEVINE_CDM_IS_COMPONENT) | 510 #endif // !defined(WIDEVINE_CDM_IS_COMPONENT) |
| 511 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 511 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 512 | 512 |
| 513 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { | 513 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioOnly_WebM) { |
| 514 TestSimplePlayback("bear-a-enc_a.webm", kWebMAudioOnly); | 514 TestSimplePlayback("bear-a_enc-a.webm", kWebMAudioOnly); |
| 515 } | 515 } |
| 516 | 516 |
| 517 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) { | 517 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_AudioClearVideo_WebM) { |
| 518 TestSimplePlayback("bear-320x240-av-enc_a.webm", kWebMAudioVideo); | 518 TestSimplePlayback("bear-320x240-av_enc-a.webm", kWebMAudioVideo); |
| 519 } | 519 } |
| 520 | 520 |
| 521 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM) { | 521 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoAudio_WebM) { |
| 522 TestSimplePlayback("bear-320x240-av-enc_av.webm", kWebMAudioVideo); | 522 TestSimplePlayback("bear-320x240-av_enc-av.webm", kWebMAudioVideo); |
| 523 } | 523 } |
| 524 | 524 |
| 525 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_WebM) { | 525 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoOnly_WebM) { |
| 526 TestSimplePlayback("bear-320x240-v-enc_v.webm", kWebMVideoOnly); | 526 TestSimplePlayback("bear-320x240-v_enc-v.webm", kWebMVideoOnly); |
| 527 } | 527 } |
| 528 | 528 |
| 529 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM) { | 529 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VideoClearAudio_WebM) { |
| 530 TestSimplePlayback("bear-320x240-av-enc_v.webm", kWebMAudioVideo); | 530 TestSimplePlayback("bear-320x240-av_enc-v.webm", kWebMAudioVideo); |
| 531 } | 531 } |
| 532 | 532 |
| 533 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VP9Video_WebM) { | 533 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, Playback_VP9Video_WebM) { |
| 534 TestSimplePlayback("bear-320x240-v-vp9-enc_v.webm", kWebMVP9VideoOnly); | 534 TestSimplePlayback("bear-320x240-v-vp9_enc-v.webm", kWebMVP9VideoOnly); |
| 535 } | 535 } |
| 536 | 536 |
| 537 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, InvalidResponseKeyError) { | 537 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, InvalidResponseKeyError) { |
| 538 RunInvalidResponseTest(); | 538 RunInvalidResponseTest(); |
| 539 } | 539 } |
| 540 | 540 |
| 541 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, ConfigChangeVideo) { | 541 IN_PROC_BROWSER_TEST_P(EncryptedMediaTest, ConfigChangeVideo) { |
| 542 if (CurrentSourceType() != MSE || !IsMSESupported()) { | 542 if (CurrentSourceType() != MSE || !IsMSESupported()) { |
| 543 VLOG(0) << "Skipping test - ConfigChange test requires MSE."; | 543 VLOG(0) << "Skipping test - ConfigChange test requires MSE."; |
| 544 return; | 544 return; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 return; | 580 return; |
| 581 } | 581 } |
| 582 TestSimplePlayback("bear-640x360-a_frag-cenc.mp4", kMP4AudioOnly); | 582 TestSimplePlayback("bear-640x360-a_frag-cenc.mp4", kMP4AudioOnly); |
| 583 } | 583 } |
| 584 #endif // defined(USE_PROPRIETARY_CODECS) | 584 #endif // defined(USE_PROPRIETARY_CODECS) |
| 585 | 585 |
| 586 #if defined(WIDEVINE_CDM_AVAILABLE) | 586 #if defined(WIDEVINE_CDM_AVAILABLE) |
| 587 // The parent key system cannot be used in generateKeyRequest. | 587 // The parent key system cannot be used in generateKeyRequest. |
| 588 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException_Prefixed) { | 588 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException_Prefixed) { |
| 589 RunEncryptedMediaTest(kDefaultEmePlayer, | 589 RunEncryptedMediaTest(kDefaultEmePlayer, |
| 590 "bear-a-enc_a.webm", | 590 "bear-a_enc-a.webm", |
| 591 kWebMAudioOnly, | 591 kWebMAudioOnly, |
| 592 "com.widevine", | 592 "com.widevine", |
| 593 MSE, | 593 MSE, |
| 594 PREFIXED, | 594 PREFIXED, |
| 595 kNoSessionToLoad, | 595 kNoSessionToLoad, |
| 596 false, | 596 false, |
| 597 kEmeNotSupportedError); | 597 kEmeNotSupportedError); |
| 598 } | 598 } |
| 599 | 599 |
| 600 // TODO(jrummell): http://crbug.com/349181 | 600 // TODO(jrummell): http://crbug.com/349181 |
| 601 // The parent key system cannot be used when creating MediaKeys. | 601 // The parent key system cannot be used when creating MediaKeys. |
| 602 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) { | 602 IN_PROC_BROWSER_TEST_F(WVEncryptedMediaTest, ParentThrowsException) { |
| 603 RunEncryptedMediaTest(kDefaultEmePlayer, | 603 RunEncryptedMediaTest(kDefaultEmePlayer, |
| 604 "bear-a-enc_a.webm", | 604 "bear-a_enc-a.webm", |
| 605 kWebMAudioOnly, | 605 kWebMAudioOnly, |
| 606 "com.widevine", | 606 "com.widevine", |
| 607 MSE, | 607 MSE, |
| 608 UNPREFIXED, | 608 UNPREFIXED, |
| 609 kNoSessionToLoad, | 609 kNoSessionToLoad, |
| 610 false, | 610 false, |
| 611 kEmeNotSupportedError); | 611 kEmeNotSupportedError); |
| 612 } | 612 } |
| 613 #endif // defined(WIDEVINE_CDM_AVAILABLE) | 613 #endif // defined(WIDEVINE_CDM_AVAILABLE) |
| 614 | 614 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 633 "plugin crash"); | 633 "plugin crash"); |
| 634 } | 634 } |
| 635 | 635 |
| 636 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, FileIOTest) { | 636 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, FileIOTest) { |
| 637 TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem, | 637 TestNonPlaybackCases(kExternalClearKeyFileIOTestKeySystem, |
| 638 kFileIOTestSuccess); | 638 kFileIOTestSuccess); |
| 639 } | 639 } |
| 640 | 640 |
| 641 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) { | 641 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadLoadableSession) { |
| 642 RunEncryptedMediaTest(kDefaultEmePlayer, | 642 RunEncryptedMediaTest(kDefaultEmePlayer, |
| 643 "bear-320x240-v-enc_v.webm", | 643 "bear-320x240-v_enc-v.webm", |
| 644 kWebMVideoOnly, | 644 kWebMVideoOnly, |
| 645 kExternalClearKeyKeySystem, | 645 kExternalClearKeyKeySystem, |
| 646 SRC, | 646 SRC, |
| 647 PREFIXED, | 647 PREFIXED, |
| 648 kLoadableSession, | 648 kLoadableSession, |
| 649 false, | 649 false, |
| 650 kEnded); | 650 kEnded); |
| 651 } | 651 } |
| 652 | 652 |
| 653 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) { | 653 IN_PROC_BROWSER_TEST_F(ECKEncryptedMediaTest, LoadUnknownSession) { |
| 654 // TODO(xhwang): Add a specific error for this failure, e.g. kSessionNotFound. | 654 // TODO(xhwang): Add a specific error for this failure, e.g. kSessionNotFound. |
| 655 RunEncryptedMediaTest(kDefaultEmePlayer, | 655 RunEncryptedMediaTest(kDefaultEmePlayer, |
| 656 "bear-320x240-v-enc_v.webm", | 656 "bear-320x240-v_enc-v.webm", |
| 657 kWebMVideoOnly, | 657 kWebMVideoOnly, |
| 658 kExternalClearKeyKeySystem, | 658 kExternalClearKeyKeySystem, |
| 659 SRC, | 659 SRC, |
| 660 PREFIXED, | 660 PREFIXED, |
| 661 kUnknownSession, | 661 kUnknownSession, |
| 662 false, | 662 false, |
| 663 kEmeKeyError); | 663 kEmeKeyError); |
| 664 } | 664 } |
| 665 #endif // defined(ENABLE_PEPPER_CDMS) | 665 #endif // defined(ENABLE_PEPPER_CDMS) |
| OLD | NEW |