Fully populate JS platform callbacks in pdfium_test

Adjust expected results accordingly.
Order functions to match platform member order.

Change-Id: I3d5f8e3ef8f532af0891b7fbbc1a8305d1922a75
Reviewed-on: https://pdfium-review.googlesource.com/c/44311
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index c5c298d..ac24bcc 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -174,6 +174,10 @@
   return 0;
 }
 
+void ExampleAppBeep(IPDF_JSPLATFORM*, int type) {
+  printf("BEEP!!! %d\n", type);
+}
+
 int ExampleAppResponse(IPDF_JSPLATFORM*,
                        FPDF_WIDESTRING question,
                        FPDF_WIDESTRING title,
@@ -197,12 +201,12 @@
   return 4;
 }
 
-void ExampleAppBeep(IPDF_JSPLATFORM*, int type) {
-  printf("BEEP!!! %d\n", type);
-}
-
-void ExampleDocGotoPage(IPDF_JSPLATFORM*, int page_number) {
-  printf("Goto Page: %d\n", page_number);
+int ExampleDocGetFilePath(IPDF_JSPLATFORM*, void* file_path, int length) {
+  static const char kPath[] = "myfile.pdf";
+  constexpr int kRequired = static_cast<int>(sizeof(kPath));
+  if (file_path && length >= kRequired)
+    memcpy(file_path, kPath, kRequired);
+  return kRequired;
 }
 
 void ExampleDocMail(IPDF_JSPLATFORM*,
@@ -232,6 +236,25 @@
   printf("Doc Print: %d, %d, %d, %d, %d, %d, %d, %d\n", bUI, nStart, nEnd,
          bSilent, bShrinkToFit, bPrintAsImage, bReverse, bAnnotations);
 }
+
+void ExampleDocSubmitForm(IPDF_JSPLATFORM*,
+                          void* formData,
+                          int length,
+                          FPDF_WIDESTRING url) {
+  printf("Doc Submit Form: url=%ls\n", GetPlatformWString(url).c_str());
+}
+
+void ExampleDocGotoPage(IPDF_JSPLATFORM*, int page_number) {
+  printf("Goto Page: %d\n", page_number);
+}
+
+int ExampleFieldBrowse(IPDF_JSPLATFORM*, void* file_path, int length) {
+  static const char kPath[] = "selected.txt";
+  constexpr int kRequired = static_cast<int>(sizeof(kPath));
+  if (file_path && length >= kRequired)
+    memcpy(file_path, kPath, kRequired);
+  return kRequired;
+}
 #endif  // PDF_ENABLE_V8
 
 void ExampleUnsupportedHandler(UNSUPPORT_INFO*, int type) {
@@ -733,11 +756,14 @@
   IPDF_JSPLATFORM platform_callbacks = {};
   platform_callbacks.version = 3;
   platform_callbacks.app_alert = ExampleAppAlert;
-  platform_callbacks.app_response = ExampleAppResponse;
   platform_callbacks.app_beep = ExampleAppBeep;
-  platform_callbacks.Doc_gotoPage = ExampleDocGotoPage;
+  platform_callbacks.app_response = ExampleAppResponse;
+  platform_callbacks.Doc_getFilePath = ExampleDocGetFilePath;
   platform_callbacks.Doc_mail = ExampleDocMail;
   platform_callbacks.Doc_print = ExampleDocPrint;
+  platform_callbacks.Doc_submitForm = ExampleDocSubmitForm;
+  platform_callbacks.Doc_gotoPage = ExampleDocGotoPage;
+  platform_callbacks.Field_browse = ExampleFieldBrowse;
 #endif  // PDF_ENABLE_V8
 
   FPDF_FORMFILLINFO_PDFiumTest form_callbacks = {};
diff --git a/testing/resources/javascript/document_methods_expected.txt b/testing/resources/javascript/document_methods_expected.txt
index d4daf99..1cb2dbd 100644
--- a/testing/resources/javascript/document_methods_expected.txt
+++ b/testing/resources/javascript/document_methods_expected.txt
@@ -141,4 +141,5 @@
 Alert: PASS: this.resetForm("myform") = undefined
 Alert: PASS: typeof this.submitForm = function
 Alert: PASS: this.submitForm() threw error Document.submitForm: Incorrect number of parameters passed to function.
+Doc Submit Form: url=myform
 Alert: PASS: this.submitForm("myform", true, true, ["name", "age"]) = undefined
diff --git a/testing/resources/javascript/document_props_expected.txt b/testing/resources/javascript/document_props_expected.txt
index 2c0aa31..5bab82f 100644
--- a/testing/resources/javascript/document_props_expected.txt
+++ b/testing/resources/javascript/document_props_expected.txt
@@ -24,11 +24,11 @@
 Alert: this.numPages is number 4
 Alert: this.pageNum is undefined undefined
 Alert: this.pageWindowRect is undefined undefined
-Alert: this.path is string /
+Alert: this.path is string /myfile.pdf
 Alert: this.producer is string 
 Alert: this.subject is string 
 Alert: this.title is string 
-Alert: this.URL is string 
+Alert: this.URL is string myfile.pdf
 Alert: this.zoom is undefined undefined
 Alert: this.zoomType is undefined undefined
 Alert: *** Setting properties to true ***
@@ -261,10 +261,10 @@
 Alert: this.numPages is number 4
 Alert: this.pageNum is undefined undefined
 Alert: this.pageWindowRect is undefined undefined
-Alert: this.path is string /
+Alert: this.path is string /myfile.pdf
 Alert: this.producer is string 3
 Alert: this.subject is string 3
 Alert: this.title is string 3
-Alert: this.URL is string 
+Alert: this.URL is string myfile.pdf
 Alert: this.zoom is undefined undefined
 Alert: this.zoomType is undefined undefined