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

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

Issue 845643005: Script streaming: don't produce (empty) cached data when debugger forces eagerness. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: test fix 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 unified diff | Download patch
« no previous file with comments | « src/background-parsing-task.cc ('k') | no next file » | 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 24404 matching lines...) Expand 10 before | Expand all | Expand 10 after
24415 delete task; 24415 delete task;
24416 24416
24417 const v8::ScriptCompiler::CachedData* cached_data = source.GetCachedData(); 24417 const v8::ScriptCompiler::CachedData* cached_data = source.GetCachedData();
24418 CHECK(cached_data != NULL); 24418 CHECK(cached_data != NULL);
24419 CHECK(cached_data->data != NULL); 24419 CHECK(cached_data->data != NULL);
24420 CHECK(!cached_data->rejected); 24420 CHECK(!cached_data->rejected);
24421 CHECK_GT(cached_data->length, 0); 24421 CHECK_GT(cached_data->length, 0);
24422 } 24422 }
24423 24423
24424 24424
24425 TEST(StreamingWithDebuggingDoesNotProduceParserCache) {
24426 // If the debugger is active, we should just not produce parser cache at
24427 // all. This is a regeression test: We used to produce a parser cache without
24428 // any data in it (just headers).
24429 i::FLAG_min_preparse_length = 0;
24430 const char* chunks[] = {"function foo() { ret", "urn 13; } f", "oo(); ",
24431 NULL};
24432
24433 LocalContext env;
24434 v8::Isolate* isolate = env->GetIsolate();
24435 v8::HandleScope scope(isolate);
24436
24437 // Make the debugger active by setting a breakpoint.
24438 CompileRun("function break_here() { }");
24439 i::Handle<i::JSFunction> func = i::Handle<i::JSFunction>::cast(
24440 v8::Utils::OpenHandle(*env->Global()->Get(v8_str("break_here"))));
24441 v8::internal::Debug* debug = CcTest::i_isolate()->debug();
24442 int position = 0;
24443 debug->SetBreakPoint(func, i::Handle<i::Object>(v8::internal::Smi::FromInt(1),
24444 CcTest::i_isolate()),
24445 &position);
24446
24447 v8::ScriptCompiler::StreamedSource source(
24448 new TestSourceStream(chunks),
24449 v8::ScriptCompiler::StreamedSource::ONE_BYTE);
24450 v8::ScriptCompiler::ScriptStreamingTask* task =
24451 v8::ScriptCompiler::StartStreamingScript(
24452 isolate, &source, v8::ScriptCompiler::kProduceParserCache);
24453
24454 // TestSourceStream::GetMoreData won't block, so it's OK to just run the
24455 // task here in the main thread.
24456 task->Run();
24457 delete task;
24458
24459 // Check that we got no cached data.
24460 CHECK(source.GetCachedData() == NULL);
24461 }
24462
24463
24425 TEST(StreamingScriptWithInvalidUtf8) { 24464 TEST(StreamingScriptWithInvalidUtf8) {
24426 // Regression test for a crash: test that invalid UTF-8 bytes in the end of a 24465 // Regression test for a crash: test that invalid UTF-8 bytes in the end of a
24427 // chunk don't produce a crash. 24466 // chunk don't produce a crash.
24428 const char* reference = "\xec\x92\x81\x80\x80"; 24467 const char* reference = "\xec\x92\x81\x80\x80";
24429 char chunk1[] = 24468 char chunk1[] =
24430 "function foo() {\n" 24469 "function foo() {\n"
24431 " // This function will contain an UTF-8 character which is not in\n" 24470 " // This function will contain an UTF-8 character which is not in\n"
24432 " // ASCII.\n" 24471 " // ASCII.\n"
24433 " var foobXXXXX"; // Too many bytes which look like incomplete chars! 24472 " var foobXXXXX"; // Too many bytes which look like incomplete chars!
24434 char chunk2[] = 24473 char chunk2[] =
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
24697 "bar2.js"); 24736 "bar2.js");
24698 } 24737 }
24699 24738
24700 24739
24701 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) { 24740 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) {
24702 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#", 24741 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#",
24703 " sourceMappingURL=bar2.js\n", "foo();", NULL}; 24742 " sourceMappingURL=bar2.js\n", "foo();", NULL};
24704 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL, 24743 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL,
24705 "bar2.js"); 24744 "bar2.js");
24706 } 24745 }
OLDNEW
« no previous file with comments | « src/background-parsing-task.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698