Commit c421f3de authored by marja's avatar marja Committed by Commit bot

Script streaming: Test that streaming <-> harmony scopes interaction is correct.

BUG=

Review URL: https://codereview.chromium.org/871893002

Cr-Commit-Position: refs/heads/master@{#26250}
parent ace7b8f2
...@@ -24165,12 +24165,11 @@ void RunStreamingTest(const char** chunks, ...@@ -24165,12 +24165,11 @@ void RunStreamingTest(const char** chunks,
task->Run(); task->Run();
delete task; delete task;
v8::ScriptOrigin origin(v8_str("http://foo.com")); // Possible errors are only produced while compiling.
char* full_source = TestSourceStream::FullSourceString(chunks);
// The possible errors are only produced while compiling.
CHECK_EQ(false, try_catch.HasCaught()); 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( v8::Handle<Script> script = v8::ScriptCompiler::Compile(
isolate, &source, v8_str(full_source), origin); isolate, &source, v8_str(full_source), origin);
if (expected_success) { if (expected_success) {
...@@ -24512,6 +24511,48 @@ TEST(StreamingUtf8ScriptWithMultipleMultibyteCharactersSomeSplit2) { ...@@ -24512,6 +24511,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) { void TestInvalidCacheData(v8::ScriptCompiler::CompileOptions option) {
const char* garbage = "garbage garbage garbage garbage."; const char* garbage = "garbage garbage garbage garbage.";
const uint8_t* data = reinterpret_cast<const uint8_t*>(garbage); const uint8_t* data = reinterpret_cast<const uint8_t*>(garbage);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment