| Index: Source/bindings/v8/PrivateScriptRunner.cpp
|
| diff --git a/Source/bindings/v8/PrivateScriptRunner.cpp b/Source/bindings/v8/PrivateScriptRunner.cpp
|
| index c1315b8cbddd442cb4ee86049b14e1c191fcda6f..b8bff72943bad992f7ac85539e803b07535a15b4 100644
|
| --- a/Source/bindings/v8/PrivateScriptRunner.cpp
|
| +++ b/Source/bindings/v8/PrivateScriptRunner.cpp
|
| @@ -9,12 +9,26 @@
|
| #include "bindings/v8/V8PerContextData.h"
|
| #include "bindings/v8/V8ScriptRunner.h"
|
| #include "core/PrivateScriptSources.h"
|
| +#ifndef NDEBUG
|
| +#include "core/PrivateScriptSourcesForTesting.h"
|
| +#endif
|
|
|
| namespace WebCore {
|
|
|
| static v8::Handle<v8::Value> compilePrivateScript(v8::Isolate* isolate, String className)
|
| {
|
| size_t index;
|
| +#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);
|
| + }
|
| +#endif
|
| +
|
| // |kPrivateScriptSources| is defined in V8PrivateScriptSources.h, which is auto-generated
|
| // by make_private_script.py.
|
| for (index = 0; index < WTF_ARRAY_LENGTH(kPrivateScriptSources); index++) {
|
| @@ -26,7 +40,7 @@ static v8::Handle<v8::Value> compilePrivateScript(v8::Isolate* isolate, String c
|
| return V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, source), isolate);
|
| }
|
|
|
| -v8::Handle<v8::Value> PrivateScriptRunner::run(ScriptState* scriptState, String className, String functionName, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> argv[])
|
| +static v8::Handle<v8::Value> propertyValue(ScriptState* scriptState, String className, String propertyName)
|
| {
|
| ASSERT(scriptState->perContextData());
|
| ASSERT(scriptState->executionContext());
|
| @@ -47,12 +61,15 @@ v8::Handle<v8::Value> PrivateScriptRunner::run(ScriptState* scriptState, String
|
| RELEASE_ASSERT(compiledClass->IsObject());
|
| scriptState->perContextData()->setCompiledPrivateScript(className, compiledClass);
|
| }
|
| + return v8::Handle<v8::Object>::Cast(compiledClass)->Get(v8String(isolate, propertyName));
|
| +}
|
|
|
| - v8::Handle<v8::Value> function = v8::Handle<v8::Object>::Cast(compiledClass)->Get(v8String(isolate, functionName));
|
| - RELEASE_ASSERT(!function.IsEmpty());
|
| - RELEASE_ASSERT(function->IsFunction());
|
| -
|
| - return V8ScriptRunner::callFunction(v8::Handle<v8::Function>::Cast(function), scriptState->executionContext(), receiver, argc, argv, isolate);
|
| +v8::Handle<v8::Value> PrivateScriptRunner::runDOMMethod(ScriptState* scriptState, String className, String operationName, v8::Handle<v8::Value> holder, int argc, v8::Handle<v8::Value> argv[])
|
| +{
|
| + v8::Handle<v8::Value> operation = propertyValue(scriptState, className, operationName);
|
| + RELEASE_ASSERT(!operation.IsEmpty());
|
| + RELEASE_ASSERT(operation->IsFunction());
|
| + return V8ScriptRunner::callFunction(v8::Handle<v8::Function>::Cast(operation), scriptState->executionContext(), holder, argc, argv, scriptState->isolate());
|
| }
|
|
|
| } // namespace WebCore
|
|
|