Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index 4d39aa543d6f79e96d1e5879f94d53638e1eebc4..017d3223c0c3943a7b4f261d799a7ce146d8a89d 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -24156,12 +24156,11 @@ void RunStreamingTest(const char** chunks, |
task->Run(); |
delete task; |
- v8::ScriptOrigin origin(v8_str("http://foo.com")); |
- char* full_source = TestSourceStream::FullSourceString(chunks); |
- |
- // The possible errors are only produced while compiling. |
+ // Possible errors are only produced while compiling. |
marja
2015/01/23 09:49:51
Cleanup: moved these lines because it's logical to
|
CHECK_EQ(false, try_catch.HasCaught()); |
+ v8::ScriptOrigin origin(v8_str("http://foo.com")); |
+ char* full_source = TestSourceStream::FullSourceString(chunks); |
v8::Handle<Script> script = v8::ScriptCompiler::Compile( |
isolate, &source, v8_str(full_source), origin); |
if (expected_success) { |
@@ -24503,6 +24502,48 @@ TEST(StreamingUtf8ScriptWithMultipleMultibyteCharactersSomeSplit2) { |
} |
+TEST(StreamingWithHarmonyScopes) { |
+ // Don't use RunStreamingTest here so that both scripts get to use the same |
+ // LocalContext and HandleScope. |
+ LocalContext env; |
+ v8::Isolate* isolate = env->GetIsolate(); |
+ v8::HandleScope scope(isolate); |
+ |
+ // First, run a script with a let variable. |
+ CompileRun("\"use strict\"; let x = 1;"); |
+ |
+ // Then stream a script which (erroneously) tries to introduce the same |
+ // variable again. |
+ const char* chunks[] = {"\"use strict\"; let x = 2;", NULL}; |
+ |
+ v8::TryCatch try_catch; |
+ v8::ScriptCompiler::StreamedSource source( |
+ new TestSourceStream(chunks), |
+ v8::ScriptCompiler::StreamedSource::ONE_BYTE); |
+ v8::ScriptCompiler::ScriptStreamingTask* task = |
+ v8::ScriptCompiler::StartStreamingScript(isolate, &source); |
+ task->Run(); |
+ delete task; |
+ |
+ // Parsing should succeed (the script will be parsed and compiled in a context |
+ // independent way, so the error is not detected). |
+ CHECK_EQ(false, try_catch.HasCaught()); |
+ |
+ v8::ScriptOrigin origin(v8_str("http://foo.com")); |
+ char* full_source = TestSourceStream::FullSourceString(chunks); |
+ v8::Handle<Script> script = v8::ScriptCompiler::Compile( |
+ isolate, &source, v8_str(full_source), origin); |
+ CHECK(!script.IsEmpty()); |
+ CHECK_EQ(false, try_catch.HasCaught()); |
+ |
+ // Running the script exposes the error. |
+ v8::Handle<Value> result(script->Run()); |
+ CHECK(result.IsEmpty()); |
+ CHECK(try_catch.HasCaught()); |
+ delete[] full_source; |
+} |
+ |
+ |
void TestInvalidCacheData(v8::ScriptCompiler::CompileOptions option) { |
const char* garbage = "garbage garbage garbage garbage."; |
const uint8_t* data = reinterpret_cast<const uint8_t*>(garbage); |