Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: test/cctest/test-api.cc

Issue 867373003: Throw on range error when creating a string via API. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/api.cc ('k') | test/cctest/test-thread-termination.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 95a64a91cfcc15ad5ee6391857fda20119ff60e8..f1593fe4efa5dbf1cab2cd68dbd963c13d5779de 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -21914,3 +21914,36 @@ TEST(StreamingScriptWithSourceMappingURLInTheMiddle) {
RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL,
"bar2.js");
}
+
+
+TEST(NewStringRangeError) {
+ v8::Isolate* isolate = CcTest::isolate();
+ v8::HandleScope handle_scope(isolate);
+ LocalContext env;
+ const int length = i::String::kMaxLength + 1;
+ const int buffer_size = length * sizeof(uint16_t);
+ void* buffer = malloc(buffer_size);
+ memset(buffer, 'A', buffer_size);
+ {
+ v8::TryCatch try_catch;
+ char* data = reinterpret_cast<char*>(buffer);
+ CHECK(v8::String::NewFromUtf8(isolate, data, v8::String::kNormalString,
+ length).IsEmpty());
+ CHECK(try_catch.HasCaught());
+ }
+ {
+ v8::TryCatch try_catch;
+ uint8_t* data = reinterpret_cast<uint8_t*>(buffer);
+ CHECK(v8::String::NewFromOneByte(isolate, data, v8::String::kNormalString,
+ length).IsEmpty());
+ CHECK(try_catch.HasCaught());
+ }
+ {
+ v8::TryCatch try_catch;
+ uint16_t* data = reinterpret_cast<uint16_t*>(buffer);
+ CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString,
+ length).IsEmpty());
+ CHECK(try_catch.HasCaught());
+ }
+ free(buffer);
+}
« no previous file with comments | « src/api.cc ('k') | test/cctest/test-thread-termination.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698