OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/test/scoped_feature_list.h" | 9 #include "base/test/scoped_feature_list.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 #include "content/public/common/content_constants.h" | 38 #include "content/public/common/content_constants.h" |
39 #include "content/public/common/content_switches.h" | 39 #include "content/public/common/content_switches.h" |
40 #include "content/public/common/mhtml_generation_params.h" | 40 #include "content/public/common/mhtml_generation_params.h" |
41 #include "content/public/test/browser_test_utils.h" | 41 #include "content/public/test/browser_test_utils.h" |
42 #include "content/public/test/ppapi_test_utils.h" | 42 #include "content/public/test/ppapi_test_utils.h" |
43 #include "content/public/test/test_utils.h" | 43 #include "content/public/test/test_utils.h" |
44 #include "media/cdm/cdm_paths.h" | 44 #include "media/cdm/cdm_paths.h" |
45 #include "net/dns/mock_host_resolver.h" | 45 #include "net/dns/mock_host_resolver.h" |
46 #include "net/test/embedded_test_server/embedded_test_server.h" | 46 #include "net/test/embedded_test_server/embedded_test_server.h" |
47 #include "net/test/url_request/url_request_mock_http_job.h" | 47 #include "net/test/url_request/url_request_mock_http_job.h" |
48 #include "ppapi/features/features.h" | |
49 #include "ppapi/shared_impl/ppapi_switches.h" | 48 #include "ppapi/shared_impl/ppapi_switches.h" |
50 #include "testing/gmock/include/gmock/gmock.h" | 49 #include "testing/gmock/include/gmock/gmock.h" |
51 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 50 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
52 | 51 |
53 #if defined(OS_MACOSX) | 52 #if defined(OS_MACOSX) |
54 #include "base/mac/scoped_nsautorelease_pool.h" | 53 #include "base/mac/scoped_nsautorelease_pool.h" |
55 #endif | 54 #endif |
56 | 55 |
57 #if BUILDFLAG(ENABLE_PEPPER_CDMS) | 56 #if defined(ENABLE_PEPPER_CDMS) |
58 #include "chrome/browser/media/pepper_cdm_test_helper.h" | 57 #include "chrome/browser/media/pepper_cdm_test_helper.h" |
59 #endif | 58 #endif |
60 | 59 |
61 using content::BrowserThread; | 60 using content::BrowserThread; |
62 using net::URLRequestMockHTTPJob; | 61 using net::URLRequestMockHTTPJob; |
63 | 62 |
64 namespace { | 63 namespace { |
65 | 64 |
66 const LocalSharedObjectsContainer* GetSiteSettingsCookieContainer( | 65 const LocalSharedObjectsContainer* GetSiteSettingsCookieContainer( |
67 Browser* browser) { | 66 Browser* browser) { |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 protected: | 349 protected: |
351 void SetUpCommandLine(base::CommandLine* command_line) override { | 350 void SetUpCommandLine(base::CommandLine* command_line) override { |
352 ASSERT_TRUE(ppapi::RegisterFlashTestPlugin(command_line)); | 351 ASSERT_TRUE(ppapi::RegisterFlashTestPlugin(command_line)); |
353 | 352 |
354 #if !defined(DISABLE_NACL) | 353 #if !defined(DISABLE_NACL) |
355 // Ensure NaCl can run. | 354 // Ensure NaCl can run. |
356 command_line->AppendSwitch(switches::kEnableNaCl); | 355 command_line->AppendSwitch(switches::kEnableNaCl); |
357 #endif | 356 #endif |
358 } | 357 } |
359 | 358 |
360 #if BUILDFLAG(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE) | 359 #if defined(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE) |
361 // Since the CDM is bundled and registered through the component updater, | 360 // Since the CDM is bundled and registered through the component updater, |
362 // we must re-enable the component updater. | 361 // we must re-enable the component updater. |
363 void SetUpDefaultCommandLine(base::CommandLine* command_line) override { | 362 void SetUpDefaultCommandLine(base::CommandLine* command_line) override { |
364 base::CommandLine default_command_line(base::CommandLine::NO_PROGRAM); | 363 base::CommandLine default_command_line(base::CommandLine::NO_PROGRAM); |
365 InProcessBrowserTest::SetUpDefaultCommandLine(&default_command_line); | 364 InProcessBrowserTest::SetUpDefaultCommandLine(&default_command_line); |
366 test_launcher_utils::RemoveCommandLineSwitch( | 365 test_launcher_utils::RemoveCommandLineSwitch( |
367 default_command_line, switches::kDisableComponentUpdate, command_line); | 366 default_command_line, switches::kDisableComponentUpdate, command_line); |
368 } | 367 } |
369 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE) | 368 #endif // defined(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE) |
370 | 369 |
371 void SetUpInProcessBrowserTestFixture() override { | 370 void SetUpInProcessBrowserTestFixture() override { |
372 ContentSettingsTest::SetUpInProcessBrowserTestFixture(); | 371 ContentSettingsTest::SetUpInProcessBrowserTestFixture(); |
373 | 372 |
374 // Disable the HTML by Default feature so we can test blocked plugins. | 373 // Disable the HTML by Default feature so we can test blocked plugins. |
375 feature_list.InitAndDisableFeature(features::kPreferHtmlOverPlugins); | 374 feature_list.InitAndDisableFeature(features::kPreferHtmlOverPlugins); |
376 } | 375 } |
377 | 376 |
378 void RunLoadPepperPluginTest(const char* mime_type, bool expect_loaded) { | 377 void RunLoadPepperPluginTest(const char* mime_type, bool expect_loaded) { |
379 const char* expected_result = expect_loaded ? "Loaded" : "Not Loaded"; | 378 const char* expected_result = expect_loaded ? "Loaded" : "Not Loaded"; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 | 490 |
492 // The following tests verify that Pepper plugins that use JavaScript settings | 491 // The following tests verify that Pepper plugins that use JavaScript settings |
493 // instead of Plugins settings still work when Plugins are blocked. | 492 // instead of Plugins settings still work when Plugins are blocked. |
494 | 493 |
495 // The plugin successfully loaded above is blocked. | 494 // The plugin successfully loaded above is blocked. |
496 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest, | 495 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest, |
497 BlockedFlash) { | 496 BlockedFlash) { |
498 RunLoadPepperPluginTest(content::kFlashPluginSwfMimeType, false); | 497 RunLoadPepperPluginTest(content::kFlashPluginSwfMimeType, false); |
499 } | 498 } |
500 | 499 |
501 #if BUILDFLAG(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE) && \ | 500 #if defined(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE) && \ |
502 !defined(OS_CHROMEOS) | 501 !defined(OS_CHROMEOS) |
503 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest, | 502 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest, |
504 WidevineCdm) { | 503 WidevineCdm) { |
505 // Check that Widevine CDM is available and registered. | 504 // Check that Widevine CDM is available and registered. |
506 base::FilePath adapter_path = | 505 base::FilePath adapter_path = |
507 GetPepperCdmPath(kWidevineCdmBaseDirectory, kWidevineCdmAdapterFileName); | 506 GetPepperCdmPath(kWidevineCdmBaseDirectory, kWidevineCdmAdapterFileName); |
508 EXPECT_TRUE(base::PathExists(adapter_path)) << adapter_path.MaybeAsASCII(); | 507 EXPECT_TRUE(base::PathExists(adapter_path)) << adapter_path.MaybeAsASCII(); |
509 EXPECT_TRUE(IsPepperCdmRegistered(kWidevineCdmPluginMimeType)); | 508 EXPECT_TRUE(IsPepperCdmRegistered(kWidevineCdmPluginMimeType)); |
510 RunLoadPepperPluginTest(kWidevineCdmPluginMimeType, true); | 509 RunLoadPepperPluginTest(kWidevineCdmPluginMimeType, true); |
511 } | 510 } |
512 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE) && | 511 #endif // defined(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE) && |
513 // !defined(OS_CHROMEOS) | 512 // !defined(OS_CHROMEOS) |
514 | 513 |
515 #if !defined(DISABLE_NACL) | 514 #if !defined(DISABLE_NACL) |
516 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest, | 515 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest, |
517 NaCl) { | 516 NaCl) { |
518 RunLoadPepperPluginTest("application/x-nacl", true); | 517 RunLoadPepperPluginTest("application/x-nacl", true); |
519 } | 518 } |
520 #endif // !defined(DISABLE_NACL) | 519 #endif // !defined(DISABLE_NACL) |
521 | 520 |
522 // The following tests verify that those same Pepper plugins do not work when | 521 // The following tests verify that those same Pepper plugins do not work when |
523 // JavaScript is blocked. | 522 // JavaScript is blocked. |
524 | 523 |
525 // A plugin with no special behavior is not blocked when JavaScript is blocked. | 524 // A plugin with no special behavior is not blocked when JavaScript is blocked. |
526 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest, | 525 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest, |
527 Flash) { | 526 Flash) { |
528 RunJavaScriptBlockedTest("load_flash_no_js.html", false); | 527 RunJavaScriptBlockedTest("load_flash_no_js.html", false); |
529 } | 528 } |
530 | 529 |
531 #if BUILDFLAG(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE) | 530 #if defined(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE) |
532 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest, | 531 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest, |
533 WidevineCdm) { | 532 WidevineCdm) { |
534 // Check that Widevine CDM is available and registered. | 533 // Check that Widevine CDM is available and registered. |
535 base::FilePath adapter_path = | 534 base::FilePath adapter_path = |
536 GetPepperCdmPath(kWidevineCdmBaseDirectory, kWidevineCdmAdapterFileName); | 535 GetPepperCdmPath(kWidevineCdmBaseDirectory, kWidevineCdmAdapterFileName); |
537 EXPECT_TRUE(base::PathExists(adapter_path)) << adapter_path.MaybeAsASCII(); | 536 EXPECT_TRUE(base::PathExists(adapter_path)) << adapter_path.MaybeAsASCII(); |
538 EXPECT_TRUE(IsPepperCdmRegistered(kWidevineCdmPluginMimeType)); | 537 EXPECT_TRUE(IsPepperCdmRegistered(kWidevineCdmPluginMimeType)); |
539 RunJavaScriptBlockedTest("load_widevine_no_js.html", true); | 538 RunJavaScriptBlockedTest("load_widevine_no_js.html", true); |
540 } | 539 } |
541 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE) | 540 #endif // defined(ENABLE_PEPPER_CDMS) && defined(WIDEVINE_CDM_AVAILABLE) |
542 | 541 |
543 #if !defined(DISABLE_NACL) | 542 #if !defined(DISABLE_NACL) |
544 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest, | 543 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest, |
545 NaCl) { | 544 NaCl) { |
546 RunJavaScriptBlockedTest("load_nacl_no_js.html", true); | 545 RunJavaScriptBlockedTest("load_nacl_no_js.html", true); |
547 } | 546 } |
548 #endif // !defined(DISABLE_NACL) | 547 #endif // !defined(DISABLE_NACL) |
549 | 548 |
550 #endif // defined(ENABLE_PLUGINS) | 549 #endif // defined(ENABLE_PLUGINS) |
OLD | NEW |