blob: d2c1ea1df3e831eba5b8e96d8b8c59dc383925a4 [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
[email protected]b7c504c2013-05-07 14:42:125#include "content/shell/common/webkit_test_helpers.h"
[email protected]55915a72012-12-18 11:55:256
[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]74ebfb12013-06-07 20:48:0010#include "base/strings/utf_string_conversions.h"
[email protected]8b5f7752013-08-29 22:40:5011#include "content/public/common/content_switches.h"
[email protected]b7c504c2013-05-07 14:42:1212#include "content/shell/common/shell_switches.h"
[email protected]1f70cfa42014-04-04 21:35:0113#include "content/shell/common/test_runner/test_preferences.h"
[email protected]fab55e72013-05-31 07:06:1814#include "webkit/common/webpreferences.h"
[email protected]55915a72012-12-18 11:55:2515
[email protected]55915a72012-12-18 11:55:2516namespace content {
17
[email protected]3184f90b2013-05-01 18:17:5318void ExportLayoutTestSpecificPreferences(
[email protected]1f70cfa42014-04-04 21:35:0119 const TestPreferences& from,
[email protected]3184f90b2013-05-01 18:17:5320 WebPreferences* to) {
[email protected]55915a72012-12-18 11:55:2521 to->allow_universal_access_from_file_urls =
[email protected]1f70cfa42014-04-04 21:35:0122 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;
[email protected]3184f90b2013-05-01 18:17:5326 to->editing_behavior = static_cast<webkit_glue::EditingBehavior>(
[email protected]1f70cfa42014-04-04 21:35:0127 from.editing_behavior);
28 to->default_font_size = from.default_font_size;
29 to->minimum_font_size = from.minimum_font_size;
30 to->default_encoding = from.default_text_encoding_name.utf8().data();
31 to->javascript_enabled = from.java_script_enabled;
32 to->supports_multiple_windows = from.supports_multiple_windows;
33 to->loads_images_automatically = from.loads_images_automatically;
34 to->plugins_enabled = from.plugins_enabled;
35 to->java_enabled = from.java_enabled;
36 to->application_cache_enabled = from.offline_web_application_cache_enabled;
37 to->tabs_to_links = from.tabs_to_links;
38 to->experimental_webgl_enabled = from.experimental_webgl_enabled;
[email protected]375db13a2012-12-18 21:42:5839 // experimentalCSSRegionsEnabled is deprecated and ignored.
[email protected]1f70cfa42014-04-04 21:35:0140 to->hyperlink_auditing_enabled = from.hyperlink_auditing_enabled;
41 to->caret_browsing_enabled = from.caret_browsing_enabled;
42 to->allow_displaying_insecure_content =
43 from.allow_display_of_insecure_content;
44 to->allow_running_insecure_content = from.allow_running_of_insecure_content;
45 to->should_respect_image_orientation = from.should_respect_image_orientation;
[email protected]a7aca152013-02-21 13:29:0946 to->asynchronous_spell_checking_enabled =
[email protected]1f70cfa42014-04-04 21:35:0147 from.asynchronous_spell_checking_enabled;
48 to->allow_file_access_from_file_urls = from.allow_file_access_from_file_urls;
[email protected]52097ca2013-02-21 14:32:4949 to->javascript_can_open_windows_automatically =
[email protected]1f70cfa42014-04-04 21:35:0150 from.java_script_can_open_windows_automatically;
[email protected]55915a72012-12-18 11:55:2551}
52
[email protected]52097ca2013-02-21 14:32:4953// Applies settings that differ between layout tests and regular mode. Some
54// of the defaults are controlled via command line flags which are
55// automatically set for layout tests.
[email protected]3184f90b2013-05-01 18:17:5356void ApplyLayoutTestDefaultPreferences(WebPreferences* prefs) {
[email protected]8b5f7752013-08-29 22:40:5057 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
[email protected]f0c25f02012-12-21 17:55:5558 prefs->allow_universal_access_from_file_urls = true;
59 prefs->dom_paste_enabled = true;
60 prefs->javascript_can_access_clipboard = true;
[email protected]d6ba5f232013-10-01 22:56:3561 prefs->xslt_enabled = true;
[email protected]f0c25f02012-12-21 17:55:5562 prefs->xss_auditor_enabled = false;
63#if defined(OS_MACOSX)
[email protected]3184f90b2013-05-01 18:17:5364 prefs->editing_behavior = webkit_glue::EDITING_BEHAVIOR_MAC;
[email protected]f0c25f02012-12-21 17:55:5565#else
[email protected]3184f90b2013-05-01 18:17:5366 prefs->editing_behavior = webkit_glue::EDITING_BEHAVIOR_WIN;
[email protected]f0c25f02012-12-21 17:55:5567#endif
68 prefs->java_enabled = false;
69 prefs->application_cache_enabled = true;
70 prefs->tabs_to_links = false;
71 prefs->hyperlink_auditing_enabled = false;
72 prefs->allow_displaying_insecure_content = true;
73 prefs->allow_running_insecure_content = true;
[email protected]3bbab7e2012-12-22 07:07:1674 prefs->webgl_errors_to_console_enabled = false;
[email protected]fcf75d42013-12-03 20:11:2675 base::string16 serif;
[email protected]933bdfbc2013-01-11 11:48:1176#if defined(OS_MACOSX)
[email protected]3184f90b2013-05-01 18:17:5377 prefs->cursive_font_family_map[webkit_glue::kCommonScript] =
[email protected]32956122013-12-25 07:29:2478 base::ASCIIToUTF16("Apple Chancery");
[email protected]3184f90b2013-05-01 18:17:5379 prefs->fantasy_font_family_map[webkit_glue::kCommonScript] =
[email protected]32956122013-12-25 07:29:2480 base::ASCIIToUTF16("Papyrus");
81 serif = base::ASCIIToUTF16("Times");
[email protected]933bdfbc2013-01-11 11:48:1182#else
[email protected]3184f90b2013-05-01 18:17:5383 prefs->cursive_font_family_map[webkit_glue::kCommonScript] =
[email protected]32956122013-12-25 07:29:2484 base::ASCIIToUTF16("Comic Sans MS");
[email protected]3184f90b2013-05-01 18:17:5385 prefs->fantasy_font_family_map[webkit_glue::kCommonScript] =
[email protected]32956122013-12-25 07:29:2486 base::ASCIIToUTF16("Impact");
87 serif = base::ASCIIToUTF16("times new roman");
[email protected]933bdfbc2013-01-11 11:48:1188#endif
[email protected]3184f90b2013-05-01 18:17:5389 prefs->serif_font_family_map[webkit_glue::kCommonScript] =
[email protected]933bdfbc2013-01-11 11:48:1190 serif;
[email protected]3184f90b2013-05-01 18:17:5391 prefs->standard_font_family_map[webkit_glue::kCommonScript] =
[email protected]933bdfbc2013-01-11 11:48:1192 serif;
[email protected]3184f90b2013-05-01 18:17:5393 prefs->fixed_font_family_map[webkit_glue::kCommonScript] =
[email protected]32956122013-12-25 07:29:2494 base::ASCIIToUTF16("Courier");
[email protected]933bdfbc2013-01-11 11:48:1195 prefs->sans_serif_font_family_map[
[email protected]32956122013-12-25 07:29:2496 webkit_glue::kCommonScript] = base::ASCIIToUTF16("Helvetica");
[email protected]933bdfbc2013-01-11 11:48:1197 prefs->minimum_logical_font_size = 9;
[email protected]9de7a11c2013-01-23 16:09:0298 prefs->asynchronous_spell_checking_enabled = false;
[email protected]1796b7c2013-02-28 10:42:1499 prefs->threaded_html_parser = true;
[email protected]0989186e2013-03-06 09:43:46100 prefs->accelerated_2d_canvas_enabled =
101 command_line.HasSwitch(switches::kEnableAccelerated2DCanvas);
[email protected]8b5f7752013-08-29 22:40:50102 prefs->force_compositing_mode =
103 command_line.HasSwitch(switches::kForceCompositingMode);
[email protected]92ee7d6b2013-03-04 09:08:59104 prefs->accelerated_compositing_for_video_enabled = false;
[email protected]92ee7d6b2013-03-04 09:08:59105 prefs->mock_scrollbars_enabled = false;
[email protected]e94f2112013-03-16 19:04:11106 prefs->fixed_position_creates_stacking_context = false;
[email protected]85f5450d2013-03-18 17:13:59107 prefs->smart_insert_delete_enabled = true;
[email protected]9c0e9df2013-03-18 22:51:18108 prefs->minimum_accelerated_2d_canvas_size = 0;
[email protected]5ee2c922013-06-18 14:03:18109#if defined(OS_ANDROID)
110 prefs->text_autosizing_enabled = false;
111#endif
[email protected]6d2eabc2014-02-20 14:55:15112 prefs->viewport_enabled = false;
[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);
[email protected]fea004c2013-07-28 14:24:18118 return base_path.Append(FILE_PATH_LITERAL("third_party/WebKit"));
[email protected]294e74f2013-04-29 14:50:54119}
120
[email protected]55915a72012-12-18 11:55:25121} // namespace content