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

Unified 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: Rebased 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index a043b364992dfd953eb2990f94c2a15e1af2c3ac..3a9927c43b9d151f0198dc821c4fa71b9606ed50 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -18142,29 +18142,39 @@ TEST(RethrowBogusErrorStackTrace) {
v8::PromiseRejectEvent reject_event = v8::kPromiseRejectWithNoHandler;
int promise_reject_counter = 0;
int promise_revoke_counter = 0;
+int promise_reject_msg_line_number = -1;
+int promise_reject_msg_column_number = -1;
int promise_reject_line_number = -1;
+int promise_reject_column_number = -1;
int promise_reject_frame_count = -1;
-void PromiseRejectCallback(v8::PromiseRejectMessage message) {
- if (message.GetEvent() == v8::kPromiseRejectWithNoHandler) {
+void PromiseRejectCallback(v8::PromiseRejectMessage reject_message) {
+ if (reject_message.GetEvent() == v8::kPromiseRejectWithNoHandler) {
promise_reject_counter++;
- CcTest::global()->Set(v8_str("rejected"), message.GetPromise());
- CcTest::global()->Set(v8_str("value"), message.GetValue());
- v8::Handle<v8::StackTrace> stack_trace =
- v8::Exception::CreateMessage(message.GetValue())->GetStackTrace();
+ CcTest::global()->Set(v8_str("rejected"), reject_message.GetPromise());
+ CcTest::global()->Set(v8_str("value"), reject_message.GetValue());
+ v8::Handle<v8::Message> message =
+ v8::Exception::CreateMessage(reject_message.GetValue());
+ v8::Handle<v8::StackTrace> stack_trace = message->GetStackTrace();
+
+ promise_reject_msg_line_number = message->GetLineNumber();
+ promise_reject_msg_column_number = message->GetStartColumn() + 1;
+
if (!stack_trace.IsEmpty()) {
promise_reject_frame_count = stack_trace->GetFrameCount();
if (promise_reject_frame_count > 0) {
CHECK(stack_trace->GetFrame(0)->GetScriptName()->Equals(v8_str("pro")));
promise_reject_line_number = stack_trace->GetFrame(0)->GetLineNumber();
+ promise_reject_column_number = stack_trace->GetFrame(0)->GetColumn();
} else {
promise_reject_line_number = -1;
+ promise_reject_column_number = -1;
}
}
} else {
promise_revoke_counter++;
- CcTest::global()->Set(v8_str("revoked"), message.GetPromise());
- CHECK(message.GetValue().IsEmpty());
+ CcTest::global()->Set(v8_str("revoked"), reject_message.GetPromise());
+ CHECK(reject_message.GetValue().IsEmpty());
}
}
@@ -18182,7 +18192,10 @@ v8::Handle<v8::Value> RejectValue() {
void ResetPromiseStates() {
promise_reject_counter = 0;
promise_revoke_counter = 0;
+ promise_reject_msg_line_number = -1;
+ promise_reject_msg_column_number = -1;
promise_reject_line_number = -1;
+ promise_reject_column_number = -1;
promise_reject_frame_count = -1;
CcTest::global()->Set(v8_str("rejected"), v8_str(""));
CcTest::global()->Set(v8_str("value"), v8_str(""));
@@ -18411,6 +18424,9 @@ TEST(PromiseRejectCallback) {
CHECK_EQ(0, promise_revoke_counter);
CHECK_EQ(2, promise_reject_frame_count);
CHECK_EQ(3, promise_reject_line_number);
+ CHECK_EQ(5, promise_reject_column_number);
+ CHECK_EQ(3, promise_reject_msg_line_number);
+ CHECK_EQ(5, promise_reject_msg_column_number);
ResetPromiseStates();
@@ -18431,6 +18447,9 @@ TEST(PromiseRejectCallback) {
CHECK_EQ(0, promise_revoke_counter);
CHECK_EQ(2, promise_reject_frame_count);
CHECK_EQ(5, promise_reject_line_number);
+ CHECK_EQ(23, promise_reject_column_number);
+ CHECK_EQ(5, promise_reject_msg_line_number);
+ CHECK_EQ(23, promise_reject_msg_column_number);
// Throw in u3, which handles u1's rejection.
CompileRunWithOrigin(
@@ -18454,6 +18473,9 @@ TEST(PromiseRejectCallback) {
CHECK_EQ(2, promise_revoke_counter);
CHECK_EQ(3, promise_reject_frame_count);
CHECK_EQ(3, promise_reject_line_number);
+ CHECK_EQ(12, promise_reject_column_number);
+ CHECK_EQ(3, promise_reject_msg_line_number);
+ CHECK_EQ(12, promise_reject_msg_column_number);
ResetPromiseStates();
@@ -18473,6 +18495,28 @@ TEST(PromiseRejectCallback) {
CHECK_EQ(1, promise_revoke_counter);
CHECK_EQ(0, promise_reject_frame_count);
CHECK_EQ(-1, promise_reject_line_number);
+ CHECK_EQ(-1, promise_reject_column_number);
+
+ ResetPromiseStates();
+
+ // Create promise t1, which rejects by throwing syntax error from eval.
+ CompileRunWithOrigin(
+ "var t1 = new Promise( \n"
+ " function(res, rej) { \n"
+ " var content = '\\n\\\n"
+ " }'; \n"
+ " eval(content); \n"
+ " } \n"
+ "); \n",
+ "pro", 0, 0);
+ CHECK(!GetPromise("t1")->HasHandler());
+ CHECK_EQ(1, promise_reject_counter);
+ CHECK_EQ(0, promise_revoke_counter);
+ CHECK_EQ(2, promise_reject_frame_count);
+ CHECK_EQ(5, promise_reject_line_number);
+ CHECK_EQ(10, promise_reject_column_number);
+ CHECK_EQ(2, promise_reject_msg_line_number);
+ CHECK_EQ(7, promise_reject_msg_column_number);
}
« no previous file with comments | « src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698