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

Unified Diff: Source/bindings/core/v8/PrivateScriptRunner.cpp

Issue 389913003: Make error messages about private scripts more descriptive (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/PrivateScriptRunner.cpp
diff --git a/Source/bindings/core/v8/PrivateScriptRunner.cpp b/Source/bindings/core/v8/PrivateScriptRunner.cpp
index a089a9987f518e00ef235597531f4a2e9deb0ee2..11ab0e21b3ebf0de879375beed14634e8c7ef37c 100644
--- a/Source/bindings/core/v8/PrivateScriptRunner.cpp
+++ b/Source/bindings/core/v8/PrivateScriptRunner.cpp
@@ -37,9 +37,21 @@ static v8::Handle<v8::Value> compilePrivateScript(v8::Isolate* isolate, String c
if (className == kPrivateScriptSources[index].name)
break;
}
- RELEASE_ASSERT(index != WTF_ARRAY_LENGTH(kPrivateScriptSources));
+ if (index == WTF_ARRAY_LENGTH(kPrivateScriptSources)) {
+ FATAL("Private script error: Target source code was not found. (Class name = %s)\n", className.utf8().data());
+ RELEASE_ASSERT_NOT_REACHED();
+ }
+
+ v8::TryCatch block;
String source(reinterpret_cast<const char*>(kPrivateScriptSources[index].source), kPrivateScriptSources[index].size);
- return V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, source), isolate);
+ v8::Handle<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, source), isolate);
+ if (block.HasCaught()) {
+ FATAL("Private script error: Compile failed. (Class name = %s)\n", className.utf8().data());
+ if (!block.Message().IsEmpty())
+ FATAL("%s\n", toCoreString(block.Message()->Get()).utf8().data());
+ RELEASE_ASSERT_NOT_REACHED();
+ }
+ return result;
}
static v8::Handle<v8::Object> classObjectOfPrivateScript(ScriptState* scriptState, String className)
@@ -93,7 +105,14 @@ static void initializeHolderIfNeeded(ScriptState* scriptState, v8::Handle<v8::Ob
if (isInitialized.IsEmpty()) {
v8::Handle<v8::Value> initializeFunction = classObject->Get(v8String(isolate, "constructor"));
if (!initializeFunction.IsEmpty() && initializeFunction->IsFunction()) {
+ v8::TryCatch block;
V8ScriptRunner::callFunction(v8::Handle<v8::Function>::Cast(initializeFunction), scriptState->executionContext(), holder, 0, 0, isolate);
+ if (block.HasCaught()) {
+ FATAL("Private script error: Object constructor threw an exception.\n");
+ if (!block.Message().IsEmpty())
+ FATAL("%s\n", toCoreString(block.Message()->Get()).utf8().data());
+ RELEASE_ASSERT_NOT_REACHED();
+ }
}
isInitialized = v8Boolean(true, isolate);
V8HiddenValue::setHiddenValue(isolate, holderObject, V8HiddenValue::privateScriptObjectIsInitialized(isolate), isInitialized);
@@ -120,8 +139,10 @@ v8::Handle<v8::Value> PrivateScriptRunner::runDOMAttributeGetter(ScriptState* sc
v8::Handle<v8::Object> classObject = classObjectOfPrivateScript(scriptState, className);
v8::Handle<v8::Object> descriptor = getOwnPropertyDescriptor(scriptState, classObject, attributeName);
v8::Handle<v8::Value> getter = descriptor->Get(v8String(scriptState->isolate(), "get"));
- RELEASE_ASSERT(!getter.IsEmpty());
- RELEASE_ASSERT(getter->IsFunction());
+ if (getter.IsEmpty() || !getter->IsFunction()) {
+ FATAL("Private script error: Target DOM attribute getter was not found. (Class name = %s, Attribute name = %s)\n", className.utf8().data(), attributeName.utf8().data());
+ RELEASE_ASSERT_NOT_REACHED();
+ }
initializeHolderIfNeeded(scriptState, classObject, holder);
return V8ScriptRunner::callFunction(v8::Handle<v8::Function>::Cast(getter), scriptState->executionContext(), holder, 0, 0, scriptState->isolate());
}
@@ -131,8 +152,10 @@ void PrivateScriptRunner::runDOMAttributeSetter(ScriptState* scriptState, String
v8::Handle<v8::Object> classObject = classObjectOfPrivateScript(scriptState, className);
v8::Handle<v8::Object> descriptor = getOwnPropertyDescriptor(scriptState, classObject, attributeName);
v8::Handle<v8::Value> setter = descriptor->Get(v8String(scriptState->isolate(), "set"));
- RELEASE_ASSERT(!setter.IsEmpty());
- RELEASE_ASSERT(setter->IsFunction());
+ if (setter.IsEmpty() || !setter->IsFunction()) {
+ FATAL("Private script error: Target DOM attribute setter was not found. (Class name = %s, Attribute name = %s)\n", className.utf8().data(), attributeName.utf8().data());
+ RELEASE_ASSERT_NOT_REACHED();
+ }
initializeHolderIfNeeded(scriptState, classObject, holder);
v8::Handle<v8::Value> argv[] = { v8Value };
V8ScriptRunner::callFunction(v8::Handle<v8::Function>::Cast(setter), scriptState->executionContext(), holder, WTF_ARRAY_LENGTH(argv), argv, scriptState->isolate());
@@ -142,8 +165,10 @@ v8::Handle<v8::Value> PrivateScriptRunner::runDOMMethod(ScriptState* scriptState
{
v8::Handle<v8::Object> classObject = classObjectOfPrivateScript(scriptState, className);
v8::Handle<v8::Value> method = classObject->Get(v8String(scriptState->isolate(), methodName));
- RELEASE_ASSERT(!method.IsEmpty());
- RELEASE_ASSERT(method->IsFunction());
+ if (method.IsEmpty() || !method->IsFunction()) {
+ FATAL("Private script error: Target DOM method was not found. (Class name = %s, Method name = %s)\n", className.utf8().data(), methodName.utf8().data());
+ RELEASE_ASSERT_NOT_REACHED();
+ }
initializeHolderIfNeeded(scriptState, classObject, holder);
return V8ScriptRunner::callFunction(v8::Handle<v8::Function>::Cast(method), scriptState->executionContext(), holder, argc, argv, scriptState->isolate());
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698