Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index 8fd87434c1b27aaeb5c31ce8af06026aa834cc62..b4cf5cf4a9891e7442ac307a71b34bc761ac5927 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -742,6 +742,53 @@ THREADED_TEST(UsingExternalOneByteString) { |
} |
+class DummyResource : public v8::String::ExternalStringResource { |
+ public: |
+ virtual const uint16_t* data() const { return string_; } |
+ virtual size_t length() const { return 1 << 30; } |
+ |
+ private: |
+ uint16_t string_[10]; |
+}; |
+ |
+ |
+class DummyOneByteResource : public v8::String::ExternalOneByteStringResource { |
+ public: |
+ virtual const char* data() const { return string_; } |
+ virtual size_t length() const { return 1 << 30; } |
+ |
+ private: |
+ char string_[10]; |
+}; |
+ |
+ |
+THREADED_TEST(NewExternalForVeryLongString) { |
+ { |
+ LocalContext env; |
+ v8::HandleScope scope(env->GetIsolate()); |
+ v8::TryCatch try_catch; |
+ DummyOneByteResource r; |
+ v8::Local<v8::String> str = v8::String::NewExternal(CcTest::isolate(), &r); |
+ CHECK(str.IsEmpty()); |
+ CHECK(try_catch.HasCaught()); |
+ String::Utf8Value exception_value(try_catch.Exception()); |
+ CHECK_EQ("RangeError: Invalid string length", *exception_value); |
+ } |
+ |
+ { |
+ LocalContext env; |
+ v8::HandleScope scope(env->GetIsolate()); |
+ v8::TryCatch try_catch; |
+ DummyResource r; |
+ v8::Local<v8::String> str = v8::String::NewExternal(CcTest::isolate(), &r); |
+ CHECK(str.IsEmpty()); |
+ CHECK(try_catch.HasCaught()); |
+ String::Utf8Value exception_value(try_catch.Exception()); |
+ CHECK_EQ("RangeError: Invalid string length", *exception_value); |
+ } |
+} |
+ |
+ |
THREADED_TEST(ScavengeExternalString) { |
i::FLAG_stress_compaction = false; |
i::FLAG_gc_global = false; |