Test error cases in util.printd() and printx().
Remove an exclamation point (!) from a message for consistency.
Change-Id: Ie93faa2a9a6dedfecbe03e191db49b97fa36e84d
Reviewed-on: https://pdfium-review.googlesource.com/c/44910
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fxjs/js_resources.cpp b/fxjs/js_resources.cpp
index 6edb768..0b53c26 100644
--- a/fxjs/js_resources.cpp
+++ b/fxjs/js_resources.cpp
@@ -34,7 +34,7 @@
case JSMessage::kSecondParamNotDateError:
return L"The second parameter can't be converted to a Date.";
case JSMessage::kSecondParamInvalidDateError:
- return L"The second parameter is an invalid Date!";
+ return L"The second parameter is an invalid Date.";
case JSMessage::kGlobalNotFoundError:
return L"Global value not found.";
case JSMessage::kReadOnlyError:
diff --git a/testing/resources/javascript/util_printd.in b/testing/resources/javascript/util_printd.in
index 2d68919..e4c8afc 100644
--- a/testing/resources/javascript/util_printd.in
+++ b/testing/resources/javascript/util_printd.in
@@ -51,6 +51,24 @@
app.alert(str + ": Caught error: " + e);
}
}
+
+// Invalid arguments.
+try {
+ util.printd();
+} catch (e) {
+ app.alert('PASS: ' + e);
+}
+try {
+ util.printd('mm');
+} catch (e) {
+ app.alert('PASS: ' + e);
+}
+try {
+ util.printd('mm', new Date(undefined));
+} catch (e) {
+ app.alert('PASS: ' + e);
+}
+
// July 4th, 2014 11:59:59 AM local time.
var d1 = new Date(2014, 06, 04, 15, 59, 58);
TestOneFormat("mm/dd/yyyy HH:MM:ss", d1);
diff --git a/testing/resources/javascript/util_printd_expected.txt b/testing/resources/javascript/util_printd_expected.txt
index c609e34..a642a4a 100644
--- a/testing/resources/javascript/util_printd_expected.txt
+++ b/testing/resources/javascript/util_printd_expected.txt
@@ -1,3 +1,6 @@
+Alert: PASS: util.printd: Incorrect number of parameters passed to function.
+Alert: PASS: util.printd: Incorrect number of parameters passed to function.
+Alert: PASS: util.printd: The second parameter is an invalid Date.
Alert: mm/dd/yyyy HH:MM:ss: 07/04/2014 14:59:58
Alert: 0: D:20140704145958
Alert: 1: 2014.07.04 14:59:58
diff --git a/testing/resources/javascript/util_printx.in b/testing/resources/javascript/util_printx.in
index f3988cb..3002051 100644
--- a/testing/resources/javascript/util_printx.in
+++ b/testing/resources/javascript/util_printx.in
@@ -44,6 +44,19 @@
app.alert(title + ": Caught error: " + e);
}
}
+
+// Error cases
+try {
+ util.printx();
+} catch (e) {
+ app.alert('PASS: ' + e);
+}
+try {
+ util.printx("99");
+} catch (e) {
+ app.alert('PASS: ' + e);
+}
+
TestOneFormat("", "");
TestOneFormat("", "123");
TestOneFormat("??", "");
diff --git a/testing/resources/javascript/util_printx_expected.txt b/testing/resources/javascript/util_printx_expected.txt
index 124767d..3854f0d 100644
--- a/testing/resources/javascript/util_printx_expected.txt
+++ b/testing/resources/javascript/util_printx_expected.txt
@@ -1,3 +1,5 @@
+Alert: PASS: util.printx: Incorrect number of parameters passed to function.
+Alert: PASS: util.printx: Incorrect number of parameters passed to function.
Alert: ('', '') => ''
Alert: ('', '123') => ''
Alert: ('??', '') => ''