Add a webstorePrivate API to show a permission prompt for delegated bundle installs
[chromium-blink-merge.git] / chrome / browser / content_settings / content_settings_browsertest.cc
blob6f15f49dd40b623c928d32ac30d6664fa9a18b22
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
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "base/path_service.h"
7 #include "base/strings/stringprintf.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/content_settings/cookie_settings.h"
11 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
12 #include "chrome/browser/net/url_request_mock_util.h"
13 #include "chrome/browser/plugins/chrome_plugin_service_filter.h"
14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_commands.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/render_messages.h"
20 #include "chrome/test/base/in_process_browser_test.h"
21 #include "chrome/test/base/test_switches.h"
22 #include "chrome/test/base/ui_test_utils.h"
23 #include "components/content_settings/core/browser/host_content_settings_map.h"
24 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/notification_observer.h"
26 #include "content/public/browser/notification_service.h"
27 #include "content/public/browser/plugin_service.h"
28 #include "content/public/browser/render_frame_host.h"
29 #include "content/public/browser/render_process_host.h"
30 #include "content/public/browser/render_view_host.h"
31 #include "content/public/browser/web_contents.h"
32 #include "content/public/common/content_switches.h"
33 #include "content/public/test/browser_test_utils.h"
34 #include "content/public/test/test_utils.h"
35 #include "net/test/spawned_test_server/spawned_test_server.h"
36 #include "net/test/url_request/url_request_mock_http_job.h"
38 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
40 #if defined(OS_MACOSX)
41 #include "base/mac/scoped_nsautorelease_pool.h"
42 #endif
44 using content::BrowserThread;
45 using net::URLRequestMockHTTPJob;
47 class ContentSettingsTest : public InProcessBrowserTest {
48 public:
49 ContentSettingsTest()
50 : https_server_(net::SpawnedTestServer::TYPE_HTTPS,
51 net::SpawnedTestServer::SSLOptions(
52 net::SpawnedTestServer::SSLOptions::CERT_OK),
53 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))) {
56 void SetUpOnMainThread() override {
57 BrowserThread::PostTask(
58 BrowserThread::IO, FROM_HERE,
59 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true));
62 // Check the cookie for the given URL in an incognito window.
63 void CookieCheckIncognitoWindow(const GURL& url, bool cookies_enabled) {
64 ASSERT_TRUE(content::GetCookies(browser()->profile(), url).empty());
66 Browser* incognito = CreateIncognitoBrowser();
67 ASSERT_TRUE(content::GetCookies(incognito->profile(), url).empty());
68 ui_test_utils::NavigateToURL(incognito, url);
69 ASSERT_EQ(cookies_enabled,
70 !content::GetCookies(incognito->profile(), url).empty());
72 // Ensure incognito cookies don't leak to regular profile.
73 ASSERT_TRUE(content::GetCookies(browser()->profile(), url).empty());
75 // Ensure cookies get wiped after last incognito window closes.
76 content::WindowedNotificationObserver signal(
77 chrome::NOTIFICATION_BROWSER_CLOSED,
78 content::Source<Browser>(incognito));
80 chrome::CloseWindow(incognito);
82 #if defined(OS_MACOSX)
83 // BrowserWindowController depends on the auto release pool being recycled
84 // in the message loop to delete itself, which frees the Browser object
85 // which fires this event.
86 AutoreleasePool()->Recycle();
87 #endif
89 signal.Wait();
91 incognito = CreateIncognitoBrowser();
92 ASSERT_TRUE(content::GetCookies(incognito->profile(), url).empty());
93 chrome::CloseWindow(incognito);
96 void PreBasic(const GURL& url) {
97 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty());
99 CookieCheckIncognitoWindow(url, true);
101 ui_test_utils::NavigateToURL(browser(), url);
102 ASSERT_FALSE(GetCookies(browser()->profile(), url).empty());
105 void Basic(const GURL& url) {
106 ASSERT_FALSE(GetCookies(browser()->profile(), url).empty());
109 net::SpawnedTestServer https_server_;
112 // Sanity check on cookies before we do other tests. While these can be written
113 // in content_browsertests, we want to verify Chrome's cookie storage and how it
114 // handles incognito windows.
115 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, PRE_BasicCookies) {
116 ASSERT_TRUE(test_server()->Start());
117 GURL http_url = test_server()->GetURL("files/setcookie.html");
118 PreBasic(http_url);
121 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, BasicCookies) {
122 ASSERT_TRUE(test_server()->Start());
123 GURL http_url = test_server()->GetURL("files/setcookie.html");
124 Basic(http_url);
127 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, PRE_BasicCookiesHttps) {
128 ASSERT_TRUE(https_server_.Start());
129 GURL https_url = https_server_.GetURL("files/setcookie.html");
130 PreBasic(https_url);
133 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, BasicCookiesHttps) {
134 ASSERT_TRUE(https_server_.Start());
135 GURL https_url = https_server_.GetURL("files/setcookie.html");
136 Basic(https_url);
139 // Verify that cookies are being blocked.
140 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, PRE_BlockCookies) {
141 ASSERT_TRUE(test_server()->Start());
142 CookieSettings::Factory::GetForProfile(browser()->profile())->
143 SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
144 GURL url = test_server()->GetURL("files/setcookie.html");
145 ui_test_utils::NavigateToURL(browser(), url);
146 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty());
147 CookieCheckIncognitoWindow(url, false);
150 // Ensure that the setting persists.
151 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, BlockCookies) {
152 ASSERT_EQ(
153 CONTENT_SETTING_BLOCK,
154 CookieSettings::Factory::GetForProfile(browser()->profile())->
155 GetDefaultCookieSetting(NULL));
158 // Verify that cookies can be allowed and set using exceptions for particular
159 // website(s) when all others are blocked.
160 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, AllowCookiesUsingExceptions) {
161 ASSERT_TRUE(test_server()->Start());
162 GURL url = test_server()->GetURL("files/setcookie.html");
163 CookieSettings* settings =
164 CookieSettings::Factory::GetForProfile(browser()->profile()).get();
165 settings->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
167 ui_test_utils::NavigateToURL(browser(), url);
168 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty());
170 settings->SetCookieSetting(
171 ContentSettingsPattern::FromURL(url),
172 ContentSettingsPattern::Wildcard(), CONTENT_SETTING_ALLOW);
174 ui_test_utils::NavigateToURL(browser(), url);
175 ASSERT_FALSE(GetCookies(browser()->profile(), url).empty());
178 // Verify that cookies can be blocked for a specific website using exceptions.
179 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, BlockCookiesUsingExceptions) {
180 ASSERT_TRUE(test_server()->Start());
181 GURL url = test_server()->GetURL("files/setcookie.html");
182 CookieSettings* settings =
183 CookieSettings::Factory::GetForProfile(browser()->profile()).get();
184 settings->SetCookieSetting(ContentSettingsPattern::FromURL(url),
185 ContentSettingsPattern::Wildcard(),
186 CONTENT_SETTING_BLOCK);
188 ui_test_utils::NavigateToURL(browser(), url);
189 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty());
191 ASSERT_TRUE(https_server_.Start());
192 GURL unblocked_url = https_server_.GetURL("files/cookie1.html");
194 ui_test_utils::NavigateToURL(browser(), unblocked_url);
195 ASSERT_FALSE(GetCookies(browser()->profile(), unblocked_url).empty());
198 // This fails on ChromeOS because kRestoreOnStartup is ignored and the startup
199 // preference is always "continue where I left off.
200 #if !defined(OS_CHROMEOS)
202 // Verify that cookies can be allowed and set using exceptions for particular
203 // website(s) only for a session when all others are blocked.
204 IN_PROC_BROWSER_TEST_F(ContentSettingsTest,
205 PRE_AllowCookiesForASessionUsingExceptions) {
206 // NOTE: don't use test_server here, since we need the port to be the same
207 // across the restart.
208 GURL url = URLRequestMockHTTPJob::GetMockUrl(
209 base::FilePath(FILE_PATH_LITERAL("setcookie.html")));
210 CookieSettings* settings =
211 CookieSettings::Factory::GetForProfile(browser()->profile()).get();
212 settings->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
214 ui_test_utils::NavigateToURL(browser(), url);
215 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty());
217 settings->SetCookieSetting(
218 ContentSettingsPattern::FromURL(url),
219 ContentSettingsPattern::Wildcard(), CONTENT_SETTING_SESSION_ONLY);
220 ui_test_utils::NavigateToURL(browser(), url);
221 ASSERT_FALSE(GetCookies(browser()->profile(), url).empty());
224 IN_PROC_BROWSER_TEST_F(ContentSettingsTest,
225 AllowCookiesForASessionUsingExceptions) {
226 GURL url = URLRequestMockHTTPJob::GetMockUrl(
227 base::FilePath(FILE_PATH_LITERAL("setcookie.html")));
228 ASSERT_TRUE(GetCookies(browser()->profile(), url).empty());
231 #endif // !CHROME_OS
233 // Regression test for http://crbug.com/63649.
234 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, RedirectLoopCookies) {
235 ASSERT_TRUE(test_server()->Start());
237 GURL test_url = test_server()->GetURL("files/redirect-loop.html");
239 CookieSettings::Factory::GetForProfile(browser()->profile())->
240 SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
242 ui_test_utils::NavigateToURL(browser(), test_url);
244 content::WebContents* web_contents =
245 browser()->tab_strip_model()->GetActiveWebContents();
246 ASSERT_EQ(base::UTF8ToUTF16(test_url.spec() + " failed to load"),
247 web_contents->GetTitle());
249 EXPECT_TRUE(TabSpecificContentSettings::FromWebContents(web_contents)->
250 IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES));
253 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, ContentSettingsBlockDataURLs) {
254 GURL url("data:text/html,<title>Data URL</title><script>alert(1)</script>");
256 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting(
257 CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK);
259 ui_test_utils::NavigateToURL(browser(), url);
261 content::WebContents* web_contents =
262 browser()->tab_strip_model()->GetActiveWebContents();
263 ASSERT_EQ(base::UTF8ToUTF16("Data URL"), web_contents->GetTitle());
265 EXPECT_TRUE(TabSpecificContentSettings::FromWebContents(web_contents)->
266 IsContentBlocked(CONTENT_SETTINGS_TYPE_JAVASCRIPT));
269 // Tests that if redirect across origins occurs, the new process still gets the
270 // content settings before the resource headers.
271 IN_PROC_BROWSER_TEST_F(ContentSettingsTest, RedirectCrossOrigin) {
272 ASSERT_TRUE(test_server()->Start());
274 net::HostPortPair host_port = test_server()->host_port_pair();
275 DCHECK_EQ(host_port.host(), std::string("127.0.0.1"));
277 std::string redirect(base::StringPrintf(
278 "http://localhost:%d/files/redirect-cross-origin.html",
279 host_port.port()));
280 GURL test_url = test_server()->GetURL("server-redirect?" + redirect);
282 CookieSettings::Factory::GetForProfile(browser()->profile())->
283 SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
285 ui_test_utils::NavigateToURL(browser(), test_url);
287 content::WebContents* web_contents =
288 browser()->tab_strip_model()->GetActiveWebContents();
290 EXPECT_TRUE(TabSpecificContentSettings::FromWebContents(web_contents)->
291 IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES));
294 #if defined(ENABLE_PLUGINS)
295 class PepperContentSettingsSpecialCasesTest : public ContentSettingsTest {
296 protected:
297 static const char* const kExternalClearKeyMimeType;
299 // Registers any CDM plugins not registered by default.
300 void SetUpCommandLine(base::CommandLine* command_line) override {
301 #if defined(ENABLE_PEPPER_CDMS)
302 // Platform-specific filename relative to the chrome executable.
303 #if defined(OS_WIN)
304 const char kLibraryName[] = "clearkeycdmadapter.dll";
305 #else // !defined(OS_WIN)
306 #if defined(OS_MACOSX)
307 const char kLibraryName[] = "clearkeycdmadapter.plugin";
308 #elif defined(OS_POSIX)
309 const char kLibraryName[] = "libclearkeycdmadapter.so";
310 #endif // defined(OS_MACOSX)
311 #endif // defined(OS_WIN)
313 // Append the switch to register the External Clear Key CDM.
314 base::FilePath::StringType pepper_plugins = BuildPepperPluginRegistration(
315 kLibraryName, "Clear Key CDM", kExternalClearKeyMimeType);
316 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
317 // The CDM must be registered when it is a component.
318 pepper_plugins.append(FILE_PATH_LITERAL(","));
319 pepper_plugins.append(
320 BuildPepperPluginRegistration(kWidevineCdmAdapterFileName,
321 kWidevineCdmDisplayName,
322 kWidevineCdmPluginMimeType));
323 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
324 command_line->AppendSwitchNative(switches::kRegisterPepperPlugins,
325 pepper_plugins);
326 #endif // defined(ENABLE_PEPPER_CDMS)
328 #if !defined(DISABLE_NACL)
329 // Ensure NaCl can run.
330 command_line->AppendSwitch(switches::kEnableNaCl);
331 #endif
334 void RunLoadPepperPluginTest(const char* mime_type, bool expect_loaded) {
335 const char* expected_result = expect_loaded ? "Loaded" : "Not Loaded";
336 content::WebContents* web_contents =
337 browser()->tab_strip_model()->GetActiveWebContents();
339 base::string16 expected_title(base::ASCIIToUTF16(expected_result));
340 content::TitleWatcher title_watcher(web_contents, expected_title);
342 // GetTestUrl assumes paths, so we must append query parameters to result.
343 GURL file_url = ui_test_utils::GetTestUrl(
344 base::FilePath(),
345 base::FilePath().AppendASCII("load_pepper_plugin.html"));
346 GURL url(file_url.spec() +
347 base::StringPrintf("?mimetype=%s", mime_type));
348 ui_test_utils::NavigateToURL(browser(), url);
350 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
351 EXPECT_EQ(!expect_loaded,
352 TabSpecificContentSettings::FromWebContents(web_contents)->
353 IsContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS));
356 void RunJavaScriptBlockedTest(const char* html_file,
357 bool expect_is_javascript_content_blocked) {
358 // Because JavaScript is blocked, <title> will be the only title set.
359 // Checking for it ensures that the page loaded, though that is not always
360 // sufficient - see below.
361 const char* const kExpectedTitle = "Initial Title";
362 content::WebContents* web_contents =
363 browser()->tab_strip_model()->GetActiveWebContents();
364 TabSpecificContentSettings* tab_settings =
365 TabSpecificContentSettings::FromWebContents(web_contents);
366 base::string16 expected_title(base::ASCIIToUTF16(kExpectedTitle));
367 content::TitleWatcher title_watcher(web_contents, expected_title);
369 // Because JavaScript is blocked, we cannot rely on JavaScript to set a
370 // title, telling us the test is complete.
371 // As a result, it is possible to reach the IsContentBlocked() checks below
372 // before the blocked content can be reported to the browser process.
373 // See http://crbug.com/306702.
374 // Therefore, when expecting blocked content, we must wait until it has been
375 // reported by checking IsContentBlocked() when notified that
376 // NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED. (It is not sufficient to wait
377 // for just the notification because the same notification is reported for
378 // other reasons and the notification contains no indication of what
379 // caused it.)
380 content::WindowedNotificationObserver javascript_content_blocked_observer(
381 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED,
382 base::Bind(&TabSpecificContentSettings::IsContentBlocked,
383 base::Unretained(tab_settings),
384 CONTENT_SETTINGS_TYPE_JAVASCRIPT));
386 GURL url = ui_test_utils::GetTestUrl(
387 base::FilePath(), base::FilePath().AppendASCII(html_file));
388 ui_test_utils::NavigateToURL(browser(), url);
390 // Always wait for the page to load.
391 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
393 if (expect_is_javascript_content_blocked) {
394 javascript_content_blocked_observer.Wait();
395 } else {
396 // Since there is no notification that content is not blocked and no
397 // content is blocked when |expect_is_javascript_content_blocked| is
398 // false, javascript_content_blocked_observer would never succeed.
399 // There is no way to ensure blocked content would not have been reported
400 // after the check below. For coverage of this scenario, we must rely on
401 // the TitleWatcher adding sufficient delay most of the time.
404 EXPECT_EQ(expect_is_javascript_content_blocked,
405 tab_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_JAVASCRIPT));
406 EXPECT_FALSE(tab_settings->IsContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS));
409 private:
410 // Builds the string to pass to kRegisterPepperPlugins for a single
411 // plugin using the provided parameters and a dummy version.
412 // Multiple results may be passed to kRegisterPepperPlugins, separated by ",".
413 base::FilePath::StringType BuildPepperPluginRegistration(
414 const char* library_name,
415 const char* display_name,
416 const char* mime_type) {
417 base::FilePath plugin_dir;
418 EXPECT_TRUE(PathService::Get(base::DIR_MODULE, &plugin_dir));
420 base::FilePath plugin_lib = plugin_dir.AppendASCII(library_name);
421 EXPECT_TRUE(base::PathExists(plugin_lib));
423 base::FilePath::StringType pepper_plugin = plugin_lib.value();
424 std::string string_to_append = "#";
425 string_to_append.append(display_name);
426 string_to_append.append("#A CDM#0.1.0.0;");
427 string_to_append.append(mime_type);
429 #if defined(OS_WIN)
430 pepper_plugin.append(base::ASCIIToUTF16(string_to_append));
431 #else
432 pepper_plugin.append(string_to_append);
433 #endif
435 return pepper_plugin;
439 const char* const
440 PepperContentSettingsSpecialCasesTest::kExternalClearKeyMimeType =
441 "application/x-ppapi-clearkey-cdm";
443 class PepperContentSettingsSpecialCasesPluginsBlockedTest
444 : public PepperContentSettingsSpecialCasesTest {
445 public:
446 void SetUpOnMainThread() override {
447 PepperContentSettingsSpecialCasesTest::SetUpOnMainThread();
448 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting(
449 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK);
453 class PepperContentSettingsSpecialCasesJavaScriptBlockedTest
454 : public PepperContentSettingsSpecialCasesTest {
455 public:
456 void SetUpOnMainThread() override {
457 PepperContentSettingsSpecialCasesTest::SetUpOnMainThread();
458 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting(
459 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_ALLOW);
460 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting(
461 CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK);
465 #if defined(ENABLE_PEPPER_CDMS)
466 // A sanity check to verify that the plugin that is used as a baseline below
467 // can be loaded.
468 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesTest, Baseline) {
469 #if defined(OS_WIN) && defined(USE_ASH)
470 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
471 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
472 switches::kAshBrowserTests))
473 return;
474 #endif
475 browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting(
476 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_ALLOW);
478 RunLoadPepperPluginTest(kExternalClearKeyMimeType, true);
480 #endif // defined(ENABLE_PEPPER_CDMS)
482 // The following tests verify that Pepper plugins that use JavaScript settings
483 // instead of Plugins settings still work when Plugins are blocked.
485 #if defined(ENABLE_PEPPER_CDMS)
486 // The plugin successfully loaded above is blocked.
487 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest,
488 Normal) {
489 #if defined(OS_WIN) && defined(USE_ASH)
490 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
491 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
492 switches::kAshBrowserTests))
493 return;
494 #endif
495 RunLoadPepperPluginTest(kExternalClearKeyMimeType, false);
498 #if defined(WIDEVINE_CDM_AVAILABLE)
499 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest,
500 WidevineCdm) {
501 #if defined(OS_WIN) && defined(USE_ASH)
502 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
503 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
504 switches::kAshBrowserTests))
505 return;
506 #endif
507 RunLoadPepperPluginTest(kWidevineCdmPluginMimeType, true);
509 #endif // defined(WIDEVINE_CDM_AVAILABLE)
510 #endif // defined(ENABLE_PEPPER_CDMS)
512 #if !defined(DISABLE_NACL)
513 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesPluginsBlockedTest,
514 NaCl) {
515 #if defined(OS_WIN) && defined(USE_ASH)
516 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
517 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
518 switches::kAshBrowserTests))
519 return;
520 #endif
521 RunLoadPepperPluginTest("application/x-nacl", true);
523 #endif // !defined(DISABLE_NACL)
525 // The following tests verify that those same Pepper plugins do not work when
526 // JavaScript is blocked.
528 #if defined(ENABLE_PEPPER_CDMS)
529 // A plugin with no special behavior is not blocked when JavaScript is blocked.
530 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest,
531 Normal) {
532 #if defined(OS_WIN) && defined(USE_ASH)
533 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
534 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
535 switches::kAshBrowserTests))
536 return;
537 #endif
538 RunJavaScriptBlockedTest("load_clearkey_no_js.html", false);
541 #if defined(WIDEVINE_CDM_AVAILABLE)
542 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest,
543 WidevineCdm) {
544 #if defined(OS_WIN) && defined(USE_ASH)
545 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
546 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
547 switches::kAshBrowserTests))
548 return;
549 #endif
550 RunJavaScriptBlockedTest("load_widevine_no_js.html", true);
552 #endif // defined(WIDEVINE_CDM_AVAILABLE)
553 #endif // defined(ENABLE_PEPPER_CDMS)
555 #if !defined(DISABLE_NACL)
556 IN_PROC_BROWSER_TEST_F(PepperContentSettingsSpecialCasesJavaScriptBlockedTest,
557 NaCl) {
558 #if defined(OS_WIN) && defined(USE_ASH)
559 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
560 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
561 switches::kAshBrowserTests))
562 return;
563 #endif
564 RunJavaScriptBlockedTest("load_nacl_no_js.html", true);
566 #endif // !defined(DISABLE_NACL)
568 #endif // defined(ENABLE_PLUGINS)