| Index: test/cctest/test-serialize.cc
|
| diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc
|
| index ef013259f3936c7acba77b14c25997ce71153421..85729cc274dadfdeaab8ee2c2ff95a610d46aac6 100644
|
| --- a/test/cctest/test-serialize.cc
|
| +++ b/test/cctest/test-serialize.cc
|
| @@ -1317,6 +1317,56 @@ TEST(SerializeToplevelIsolates) {
|
| }
|
|
|
|
|
| +TEST(SerializeToplevelFlagChange) {
|
| + FLAG_serialize_toplevel = true;
|
| +
|
| + const char* source = "function f() { return 'abc'; }; f() + 'def'";
|
| + v8::ScriptCompiler::CachedData* cache;
|
| +
|
| + v8::Isolate* isolate1 = v8::Isolate::New();
|
| + {
|
| + v8::Isolate::Scope iscope(isolate1);
|
| + v8::HandleScope scope(isolate1);
|
| + v8::Local<v8::Context> context = v8::Context::New(isolate1);
|
| + v8::Context::Scope context_scope(context);
|
| +
|
| + v8::Local<v8::String> source_str = v8_str(source);
|
| + v8::ScriptOrigin origin(v8_str("test"));
|
| + v8::ScriptCompiler::Source source(source_str, origin);
|
| + v8::Local<v8::UnboundScript> script = v8::ScriptCompiler::CompileUnbound(
|
| + isolate1, &source, v8::ScriptCompiler::kProduceCodeCache);
|
| + const v8::ScriptCompiler::CachedData* data = source.GetCachedData();
|
| + CHECK(data);
|
| + // Persist cached data.
|
| + uint8_t* buffer = NewArray<uint8_t>(data->length);
|
| + MemCopy(buffer, data->data, data->length);
|
| + cache = new v8::ScriptCompiler::CachedData(
|
| + buffer, data->length, v8::ScriptCompiler::CachedData::BufferOwned);
|
| +
|
| + v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
|
| + CHECK(result->ToString(isolate1)->Equals(v8_str("abcdef")));
|
| + }
|
| + isolate1->Dispose();
|
| +
|
| + v8::Isolate* isolate2 = v8::Isolate::New();
|
| + FLAG_allow_natives_syntax = true; // Flag change should trigger cache reject.
|
| + {
|
| + v8::Isolate::Scope iscope(isolate2);
|
| + v8::HandleScope scope(isolate2);
|
| + v8::Local<v8::Context> context = v8::Context::New(isolate2);
|
| + v8::Context::Scope context_scope(context);
|
| +
|
| + v8::Local<v8::String> source_str = v8_str(source);
|
| + v8::ScriptOrigin origin(v8_str("test"));
|
| + v8::ScriptCompiler::Source source(source_str, origin, cache);
|
| + v8::ScriptCompiler::CompileUnbound(isolate2, &source,
|
| + v8::ScriptCompiler::kConsumeCodeCache);
|
| + CHECK(cache->rejected);
|
| + }
|
| + isolate2->Dispose();
|
| +}
|
| +
|
| +
|
| TEST(SerializeWithHarmonyScoping) {
|
| FLAG_serialize_toplevel = true;
|
| FLAG_harmony_scoping = true;
|
|
|