Skip to content

Commit

Permalink
[TIMOB-25963] Improve jsstring validation, rename to nativeStack
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Mathews committed Apr 26, 2018
1 parent dc2d097 commit 9d1044e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion android/runtime/v8/src/native/JSException.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Local<Value> JSException::fromJavaException(v8::Isolate* isolate, jthrowable jav

// Now explicitly assign our properly generated stacktrace
Local<String> javaStack = String::NewFromUtf8(isolate, stackStream.str().c_str());
error->Set(context, STRING_NEW(isolate, "javaStack"), javaStack);
error->Set(context, STRING_NEW(isolate, "nativeStack"), javaStack);

// throw it
return isolate->ThrowException(error);
Expand Down
2 changes: 1 addition & 1 deletion android/runtime/v8/src/native/TypeConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ jstring TypeConverter::jsValueToJavaString(v8::Isolate* isolate, v8::Local<v8::V

jstring TypeConverter::jsValueToJavaString(v8::Isolate* isolate, JNIEnv *env, v8::Local<v8::Value> jsValue)
{
if (jsValue->IsNull()) {
if (jsValue->IsNullOrUndefined()) {
return NULL;
}

Expand Down
4 changes: 2 additions & 2 deletions android/runtime/v8/src/native/V8Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ void V8Util::openJSErrorDialog(Isolate* isolate, TryCatch &tryCatch)

if (exception->IsObject()) {
Local<Object> error = exception.As<Object>();
jsStack = exception.As<Object>()->Get(STRING_NEW(isolate, "stack"));
javaStack = exception.As<Object>()->Get(STRING_NEW(isolate, "javaStack"));
jsStack = error->Get(STRING_NEW(isolate, "stack"));
javaStack = error->Get(STRING_NEW(isolate, "nativeStack"));
}

// obtain javascript stack trace
Expand Down
8 changes: 4 additions & 4 deletions tests/Resources/ti.addontest.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Error', function () {
ex.should.have.property('stack');
ex.stack.should.containEql('TypeError: Cannot read property \'crash\' of undefined');
// does not have java stack trace
ex.should.not.have.property('javaStack');
ex.should.not.have.property('nativeStack');
}
});

Expand All @@ -39,8 +39,8 @@ describe('Error', function () {
ex.should.have.property('stack');
ex.stack.should.containEql('Error: Unable to convert null'); // TODO Verify app.js in stack?
// has special javaStack property for java stacktrace
ex.should.have.property('javaStack');
ex.javaStack.should.containEql('org.appcelerator.titanium.util.TiConvert.toInt(TiConvert.java:'); // points to Java code in stack
ex.should.have.property('nativeStack');
ex.nativeStack.should.containEql('org.appcelerator.titanium.util.TiConvert.toInt(TiConvert.java:'); // points to Java code in stack
}
});

Expand All @@ -51,7 +51,7 @@ describe('Error', function () {
ex.should.equal('this is my error string');
ex.should.not.have.property('message');
ex.should.not.have.property('stack');
ex.should.not.have.property('javaStack');
ex.should.not.have.property('nativeStack');
}
});
});

0 comments on commit 9d1044e

Please sign in to comment.