Handle v8_enable_webassembly build flag in FPDF_GetRecommendedV8Flags().

FPDF_GetRecommendedV8Flags() should only return --no-expose-wasm if
v8_enable_webassembly is set to true.

Bug: pdfium:1721
Change-Id: Iab0020f60631db3cc59e382492dd48c6a83c02e5
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/85072
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 885c2bb..69cd332 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -6,6 +6,10 @@
 import("//testing/test.gni")
 import("pdfium.gni")
 
+if (pdf_enable_v8) {
+  import("//v8/gni/v8.gni")
+}
+
 group("freetype_common") {
   public_deps = []
   if (pdf_bundle_freetype) {
@@ -98,6 +102,10 @@
         defines += [ "PDF_ENABLE_XFA_TIFF" ]
       }
     }
+
+    if (v8_enable_webassembly) {
+      defines += [ "PDF_ENABLE_V8_WASM" ]
+    }
   }
 
   if (pdf_use_win32_gdi) {
diff --git a/fpdfsdk/fpdf_view.cpp b/fpdfsdk/fpdf_view.cpp
index 3e3a649..a528781 100644
--- a/fpdfsdk/fpdf_view.cpp
+++ b/fpdfsdk/fpdf_view.cpp
@@ -1065,7 +1065,11 @@
 FPDF_EXPORT const char* FPDF_CALLCONV FPDF_GetRecommendedV8Flags() {
   // Use interpreted JS only to avoid RWX pages in our address space.
   // Reduce exposure since no PDF should contain web assembly.
+#if defined(PDF_ENABLE_V8_WASM)
   return "--jitless --no-expose-wasm";
+#else
+  return "--jitless";
+#endif
 }
 
 FPDF_EXPORT void* FPDF_CALLCONV FPDF_GetArrayBufferAllocatorSharedInstance() {