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

Side by Side Diff: test/cctest/test-api.cc

Issue 733023003: Reland "Soft fail for invalid cache data." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix leak Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « src/serialize.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 24189 matching lines...) Expand 10 before | Expand all | Expand 10 after
24200 char chunk2[] = 24200 char chunk2[] =
24201 "XX\xec\x92\x81r = 13;\n" 24201 "XX\xec\x92\x81r = 13;\n"
24202 " return foob\xec\x92\x81\xec\x92\x81r;\n" 24202 " return foob\xec\x92\x81\xec\x92\x81r;\n"
24203 "}\n"; 24203 "}\n";
24204 chunk1[strlen(chunk1) - 1] = reference[0]; 24204 chunk1[strlen(chunk1) - 1] = reference[0];
24205 chunk2[0] = reference[1]; 24205 chunk2[0] = reference[1];
24206 chunk2[1] = reference[2]; 24206 chunk2[1] = reference[2];
24207 const char* chunks[] = {chunk1, chunk2, "foo();", NULL}; 24207 const char* chunks[] = {chunk1, chunk2, "foo();", NULL};
24208 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8); 24208 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8);
24209 } 24209 }
24210
24211
24212 void TestInvalidCacheData(v8::ScriptCompiler::CompileOptions option) {
24213 const char* garbage = "garbage garbage garbage garbage.";
24214 const uint8_t* data = reinterpret_cast<const uint8_t*>(garbage);
24215 int length = 16;
24216 v8::ScriptCompiler::CachedData* cached_data =
24217 new v8::ScriptCompiler::CachedData(data, length);
24218 DCHECK(!cached_data->rejected);
24219 v8::ScriptOrigin origin(v8_str("origin"));
24220 v8::ScriptCompiler::Source source(v8_str("42"), origin, cached_data);
24221 v8::Handle<v8::Script> script =
24222 v8::ScriptCompiler::Compile(CcTest::isolate(), &source, option);
24223 CHECK(cached_data->rejected);
24224 CHECK_EQ(42, script->Run()->Int32Value());
24225 }
24226
24227
24228 TEST(InvalidCacheData) {
24229 v8::V8::Initialize();
24230 v8::HandleScope scope(CcTest::isolate());
24231 LocalContext context;
24232 TestInvalidCacheData(v8::ScriptCompiler::kConsumeParserCache);
24233 TestInvalidCacheData(v8::ScriptCompiler::kConsumeCodeCache);
24234 }
OLDNEW
« no previous file with comments | « src/serialize.cc ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698