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

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

Issue 885043002: [V8] Added line, column and script symbols for SyntaxError (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Test added Created 5 years, 10 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
« src/isolate.cc ('K') | « src/parser.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 18122 matching lines...) Expand 10 before | Expand all | Expand 10 after
18133 CompileRun(source); 18133 CompileRun(source);
18134 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false); 18134 v8::V8::SetCaptureStackTraceForUncaughtExceptions(false);
18135 v8::V8::RemoveMessageListeners(RethrowBogusErrorStackTraceHandler); 18135 v8::V8::RemoveMessageListeners(RethrowBogusErrorStackTraceHandler);
18136 } 18136 }
18137 18137
18138 18138
18139 v8::PromiseRejectEvent reject_event = v8::kPromiseRejectWithNoHandler; 18139 v8::PromiseRejectEvent reject_event = v8::kPromiseRejectWithNoHandler;
18140 int promise_reject_counter = 0; 18140 int promise_reject_counter = 0;
18141 int promise_revoke_counter = 0; 18141 int promise_revoke_counter = 0;
18142 int promise_reject_line_number = -1; 18142 int promise_reject_line_number = -1;
18143 int promise_reject_column_number = -1;
18143 int promise_reject_frame_count = -1; 18144 int promise_reject_frame_count = -1;
18144 18145
18145 void PromiseRejectCallback(v8::PromiseRejectMessage message) { 18146 void PromiseRejectCallback(v8::PromiseRejectMessage reject_message) {
18146 if (message.GetEvent() == v8::kPromiseRejectWithNoHandler) { 18147 if (reject_message.GetEvent() == v8::kPromiseRejectWithNoHandler) {
18147 promise_reject_counter++; 18148 promise_reject_counter++;
18148 CcTest::global()->Set(v8_str("rejected"), message.GetPromise()); 18149 CcTest::global()->Set(v8_str("rejected"), reject_message.GetPromise());
18149 CcTest::global()->Set(v8_str("value"), message.GetValue()); 18150 CcTest::global()->Set(v8_str("value"), reject_message.GetValue());
18150 v8::Handle<v8::StackTrace> stack_trace = 18151 v8::Handle<v8::Message> message =
18151 v8::Exception::CreateMessage(message.GetValue())->GetStackTrace(); 18152 v8::Exception::CreateMessage(reject_message.GetValue());
18153 v8::Handle<v8::StackTrace> stack_trace = message->GetStackTrace();
18154
18155 promise_reject_line_number = message->GetLineNumber();
18156 promise_reject_column_number = message->GetStartColumn() + 1;
18157
18152 if (!stack_trace.IsEmpty()) { 18158 if (!stack_trace.IsEmpty()) {
18153 promise_reject_frame_count = stack_trace->GetFrameCount(); 18159 promise_reject_frame_count = stack_trace->GetFrameCount();
18154 if (promise_reject_frame_count > 0) { 18160 if (promise_reject_frame_count > 0) {
18155 CHECK(stack_trace->GetFrame(0)->GetScriptName()->Equals(v8_str("pro"))); 18161 CHECK(stack_trace->GetFrame(0)->GetScriptName()->Equals(v8_str("pro")));
18156 promise_reject_line_number = stack_trace->GetFrame(0)->GetLineNumber();
yurys 2015/02/02 07:07:56 Now we don't check line number in the stack trace,
kozy 2015/02/02 09:18:57 Fixed and added column number checks.
18157 } else { 18162 } else {
18158 promise_reject_line_number = -1; 18163 promise_reject_line_number = -1;
18159 } 18164 }
18160 } 18165 }
18161 } else { 18166 } else {
18162 promise_revoke_counter++; 18167 promise_revoke_counter++;
18163 CcTest::global()->Set(v8_str("revoked"), message.GetPromise()); 18168 CcTest::global()->Set(v8_str("revoked"), reject_message.GetPromise());
18164 CHECK(message.GetValue().IsEmpty()); 18169 CHECK(reject_message.GetValue().IsEmpty());
18165 } 18170 }
18166 } 18171 }
18167 18172
18168 18173
18169 v8::Handle<v8::Promise> GetPromise(const char* name) { 18174 v8::Handle<v8::Promise> GetPromise(const char* name) {
18170 return v8::Handle<v8::Promise>::Cast(CcTest::global()->Get(v8_str(name))); 18175 return v8::Handle<v8::Promise>::Cast(CcTest::global()->Get(v8_str(name)));
18171 } 18176 }
18172 18177
18173 18178
18174 v8::Handle<v8::Value> RejectValue() { 18179 v8::Handle<v8::Value> RejectValue() {
18175 return CcTest::global()->Get(v8_str("value")); 18180 return CcTest::global()->Get(v8_str("value"));
18176 } 18181 }
18177 18182
18178 18183
18179 void ResetPromiseStates() { 18184 void ResetPromiseStates() {
18180 promise_reject_counter = 0; 18185 promise_reject_counter = 0;
18181 promise_revoke_counter = 0; 18186 promise_revoke_counter = 0;
18182 promise_reject_line_number = -1; 18187 promise_reject_line_number = -1;
18188 promise_reject_column_number = -1;
18183 promise_reject_frame_count = -1; 18189 promise_reject_frame_count = -1;
18184 CcTest::global()->Set(v8_str("rejected"), v8_str("")); 18190 CcTest::global()->Set(v8_str("rejected"), v8_str(""));
18185 CcTest::global()->Set(v8_str("value"), v8_str("")); 18191 CcTest::global()->Set(v8_str("value"), v8_str(""));
18186 CcTest::global()->Set(v8_str("revoked"), v8_str("")); 18192 CcTest::global()->Set(v8_str("revoked"), v8_str(""));
18187 } 18193 }
18188 18194
18189 18195
18190 TEST(PromiseRejectCallback) { 18196 TEST(PromiseRejectCallback) {
18191 LocalContext env; 18197 LocalContext env;
18192 v8::Isolate* isolate = env->GetIsolate(); 18198 v8::Isolate* isolate = env->GetIsolate();
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
18463 " return v1; \n" 18469 " return v1; \n"
18464 " } \n" 18470 " } \n"
18465 " ); \n", 18471 " ); \n",
18466 "pro", 0, 0); 18472 "pro", 0, 0);
18467 CHECK(GetPromise("v0")->HasHandler()); 18473 CHECK(GetPromise("v0")->HasHandler());
18468 CHECK(!GetPromise("v1")->HasHandler()); 18474 CHECK(!GetPromise("v1")->HasHandler());
18469 CHECK_EQ(2, promise_reject_counter); 18475 CHECK_EQ(2, promise_reject_counter);
18470 CHECK_EQ(1, promise_revoke_counter); 18476 CHECK_EQ(1, promise_revoke_counter);
18471 CHECK_EQ(0, promise_reject_frame_count); 18477 CHECK_EQ(0, promise_reject_frame_count);
18472 CHECK_EQ(-1, promise_reject_line_number); 18478 CHECK_EQ(-1, promise_reject_line_number);
18479
18480 ResetPromiseStates();
18481
18482 // Create promise t1, which rejects by throwing syntax error from eval.
18483 CompileRunWithOrigin(
18484 "var t1 = new Promise( \n"
18485 " function(res, rej) { \n"
18486 " var content = '\\n\\\n"
18487 " }'; \n"
18488 " eval(content); \n"
18489 " } \n"
18490 "); \n",
18491 "pro", 0, 0);
18492 CHECK(!GetPromise("t1")->HasHandler());
18493 CHECK_EQ(1, promise_reject_counter);
18494 CHECK_EQ(0, promise_revoke_counter);
18495 CHECK_EQ(2, promise_reject_frame_count);
18496 CHECK_EQ(2, promise_reject_line_number);
18497 CHECK_EQ(7, promise_reject_column_number);
18473 } 18498 }
18474 18499
18475 18500
18476 void AnalyzeStackOfEvalWithSourceURL( 18501 void AnalyzeStackOfEvalWithSourceURL(
18477 const v8::FunctionCallbackInfo<v8::Value>& args) { 18502 const v8::FunctionCallbackInfo<v8::Value>& args) {
18478 v8::HandleScope scope(args.GetIsolate()); 18503 v8::HandleScope scope(args.GetIsolate());
18479 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( 18504 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
18480 args.GetIsolate(), 10, v8::StackTrace::kDetailed); 18505 args.GetIsolate(), 10, v8::StackTrace::kDetailed);
18481 CHECK_EQ(5, stackTrace->GetFrameCount()); 18506 CHECK_EQ(5, stackTrace->GetFrameCount());
18482 v8::Handle<v8::String> url = v8_str("eval_url"); 18507 v8::Handle<v8::String> url = v8_str("eval_url");
(...skipping 6283 matching lines...) Expand 10 before | Expand all | Expand 10 after
24766 "bar2.js"); 24791 "bar2.js");
24767 } 24792 }
24768 24793
24769 24794
24770 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) { 24795 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) {
24771 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#", 24796 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#",
24772 " sourceMappingURL=bar2.js\n", "foo();", NULL}; 24797 " sourceMappingURL=bar2.js\n", "foo();", NULL};
24773 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL, 24798 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL,
24774 "bar2.js"); 24799 "bar2.js");
24775 } 24800 }
OLDNEW
« src/isolate.cc ('K') | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698