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

Unified Diff: test/cctest/test-api.cc

Issue 871893002: Script streaming: Test that streaming <-> harmony scopes interaction is correct. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698