Improve test for CJS_Field::get_button_position()

Show that out-of-range /TP values are passed through as-is.

Change-Id: I34169091069c74fd68e868975d46358b4fe52f3e
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/80711
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/testing/resources/javascript/field.fragment b/testing/resources/javascript/field.fragment
index 335e1ae..ff8f7f4 100644
--- a/testing/resources/javascript/field.fragment
+++ b/testing/resources/javascript/field.fragment
@@ -46,6 +46,7 @@
     10 0 R
     11 0 R
     12 0 R
+    13 0 R
   ]
 >>
 endobj
@@ -68,6 +69,9 @@
   /Parent 5 0 R
   /T (MyPushButton)
   /Rect [220 221 240 241]
+  /MK <<
+    /TP 4
+  >>
 >>
 endobj
 {{object 8 0}} <<
@@ -132,6 +136,20 @@
   /V ("/path/to/file.pdf")
 >>
 endobj
+% Questionable TP value.
+{{object 13 0}} <<
+  /Type /Annot
+  /Subtype /Widget
+  /FT /Btn
+  /Ff 65536
+  /Parent 5 0 R
+  /T (MyBadPushButton)
+  /Rect [400 421 440 441]
+  /MK <<
+    /TP 7
+  >>
+>>
+endobj
 % OpenAction action
 {{object 15 0}} <<
   /Type /Action
diff --git a/testing/resources/javascript/field_methods_expected.txt b/testing/resources/javascript/field_methods_expected.txt
index 687acd0..99dbf09 100644
--- a/testing/resources/javascript/field_methods_expected.txt
+++ b/testing/resources/javascript/field_methods_expected.txt
@@ -8,7 +8,8 @@
 Alert: dotdot1 is 
 Alert: dotdot2 is MyField.MyPushButton
 Alert: dotdot3 is MyField
-Alert: found 7 sub-fields:
+Alert: found 8 sub-fields:
+Alert: MyField.MyBadPushButton
 Alert: MyField.MyCheckBox
 Alert: MyField.MyFile
 Alert: MyField.MyMultiSelect
diff --git a/testing/resources/javascript/field_properties.in b/testing/resources/javascript/field_properties.in
index 0158956..e498547 100644
--- a/testing/resources/javascript/field_properties.in
+++ b/testing/resources/javascript/field_properties.in
@@ -11,6 +11,7 @@
     var field = this.getField("MyField");
     var text = this.getField("MyField.MyText");
     var button = this.getField("MyField.MyPushButton");
+    var badbutton = this.getField("MyField.MyBadPushButton");
     var radio = this.getField("MyField.MyRadio");
     var list = this.getField("MyField.MyMultiSelect");
     var check = this.getField("MyField.MyCheckBox");
@@ -23,6 +24,7 @@
     testFieldPropertiesCase(field);
     testTextPropertiesCase(text);
     testPushButtonPropertiesCase(button);
+    testBadPushButtonPropertiesCase(badbutton);
     testRadioButtonPropertiesCase(radio);
     testCheckBoxPropertiesCase(check);
     testListBoxPropertiesCase(list);
@@ -94,7 +96,7 @@
     testRIProperty(field, "buttonAlignX", 0, 50);
     testRIProperty(field, "buttonAlignY", 0, 50);
     testRIProperty(field, "buttonFitBounds", false);
-    testRIProperty(field, "buttonPosition", 0);
+    testRIProperty(field, "buttonPosition", 4);
     testRIProperty(field, "buttonScaleHow", 0);
     testRIProperty(field, "buttonScaleWhen", 0);
     testRIProperty(field, "highlight", "invert");
@@ -104,6 +106,14 @@
   }
 }
 
+function testBadPushButtonPropertiesCase(field) {
+  try {
+    testRIProperty(field, "buttonPosition", 7); // not checked.
+  } catch (e) {
+    app.alert("Unexpected error: " + e);
+  }
+}
+
 function testRadioButtonPropertiesCase(field) {
   try {
     testROProperty(field, "exportValues", "N");
diff --git a/testing/resources/javascript/field_properties_expected.txt b/testing/resources/javascript/field_properties_expected.txt
index 3b2e6f6..590fc65 100644
--- a/testing/resources/javascript/field_properties_expected.txt
+++ b/testing/resources/javascript/field_properties_expected.txt
@@ -84,8 +84,8 @@
 Alert: PASS: buttonAlignY = 0
 Alert: PASS: buttonFitBounds = false
 Alert: PASS: buttonFitBounds = false
-Alert: PASS: buttonPosition = 0
-Alert: PASS: buttonPosition = 0
+Alert: PASS: buttonPosition = 4
+Alert: PASS: buttonPosition = 4
 Alert: PASS: buttonScaleHow = false
 Alert: PASS: buttonScaleHow = false
 Alert: PASS: buttonScaleWhen = 0
@@ -94,6 +94,8 @@
 Alert: PASS: highlight = invert
 Alert: PASS: type = button
 Alert: PASS: type threw Field.type: Operation not supported.
+Alert: PASS: buttonPosition = 7
+Alert: PASS: buttonPosition = 7
 Alert: PASS: exportValues = N
 Alert: PASS: exportValues threw Field.exportValues: Object no longer exists.
 Alert: PASS: radiosInUnison = false