Content settings: remove some plugin-related code/resources when... there are no...
[chromium-blink-merge.git] / content / shell / renderer / layout_test / blink_test_helpers.cc
blob97b2b8ae196c1d0b9b3e306054b25689f401bc9b
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 "content/shell/renderer/layout_test/blink_test_helpers.h"
7 #include "base/command_line.h"
8 #include "base/files/file_util.h"
9 #include "base/path_service.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "components/test_runner/test_preferences.h"
12 #include "content/public/common/content_switches.h"
13 #include "content/public/common/web_preferences.h"
14 #include "content/shell/common/shell_switches.h"
16 namespace content {
18 void ExportLayoutTestSpecificPreferences(
19 const test_runner::TestPreferences& from,
20 WebPreferences* to) {
21 to->allow_universal_access_from_file_urls =
22 from.allow_universal_access_from_file_urls;
23 to->dom_paste_enabled = from.dom_paste_allowed;
24 to->javascript_can_access_clipboard = from.java_script_can_access_clipboard;
25 to->xss_auditor_enabled = from.xss_auditor_enabled;
26 to->editing_behavior = static_cast<EditingBehavior>(from.editing_behavior);
27 to->default_font_size = from.default_font_size;
28 to->minimum_font_size = from.minimum_font_size;
29 to->default_encoding = from.default_text_encoding_name.utf8().data();
30 to->javascript_enabled = from.java_script_enabled;
31 to->supports_multiple_windows = from.supports_multiple_windows;
32 to->loads_images_automatically = from.loads_images_automatically;
33 to->plugins_enabled = from.plugins_enabled;
34 to->application_cache_enabled = from.offline_web_application_cache_enabled;
35 to->tabs_to_links = from.tabs_to_links;
36 to->experimental_webgl_enabled = from.experimental_webgl_enabled;
37 // experimentalCSSRegionsEnabled is deprecated and ignored.
38 to->hyperlink_auditing_enabled = from.hyperlink_auditing_enabled;
39 to->caret_browsing_enabled = from.caret_browsing_enabled;
40 to->allow_displaying_insecure_content =
41 from.allow_display_of_insecure_content;
42 to->allow_running_insecure_content = from.allow_running_of_insecure_content;
43 to->should_respect_image_orientation = from.should_respect_image_orientation;
44 to->asynchronous_spell_checking_enabled =
45 from.asynchronous_spell_checking_enabled;
46 to->allow_file_access_from_file_urls = from.allow_file_access_from_file_urls;
47 to->javascript_can_open_windows_automatically =
48 from.java_script_can_open_windows_automatically;
49 to->web_security_enabled =
50 from.web_security_enabled;
51 to->disable_reading_from_canvas = from.disable_reading_from_canvas;
52 to->strict_mixed_content_checking =
53 from.strict_mixed_content_checking;
54 to->strict_powerful_feature_restrictions =
55 from.strict_powerful_feature_restrictions;
58 // Applies settings that differ between layout tests and regular mode. Some
59 // of the defaults are controlled via command line flags which are
60 // automatically set for layout tests.
61 void ApplyLayoutTestDefaultPreferences(WebPreferences* prefs) {
62 const base::CommandLine& command_line =
63 *base::CommandLine::ForCurrentProcess();
64 prefs->allow_universal_access_from_file_urls = true;
65 prefs->dom_paste_enabled = true;
66 prefs->javascript_can_access_clipboard = true;
67 prefs->xslt_enabled = true;
68 prefs->xss_auditor_enabled = false;
69 #if defined(OS_MACOSX)
70 prefs->editing_behavior = EDITING_BEHAVIOR_MAC;
71 #else
72 prefs->editing_behavior = EDITING_BEHAVIOR_WIN;
73 #endif
74 prefs->application_cache_enabled = true;
75 prefs->tabs_to_links = false;
76 prefs->hyperlink_auditing_enabled = false;
77 prefs->allow_displaying_insecure_content = true;
78 prefs->allow_running_insecure_content = false;
79 prefs->disable_reading_from_canvas = false;
80 prefs->strict_mixed_content_checking = false;
81 prefs->strict_powerful_feature_restrictions = false;
82 prefs->webgl_errors_to_console_enabled = false;
83 base::string16 serif;
84 #if defined(OS_MACOSX)
85 prefs->cursive_font_family_map[kCommonScript] =
86 base::ASCIIToUTF16("Apple Chancery");
87 prefs->fantasy_font_family_map[kCommonScript] = base::ASCIIToUTF16("Papyrus");
88 serif = base::ASCIIToUTF16("Times");
89 #else
90 prefs->cursive_font_family_map[kCommonScript] =
91 base::ASCIIToUTF16("Comic Sans MS");
92 prefs->fantasy_font_family_map[kCommonScript] = base::ASCIIToUTF16("Impact");
93 serif = base::ASCIIToUTF16("times new roman");
94 #endif
95 prefs->serif_font_family_map[kCommonScript] = serif;
96 prefs->standard_font_family_map[kCommonScript] = serif;
97 prefs->fixed_font_family_map[kCommonScript] = base::ASCIIToUTF16("Courier");
98 prefs->sans_serif_font_family_map[kCommonScript] =
99 base::ASCIIToUTF16("Helvetica");
100 prefs->minimum_logical_font_size = 9;
101 prefs->asynchronous_spell_checking_enabled = false;
102 prefs->accelerated_2d_canvas_enabled =
103 command_line.HasSwitch(switches::kEnableAccelerated2DCanvas);
104 prefs->mock_scrollbars_enabled = false;
105 prefs->smart_insert_delete_enabled = true;
106 prefs->minimum_accelerated_2d_canvas_size = 0;
107 #if defined(OS_ANDROID)
108 prefs->text_autosizing_enabled = false;
109 #endif
110 prefs->viewport_enabled = false;
111 prefs->default_minimum_page_scale_factor = 1.f;
112 prefs->default_maximum_page_scale_factor = 4.f;
115 base::FilePath GetWebKitRootDirFilePath() {
116 base::FilePath base_path;
117 PathService::Get(base::DIR_SOURCE_ROOT, &base_path);
118 return base_path.Append(FILE_PATH_LITERAL("third_party/WebKit"));
121 } // namespace content