// Copyright 2017 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "gin/data_object_builder.h" #include <string_view> #include "base/check_op.h" #include "base/debug/debugging_buildflags.h" #include "base/functional/bind.h" #include "base/logging.h" #include "gin/dictionary.h" #include "gin/public/isolate_holder.h" #include "gin/test/v8_test.h" #include "v8/include/v8-context.h" #include "v8/include/v8-function.h" namespace gin { namespace { DataObjectBuilderTest; // It should create ordinary data properties. TEST_F(DataObjectBuilderTest, CreatesDataProperties) { … } // It should not invoke setters on the prototype chain. TEST_F(DataObjectBuilderTest, DoesNotInvokeSetters) { … } // The internal handle is cleared when the builder is finished. // This makes the class harder to abuse, so that its methods cannot be used // after something may have modified the object in unexpected ways. // TODO(pbos): Consider making this a CHECK and test this everywhere. #if DCHECK_IS_ON() && !BUILDFLAG(DCHECK_IS_CONFIGURABLE) TEST_F(DataObjectBuilderTest, UnusableAfterBuild) { … } #endif // DCHECK_IS_ON() // As is the normal behaviour of CreateDataProperty, new data properties should // replace existing ones. Since no non-configurable ones are present, nor should // the object be non-extensible, this should work. TEST_F(DataObjectBuilderTest, ReplacesExistingProperties) { … } // It should work for array indices, too. TEST_F(DataObjectBuilderTest, CreatesDataPropertiesForIndices) { … } } // namespace } // namespace gin