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

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

Issue 2141523002: Remove detailed from simple stack trace functionality (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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/isolate.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 16977 matching lines...) Expand 10 before | Expand all | Expand 10 after
16988 v8::Local<v8::Object> global = env->Global(); 16988 v8::Local<v8::Object> global = env->Global();
16989 Local<Value> trouble = 16989 Local<Value> trouble =
16990 global->Get(env.local(), v8_str("bar")).ToLocalChecked(); 16990 global->Get(env.local(), v8_str("bar")).ToLocalChecked();
16991 CHECK(trouble->IsFunction()); 16991 CHECK(trouble->IsFunction());
16992 CHECK(Function::Cast(*trouble)->Call(env.local(), global, 0, NULL).IsEmpty()); 16992 CHECK(Function::Cast(*trouble)->Call(env.local(), global, 0, NULL).IsEmpty());
16993 isolate->SetCaptureStackTraceForUncaughtExceptions(false); 16993 isolate->SetCaptureStackTraceForUncaughtExceptions(false);
16994 isolate->RemoveMessageListeners(StackTraceForUncaughtExceptionListener); 16994 isolate->RemoveMessageListeners(StackTraceForUncaughtExceptionListener);
16995 CHECK_EQ(1, report_count); 16995 CHECK_EQ(1, report_count);
16996 } 16996 }
16997 16997
16998
16999 TEST(GetStackTraceForUncaughtExceptionFromSimpleStackTrace) {
17000 report_count = 0;
17001 LocalContext env;
17002 v8::Isolate* isolate = env->GetIsolate();
17003 v8::HandleScope scope(isolate);
17004
17005 // Create an Error object first.
17006 CompileRunWithOrigin(
17007 "function foo() {\n"
17008 "e=new Error('err');\n"
17009 "};\n"
17010 "function bar() {\n"
17011 " foo();\n"
17012 "};\n"
17013 "var e;",
17014 "origin");
17015 v8::Local<v8::Object> global = env->Global();
17016 Local<Value> trouble =
17017 global->Get(env.local(), v8_str("bar")).ToLocalChecked();
17018 CHECK(trouble->IsFunction());
17019 Function::Cast(*trouble)->Call(env.local(), global, 0, NULL).ToLocalChecked();
17020
17021 // Enable capturing detailed stack trace late, and throw the exception.
17022 // The detailed stack trace should be extracted from the simple stack.
17023 isolate->AddMessageListener(StackTraceForUncaughtExceptionListener);
17024 isolate->SetCaptureStackTraceForUncaughtExceptions(true);
17025 CompileRunWithOrigin("throw e", "origin");
17026 isolate->SetCaptureStackTraceForUncaughtExceptions(false);
17027 isolate->RemoveMessageListeners(StackTraceForUncaughtExceptionListener);
17028 CHECK_EQ(1, report_count);
17029 }
17030
17031
17032 TEST(CaptureStackTraceForUncaughtExceptionAndSetters) { 16998 TEST(CaptureStackTraceForUncaughtExceptionAndSetters) {
17033 LocalContext env; 16999 LocalContext env;
17034 v8::Isolate* isolate = env->GetIsolate(); 17000 v8::Isolate* isolate = env->GetIsolate();
17035 v8::HandleScope scope(isolate); 17001 v8::HandleScope scope(isolate);
17036 isolate->SetCaptureStackTraceForUncaughtExceptions(true, 1024, 17002 isolate->SetCaptureStackTraceForUncaughtExceptions(true, 1024,
17037 v8::StackTrace::kDetailed); 17003 v8::StackTrace::kDetailed);
17038 17004
17039 CompileRun( 17005 CompileRun(
17040 "var setters = ['column', 'lineNumber', 'scriptName',\n" 17006 "var setters = ['column', 'lineNumber', 'scriptName',\n"
17041 " 'scriptNameOrSourceURL', 'functionName', 'isEval',\n" 17007 " 'scriptNameOrSourceURL', 'functionName', 'isEval',\n"
(...skipping 8328 matching lines...) Expand 10 before | Expand all | Expand 10 after
25370 CHECK(object->SetPrototype(context.local(), v8::Null(isolate)).IsNothing()); 25336 CHECK(object->SetPrototype(context.local(), v8::Null(isolate)).IsNothing());
25371 25337
25372 // The original prototype is still there 25338 // The original prototype is still there
25373 Local<Value> new_proto = 25339 Local<Value> new_proto =
25374 object->Get(context.local(), v8_str("__proto__")).ToLocalChecked(); 25340 object->Get(context.local(), v8_str("__proto__")).ToLocalChecked();
25375 CHECK(new_proto->IsObject()); 25341 CHECK(new_proto->IsObject());
25376 CHECK(new_proto.As<v8::Object>() 25342 CHECK(new_proto.As<v8::Object>()
25377 ->Equals(context.local(), original_proto) 25343 ->Equals(context.local(), original_proto)
25378 .FromJust()); 25344 .FromJust());
25379 } 25345 }
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698