Commit 061b43d4 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[unified-heap] Adjust ScriptPromiseProperty GC test

The test checks that the JS wrapper gets collected while the C++
wrappable stays alive. This only worked by accident as wrapper tracing
does not see any stack pointers.

Adjust test to check that the JS wrapper gets collected as soon as the
C++ wrappable is cleared.

Bug: 843903
Change-Id: I2041f682f4a94d690f43292f70ea3e8d7fb3fd6b
Reviewed-on: https://chromium-review.googlesource.com/c/1293450Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601554}
parent d0a1b1a0
...@@ -130,7 +130,9 @@ class ScriptPromisePropertyTestBase { ...@@ -130,7 +130,9 @@ class ScriptPromisePropertyTestBase {
} }
void Gc() { void Gc() {
V8GCController::CollectAllGarbageForTesting(v8::Isolate::GetCurrent()); V8GCController::CollectAllGarbageForTesting(
v8::Isolate::GetCurrent(),
v8::EmbedderHeapTracer::EmbedderStackState::kEmpty);
} }
v8::Local<v8::Function> NotReached(ScriptState* script_state) { v8::Local<v8::Function> NotReached(ScriptState* script_state) {
...@@ -170,6 +172,7 @@ class ScriptPromisePropertyGarbageCollectedTest ...@@ -170,6 +172,7 @@ class ScriptPromisePropertyGarbageCollectedTest
ScriptPromisePropertyGarbageCollectedTest() ScriptPromisePropertyGarbageCollectedTest()
: holder_(new GarbageCollectedHolder(&GetDocument())) {} : holder_(new GarbageCollectedHolder(&GetDocument())) {}
void ClearHolder() { holder_.Clear(); }
GarbageCollectedHolder* Holder() { return holder_; } GarbageCollectedHolder* Holder() { return holder_; }
Property* GetProperty() { return holder_->GetProperty(); } Property* GetProperty() { return holder_->GetProperty(); }
ScriptPromise Promise(DOMWrapperWorld& world) { ScriptPromise Promise(DOMWrapperWorld& world) {
...@@ -290,10 +293,9 @@ TEST_F(ScriptPromisePropertyGarbageCollectedTest, ...@@ -290,10 +293,9 @@ TEST_F(ScriptPromisePropertyGarbageCollectedTest,
EXPECT_FALSE(observation->wasCollected()); EXPECT_FALSE(observation->wasCollected());
holder_wrapper.Clear(); holder_wrapper.Clear();
ClearHolder();
Gc(); Gc();
EXPECT_TRUE(observation->wasCollected()); EXPECT_TRUE(observation->wasCollected());
EXPECT_EQ(Property::kPending, GetProperty()->GetState());
} }
TEST_F(ScriptPromisePropertyGarbageCollectedTest, TEST_F(ScriptPromisePropertyGarbageCollectedTest,
......
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