Commit f00440f5 authored by kinuko@chromium.org's avatar kinuko@chromium.org

Force running GC on the worker thread before the unit test exits

For the main thread we seem to always run
v8::Isolate::RequestGarbageCollectionForTesting but it's
not the case on the worker thread, which seems to cause leaks
on the context object.

BUG=526424

Review URL: https://codereview.chromium.org/1316233004

git-svn-id: svn://svn.chromium.org/blink/trunk@201601 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent b35cbbd9
...@@ -9,10 +9,12 @@ ...@@ -9,10 +9,12 @@
#include "core/workers/WorkerReportingProxy.h" #include "core/workers/WorkerReportingProxy.h"
#include "core/workers/WorkerThreadStartupData.h" #include "core/workers/WorkerThreadStartupData.h"
#include "platform/NotImplemented.h" #include "platform/NotImplemented.h"
#include "platform/heap/Heap.h"
#include "public/platform/WebScheduler.h" #include "public/platform/WebScheduler.h"
#include "public/platform/WebWaitableEvent.h" #include "public/platform/WebWaitableEvent.h"
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <v8.h>
using testing::_; using testing::_;
using testing::AtMost; using testing::AtMost;
...@@ -109,6 +111,12 @@ public: ...@@ -109,6 +111,12 @@ public:
{ {
return *m_thread; return *m_thread;
} }
void willDestroyIsolate() override
{
v8::Isolate::GetCurrent()->RequestGarbageCollectionForTesting(v8::Isolate::kFullGarbageCollection);
Heap::collectAllGarbage();
WorkerThread::willDestroyIsolate();
}
MOCK_METHOD1(doIdleGc, bool(double deadlineSeconds)); MOCK_METHOD1(doIdleGc, bool(double deadlineSeconds));
......
...@@ -14,10 +14,12 @@ ...@@ -14,10 +14,12 @@
#include "modules/compositorworker/CompositorWorkerThread.h" #include "modules/compositorworker/CompositorWorkerThread.h"
#include "platform/NotImplemented.h" #include "platform/NotImplemented.h"
#include "platform/ThreadSafeFunctional.h" #include "platform/ThreadSafeFunctional.h"
#include "platform/heap/Heap.h"
#include "platform/testing/UnitTestHelpers.h" #include "platform/testing/UnitTestHelpers.h"
#include "public/platform/Platform.h" #include "public/platform/Platform.h"
#include "public/platform/WebWaitableEvent.h" #include "public/platform/WebWaitableEvent.h"
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <v8.h>
namespace blink { namespace blink {
namespace { namespace {
...@@ -49,6 +51,12 @@ private: ...@@ -49,6 +51,12 @@ private:
if (m_v8TerminationCallback) if (m_v8TerminationCallback)
(*m_v8TerminationCallback)(); (*m_v8TerminationCallback)();
} }
void willDestroyIsolate() override
{
v8::Isolate::GetCurrent()->RequestGarbageCollectionForTesting(v8::Isolate::kFullGarbageCollection);
Heap::collectAllGarbage();
CompositorWorkerThread::willDestroyIsolate();
}
WebWaitableEvent* m_startEvent; WebWaitableEvent* m_startEvent;
OwnPtr<Function<void()>> m_v8TerminationCallback; OwnPtr<Function<void()>> m_v8TerminationCallback;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment