| Index: test/cctest/test-spaces.cc
 | 
| diff --git a/test/cctest/test-spaces.cc b/test/cctest/test-spaces.cc
 | 
| index 5c01f5bc281d4ca2e1da51b6f819933300d958b1..5667b201571f4ebb24b9a542bbd4134dba5982eb 100644
 | 
| --- a/test/cctest/test-spaces.cc
 | 
| +++ b/test/cctest/test-spaces.cc
 | 
| @@ -456,3 +456,54 @@ TEST(SizeOfFirstPageIsLargeEnough) {
 | 
|    // No large objects required to perform the above steps.
 | 
|    CHECK(isolate->heap()->lo_space()->IsEmpty());
 | 
|  }
 | 
| +
 | 
| +
 | 
| +static inline void FillCurrentPage(v8::internal::NewSpace* space) {
 | 
| +  int new_linear_size = static_cast<int>(*space->allocation_limit_address() -
 | 
| +                                         *space->allocation_top_address());
 | 
| +  if (new_linear_size == 0) return;
 | 
| +  v8::internal::AllocationResult allocation =
 | 
| +      space->AllocateRaw(new_linear_size);
 | 
| +  v8::internal::FreeListNode* node =
 | 
| +      v8::internal::FreeListNode::cast(allocation.ToObjectChecked());
 | 
| +  node->set_size(space->heap(), new_linear_size);
 | 
| +}
 | 
| +
 | 
| +
 | 
| +UNINITIALIZED_TEST(NewSpaceGrowsToTargetCapacity) {
 | 
| +  FLAG_target_semi_space_size = 2;
 | 
| +
 | 
| +  v8::Isolate* isolate = v8::Isolate::New();
 | 
| +  {
 | 
| +    v8::Isolate::Scope isolate_scope(isolate);
 | 
| +    v8::HandleScope handle_scope(isolate);
 | 
| +    v8::Context::New(isolate)->Enter();
 | 
| +
 | 
| +    Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate);
 | 
| +
 | 
| +    NewSpace* new_space = i_isolate->heap()->new_space();
 | 
| +
 | 
| +    // This test doesn't work if we start with a non-default new space
 | 
| +    // configuration.
 | 
| +    if (new_space->InitialTotalCapacity() == Page::kPageSize) {
 | 
| +      CHECK(new_space->CommittedMemory() == new_space->InitialTotalCapacity());
 | 
| +
 | 
| +      // Fill up the first (and only) page of the semi space.
 | 
| +      FillCurrentPage(new_space);
 | 
| +
 | 
| +      // Try to allocate out of the new space. A new page should be added and
 | 
| +      // the
 | 
| +      // allocation should succeed.
 | 
| +      v8::internal::AllocationResult allocation = new_space->AllocateRaw(80);
 | 
| +      CHECK(!allocation.IsRetry());
 | 
| +      CHECK(new_space->CommittedMemory() == 2 * Page::kPageSize);
 | 
| +
 | 
| +      // Turn the allocation into a proper object so isolate teardown won't
 | 
| +      // crash.
 | 
| +      v8::internal::FreeListNode* node =
 | 
| +          v8::internal::FreeListNode::cast(allocation.ToObjectChecked());
 | 
| +      node->set_size(new_space->heap(), 80);
 | 
| +    }
 | 
| +  }
 | 
| +  isolate->Dispose();
 | 
| +}
 | 
| 
 |