Do not initialize V8 in pdfium_test if --disable-javascript.
Bug: pdfium:450
Change-Id: Ifb6cf4beecf8ae6cdd0c82d8c2bf97cdd552d8da
Reviewed-on: https://pdfium-review.googlesource.com/c/50890
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index c7e49c6..51a33ad 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -939,10 +939,13 @@
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
v8::StartupData natives;
v8::StartupData snapshot;
- platform = InitializeV8ForPDFiumWithStartupData(
- options.exe_path, options.bin_directory, &natives, &snapshot);
+ if (!options.disable_javascript) {
+ platform = InitializeV8ForPDFiumWithStartupData(
+ options.exe_path, options.bin_directory, &natives, &snapshot);
+ }
#else // V8_USE_EXTERNAL_STARTUP_DATA
- platform = InitializeV8ForPDFium(options.exe_path);
+ if (!options.disable_javascript)
+ platform = InitializeV8ForPDFium(options.exe_path);
#endif // V8_USE_EXTERNAL_STARTUP_DATA
#endif // PDF_ENABLE_V8
@@ -1015,13 +1018,15 @@
}
FPDF_DestroyLibrary();
-#ifdef PDF_ENABLE_V8
- v8::V8::ShutdownPlatform();
+#ifdef PDF_ENABLE_V8
+ if (!options.disable_javascript) {
+ v8::V8::ShutdownPlatform();
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
- free(const_cast<char*>(natives.data));
- free(const_cast<char*>(snapshot.data));
+ free(const_cast<char*>(natives.data));
+ free(const_cast<char*>(snapshot.data));
#endif // V8_USE_EXTERNAL_STARTUP_DATA
+ }
#endif // PDF_ENABLE_V8
return 0;