| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Creates an instance of the test_shell. | 5 // Creates an instance of the test_shell. |
| 6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
| 7 | 7 |
| 8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/event_recorder.h" | 11 #include "base/event_recorder.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/icu_util.h" | 13 #include "base/icu_util.h" |
| 14 #include "base/memory_debug.h" | 14 #include "base/memory_debug.h" |
| 15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 17 #include "base/process_util.h" | 17 #include "base/process_util.h" |
| 18 #include "base/rand_util.h" | 18 #include "base/rand_util.h" |
| 19 #include "base/stats_table.h" | 19 #include "base/stats_table.h" |
| 20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 21 #include "base/sys_info.h" | 21 #include "base/sys_info.h" |
| 22 #include "base/trace_event.h" | 22 #include "base/trace_event.h" |
| 23 #include "net/base/cookie_monster.h" | 23 #include "net/base/cookie_monster.h" |
| 24 #include "net/base/net_module.h" | 24 #include "net/base/net_module.h" |
| 25 #include "net/http/http_cache.h" | 25 #include "net/http/http_cache.h" |
| 26 #include "net/base/ssl_test_util.h" | 26 #include "net/base/ssl_test_util.h" |
| 27 #include "net/url_request/url_request_context.h" | 27 #include "net/url_request/url_request_context.h" |
| 28 #include "webkit/glue/webkit_glue.h" | 28 #include "webkit/glue/webkit_glue.h" |
| 29 #include "webkit/glue/window_open_disposition.h" | 29 #include "webkit/glue/window_open_disposition.h" |
| 30 #include "webkit/extensions/v8/gc_extension.h" |
| 31 #include "webkit/extensions/v8/playback_extension.h" |
| 30 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" | 32 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" |
| 31 #include "webkit/tools/test_shell/test_shell.h" | 33 #include "webkit/tools/test_shell/test_shell.h" |
| 32 #include "webkit/tools/test_shell/test_shell_platform_delegate.h" | 34 #include "webkit/tools/test_shell/test_shell_platform_delegate.h" |
| 33 #include "webkit/tools/test_shell/test_shell_request_context.h" | 35 #include "webkit/tools/test_shell/test_shell_request_context.h" |
| 34 #include "webkit/tools/test_shell/test_shell_switches.h" | 36 #include "webkit/tools/test_shell/test_shell_switches.h" |
| 35 #include "webkit/tools/test_shell/test_shell_webkit_init.h" | 37 #include "webkit/tools/test_shell/test_shell_webkit_init.h" |
| 36 | 38 |
| 37 #include "WebKit.h" | 39 #include "WebKit.h" |
| 38 | 40 |
| 39 #include <iostream> | 41 #include <iostream> |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 95 |
| 94 // Suppress abort message in v8 library in debugging mode. | 96 // Suppress abort message in v8 library in debugging mode. |
| 95 // V8 calls abort() when it hits assertion errors. | 97 // V8 calls abort() when it hits assertion errors. |
| 96 if (suppress_error_dialogs) | 98 if (suppress_error_dialogs) |
| 97 platform.SuppressErrorReporting(); | 99 platform.SuppressErrorReporting(); |
| 98 | 100 |
| 99 if (parsed_command_line.HasSwitch(test_shell::kEnableTracing)) | 101 if (parsed_command_line.HasSwitch(test_shell::kEnableTracing)) |
| 100 base::TraceLog::StartTracing(); | 102 base::TraceLog::StartTracing(); |
| 101 | 103 |
| 102 net::HttpCache::Mode cache_mode = net::HttpCache::NORMAL; | 104 net::HttpCache::Mode cache_mode = net::HttpCache::NORMAL; |
| 105 |
| 106 // This is a special mode where JS helps the browser implement |
| 107 // playback/record mode. Generally, in this mode, some functions |
| 108 // of client-side randomness are removed. For example, in |
| 109 // this mode Math.random() and Date.getTime() may not return |
| 110 // values which vary. |
| 103 bool playback_mode = | 111 bool playback_mode = |
| 104 parsed_command_line.HasSwitch(test_shell::kPlaybackMode); | 112 parsed_command_line.HasSwitch(test_shell::kPlaybackMode); |
| 105 bool record_mode = | 113 bool record_mode = |
| 106 parsed_command_line.HasSwitch(test_shell::kRecordMode); | 114 parsed_command_line.HasSwitch(test_shell::kRecordMode); |
| 107 | 115 |
| 108 if (playback_mode) | 116 if (playback_mode) |
| 109 cache_mode = net::HttpCache::PLAYBACK; | 117 cache_mode = net::HttpCache::PLAYBACK; |
| 110 else if (record_mode) | 118 else if (record_mode) |
| 111 cache_mode = net::HttpCache::RECORD; | 119 cache_mode = net::HttpCache::RECORD; |
| 112 | 120 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 179 |
| 172 std::vector<std::wstring> loose_values = parsed_command_line.GetLooseValues(); | 180 std::vector<std::wstring> loose_values = parsed_command_line.GetLooseValues(); |
| 173 if (loose_values.size() > 0) | 181 if (loose_values.size() > 0) |
| 174 uri = loose_values[0]; | 182 uri = loose_values[0]; |
| 175 | 183 |
| 176 std::wstring js_flags = | 184 std::wstring js_flags = |
| 177 parsed_command_line.GetSwitchValue(test_shell::kJavaScriptFlags); | 185 parsed_command_line.GetSwitchValue(test_shell::kJavaScriptFlags); |
| 178 // Test shell always exposes the GC. | 186 // Test shell always exposes the GC. |
| 179 js_flags += L" --expose-gc"; | 187 js_flags += L" --expose-gc"; |
| 180 webkit_glue::SetJavaScriptFlags(js_flags); | 188 webkit_glue::SetJavaScriptFlags(js_flags); |
| 181 // Also expose GCController to JavaScript. | 189 // Expose GCController to JavaScript. |
| 182 webkit_glue::SetShouldExposeGCController(true); | 190 WebKit::registerExtension(extensions_v8::GCExtension::Get()); |
| 183 | 191 |
| 184 // Load and initialize the stats table. Attempt to construct a somewhat | 192 // Load and initialize the stats table. Attempt to construct a somewhat |
| 185 // unique name to isolate separate instances from each other. | 193 // unique name to isolate separate instances from each other. |
| 186 StatsTable *table = new StatsTable( | 194 StatsTable *table = new StatsTable( |
| 187 // truncate the random # to 32 bits for the benefit of Mac OS X, to | 195 // truncate the random # to 32 bits for the benefit of Mac OS X, to |
| 188 // avoid tripping over its maximum shared memory segment name length | 196 // avoid tripping over its maximum shared memory segment name length |
| 189 kStatsFilePrefix + Uint64ToString(base::RandUint64() & 0xFFFFFFFFL), | 197 kStatsFilePrefix + Uint64ToString(base::RandUint64() & 0xFFFFFFFFL), |
| 190 kStatsFileThreads, | 198 kStatsFileThreads, |
| 191 kStatsFileCounters); | 199 kStatsFileCounters); |
| 192 StatsTable::set_current(table); | 200 StatsTable::set_current(table); |
| 193 | 201 |
| 194 TestShell* shell; | 202 TestShell* shell; |
| 195 if (TestShell::CreateNewWindow(uri, &shell)) { | 203 if (TestShell::CreateNewWindow(uri, &shell)) { |
| 196 if (record_mode || playback_mode) { | 204 if (record_mode || playback_mode) { |
| 197 platform.SetWindowPositionForRecording(shell); | 205 platform.SetWindowPositionForRecording(shell); |
| 198 // Tell webkit as well. | 206 WebKit::registerExtension(extensions_v8::PlaybackExtension::Get()); |
| 199 webkit_glue::SetRecordPlaybackMode(true); | |
| 200 } | 207 } |
| 201 | 208 |
| 202 shell->Show(shell->webView(), NEW_WINDOW); | 209 shell->Show(shell->webView(), NEW_WINDOW); |
| 203 | 210 |
| 204 if (parsed_command_line.HasSwitch(test_shell::kDumpStatsTable)) | 211 if (parsed_command_line.HasSwitch(test_shell::kDumpStatsTable)) |
| 205 shell->DumpStatsTableOnExit(); | 212 shell->DumpStatsTableOnExit(); |
| 206 | 213 |
| 207 bool no_events = parsed_command_line.HasSwitch(test_shell::kNoEvents); | 214 bool no_events = parsed_command_line.HasSwitch(test_shell::kNoEvents); |
| 208 if ((record_mode || playback_mode) && !no_events) { | 215 if ((record_mode || playback_mode) && !no_events) { |
| 209 std::wstring script_path = cache_path; | 216 std::wstring script_path = cache_path; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 | 297 |
| 291 TestShell::ShutdownTestShell(); | 298 TestShell::ShutdownTestShell(); |
| 292 TestShell::CleanupLogging(); | 299 TestShell::CleanupLogging(); |
| 293 | 300 |
| 294 // Tear down shared StatsTable; prevents unit_tests from leaking it. | 301 // Tear down shared StatsTable; prevents unit_tests from leaking it. |
| 295 StatsTable::set_current(NULL); | 302 StatsTable::set_current(NULL); |
| 296 delete table; | 303 delete table; |
| 297 | 304 |
| 298 return 0; | 305 return 0; |
| 299 } | 306 } |
| OLD | NEW |