Add test for FFI_DownloadFromURL()

Change-Id: I9884e7ac6a6bc94a3a18dc3f97dbf47828c7391c
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/93450
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp b/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp
index 86d19c5..cc8f249 100644
--- a/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp
@@ -990,7 +990,8 @@
 }
 
 TEST_F(CFXJSE_FormCalcContextEmbedderTest, Get) {
-  // TODO(dsinclair): Is this supported?
+  ASSERT_TRUE(OpenDocument("simple_xfa.pdf"));
+  ExecuteExpectString("Get(\"https://example.com\")", "<body>secrets</body>");
 }
 
 TEST_F(CFXJSE_FormCalcContextEmbedderTest, Post) {
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp
index 718f88d..f29eb1b 100644
--- a/testing/embedder_test.cpp
+++ b/testing/embedder_test.cpp
@@ -4,6 +4,7 @@
 
 #include "testing/embedder_test.h"
 
+#include <algorithm>
 #include <memory>
 #include <string>
 #include <utility>
@@ -225,7 +226,21 @@
 
 FPDF_FILEHANDLER* DownloadFromURLStub(FPDF_FORMFILLINFO* pThis,
                                       FPDF_WIDESTRING URL) {
-  return nullptr;
+  static const char kString[] = "<body>secrets</body>";
+  static FPDF_FILEHANDLER kFakeFileHandler = {
+      nullptr,
+      [](void*) -> void {},
+      [](void*) -> FPDF_DWORD { return sizeof(kString); },
+      [](void*, FPDF_DWORD off, void* buffer, FPDF_DWORD size) -> FPDF_RESULT {
+        memcpy(buffer, kString, std::min<size_t>(size, sizeof(kString)));
+        return 0;
+      },
+      [](void*, FPDF_DWORD, const void*, FPDF_DWORD) -> FPDF_RESULT {
+        return -1;
+      },
+      [](void*) -> FPDF_RESULT { return 0; },
+      [](void*, FPDF_DWORD) -> FPDF_RESULT { return 0; }};
+  return &kFakeFileHandler;
 }
 
 FPDF_BOOL PostRequestURLStub(FPDF_FORMFILLINFO* pThis,