Index: Source/bindings/core/v8/PrivateScriptRunner.cpp |
diff --git a/Source/bindings/core/v8/PrivateScriptRunner.cpp b/Source/bindings/core/v8/PrivateScriptRunner.cpp |
index ff3a7bb32030cb2abad66cb4e5c4c3f7fb1538a8..cecc6e0f122489d5ba4c0898c82a1ac8f558bd06 100644 |
--- a/Source/bindings/core/v8/PrivateScriptRunner.cpp |
+++ b/Source/bindings/core/v8/PrivateScriptRunner.cpp |
@@ -18,24 +18,56 @@ |
namespace blink { |
-static v8::Handle<v8::Value> compilePrivateScript(v8::Isolate* isolate, String className) |
+static void compilePrivateScript(v8::Isolate* isolate, String className) |
{ |
- size_t index; |
+ int compiledScriptCount = 0; |
+ // |kPrivateScriptSources| is defined in V8PrivateScriptSources.h, which is auto-generated |
+ // by make_private_script.py. |
#ifndef NDEBUG |
- for (index = 0; index < WTF_ARRAY_LENGTH(kPrivateScriptSourcesForTesting); index++) { |
- if (className == kPrivateScriptSourcesForTesting[index].name) |
- break; |
- } |
- if (index != WTF_ARRAY_LENGTH(kPrivateScriptSourcesForTesting)) { |
- String source(reinterpret_cast<const char*>(kPrivateScriptSourcesForTesting[index].source), kPrivateScriptSourcesForTesting[index].size); |
- return V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, source), isolate); |
+ for (size_t index = 0; index < WTF_ARRAY_LENGTH(kPrivateScriptSourcesForTesting); index++) { |
+ if (className == kPrivateScriptSourcesForTesting[index].dependencyClassName) { |
+ v8::TryCatch block; |
+ String source(reinterpret_cast<const char*>(kPrivateScriptSourcesForTesting[index].source), kPrivateScriptSourcesForTesting[index].size); |
+ V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, source), isolate); |
+ if (block.HasCaught()) { |
+ WTF_LOG_ERROR("Private script error: Compile failed. (Class name = %s)\n", className.utf8().data()); |
+ if (!block.Message().IsEmpty()) |
+ WTF_LOG_ERROR("%s\n", toCoreString(block.Message()->Get()).utf8().data()); |
+ RELEASE_ASSERT_NOT_REACHED(); |
+ } |
+ compiledScriptCount++; |
+ } |
} |
#endif |
+ for (size_t index = 0; index < WTF_ARRAY_LENGTH(kPrivateScriptSources); index++) { |
+ if (className == kPrivateScriptSources[index].dependencyClassName) { |
+ v8::TryCatch block; |
+ String source(reinterpret_cast<const char*>(kPrivateScriptSources[index].source), kPrivateScriptSources[index].size); |
+ V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, source), isolate); |
+ if (block.HasCaught()) { |
+ WTF_LOG_ERROR("Private script error: Compile failed. (Class name = %s)\n", className.utf8().data()); |
+ if (!block.Message().IsEmpty()) |
+ WTF_LOG_ERROR("%s\n", toCoreString(block.Message()->Get()).utf8().data()); |
+ RELEASE_ASSERT_NOT_REACHED(); |
+ } |
+ compiledScriptCount++; |
+ } |
+ } |
+ |
+ if (!compiledScriptCount) { |
+ WTF_LOG_ERROR("Private script error: Target source code was not found. (Class name = %s)\n", className.utf8().data()); |
+ RELEASE_ASSERT_NOT_REACHED(); |
+ } |
+} |
+ |
+static v8::Handle<v8::Value> compilePrivateScriptRunner(v8::Isolate* isolate, String className) |
+{ |
+ size_t index; |
// |kPrivateScriptSources| is defined in V8PrivateScriptSources.h, which is auto-generated |
// by make_private_script.py. |
for (index = 0; index < WTF_ARRAY_LENGTH(kPrivateScriptSources); index++) { |
- if (className == kPrivateScriptSources[index].name) |
+ if (className == kPrivateScriptSources[index].className) |
break; |
} |
if (index == WTF_ARRAY_LENGTH(kPrivateScriptSources)) { |
@@ -64,7 +96,7 @@ static v8::Handle<v8::Object> classObjectOfPrivateScript(ScriptState* scriptStat |
if (compiledClass.IsEmpty()) { |
v8::Handle<v8::Value> installedClasses = scriptState->perContextData()->compiledPrivateScript("PrivateScriptRunner"); |
if (installedClasses.IsEmpty()) { |
- installedClasses = compilePrivateScript(isolate, "PrivateScriptRunner"); |
+ installedClasses = compilePrivateScriptRunner(isolate, "PrivateScriptRunner"); |
scriptState->perContextData()->setCompiledPrivateScript("PrivateScriptRunner", installedClasses); |
} |
RELEASE_ASSERT(!installedClasses.IsEmpty()); |