OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "content/test/test_webkit_platform_support.h" | 5 #include "content/test/test_webkit_platform_support.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 #if defined(OS_MACOSX) | 36 #if defined(OS_MACOSX) |
37 #include "base/mac/mac_util.h" | 37 #include "base/mac/mac_util.h" |
38 #endif | 38 #endif |
39 | 39 |
40 namespace content { | 40 namespace content { |
41 | 41 |
42 TestWebKitPlatformSupport::TestWebKitPlatformSupport() { | 42 TestWebKitPlatformSupport::TestWebKitPlatformSupport() { |
43 url_loader_factory_.reset(new WebURLLoaderMockFactory()); | 43 url_loader_factory_.reset(new WebURLLoaderMockFactory()); |
44 mock_clipboard_.reset(new MockWebClipboardImpl()); | 44 mock_clipboard_.reset(new MockWebClipboardImpl()); |
45 v8::V8::SetCounterFunction(base::StatsTable::FindLocation); | 45 |
| 46 // Create an anonymous stats table since we don't need to share between |
| 47 // processes. |
| 48 stats_table_.reset( |
| 49 new base::StatsTable(base::StatsTable::TableIdentifier(), 20, 200)); |
| 50 base::StatsTable::set_current(stats_table_.get()); |
46 | 51 |
47 blink::initialize(this); | 52 blink::initialize(this); |
| 53 blink::mainThreadIsolate()->SetCounterFunction( |
| 54 base::StatsTable::FindLocation); |
48 blink::setLayoutTestMode(true); | 55 blink::setLayoutTestMode(true); |
49 blink::WebSecurityPolicy::registerURLSchemeAsLocal( | 56 blink::WebSecurityPolicy::registerURLSchemeAsLocal( |
50 blink::WebString::fromUTF8("test-shell-resource")); | 57 blink::WebString::fromUTF8("test-shell-resource")); |
51 blink::WebSecurityPolicy::registerURLSchemeAsNoAccess( | 58 blink::WebSecurityPolicy::registerURLSchemeAsNoAccess( |
52 blink::WebString::fromUTF8("test-shell-resource")); | 59 blink::WebString::fromUTF8("test-shell-resource")); |
53 blink::WebSecurityPolicy::registerURLSchemeAsDisplayIsolated( | 60 blink::WebSecurityPolicy::registerURLSchemeAsDisplayIsolated( |
54 blink::WebString::fromUTF8("test-shell-resource")); | 61 blink::WebString::fromUTF8("test-shell-resource")); |
55 blink::WebSecurityPolicy::registerURLSchemeAsEmptyDocument( | 62 blink::WebSecurityPolicy::registerURLSchemeAsEmptyDocument( |
56 blink::WebString::fromUTF8("test-shell-resource")); | 63 blink::WebString::fromUTF8("test-shell-resource")); |
57 blink::WebRuntimeFeatures::enableApplicationCache(true); | 64 blink::WebRuntimeFeatures::enableApplicationCache(true); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 97 |
91 // Test shell always exposes the GC. | 98 // Test shell always exposes the GC. |
92 std::string flags("--expose-gc"); | 99 std::string flags("--expose-gc"); |
93 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); | 100 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); |
94 } | 101 } |
95 | 102 |
96 TestWebKitPlatformSupport::~TestWebKitPlatformSupport() { | 103 TestWebKitPlatformSupport::~TestWebKitPlatformSupport() { |
97 url_loader_factory_.reset(); | 104 url_loader_factory_.reset(); |
98 mock_clipboard_.reset(); | 105 mock_clipboard_.reset(); |
99 blink::shutdown(); | 106 blink::shutdown(); |
| 107 base::StatsTable::set_current(NULL); |
| 108 stats_table_.reset(); |
100 } | 109 } |
101 | 110 |
102 blink::WebMimeRegistry* TestWebKitPlatformSupport::mimeRegistry() { | 111 blink::WebMimeRegistry* TestWebKitPlatformSupport::mimeRegistry() { |
103 return &mime_registry_; | 112 return &mime_registry_; |
104 } | 113 } |
105 | 114 |
106 blink::WebClipboard* TestWebKitPlatformSupport::clipboard() { | 115 blink::WebClipboard* TestWebKitPlatformSupport::clipboard() { |
107 // Mock out clipboard calls so that tests don't mess | 116 // Mock out clipboard calls so that tests don't mess |
108 // with each other's copies/pastes when running in parallel. | 117 // with each other's copies/pastes when running in parallel. |
109 return mock_clipboard_.get(); | 118 return mock_clipboard_.get(); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 const blink::WebString& path) { | 285 const blink::WebString& path) { |
277 base::FilePath file_path = base::FilePath::FromUTF16Unsafe(path); | 286 base::FilePath file_path = base::FilePath::FromUTF16Unsafe(path); |
278 | 287 |
279 std::string buffer; | 288 std::string buffer; |
280 base::ReadFileToString(file_path, &buffer); | 289 base::ReadFileToString(file_path, &buffer); |
281 | 290 |
282 return blink::WebData(buffer.data(), buffer.size()); | 291 return blink::WebData(buffer.data(), buffer.size()); |
283 } | 292 } |
284 | 293 |
285 } // namespace content | 294 } // namespace content |
OLD | NEW |