| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 23316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 23327 // TestSourceStream::GetMoreData won't block, so it's OK to just run the | 23327 // TestSourceStream::GetMoreData won't block, so it's OK to just run the |
| 23328 // task here in the main thread. | 23328 // task here in the main thread. |
| 23329 task->Run(); | 23329 task->Run(); |
| 23330 delete task; | 23330 delete task; |
| 23331 | 23331 |
| 23332 const v8::ScriptCompiler::CachedData* cached_data = source.GetCachedData(); | 23332 const v8::ScriptCompiler::CachedData* cached_data = source.GetCachedData(); |
| 23333 CHECK(cached_data != NULL); | 23333 CHECK(cached_data != NULL); |
| 23334 CHECK(cached_data->data != NULL); | 23334 CHECK(cached_data->data != NULL); |
| 23335 CHECK_GT(cached_data->length, 0); | 23335 CHECK_GT(cached_data->length, 0); |
| 23336 } | 23336 } |
| 23337 |
| 23338 |
| 23339 TEST(StreamingScriptWithInvalidUtf8) { |
| 23340 // Regression test for a crash: test that invalid UTF-8 bytes in the end of a |
| 23341 // chunk don't produce a crash. |
| 23342 const char* reference = "\xeb\x91\x80\x80\x80"; |
| 23343 char chunk1[] = |
| 23344 "function foo() {\n" |
| 23345 " // This function will contain an UTF-8 character which is not in\n" |
| 23346 " // ASCII.\n" |
| 23347 " var foobXXXXX"; // Too many bytes which look like incomplete chars! |
| 23348 char chunk2[] = |
| 23349 "r = 13;\n" |
| 23350 " return foob\xeb\x91\x80\x80\x80r;\n" |
| 23351 "}\n"; |
| 23352 for (int i = 0; i < 5; ++i) chunk1[strlen(chunk1) - 5 + i] = reference[i]; |
| 23353 |
| 23354 const char* chunks[] = {chunk1, chunk2, "foo();", NULL}; |
| 23355 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, false); |
| 23356 } |
| OLD | NEW |