Commit 4ef0fa09 authored by yhirano@chromium.org's avatar yhirano@chromium.org

Do not run GC in ScriptPromisePropertyBase::destroyContext().

Discussion: https://codereview.chromium.org/1306083008/
BUG=526608

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

git-svn-id: svn://svn.chromium.org/blink/trunk@201544 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 84e101f9
...@@ -131,7 +131,7 @@ public: ...@@ -131,7 +131,7 @@ public:
virtual ~ScriptPromisePropertyTestBase() virtual ~ScriptPromisePropertyTestBase()
{ {
ScriptPromisePropertyTestBase::destroyContext(); destroyContext();
} }
Document& document() { return m_page->document(); } Document& document() { return m_page->document(); }
...@@ -142,15 +142,13 @@ public: ...@@ -142,15 +142,13 @@ public:
DOMWrapperWorld& otherWorld() { return m_otherScriptState->world(); } DOMWrapperWorld& otherWorld() { return m_otherScriptState->world(); }
ScriptState* currentScriptState() { return ScriptState::current(isolate()); } ScriptState* currentScriptState() { return ScriptState::current(isolate()); }
virtual void destroyContext() void destroyContext()
{ {
m_page.clear(); m_page.clear();
if (m_otherScriptState) { if (m_otherScriptState) {
m_otherScriptState->disposePerContextData(); m_otherScriptState->disposePerContextData();
m_otherScriptState = nullptr; m_otherScriptState = nullptr;
} }
gc();
Heap::collectAllGarbage();
} }
void gc() { V8GCController::collectGarbage(v8::Isolate::GetCurrent()); } void gc() { V8GCController::collectGarbage(v8::Isolate::GetCurrent()); }
...@@ -188,12 +186,6 @@ public: ...@@ -188,12 +186,6 @@ public:
Property* property() { return m_holder->property(); } Property* property() { return m_holder->property(); }
ScriptPromise promise(DOMWrapperWorld& world) { return property()->promise(world); } ScriptPromise promise(DOMWrapperWorld& world) { return property()->promise(world); }
void destroyContext() override
{
m_holder = nullptr;
ScriptPromisePropertyTestBase::destroyContext();
}
private: private:
Persistent<GarbageCollectedHolder> m_holder; Persistent<GarbageCollectedHolder> m_holder;
}; };
...@@ -362,29 +354,26 @@ TEST_F(ScriptPromisePropertyGarbageCollectedTest, Reject_RejectsScriptPromise) ...@@ -362,29 +354,26 @@ TEST_F(ScriptPromisePropertyGarbageCollectedTest, Reject_RejectsScriptPromise)
TEST_F(ScriptPromisePropertyGarbageCollectedTest, Promise_DeadContext) TEST_F(ScriptPromisePropertyGarbageCollectedTest, Promise_DeadContext)
{ {
Persistent<Property> property = this->property(); property()->resolve(new GarbageCollectedScriptWrappable("value"));
property->resolve(new GarbageCollectedScriptWrappable("value")); EXPECT_EQ(Property::Resolved, property()->state());
EXPECT_EQ(Property::Resolved, property->state());
destroyContext(); destroyContext();
EXPECT_TRUE(property->promise(DOMWrapperWorld::mainWorld()).isEmpty()); EXPECT_TRUE(property()->promise(DOMWrapperWorld::mainWorld()).isEmpty());
} }
TEST_F(ScriptPromisePropertyGarbageCollectedTest, Resolve_DeadContext) TEST_F(ScriptPromisePropertyGarbageCollectedTest, Resolve_DeadContext)
{ {
Persistent<Property> property = this->property();
{ {
ScriptState::Scope scope(mainScriptState()); ScriptState::Scope scope(mainScriptState());
property->promise(DOMWrapperWorld::mainWorld()).then(notReached(currentScriptState()), notReached(currentScriptState())); property()->promise(DOMWrapperWorld::mainWorld()).then(notReached(currentScriptState()), notReached(currentScriptState()));
} }
destroyContext(); destroyContext();
EXPECT_TRUE(!property->executionContext() || property->executionContext()->activeDOMObjectsAreStopped()); EXPECT_TRUE(!property()->executionContext() || property()->executionContext()->activeDOMObjectsAreStopped());
property->resolve(new GarbageCollectedScriptWrappable("value")); property()->resolve(new GarbageCollectedScriptWrappable("value"));
EXPECT_EQ(Property::Pending, property->state()); EXPECT_EQ(Property::Pending, property()->state());
v8::Isolate::GetCurrent()->RunMicrotasks(); v8::Isolate::GetCurrent()->RunMicrotasks();
} }
......
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