#include "src/objects/value-serializer.h"
#include <algorithm>
#include <string>
#include "include/v8-context.h"
#include "include/v8-date.h"
#include "include/v8-function.h"
#include "include/v8-json.h"
#include "include/v8-local-handle.h"
#include "include/v8-primitive-object.h"
#include "include/v8-template.h"
#include "include/v8-value-serializer-version.h"
#include "include/v8-value-serializer.h"
#include "include/v8-wasm.h"
#include "src/api/api-inl.h"
#include "src/base/build_config.h"
#include "src/objects/backing-store.h"
#include "src/objects/js-array-buffer-inl.h"
#include "src/objects/js-array-buffer.h"
#include "src/objects/objects-inl.h"
#include "test/common/flag-utils.h"
#include "test/unittests/heap/heap-utils.h"
#include "test/unittests/test-utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-objects.h"
#include "src/wasm/wasm-result.h"
#endif
namespace v8 {
namespace {
_;
Invoke;
Return;
class ValueSerializerTest : public TestWithIsolate { … };
TEST_F(ValueSerializerTest, DecodeInvalid) { … }
TEST_F(ValueSerializerTest, RoundTripOddball) { … }
TEST_F(ValueSerializerTest, DecodeOddball) { … }
TEST_F(ValueSerializerTest, EncodeArrayStackOverflow) { … }
TEST_F(ValueSerializerTest, EncodeObjectStackOverflow) { … }
TEST_F(ValueSerializerTest, DecodeArrayStackOverflow) { … }
TEST_F(ValueSerializerTest, DecodeObjectStackOverflow) { … }
TEST_F(ValueSerializerTest, DecodeVerifyObjectCount) { … }
TEST_F(ValueSerializerTest, RoundTripNumber) { … }
TEST_F(ValueSerializerTest, DecodeNumber) { … }
TEST_F(ValueSerializerTest, RoundTripBigInt) { … }
TEST_F(ValueSerializerTest, DecodeBigInt) { … }
static const char kHelloString[] = …;
static const char kQuebecString[] = …;
static const char kEmojiString[] = …;
TEST_F(ValueSerializerTest, RoundTripString) { … }
TEST_F(ValueSerializerTest, DecodeString) { … }
TEST_F(ValueSerializerTest, DecodeInvalidString) { … }
TEST_F(ValueSerializerTest, EncodeTwoByteStringUsesPadding) { … }
TEST_F(ValueSerializerTest, RoundTripDictionaryObject) { … }
TEST_F(ValueSerializerTest, DecodeDictionaryObject) { … }
TEST_F(ValueSerializerTest, InvalidDecodeObjectWithInvalidKeyType) { … }
TEST_F(ValueSerializerTest, RoundTripOnlyOwnEnumerableStringKeys) { … }
TEST_F(ValueSerializerTest, RoundTripTrickyGetters) { … }
TEST_F(ValueSerializerTest, RoundTripDictionaryObjectForTransitions) { … }
TEST_F(ValueSerializerTest, DecodeDictionaryObjectVersion0) { … }
TEST_F(ValueSerializerTest, RoundTripArray) { … }
TEST_F(ValueSerializerTest, DecodeArray) { … }
TEST_F(ValueSerializerTest, DecodeInvalidOverLargeArray) { … }
TEST_F(ValueSerializerTest, RoundTripArrayWithNonEnumerableElement) { … }
TEST_F(ValueSerializerTest, RoundTripArrayWithTrickyGetters) { … }
TEST_F(ValueSerializerTest, DecodeSparseArrayVersion0) { … }
TEST_F(ValueSerializerTest, RoundTripDenseArrayContainingUndefined) { … }
TEST_F(ValueSerializerTest,
DecodeDenseArrayContainingUndefinedBackwardCompatibility) { … }
TEST_F(ValueSerializerTest, DecodeDenseArrayContainingUndefined) { … }
TEST_F(ValueSerializerTest, RoundTripDate) { … }
TEST_F(ValueSerializerTest, DecodeDate) { … }
TEST_F(ValueSerializerTest, RoundTripValueObjects) { … }
TEST_F(ValueSerializerTest, RejectsOtherValueObjects) { … }
TEST_F(ValueSerializerTest, DecodeValueObjects) { … }
TEST_F(ValueSerializerTest, RoundTripRegExp) { … }
TEST_F(ValueSerializerTest, DecodeRegExp) { … }
TEST_F(ValueSerializerTest, DecodeRegExpDotAll) { … }
TEST_F(ValueSerializerTest, DecodeLinearRegExp) { … }
TEST_F(ValueSerializerTest, DecodeHasIndicesRegExp) { … }
TEST_F(ValueSerializerTest, DecodeRegExpUnicodeSets) { … }
TEST_F(ValueSerializerTest, RoundTripMap) { … }
TEST_F(ValueSerializerTest, DecodeMap) { … }
TEST_F(ValueSerializerTest, RoundTripMapWithTrickyGetters) { … }
TEST_F(ValueSerializerTest, RoundTripSet) { … }
TEST_F(ValueSerializerTest, DecodeSet) { … }
TEST_F(ValueSerializerTest, RoundTripSetWithTrickyGetters) { … }
TEST_F(ValueSerializerTest, RoundTripArrayBuffer) { … }
TEST_F(ValueSerializerTest, RoundTripResizableArrayBuffer) { … }
TEST_F(ValueSerializerTest, DecodeArrayBuffer) { … }
TEST_F(ValueSerializerTest, DecodeInvalidArrayBuffer) { … }
TEST_F(ValueSerializerTest, DecodeInvalidResizableArrayBuffer) { … }
class OOMArrayBufferAllocator : public ArrayBuffer::Allocator { … };
TEST_F(ValueSerializerTest, DecodeArrayBufferOOM) { … }
class ValueSerializerTestWithArrayBufferTransfer : public ValueSerializerTest { … };
TEST_F(ValueSerializerTestWithArrayBufferTransfer,
RoundTripArrayBufferTransfer) { … }
TEST_F(ValueSerializerTest, RoundTripTypedArray) { … }
TEST_F(ValueSerializerTest, RoundTripRabBackedLengthTrackingTypedArray) { … }
TEST_F(ValueSerializerTest, RoundTripRabBackedNonLengthTrackingTypedArray) { … }
TEST_F(ValueSerializerTest, DecodeTypedArray) { … }
TEST_F(ValueSerializerTest, DecodeTypedArrayBackwardsCompatiblity) { … }
TEST_F(ValueSerializerTest, DecodeTypedArrayBrokenData) { … }
TEST_F(ValueSerializerTest, DecodeInvalidTypedArray) { … }
TEST_F(ValueSerializerTest, RoundTripDataView) { … }
TEST_F(ValueSerializerTest, DecodeDataView) { … }
TEST_F(ValueSerializerTest, RoundTripRabBackedDataView) { … }
TEST_F(ValueSerializerTest, RoundTripRabBackedLengthTrackingDataView) { … }
TEST_F(ValueSerializerTest, DecodeDataViewBackwardsCompatibility) { … }
TEST_F(ValueSerializerTest, DecodeArrayWithLengthProperty1) { … }
TEST_F(ValueSerializerTest, DecodeArrayWithLengthProperty2) { … }
TEST_F(ValueSerializerTest, DecodeInvalidDataView) { … }
class ValueSerializerTestWithSharedArrayBufferClone
: public ValueSerializerTest { … };
TEST_F(ValueSerializerTestWithSharedArrayBufferClone,
RoundTripSharedArrayBufferClone) { … }
#if V8_ENABLE_WEBASSEMBLY
TEST_F(ValueSerializerTestWithSharedArrayBufferClone,
RoundTripWebAssemblyMemory) { … }
TEST_F(ValueSerializerTestWithSharedArrayBufferClone,
RoundTripWebAssemblyMemory_WithPreviousReference) { … }
#endif
TEST_F(ValueSerializerTest, UnsupportedHostObject) { … }
class ValueSerializerTestWithHostObject : public ValueSerializerTest { … };
const uint8_t ValueSerializerTestWithHostObject::kExampleHostObjectTag = …;
TEST_F(ValueSerializerTestWithHostObject, RoundTripUint32) { … }
TEST_F(ValueSerializerTestWithHostObject, RoundTripUint64) { … }
TEST_F(ValueSerializerTestWithHostObject, RoundTripDouble) { … }
TEST_F(ValueSerializerTestWithHostObject, RoundTripRawBytes) { … }
TEST_F(ValueSerializerTestWithHostObject, RoundTripSameObject) { … }
TEST_F(ValueSerializerTestWithHostObject, DecodeSimpleHostObject) { … }
TEST_F(ValueSerializerTestWithHostObject,
RoundTripHostJSObjectWithoutCustomHostObject) { … }
TEST_F(ValueSerializerTestWithHostObject, RoundTripHostJSObject) { … }
class ValueSerializerTestWithHostArrayBufferView
: public ValueSerializerTestWithHostObject { … };
TEST_F(ValueSerializerTestWithHostArrayBufferView, RoundTripUint8ArrayInput) { … }
#if V8_ENABLE_WEBASSEMBLY
constexpr uint8_t kIncrementerWasm[] = …;
class ValueSerializerTestWithWasm : public ValueSerializerTest { … };
bool ValueSerializerTestWithWasm::g_saved_flag = …;
const char* ValueSerializerTestWithWasm::kUnsupportedSerialization = …;
TEST_F(ValueSerializerTestWithWasm, DefaultSerializationDelegate) { … }
TEST_F(ValueSerializerTestWithWasm, DefaultDeserializationDelegate) { … }
TEST_F(ValueSerializerTestWithWasm, RoundtripWasmTransfer) { … }
TEST_F(ValueSerializerTestWithWasm, CannotTransferWasmWhenExpectingInline) { … }
TEST_F(ValueSerializerTestWithWasm, ComplexObjectDuplicateTransfer) { … }
TEST_F(ValueSerializerTestWithWasm, ComplexObjectWithManyTransfer) { … }
#endif
class ValueSerializerTestWithLimitedMemory : public ValueSerializerTest { … };
TEST_F(ValueSerializerTestWithLimitedMemory, FailIfNoMemoryInWriteHostObject) { … }
TEST_F(ValueSerializerTest, RoundTripError) { … }
TEST_F(ValueSerializerTest, DefaultErrorStack) { … }
TEST_F(ValueSerializerTest, ModifiedErrorStack) { … }
TEST_F(ValueSerializerTest, NonStringErrorStack) { … }
TEST_F(ValueSerializerTest, InvalidLegacyFormatData) { … }
}
}