OLD | NEW |
---|---|
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 16647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
16658 "eval('(' + outer +')()%s');"; | 16658 "eval('(' + outer +')()%s');"; |
16659 | 16659 |
16660 i::ScopedVector<char> code(1024); | 16660 i::ScopedVector<char> code(1024); |
16661 i::OS::SNPrintF(code, source, "//# sourceURL=eval_url"); | 16661 i::OS::SNPrintF(code, source, "//# sourceURL=eval_url"); |
16662 CHECK(CompileRun(code.start())->IsUndefined()); | 16662 CHECK(CompileRun(code.start())->IsUndefined()); |
16663 i::OS::SNPrintF(code, source, "//@ sourceURL=eval_url"); | 16663 i::OS::SNPrintF(code, source, "//@ sourceURL=eval_url"); |
16664 CHECK(CompileRun(code.start())->IsUndefined()); | 16664 CHECK(CompileRun(code.start())->IsUndefined()); |
16665 } | 16665 } |
16666 | 16666 |
16667 | 16667 |
16668 static int scriptIdInStack[2]; | |
16669 | |
16670 void AnalyzeScriptIdInStack( | |
16671 const v8::FunctionCallbackInfo<v8::Value>& args) { | |
16672 v8::HandleScope scope(args.GetIsolate()); | |
16673 v8::Handle<v8::StackTrace> stackTrace = | |
16674 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kScriptId); | |
16675 CHECK_EQ(2, stackTrace->GetFrameCount()); | |
16676 for (int i = 0; i < 2; i++) { | |
16677 scriptIdInStack[i] = stackTrace->GetFrame(i)->GetScriptId(); | |
yurys
2013/08/30 13:07:25
Instead of using global array to collect script id
| |
16678 } | |
16679 } | |
16680 | |
16681 | |
16682 TEST(ScriptIdInStackTrace) { | |
16683 v8::HandleScope scope(v8::Isolate::GetCurrent()); | |
16684 Local<ObjectTemplate> templ = ObjectTemplate::New(); | |
16685 templ->Set(v8_str("AnalyzeScriptIdInStack"), | |
16686 v8::FunctionTemplate::New(AnalyzeScriptIdInStack)); | |
16687 LocalContext context(0, templ); | |
16688 | |
16689 v8::Handle<v8::String> scriptSource = v8::String::New( | |
16690 "function foo() {\n" | |
16691 " AnalyzeScriptIdInStack();" | |
16692 "}\n" | |
16693 "foo();\n"); | |
16694 v8::ScriptOrigin origin = v8::ScriptOrigin(v8::String::New("test")); | |
16695 v8::Local<v8::Script> script(v8::Script::Compile(scriptSource, &origin)); | |
16696 script->Run(); | |
16697 for (int i = 0; i < 2; i++) { | |
16698 CHECK(scriptIdInStack[i] != v8::Message::kNoScriptIdInfo); | |
16699 CHECK_EQ(scriptIdInStack[i], script->GetId()); | |
16700 } | |
16701 } | |
16702 | |
16703 | |
16668 void AnalyzeStackOfInlineScriptWithSourceURL( | 16704 void AnalyzeStackOfInlineScriptWithSourceURL( |
16669 const v8::FunctionCallbackInfo<v8::Value>& args) { | 16705 const v8::FunctionCallbackInfo<v8::Value>& args) { |
16670 v8::HandleScope scope(args.GetIsolate()); | 16706 v8::HandleScope scope(args.GetIsolate()); |
16671 v8::Handle<v8::StackTrace> stackTrace = | 16707 v8::Handle<v8::StackTrace> stackTrace = |
16672 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); | 16708 v8::StackTrace::CurrentStackTrace(10, v8::StackTrace::kDetailed); |
16673 CHECK_EQ(4, stackTrace->GetFrameCount()); | 16709 CHECK_EQ(4, stackTrace->GetFrameCount()); |
16674 v8::Handle<v8::String> url = v8_str("url"); | 16710 v8::Handle<v8::String> url = v8_str("url"); |
16675 for (int i = 0; i < 3; i++) { | 16711 for (int i = 0; i < 3; i++) { |
16676 v8::Handle<v8::String> name = | 16712 v8::Handle<v8::String> name = |
16677 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); | 16713 stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); |
(...skipping 3589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
20267 CheckCorrectThrow("%GetLocalPropertyNames(other, true)"); | 20303 CheckCorrectThrow("%GetLocalPropertyNames(other, true)"); |
20268 CheckCorrectThrow("%DefineOrRedefineAccessorProperty(" | 20304 CheckCorrectThrow("%DefineOrRedefineAccessorProperty(" |
20269 "other, 'x', null, null, 1)"); | 20305 "other, 'x', null, null, 1)"); |
20270 | 20306 |
20271 // Reset the failed access check callback so it does not influence | 20307 // Reset the failed access check callback so it does not influence |
20272 // the other tests. | 20308 // the other tests. |
20273 v8::V8::SetFailedAccessCheckCallbackFunction(NULL); | 20309 v8::V8::SetFailedAccessCheckCallbackFunction(NULL); |
20274 } | 20310 } |
20275 | 20311 |
20276 #endif // V8_OS_POSIX | 20312 #endif // V8_OS_POSIX |
OLD | NEW |