blob: 5599d43d68e157f6bcd466692973a8a6d29df8da [file] [log] [blame]
[email protected]55915a72012-12-18 11:55:251// 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.
4
5#include "content/shell/webkit_test_helpers.h"
6
[email protected]0989186e2013-03-06 09:43:467#include "base/command_line.h"
[email protected]294e74f2013-04-29 14:50:548#include "base/file_util.h"
9#include "base/path_service.h"
[email protected]933bdfbc2013-01-11 11:48:1110#include "base/utf_string_conversions.h"
[email protected]0989186e2013-03-06 09:43:4611#include "content/shell/shell_switches.h"
[email protected]55915a72012-12-18 11:55:2512#include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebPreferences.h"
13#include "webkit/glue/webpreferences.h"
14
15using WebTestRunner::WebPreferences;
16
17namespace content {
18
[email protected]d48eab082012-12-19 09:25:4719void ExportLayoutTestSpecificPreferences(const WebPreferences& from,
20 webkit_glue::WebPreferences* to) {
[email protected]55915a72012-12-18 11:55:2521 to->allow_universal_access_from_file_urls =
22 from.allowUniversalAccessFromFileURLs;
23 to->dom_paste_enabled = from.DOMPasteAllowed;
24 to->javascript_can_access_clipboard = from.javaScriptCanAccessClipboard;
25 to->xss_auditor_enabled = from.XSSAuditorEnabled;
26 to->editing_behavior =
27 static_cast<webkit_glue::WebPreferences::EditingBehavior>(
28 from.editingBehavior);
[email protected]375db13a2012-12-18 21:42:5829 to->default_font_size = from.defaultFontSize;
30 to->minimum_font_size = from.minimumFontSize;
31 to->default_encoding = from.defaultTextEncodingName.utf8().data();
32 to->javascript_enabled = from.javaScriptEnabled;
33 to->supports_multiple_windows = from.supportsMultipleWindows;
34 to->loads_images_automatically = from.loadsImagesAutomatically;
35 to->plugins_enabled = from.pluginsEnabled;
36 to->java_enabled = from.javaEnabled;
[email protected]375db13a2012-12-18 21:42:5837 to->application_cache_enabled = from.offlineWebApplicationCacheEnabled;
38 to->tabs_to_links = from.tabsToLinks;
39 to->experimental_webgl_enabled = from.experimentalWebGLEnabled;
40 to->css_grid_layout_enabled = from.experimentalCSSGridLayoutEnabled;
41 // experimentalCSSRegionsEnabled is deprecated and ignored.
42 to->hyperlink_auditing_enabled = from.hyperlinkAuditingEnabled;
43 to->caret_browsing_enabled = from.caretBrowsingEnabled;
44 to->allow_displaying_insecure_content = from.allowDisplayOfInsecureContent;
45 to->allow_running_insecure_content = from.allowRunningOfInsecureContent;
46 to->css_shaders_enabled = from.cssCustomFilterEnabled;
47 to->should_respect_image_orientation = from.shouldRespectImageOrientation;
[email protected]a7aca152013-02-21 13:29:0948 to->asynchronous_spell_checking_enabled =
49 from.asynchronousSpellCheckingEnabled;
[email protected]52097ca2013-02-21 14:32:4950 to->allow_file_access_from_file_urls = from.allowFileAccessFromFileURLs;
51 to->author_and_user_styles_enabled = from.authorAndUserStylesEnabled;
52 to->javascript_can_open_windows_automatically =
53 from.javaScriptCanOpenWindowsAutomatically;
54 to->user_style_sheet_location = from.userStyleSheetLocation;
[email protected]7e1ca112013-02-23 01:07:3655 to->touch_drag_drop_enabled = from.touchDragDropEnabled;
[email protected]55915a72012-12-18 11:55:2556}
57
[email protected]52097ca2013-02-21 14:32:4958// 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.
[email protected]f0c25f02012-12-21 17:55:5561void ApplyLayoutTestDefaultPreferences(webkit_glue::WebPreferences* prefs) {
[email protected]0989186e2013-03-06 09:43:4662 CommandLine& command_line = *CommandLine::ForCurrentProcess();
[email protected]f0c25f02012-12-21 17:55:5563 prefs->allow_universal_access_from_file_urls = true;
64 prefs->dom_paste_enabled = true;
65 prefs->javascript_can_access_clipboard = true;
66 prefs->xss_auditor_enabled = false;
67#if defined(OS_MACOSX)
68 prefs->editing_behavior = webkit_glue::WebPreferences::EDITING_BEHAVIOR_MAC;
69#else
70 prefs->editing_behavior = webkit_glue::WebPreferences::EDITING_BEHAVIOR_WIN;
71#endif
72 prefs->java_enabled = false;
73 prefs->application_cache_enabled = true;
74 prefs->tabs_to_links = false;
75 prefs->hyperlink_auditing_enabled = false;
76 prefs->allow_displaying_insecure_content = true;
77 prefs->allow_running_insecure_content = true;
[email protected]3bbab7e2012-12-22 07:07:1678 prefs->webgl_errors_to_console_enabled = false;
[email protected]933bdfbc2013-01-11 11:48:1179 string16 serif;
80#if defined(OS_MACOSX)
81 prefs->cursive_font_family_map[webkit_glue::WebPreferences::kCommonScript] =
82 ASCIIToUTF16("Apple Chancery");
83 prefs->fantasy_font_family_map[webkit_glue::WebPreferences::kCommonScript] =
84 ASCIIToUTF16("Papyrus");
85 serif = ASCIIToUTF16("Times");
86#else
87 prefs->cursive_font_family_map[webkit_glue::WebPreferences::kCommonScript] =
88 ASCIIToUTF16("Comic Sans MS");
89 prefs->fantasy_font_family_map[webkit_glue::WebPreferences::kCommonScript] =
90 ASCIIToUTF16("Impact");
91 serif = ASCIIToUTF16("times new roman");
92#endif
93 prefs->serif_font_family_map[webkit_glue::WebPreferences::kCommonScript] =
94 serif;
95 prefs->standard_font_family_map[webkit_glue::WebPreferences::kCommonScript] =
96 serif;
97 prefs->fixed_font_family_map[webkit_glue::WebPreferences::kCommonScript] =
98 ASCIIToUTF16("Courier");
99 prefs->sans_serif_font_family_map[
100 webkit_glue::WebPreferences::kCommonScript] = ASCIIToUTF16("Helvetica");
101 prefs->minimum_logical_font_size = 9;
[email protected]9de7a11c2013-01-23 16:09:02102 prefs->asynchronous_spell_checking_enabled = false;
[email protected]52097ca2013-02-21 14:32:49103 prefs->user_style_sheet_enabled = true;
[email protected]1796b7c2013-02-28 10:42:14104 prefs->threaded_html_parser = true;
[email protected]0989186e2013-03-06 09:43:46105 prefs->accelerated_2d_canvas_enabled =
106 command_line.HasSwitch(switches::kEnableAccelerated2DCanvas);
[email protected]92ee7d6b2013-03-04 09:08:59107 prefs->accelerated_compositing_for_video_enabled = false;
[email protected]92ee7d6b2013-03-04 09:08:59108 prefs->mock_scrollbars_enabled = false;
[email protected]e94f2112013-03-16 19:04:11109 prefs->fixed_position_creates_stacking_context = false;
[email protected]e8f35bc2013-03-18 15:22:01110 prefs->apply_page_scale_factor_in_compositor = false;
[email protected]85f5450d2013-03-18 17:13:59111 prefs->smart_insert_delete_enabled = true;
[email protected]9c0e9df2013-03-18 22:51:18112 prefs->minimum_accelerated_2d_canvas_size = 0;
[email protected]d48eab082012-12-19 09:25:47113}
114
[email protected]294e74f2013-04-29 14:50:54115base::FilePath GetWebKitRootDirFilePath() {
116 base::FilePath base_path;
117 PathService::Get(base::DIR_SOURCE_ROOT, &base_path);
118 if (file_util::PathExists(
119 base_path.Append(FILE_PATH_LITERAL("third_party/WebKit")))) {
120 // We're in a WebKit-in-chrome checkout.
121 return base_path.Append(FILE_PATH_LITERAL("third_party/WebKit"));
122 } else if (file_util::PathExists(
123 base_path.Append(FILE_PATH_LITERAL("chromium")))) {
124 // We're in a WebKit-only checkout on Windows.
125 return base_path.Append(FILE_PATH_LITERAL("../.."));
126 } else if (file_util::PathExists(
127 base_path.Append(FILE_PATH_LITERAL("webkit/support")))) {
128 // We're in a WebKit-only/xcodebuild checkout on Mac
129 return base_path.Append(FILE_PATH_LITERAL("../../.."));
130 }
131 // We're in a WebKit-only, make-build, so the DIR_SOURCE_ROOT is already the
132 // WebKit root. That, or we have no idea where we are.
133 return base_path;
134}
135
136base::FilePath GetChromiumRootDirFilePath() {
137 base::FilePath webkit_path = GetWebKitRootDirFilePath();
138 if (file_util::PathExists(webkit_path.Append(
139 FILE_PATH_LITERAL("Source/WebKit/chromium/webkit/support")))) {
140 // We're in a WebKit-only checkout.
141 return webkit_path.Append(FILE_PATH_LITERAL("Source/WebKit/chromium"));
142 } else {
143 // We're in a Chromium checkout, and WebKit is in third_party/WebKit.
144 return webkit_path.Append(FILE_PATH_LITERAL("../.."));
145 }
146}
147
[email protected]55915a72012-12-18 11:55:25148} // namespace content