Beef up timer cancellation tests
Adds more questionable invocations of ClearTimeOut().
Also, checking that nothing happened is fragile. Log at least
one thing to show that the code ran.
Review-Url: https://codereview.chromium.org/2218473002
diff --git a/fpdfsdk/fpdfformfill_embeddertest.cpp b/fpdfsdk/fpdfformfill_embeddertest.cpp
index e2920e0..27b8890 100644
--- a/fpdfsdk/fpdfformfill_embeddertest.cpp
+++ b/fpdfsdk/fpdfformfill_embeddertest.cpp
@@ -130,7 +130,8 @@
UnloadPage(page);
const auto& alerts = delegate.GetAlerts();
- EXPECT_EQ(0U, alerts.size());
+ ASSERT_EQ(1U, alerts.size());
+ EXPECT_STREQ(L"done", alerts[0].message.c_str());
}
#endif // PDF_ENABLE_V8
diff --git a/testing/resources/bug_620428.in b/testing/resources/bug_620428.in
index 1942305..050488b 100644
--- a/testing/resources/bug_620428.in
+++ b/testing/resources/bug_620428.in
@@ -73,8 +73,22 @@
}
var timer = app.setTimeOut("fireTimeOut()", 3000);
var interval = app.setInterval("fireInterval()", 1000);
+// Clear timers before they fire.
app.clearTimeOut(timer);
app.clearInterval(interval);
+// Check that clearing a cleared timer is ok.
+app.clearTimeOut(timer);
+app.clearInterval(interval);
+// Check that invoking the wrong clear method is ok
+var timer = app.setTimeOut("fireTimeOut()", 3000);
+var interval = app.setInterval("fireInterval()", 1000);
+app.clearTimeOut(interval);
+app.clearInterval(timer);
+// Check that clearing a non-timer is ok.
+app.clearTimeOut({"size": 42});
+app.clearInterval({"size": 42});
+// Be sure all of this code ran to completion.
+app.alert("done");
endstream
endobj
{{xref}}
diff --git a/testing/resources/bug_620428.pdf b/testing/resources/bug_620428.pdf
index ff625b7..e53ed50 100644
--- a/testing/resources/bug_620428.pdf
+++ b/testing/resources/bug_620428.pdf
@@ -74,8 +74,22 @@
}
var timer = app.setTimeOut("fireTimeOut()", 3000);
var interval = app.setInterval("fireInterval()", 1000);
+// Clear timers before they fire.
app.clearTimeOut(timer);
app.clearInterval(interval);
+// Check that clearing a cleared timer is ok.
+app.clearTimeOut(timer);
+app.clearInterval(interval);
+// Check that invoking the wrong clear method is ok
+var timer = app.setTimeOut("fireTimeOut()", 3000);
+var interval = app.setInterval("fireInterval()", 1000);
+app.clearTimeOut(interval);
+app.clearInterval(timer);
+// Check that clearing a non-timer is ok.
+app.clearTimeOut({"size": 42});
+app.clearInterval({"size": 42});
+// Be sure all of this code ran to completion.
+app.alert("done");
endstream
endobj
xref
@@ -135,5 +149,5 @@
/Root 1 0 R
>>
startxref
-1135
+1655
%%EOF