- Fix use-after-return in ReleaseAndWaitForDestructor if it times out

while running unit tests.
- Increase PluginTest PDF load timeout.
This commit is contained in:
Marshall Greenblatt 2015-10-14 09:42:42 -07:00
parent 70ed95bcca
commit 16f8a66040
2 changed files with 9 additions and 0 deletions

View File

@ -51,7 +51,11 @@ const char kPdfHtmlUrl[] = "http://tests/pdf.html";
const char kPdfDirectUrl[] = "http://tests/pdf.pdf";
// Delay waiting for iframe tests to load the PDF file.
#if defined(OS_LINUX)
const int64 kPdfLoadDelayMs = 7000;
#else
const int64 kPdfLoadDelayMs = 5000;
#endif
// Browser-side test handler.
class PluginTestHandler : public RoutingTestHandler,

View File

@ -299,10 +299,15 @@ template<typename T>
void ReleaseAndWaitForDestructor(CefRefPtr<T>& handler, int delay_ms = 2000) {
base::WaitableEvent event(true, false);
handler->SetDestroyEvent(&event);
T* _handler_ptr = handler.get();
handler = NULL;
bool handler_destructed =
event.TimedWait(base::TimeDelta::FromMilliseconds(delay_ms));
EXPECT_TRUE(handler_destructed);
if (!handler_destructed) {
// |event| is a stack variable so clear the reference before returning.
_handler_ptr->SetDestroyEvent(NULL);
}
}
// Post a task to the specified thread and wait for the task to execute as