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_blink_web_unit_test_support.h" | 5 #include "content/test/test_blink_web_unit_test_support.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 31 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
32 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 32 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
33 #include "third_party/WebKit/public/web/WebStorageEventDispatcher.h" | 33 #include "third_party/WebKit/public/web/WebStorageEventDispatcher.h" |
34 #include "v8/include/v8.h" | 34 #include "v8/include/v8.h" |
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 #include "base/mac/scoped_nsautorelease_pool.h" | 38 #include "base/mac/scoped_nsautorelease_pool.h" |
39 #endif | 39 #endif |
40 | 40 |
| 41 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
| 42 #include "gin/public/isolate_holder.h" |
| 43 #endif |
| 44 |
41 namespace content { | 45 namespace content { |
42 | 46 |
43 TestBlinkWebUnitTestSupport::TestBlinkWebUnitTestSupport() { | 47 TestBlinkWebUnitTestSupport::TestBlinkWebUnitTestSupport() { |
44 #if defined(OS_MACOSX) | 48 #if defined(OS_MACOSX) |
45 base::mac::ScopedNSAutoreleasePool autorelease_pool; | 49 base::mac::ScopedNSAutoreleasePool autorelease_pool; |
46 #endif | 50 #endif |
47 | 51 |
48 url_loader_factory_.reset(new WebURLLoaderMockFactory()); | 52 url_loader_factory_.reset(new WebURLLoaderMockFactory()); |
49 mock_clipboard_.reset(new MockWebClipboardImpl()); | 53 mock_clipboard_.reset(new MockWebClipboardImpl()); |
50 | 54 |
51 // Create an anonymous stats table since we don't need to share between | 55 // Create an anonymous stats table since we don't need to share between |
52 // processes. | 56 // processes. |
53 stats_table_.reset( | 57 stats_table_.reset( |
54 new base::StatsTable(base::StatsTable::TableIdentifier(), 20, 200)); | 58 new base::StatsTable(base::StatsTable::TableIdentifier(), 20, 200)); |
55 base::StatsTable::set_current(stats_table_.get()); | 59 base::StatsTable::set_current(stats_table_.get()); |
56 | 60 |
| 61 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
| 62 gin::IsolateHolder::LoadV8Snapshot(); |
| 63 #endif |
| 64 |
57 blink::initialize(this); | 65 blink::initialize(this); |
58 blink::mainThreadIsolate()->SetCounterFunction( | 66 blink::mainThreadIsolate()->SetCounterFunction( |
59 base::StatsTable::FindLocation); | 67 base::StatsTable::FindLocation); |
60 blink::setLayoutTestMode(true); | 68 blink::setLayoutTestMode(true); |
61 blink::WebSecurityPolicy::registerURLSchemeAsLocal( | 69 blink::WebSecurityPolicy::registerURLSchemeAsLocal( |
62 blink::WebString::fromUTF8("test-shell-resource")); | 70 blink::WebString::fromUTF8("test-shell-resource")); |
63 blink::WebSecurityPolicy::registerURLSchemeAsNoAccess( | 71 blink::WebSecurityPolicy::registerURLSchemeAsNoAccess( |
64 blink::WebString::fromUTF8("test-shell-resource")); | 72 blink::WebString::fromUTF8("test-shell-resource")); |
65 blink::WebSecurityPolicy::registerURLSchemeAsDisplayIsolated( | 73 blink::WebSecurityPolicy::registerURLSchemeAsDisplayIsolated( |
66 blink::WebString::fromUTF8("test-shell-resource")); | 74 blink::WebString::fromUTF8("test-shell-resource")); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 const blink::WebString& path) { | 306 const blink::WebString& path) { |
299 base::FilePath file_path = base::FilePath::FromUTF16Unsafe(path); | 307 base::FilePath file_path = base::FilePath::FromUTF16Unsafe(path); |
300 | 308 |
301 std::string buffer; | 309 std::string buffer; |
302 base::ReadFileToString(file_path, &buffer); | 310 base::ReadFileToString(file_path, &buffer); |
303 | 311 |
304 return blink::WebData(buffer.data(), buffer.size()); | 312 return blink::WebData(buffer.data(), buffer.size()); |
305 } | 313 } |
306 | 314 |
307 } // namespace content | 315 } // namespace content |
OLD | NEW |