| OLD | NEW |
| (Empty) |
| 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 | |
| 5 #include "content/shell/webkit_test_helpers.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "base/file_util.h" | |
| 9 #include "base/path_service.h" | |
| 10 #include "base/utf_string_conversions.h" | |
| 11 #include "content/shell/shell_switches.h" | |
| 12 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web
Preferences.h" | |
| 13 #include "webkit/glue/webpreferences.h" | |
| 14 | |
| 15 namespace content { | |
| 16 | |
| 17 void ExportLayoutTestSpecificPreferences( | |
| 18 const WebTestRunner::WebPreferences& from, | |
| 19 WebPreferences* to) { | |
| 20 to->allow_universal_access_from_file_urls = | |
| 21 from.allowUniversalAccessFromFileURLs; | |
| 22 to->dom_paste_enabled = from.DOMPasteAllowed; | |
| 23 to->javascript_can_access_clipboard = from.javaScriptCanAccessClipboard; | |
| 24 to->xss_auditor_enabled = from.XSSAuditorEnabled; | |
| 25 to->editing_behavior = static_cast<webkit_glue::EditingBehavior>( | |
| 26 from.editingBehavior); | |
| 27 to->default_font_size = from.defaultFontSize; | |
| 28 to->minimum_font_size = from.minimumFontSize; | |
| 29 to->default_encoding = from.defaultTextEncodingName.utf8().data(); | |
| 30 to->javascript_enabled = from.javaScriptEnabled; | |
| 31 to->supports_multiple_windows = from.supportsMultipleWindows; | |
| 32 to->loads_images_automatically = from.loadsImagesAutomatically; | |
| 33 to->plugins_enabled = from.pluginsEnabled; | |
| 34 to->java_enabled = from.javaEnabled; | |
| 35 to->application_cache_enabled = from.offlineWebApplicationCacheEnabled; | |
| 36 to->tabs_to_links = from.tabsToLinks; | |
| 37 to->experimental_webgl_enabled = from.experimentalWebGLEnabled; | |
| 38 to->css_grid_layout_enabled = from.experimentalCSSGridLayoutEnabled; | |
| 39 // experimentalCSSRegionsEnabled is deprecated and ignored. | |
| 40 to->hyperlink_auditing_enabled = from.hyperlinkAuditingEnabled; | |
| 41 to->caret_browsing_enabled = from.caretBrowsingEnabled; | |
| 42 to->allow_displaying_insecure_content = from.allowDisplayOfInsecureContent; | |
| 43 to->allow_running_insecure_content = from.allowRunningOfInsecureContent; | |
| 44 to->css_shaders_enabled = from.cssCustomFilterEnabled; | |
| 45 to->should_respect_image_orientation = from.shouldRespectImageOrientation; | |
| 46 to->asynchronous_spell_checking_enabled = | |
| 47 from.asynchronousSpellCheckingEnabled; | |
| 48 to->allow_file_access_from_file_urls = from.allowFileAccessFromFileURLs; | |
| 49 to->author_and_user_styles_enabled = from.authorAndUserStylesEnabled; | |
| 50 to->javascript_can_open_windows_automatically = | |
| 51 from.javaScriptCanOpenWindowsAutomatically; | |
| 52 to->user_style_sheet_location = from.userStyleSheetLocation; | |
| 53 to->touch_drag_drop_enabled = from.touchDragDropEnabled; | |
| 54 } | |
| 55 | |
| 56 // Applies settings that differ between layout tests and regular mode. Some | |
| 57 // of the defaults are controlled via command line flags which are | |
| 58 // automatically set for layout tests. | |
| 59 void ApplyLayoutTestDefaultPreferences(WebPreferences* prefs) { | |
| 60 CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 61 prefs->allow_universal_access_from_file_urls = true; | |
| 62 prefs->dom_paste_enabled = true; | |
| 63 prefs->javascript_can_access_clipboard = true; | |
| 64 prefs->xss_auditor_enabled = false; | |
| 65 #if defined(OS_MACOSX) | |
| 66 prefs->editing_behavior = webkit_glue::EDITING_BEHAVIOR_MAC; | |
| 67 #else | |
| 68 prefs->editing_behavior = webkit_glue::EDITING_BEHAVIOR_WIN; | |
| 69 #endif | |
| 70 prefs->java_enabled = false; | |
| 71 prefs->application_cache_enabled = true; | |
| 72 prefs->tabs_to_links = false; | |
| 73 prefs->hyperlink_auditing_enabled = false; | |
| 74 prefs->allow_displaying_insecure_content = true; | |
| 75 prefs->allow_running_insecure_content = true; | |
| 76 prefs->webgl_errors_to_console_enabled = false; | |
| 77 string16 serif; | |
| 78 #if defined(OS_MACOSX) | |
| 79 prefs->cursive_font_family_map[webkit_glue::kCommonScript] = | |
| 80 ASCIIToUTF16("Apple Chancery"); | |
| 81 prefs->fantasy_font_family_map[webkit_glue::kCommonScript] = | |
| 82 ASCIIToUTF16("Papyrus"); | |
| 83 serif = ASCIIToUTF16("Times"); | |
| 84 #else | |
| 85 prefs->cursive_font_family_map[webkit_glue::kCommonScript] = | |
| 86 ASCIIToUTF16("Comic Sans MS"); | |
| 87 prefs->fantasy_font_family_map[webkit_glue::kCommonScript] = | |
| 88 ASCIIToUTF16("Impact"); | |
| 89 serif = ASCIIToUTF16("times new roman"); | |
| 90 #endif | |
| 91 prefs->serif_font_family_map[webkit_glue::kCommonScript] = | |
| 92 serif; | |
| 93 prefs->standard_font_family_map[webkit_glue::kCommonScript] = | |
| 94 serif; | |
| 95 prefs->fixed_font_family_map[webkit_glue::kCommonScript] = | |
| 96 ASCIIToUTF16("Courier"); | |
| 97 prefs->sans_serif_font_family_map[ | |
| 98 webkit_glue::kCommonScript] = ASCIIToUTF16("Helvetica"); | |
| 99 prefs->minimum_logical_font_size = 9; | |
| 100 prefs->asynchronous_spell_checking_enabled = false; | |
| 101 prefs->user_style_sheet_enabled = true; | |
| 102 prefs->threaded_html_parser = true; | |
| 103 prefs->accelerated_2d_canvas_enabled = | |
| 104 command_line.HasSwitch(switches::kEnableAccelerated2DCanvas); | |
| 105 prefs->accelerated_compositing_for_video_enabled = false; | |
| 106 prefs->mock_scrollbars_enabled = false; | |
| 107 prefs->fixed_position_creates_stacking_context = false; | |
| 108 prefs->apply_page_scale_factor_in_compositor = false; | |
| 109 prefs->smart_insert_delete_enabled = true; | |
| 110 prefs->minimum_accelerated_2d_canvas_size = 0; | |
| 111 } | |
| 112 | |
| 113 base::FilePath GetWebKitRootDirFilePath() { | |
| 114 base::FilePath base_path; | |
| 115 PathService::Get(base::DIR_SOURCE_ROOT, &base_path); | |
| 116 if (file_util::PathExists( | |
| 117 base_path.Append(FILE_PATH_LITERAL("third_party/WebKit")))) { | |
| 118 // We're in a WebKit-in-chrome checkout. | |
| 119 return base_path.Append(FILE_PATH_LITERAL("third_party/WebKit")); | |
| 120 } else if (file_util::PathExists( | |
| 121 base_path.Append(FILE_PATH_LITERAL("chromium")))) { | |
| 122 // We're in a WebKit-only checkout on Windows. | |
| 123 return base_path.Append(FILE_PATH_LITERAL("../..")); | |
| 124 } else if (file_util::PathExists( | |
| 125 base_path.Append(FILE_PATH_LITERAL("webkit/support")))) { | |
| 126 // We're in a WebKit-only/xcodebuild checkout on Mac | |
| 127 return base_path.Append(FILE_PATH_LITERAL("../../..")); | |
| 128 } | |
| 129 // We're in a WebKit-only, make-build, so the DIR_SOURCE_ROOT is already the | |
| 130 // WebKit root. That, or we have no idea where we are. | |
| 131 return base_path; | |
| 132 } | |
| 133 | |
| 134 base::FilePath GetChromiumRootDirFilePath() { | |
| 135 base::FilePath webkit_path = GetWebKitRootDirFilePath(); | |
| 136 if (file_util::PathExists(webkit_path.Append( | |
| 137 FILE_PATH_LITERAL("Source/WebKit/chromium/webkit/support")))) { | |
| 138 // We're in a WebKit-only checkout. | |
| 139 return webkit_path.Append(FILE_PATH_LITERAL("Source/WebKit/chromium")); | |
| 140 } else { | |
| 141 // We're in a Chromium checkout, and WebKit is in third_party/WebKit. | |
| 142 return webkit_path.Append(FILE_PATH_LITERAL("../..")); | |
| 143 } | |
| 144 } | |
| 145 | |
| 146 } // namespace content | |
| OLD | NEW |