diff options
Diffstat (limited to 'testing/test_support.cpp')
-rw-r--r-- | testing/test_support.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/testing/test_support.cpp b/testing/test_support.cpp index 2b6f436c32..b32ec7de96 100644 --- a/testing/test_support.cpp +++ b/testing/test_support.cpp @@ -60,18 +60,17 @@ bool GetExternalData(const std::string& exe_path, } #endif // V8_USE_EXTERNAL_STARTUP_DATA -std::unique_ptr<v8::Platform> InitializeV8Common(const std::string& exe_path) { - v8::V8::InitializeICUDefaultLocation(exe_path.c_str()); +void InitializeV8Common(const char* exe_path, v8::Platform** platform) { + v8::V8::InitializeICUDefaultLocation(exe_path); - std::unique_ptr<v8::Platform> platform = v8::platform::NewDefaultPlatform(); - v8::V8::InitializePlatform(platform.get()); + *platform = v8::platform::CreateDefaultPlatform(); + v8::V8::InitializePlatform(*platform); // By enabling predictable mode, V8 won't post any background tasks. // By enabling GC, it makes it easier to chase use-after-free. const char v8_flags[] = "--predictable --expose-gc"; v8::V8::SetFlagsFromString(v8_flags, static_cast<int>(strlen(v8_flags))); v8::V8::Initialize(); - return platform; } #endif // PDF_ENABLE_V8 @@ -178,26 +177,27 @@ std::string GenerateMD5Base16(const uint8_t* data, uint32_t size) { #ifdef PDF_ENABLE_V8 #ifdef V8_USE_EXTERNAL_STARTUP_DATA -std::unique_ptr<v8::Platform> InitializeV8ForPDFiumWithStartupData( - const std::string& exe_path, - const std::string& bin_dir, - v8::StartupData* natives_blob, - v8::StartupData* snapshot_blob) { - std::unique_ptr<v8::Platform> platform = InitializeV8Common(exe_path); +bool InitializeV8ForPDFium(const std::string& exe_path, + const std::string& bin_dir, + v8::StartupData* natives_blob, + v8::StartupData* snapshot_blob, + v8::Platform** platform) { + InitializeV8Common(exe_path.c_str(), platform); if (natives_blob && snapshot_blob) { if (!GetExternalData(exe_path, bin_dir, "natives_blob.bin", natives_blob)) - return nullptr; + return false; if (!GetExternalData(exe_path, bin_dir, "snapshot_blob.bin", snapshot_blob)) - return nullptr; + return false; v8::V8::SetNativesDataBlob(natives_blob); v8::V8::SetSnapshotDataBlob(snapshot_blob); } - return platform; + return true; } #else // V8_USE_EXTERNAL_STARTUP_DATA -std::unique_ptr<v8::Platform> InitializeV8ForPDFium( - const std::string& exe_path) { - return InitializeV8Common(exe_path); +bool InitializeV8ForPDFium(const std::string& exe_path, + v8::Platform** platform) { + InitializeV8Common(exe_path.c_str(), platform); + return true; } #endif // V8_USE_EXTERNAL_STARTUP_DATA #endif // PDF_ENABLE_V8 |