Enable right clicking on the applist doodle web contents and log the data.
[chromium-blink-merge.git] / content / shell / common / webkit_test_helpers.cc
blob65e3138b9f94b67c79ab151adcab40e255bf1d52
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/common/webkit_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/string_split.h"
11 #include "base/strings/utf_string_conversions.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"
15 #include "content/shell/common/test_runner/test_preferences.h"
17 namespace content {
19 void ExportLayoutTestSpecificPreferences(const 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->java_enabled = from.java_enabled;
35 to->application_cache_enabled = from.offline_web_application_cache_enabled;
36 to->tabs_to_links = from.tabs_to_links;
37 to->experimental_webgl_enabled = from.experimental_webgl_enabled;
38 // experimentalCSSRegionsEnabled is deprecated and ignored.
39 to->hyperlink_auditing_enabled = from.hyperlink_auditing_enabled;
40 to->caret_browsing_enabled = from.caret_browsing_enabled;
41 to->allow_displaying_insecure_content =
42 from.allow_display_of_insecure_content;
43 to->allow_running_insecure_content = from.allow_running_of_insecure_content;
44 to->should_respect_image_orientation = from.should_respect_image_orientation;
45 to->asynchronous_spell_checking_enabled =
46 from.asynchronous_spell_checking_enabled;
47 to->allow_file_access_from_file_urls = from.allow_file_access_from_file_urls;
48 to->javascript_can_open_windows_automatically =
49 from.java_script_can_open_windows_automatically;
50 to->web_security_enabled =
51 from.web_security_enabled;
52 to->disable_reading_from_canvas = from.disable_reading_from_canvas;
53 to->strict_mixed_content_checking =
54 from.strict_mixed_content_checking;
55 to->strict_powerful_feature_restrictions =
56 from.strict_powerful_feature_restrictions;
59 // Applies settings that differ between layout tests and regular mode. Some
60 // of the defaults are controlled via command line flags which are
61 // automatically set for layout tests.
62 void ApplyLayoutTestDefaultPreferences(WebPreferences* prefs) {
63 const base::CommandLine& command_line =
64 *base::CommandLine::ForCurrentProcess();
65 prefs->allow_universal_access_from_file_urls = true;
66 prefs->dom_paste_enabled = true;
67 prefs->javascript_can_access_clipboard = true;
68 prefs->xslt_enabled = true;
69 prefs->xss_auditor_enabled = false;
70 #if defined(OS_MACOSX)
71 prefs->editing_behavior = EDITING_BEHAVIOR_MAC;
72 #else
73 prefs->editing_behavior = EDITING_BEHAVIOR_WIN;
74 #endif
75 prefs->java_enabled = false;
76 prefs->application_cache_enabled = true;
77 prefs->tabs_to_links = false;
78 prefs->hyperlink_auditing_enabled = false;
79 prefs->allow_displaying_insecure_content = true;
80 prefs->allow_running_insecure_content = true;
81 prefs->disable_reading_from_canvas = false;
82 prefs->strict_mixed_content_checking = false;
83 prefs->strict_powerful_feature_restrictions = false;
84 prefs->webgl_errors_to_console_enabled = false;
85 base::string16 serif;
86 #if defined(OS_MACOSX)
87 prefs->cursive_font_family_map[kCommonScript] =
88 base::ASCIIToUTF16("Apple Chancery");
89 prefs->fantasy_font_family_map[kCommonScript] = base::ASCIIToUTF16("Papyrus");
90 serif = base::ASCIIToUTF16("Times");
91 #else
92 prefs->cursive_font_family_map[kCommonScript] =
93 base::ASCIIToUTF16("Comic Sans MS");
94 prefs->fantasy_font_family_map[kCommonScript] = base::ASCIIToUTF16("Impact");
95 serif = base::ASCIIToUTF16("times new roman");
96 #endif
97 prefs->serif_font_family_map[kCommonScript] = serif;
98 prefs->standard_font_family_map[kCommonScript] = serif;
99 prefs->fixed_font_family_map[kCommonScript] = base::ASCIIToUTF16("Courier");
100 prefs->sans_serif_font_family_map[kCommonScript] =
101 base::ASCIIToUTF16("Helvetica");
102 prefs->minimum_logical_font_size = 9;
103 prefs->asynchronous_spell_checking_enabled = false;
104 prefs->accelerated_2d_canvas_enabled =
105 command_line.HasSwitch(switches::kEnableAccelerated2DCanvas);
106 prefs->mock_scrollbars_enabled = false;
107 prefs->smart_insert_delete_enabled = true;
108 prefs->minimum_accelerated_2d_canvas_size = 0;
109 #if defined(OS_ANDROID)
110 prefs->text_autosizing_enabled = false;
111 #endif
112 prefs->viewport_enabled = false;
113 prefs->default_minimum_page_scale_factor = 1.f;
114 prefs->default_maximum_page_scale_factor = 4.f;
117 base::FilePath GetWebKitRootDirFilePath() {
118 base::FilePath base_path;
119 PathService::Get(base::DIR_SOURCE_ROOT, &base_path);
120 return base_path.Append(FILE_PATH_LITERAL("third_party/WebKit"));
123 std::vector<std::string> GetSideloadFontFiles() {
124 std::vector<std::string> files;
125 const base::CommandLine& command_line =
126 *base::CommandLine::ForCurrentProcess();
127 if (command_line.HasSwitch(switches::kRegisterFontFiles)) {
128 base::SplitString(
129 command_line.GetSwitchValueASCII(switches::kRegisterFontFiles),
130 ';',
131 &files);
133 return files;
136 } // namespace content