OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 v8::HandleScope scope(CcTest::isolate()); | 303 v8::HandleScope scope(CcTest::isolate()); |
304 v8::Handle<v8::Context> env = v8::Context::New(CcTest::isolate()); | 304 v8::Handle<v8::Context> env = v8::Context::New(CcTest::isolate()); |
305 env->Enter(); | 305 env->Enter(); |
306 | 306 |
307 SimpleExternalString source_ext_str("(function ext() {})();"); | 307 SimpleExternalString source_ext_str("(function ext() {})();"); |
308 v8::Local<v8::String> source = | 308 v8::Local<v8::String> source = |
309 v8::String::NewExternal(CcTest::isolate(), &source_ext_str); | 309 v8::String::NewExternal(CcTest::isolate(), &source_ext_str); |
310 // Script needs to have a name in order to trigger InitLineEnds execution. | 310 // Script needs to have a name in order to trigger InitLineEnds execution. |
311 v8::Handle<v8::String> origin = | 311 v8::Handle<v8::String> origin = |
312 v8::String::NewFromUtf8(CcTest::isolate(), "issue-23768-test"); | 312 v8::String::NewFromUtf8(CcTest::isolate(), "issue-23768-test"); |
313 v8::Handle<v8::Script> evil_script = CompileWithOrigin(source, origin); | 313 v8::Handle<v8::Script> evil_script = v8::Script::Compile(source, origin); |
314 CHECK(!evil_script.IsEmpty()); | 314 CHECK(!evil_script.IsEmpty()); |
315 CHECK(!evil_script->Run().IsEmpty()); | 315 CHECK(!evil_script->Run().IsEmpty()); |
316 i::Handle<i::ExternalTwoByteString> i_source( | 316 i::Handle<i::ExternalTwoByteString> i_source( |
317 i::ExternalTwoByteString::cast(*v8::Utils::OpenHandle(*source))); | 317 i::ExternalTwoByteString::cast(*v8::Utils::OpenHandle(*source))); |
318 // This situation can happen if source was an external string disposed | 318 // This situation can happen if source was an external string disposed |
319 // by its owner. | 319 // by its owner. |
320 i_source->set_resource(NULL); | 320 i_source->set_resource(NULL); |
321 | 321 |
322 // Must not crash. | 322 // Must not crash. |
323 CcTest::i_isolate()->logger()->LogCompiledFunctions(); | 323 CcTest::i_isolate()->logger()->LogCompiledFunctions(); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 CHECK(exists); | 461 CHECK(exists); |
462 v8::Handle<v8::String> log_str = v8::String::NewFromUtf8( | 462 v8::Handle<v8::String> log_str = v8::String::NewFromUtf8( |
463 CcTest::isolate(), log.start(), v8::String::kNormalString, log.length()); | 463 CcTest::isolate(), log.start(), v8::String::kNormalString, log.length()); |
464 initialize_logger.env()->Global()->Set(v8_str("_log"), log_str); | 464 initialize_logger.env()->Global()->Set(v8_str("_log"), log_str); |
465 | 465 |
466 i::Vector<const unsigned char> source = TestSources::GetScriptsSource(); | 466 i::Vector<const unsigned char> source = TestSources::GetScriptsSource(); |
467 v8::Handle<v8::String> source_str = v8::String::NewFromUtf8( | 467 v8::Handle<v8::String> source_str = v8::String::NewFromUtf8( |
468 CcTest::isolate(), reinterpret_cast<const char*>(source.start()), | 468 CcTest::isolate(), reinterpret_cast<const char*>(source.start()), |
469 v8::String::kNormalString, source.length()); | 469 v8::String::kNormalString, source.length()); |
470 v8::TryCatch try_catch; | 470 v8::TryCatch try_catch; |
471 v8::Handle<v8::Script> script = CompileWithOrigin(source_str, ""); | 471 v8::Handle<v8::Script> script = v8::Script::Compile(source_str, v8_str("")); |
472 if (script.IsEmpty()) { | 472 if (script.IsEmpty()) { |
473 v8::String::Utf8Value exception(try_catch.Exception()); | 473 v8::String::Utf8Value exception(try_catch.Exception()); |
474 printf("compile: %s\n", *exception); | 474 printf("compile: %s\n", *exception); |
475 CHECK(false); | 475 CHECK(false); |
476 } | 476 } |
477 v8::Handle<v8::Value> result = script->Run(); | 477 v8::Handle<v8::Value> result = script->Run(); |
478 if (result.IsEmpty()) { | 478 if (result.IsEmpty()) { |
479 v8::String::Utf8Value exception(try_catch.Exception()); | 479 v8::String::Utf8Value exception(try_catch.Exception()); |
480 printf("run: %s\n", *exception); | 480 printf("run: %s\n", *exception); |
481 CHECK(false); | 481 CHECK(false); |
482 } | 482 } |
483 // The result either be a "true" literal or problem description. | 483 // The result either be a "true" literal or problem description. |
484 if (!result->IsTrue()) { | 484 if (!result->IsTrue()) { |
485 v8::Local<v8::String> s = result->ToString(); | 485 v8::Local<v8::String> s = result->ToString(); |
486 i::ScopedVector<char> data(s->Utf8Length() + 1); | 486 i::ScopedVector<char> data(s->Utf8Length() + 1); |
487 CHECK_NE(NULL, data.start()); | 487 CHECK_NE(NULL, data.start()); |
488 s->WriteUtf8(data.start()); | 488 s->WriteUtf8(data.start()); |
489 printf("%s\n", data.start()); | 489 printf("%s\n", data.start()); |
490 // Make sure that our output is written prior crash due to CHECK failure. | 490 // Make sure that our output is written prior crash due to CHECK failure. |
491 fflush(stdout); | 491 fflush(stdout); |
492 CHECK(false); | 492 CHECK(false); |
493 } | 493 } |
494 } | 494 } |
OLD | NEW |