[email protected] | 55915a7 | 2012-12-18 11:55:25 | [diff] [blame] | 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. | ||||
4 | |||||
[email protected] | b7c504c | 2013-05-07 14:42:12 | [diff] [blame] | 5 | #include "content/shell/common/webkit_test_helpers.h" |
[email protected] | 55915a7 | 2012-12-18 11:55:25 | [diff] [blame] | 6 | |
[email protected] | 0989186e | 2013-03-06 09:43:46 | [diff] [blame] | 7 | #include "base/command_line.h" |
[email protected] | 294e74f | 2013-04-29 14:50:54 | [diff] [blame] | 8 | #include "base/file_util.h" |
9 | #include "base/path_service.h" | ||||
[email protected] | 74ebfb1 | 2013-06-07 20:48:00 | [diff] [blame] | 10 | #include "base/strings/utf_string_conversions.h" |
[email protected] | 8b5f775 | 2013-08-29 22:40:50 | [diff] [blame] | 11 | #include "content/public/common/content_switches.h" |
[email protected] | b7c504c | 2013-05-07 14:42:12 | [diff] [blame] | 12 | #include "content/shell/common/shell_switches.h" |
[email protected] | 1f70cfa4 | 2014-04-04 21:35:01 | [diff] [blame^] | 13 | #include "content/shell/common/test_runner/test_preferences.h" |
[email protected] | fab55e7 | 2013-05-31 07:06:18 | [diff] [blame] | 14 | #include "webkit/common/webpreferences.h" |
[email protected] | 55915a7 | 2012-12-18 11:55:25 | [diff] [blame] | 15 | |
[email protected] | 55915a7 | 2012-12-18 11:55:25 | [diff] [blame] | 16 | namespace content { |
17 | |||||
[email protected] | 3184f90b | 2013-05-01 18:17:53 | [diff] [blame] | 18 | void ExportLayoutTestSpecificPreferences( |
[email protected] | 1f70cfa4 | 2014-04-04 21:35:01 | [diff] [blame^] | 19 | const TestPreferences& from, |
[email protected] | 3184f90b | 2013-05-01 18:17:53 | [diff] [blame] | 20 | WebPreferences* to) { |
[email protected] | 55915a7 | 2012-12-18 11:55:25 | [diff] [blame] | 21 | to->allow_universal_access_from_file_urls = |
[email protected] | 1f70cfa4 | 2014-04-04 21:35:01 | [diff] [blame^] | 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; | ||||
[email protected] | 3184f90b | 2013-05-01 18:17:53 | [diff] [blame] | 26 | to->editing_behavior = static_cast<webkit_glue::EditingBehavior>( |
[email protected] | 1f70cfa4 | 2014-04-04 21:35:01 | [diff] [blame^] | 27 | 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] | 375db13a | 2012-12-18 21:42:58 | [diff] [blame] | 39 | // experimentalCSSRegionsEnabled is deprecated and ignored. |
[email protected] | 1f70cfa4 | 2014-04-04 21:35:01 | [diff] [blame^] | 40 | 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] | a7aca15 | 2013-02-21 13:29:09 | [diff] [blame] | 46 | to->asynchronous_spell_checking_enabled = |
[email protected] | 1f70cfa4 | 2014-04-04 21:35:01 | [diff] [blame^] | 47 | from.asynchronous_spell_checking_enabled; |
48 | to->allow_file_access_from_file_urls = from.allow_file_access_from_file_urls; | ||||
[email protected] | 52097ca | 2013-02-21 14:32:49 | [diff] [blame] | 49 | to->javascript_can_open_windows_automatically = |
[email protected] | 1f70cfa4 | 2014-04-04 21:35:01 | [diff] [blame^] | 50 | from.java_script_can_open_windows_automatically; |
[email protected] | 55915a7 | 2012-12-18 11:55:25 | [diff] [blame] | 51 | } |
52 | |||||
[email protected] | 52097ca | 2013-02-21 14:32:49 | [diff] [blame] | 53 | // 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] | 3184f90b | 2013-05-01 18:17:53 | [diff] [blame] | 56 | void ApplyLayoutTestDefaultPreferences(WebPreferences* prefs) { |
[email protected] | 8b5f775 | 2013-08-29 22:40:50 | [diff] [blame] | 57 | const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
[email protected] | f0c25f0 | 2012-12-21 17:55:55 | [diff] [blame] | 58 | prefs->allow_universal_access_from_file_urls = true; |
59 | prefs->dom_paste_enabled = true; | ||||
60 | prefs->javascript_can_access_clipboard = true; | ||||
[email protected] | d6ba5f23 | 2013-10-01 22:56:35 | [diff] [blame] | 61 | prefs->xslt_enabled = true; |
[email protected] | f0c25f0 | 2012-12-21 17:55:55 | [diff] [blame] | 62 | prefs->xss_auditor_enabled = false; |
63 | #if defined(OS_MACOSX) | ||||
[email protected] | 3184f90b | 2013-05-01 18:17:53 | [diff] [blame] | 64 | prefs->editing_behavior = webkit_glue::EDITING_BEHAVIOR_MAC; |
[email protected] | f0c25f0 | 2012-12-21 17:55:55 | [diff] [blame] | 65 | #else |
[email protected] | 3184f90b | 2013-05-01 18:17:53 | [diff] [blame] | 66 | prefs->editing_behavior = webkit_glue::EDITING_BEHAVIOR_WIN; |
[email protected] | f0c25f0 | 2012-12-21 17:55:55 | [diff] [blame] | 67 | #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] | 3bbab7e | 2012-12-22 07:07:16 | [diff] [blame] | 74 | prefs->webgl_errors_to_console_enabled = false; |
[email protected] | fcf75d4 | 2013-12-03 20:11:26 | [diff] [blame] | 75 | base::string16 serif; |
[email protected] | 933bdfbc | 2013-01-11 11:48:11 | [diff] [blame] | 76 | #if defined(OS_MACOSX) |
[email protected] | 3184f90b | 2013-05-01 18:17:53 | [diff] [blame] | 77 | prefs->cursive_font_family_map[webkit_glue::kCommonScript] = |
[email protected] | 3295612 | 2013-12-25 07:29:24 | [diff] [blame] | 78 | base::ASCIIToUTF16("Apple Chancery"); |
[email protected] | 3184f90b | 2013-05-01 18:17:53 | [diff] [blame] | 79 | prefs->fantasy_font_family_map[webkit_glue::kCommonScript] = |
[email protected] | 3295612 | 2013-12-25 07:29:24 | [diff] [blame] | 80 | base::ASCIIToUTF16("Papyrus"); |
81 | serif = base::ASCIIToUTF16("Times"); | ||||
[email protected] | 933bdfbc | 2013-01-11 11:48:11 | [diff] [blame] | 82 | #else |
[email protected] | 3184f90b | 2013-05-01 18:17:53 | [diff] [blame] | 83 | prefs->cursive_font_family_map[webkit_glue::kCommonScript] = |
[email protected] | 3295612 | 2013-12-25 07:29:24 | [diff] [blame] | 84 | base::ASCIIToUTF16("Comic Sans MS"); |
[email protected] | 3184f90b | 2013-05-01 18:17:53 | [diff] [blame] | 85 | prefs->fantasy_font_family_map[webkit_glue::kCommonScript] = |
[email protected] | 3295612 | 2013-12-25 07:29:24 | [diff] [blame] | 86 | base::ASCIIToUTF16("Impact"); |
87 | serif = base::ASCIIToUTF16("times new roman"); | ||||
[email protected] | 933bdfbc | 2013-01-11 11:48:11 | [diff] [blame] | 88 | #endif |
[email protected] | 3184f90b | 2013-05-01 18:17:53 | [diff] [blame] | 89 | prefs->serif_font_family_map[webkit_glue::kCommonScript] = |
[email protected] | 933bdfbc | 2013-01-11 11:48:11 | [diff] [blame] | 90 | serif; |
[email protected] | 3184f90b | 2013-05-01 18:17:53 | [diff] [blame] | 91 | prefs->standard_font_family_map[webkit_glue::kCommonScript] = |
[email protected] | 933bdfbc | 2013-01-11 11:48:11 | [diff] [blame] | 92 | serif; |
[email protected] | 3184f90b | 2013-05-01 18:17:53 | [diff] [blame] | 93 | prefs->fixed_font_family_map[webkit_glue::kCommonScript] = |
[email protected] | 3295612 | 2013-12-25 07:29:24 | [diff] [blame] | 94 | base::ASCIIToUTF16("Courier"); |
[email protected] | 933bdfbc | 2013-01-11 11:48:11 | [diff] [blame] | 95 | prefs->sans_serif_font_family_map[ |
[email protected] | 3295612 | 2013-12-25 07:29:24 | [diff] [blame] | 96 | webkit_glue::kCommonScript] = base::ASCIIToUTF16("Helvetica"); |
[email protected] | 933bdfbc | 2013-01-11 11:48:11 | [diff] [blame] | 97 | prefs->minimum_logical_font_size = 9; |
[email protected] | 9de7a11c | 2013-01-23 16:09:02 | [diff] [blame] | 98 | prefs->asynchronous_spell_checking_enabled = false; |
[email protected] | 1796b7c | 2013-02-28 10:42:14 | [diff] [blame] | 99 | prefs->threaded_html_parser = true; |
[email protected] | 0989186e | 2013-03-06 09:43:46 | [diff] [blame] | 100 | prefs->accelerated_2d_canvas_enabled = |
101 | command_line.HasSwitch(switches::kEnableAccelerated2DCanvas); | ||||
[email protected] | 8b5f775 | 2013-08-29 22:40:50 | [diff] [blame] | 102 | prefs->force_compositing_mode = |
103 | command_line.HasSwitch(switches::kForceCompositingMode); | ||||
[email protected] | 92ee7d6b | 2013-03-04 09:08:59 | [diff] [blame] | 104 | prefs->accelerated_compositing_for_video_enabled = false; |
[email protected] | 92ee7d6b | 2013-03-04 09:08:59 | [diff] [blame] | 105 | prefs->mock_scrollbars_enabled = false; |
[email protected] | e94f211 | 2013-03-16 19:04:11 | [diff] [blame] | 106 | prefs->fixed_position_creates_stacking_context = false; |
[email protected] | 85f5450d | 2013-03-18 17:13:59 | [diff] [blame] | 107 | prefs->smart_insert_delete_enabled = true; |
[email protected] | 9c0e9df | 2013-03-18 22:51:18 | [diff] [blame] | 108 | prefs->minimum_accelerated_2d_canvas_size = 0; |
[email protected] | 5ee2c92 | 2013-06-18 14:03:18 | [diff] [blame] | 109 | #if defined(OS_ANDROID) |
110 | prefs->text_autosizing_enabled = false; | ||||
111 | #endif | ||||
[email protected] | 6d2eabc | 2014-02-20 14:55:15 | [diff] [blame] | 112 | prefs->viewport_enabled = false; |
[email protected] | d48eab08 | 2012-12-19 09:25:47 | [diff] [blame] | 113 | } |
114 | |||||
[email protected] | 294e74f | 2013-04-29 14:50:54 | [diff] [blame] | 115 | base::FilePath GetWebKitRootDirFilePath() { |
116 | base::FilePath base_path; | ||||
117 | PathService::Get(base::DIR_SOURCE_ROOT, &base_path); | ||||
[email protected] | fea004c | 2013-07-28 14:24:18 | [diff] [blame] | 118 | return base_path.Append(FILE_PATH_LITERAL("third_party/WebKit")); |
[email protected] | 294e74f | 2013-04-29 14:50:54 | [diff] [blame] | 119 | } |
120 | |||||
[email protected] | 55915a7 | 2012-12-18 11:55:25 | [diff] [blame] | 121 | } // namespace content |